nterminal 1.2.60 → 1.2.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/MarkdownPreview-pEj4ukXa.js +1 -0
- package/dist/client/assets/{TranscriptMarkdownBody-J4Bk7GDH.js → TranscriptMarkdownBody-B5UquJIY.js} +1 -1
- package/dist/client/assets/{index-DuPhXutl.js → index-B56tTIJv.js} +1 -1
- package/dist/client/assets/index-Kt-1DNuk.js +55 -0
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/dist/client/assets/MarkdownPreview-jgdUGtLt.js +0 -1
- package/dist/client/assets/index-BhvB-e5O.js +0 -55
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-pEj4ukXa.js","assets/index-B56tTIJv.js","assets/TranscriptMarkdownBody-B5UquJIY.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const h of c.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&r(h)}).observe(document,{childList:!0,subtree:!0});function s(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(o){if(o.ep)return;o.ep=!0;const c=s(o);fetch(o.href,c)}})();function nE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Af={exports:{}},yo={};var cy;function sE(){if(cy)return yo;cy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function s(r,o,c){var h=null;if(c!==void 0&&(h=""+c),o.key!==void 0&&(h=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:r,key:h,ref:o!==void 0?o:null,props:c}}return yo.Fragment=t,yo.jsx=s,yo.jsxs=s,yo}var uy;function rE(){return uy||(uy=1,Af.exports=sE()),Af.exports}var m=rE(),Lf={exports:{}},Ye={};var hy;function aE(){if(hy)return Ye;hy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),h=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),w=Symbol.iterator;function S(R){return R===null||typeof R!="object"?null:(R=w&&R[w]||R["@@iterator"],typeof R=="function"?R:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,O={};function L(R,H,ee){this.props=R,this.context=H,this.refs=O,this.updater=ee||E}L.prototype.isReactComponent={},L.prototype.setState=function(R,H){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,H,"setState")},L.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=L.prototype;function I(R,H,ee){this.props=R,this.context=H,this.refs=O,this.updater=ee||E}var U=I.prototype=new N;U.constructor=I,T(U,L.prototype),U.isPureReactComponent=!0;var Q=Array.isArray;function ie(){}var le={H:null,A:null,T:null,S:null},ce=Object.prototype.hasOwnProperty;function ve(R,H,ee){var de=ee.ref;return{$$typeof:e,type:R,key:H,ref:de!==void 0?de:null,props:ee}}function we(R,H){return ve(R.type,H,R.props)}function ne(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function se(R){var H={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(ee){return H[ee]})}var V=/\/+/g;function F(R,H){return typeof R=="object"&&R!==null&&R.key!=null?se(""+R.key):H.toString(36)}function re(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(ie,ie):(R.status="pending",R.then(function(H){R.status==="pending"&&(R.status="fulfilled",R.value=H)},function(H){R.status==="pending"&&(R.status="rejected",R.reason=H)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function B(R,H,ee,de,Ee){var ke=typeof R;(ke==="undefined"||ke==="boolean")&&(R=null);var Me=!1;if(R===null)Me=!0;else switch(ke){case"bigint":case"string":case"number":Me=!0;break;case"object":switch(R.$$typeof){case e:case t:Me=!0;break;case y:return Me=R._init,B(Me(R._payload),H,ee,de,Ee)}}if(Me)return Ee=Ee(R),Me=de===""?"."+F(R,0):de,Q(Ee)?(ee="",Me!=null&&(ee=Me.replace(V,"$&/")+"/"),B(Ee,H,ee,"",function(X){return X})):Ee!=null&&(ne(Ee)&&(Ee=we(Ee,ee+(Ee.key==null||R&&R.key===Ee.key?"":(""+Ee.key).replace(V,"$&/")+"/")+Me)),H.push(Ee)),1;Me=0;var Fe=de===""?".":de+":";if(Q(R))for(var _e=0;_e<R.length;_e++)de=R[_e],ke=Fe+F(de,_e),Me+=B(de,H,ee,ke,Ee);else if(_e=S(R),typeof _e=="function")for(R=_e.call(R),_e=0;!(de=R.next()).done;)de=de.value,ke=Fe+F(de,_e++),Me+=B(de,H,ee,ke,Ee);else if(ke==="object"){if(typeof R.then=="function")return B(re(R),H,ee,de,Ee);throw H=String(R),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return Me}function W(R,H,ee){if(R==null)return R;var de=[],Ee=0;return B(R,de,"","",function(ke){return H.call(ee,ke,Ee++)}),de}function D(R){if(R._status===-1){var H=R._result;H=H(),H.then(function(ee){(R._status===0||R._status===-1)&&(R._status=1,R._result=ee)},function(ee){(R._status===0||R._status===-1)&&(R._status=2,R._result=ee)}),R._status===-1&&(R._status=0,R._result=H)}if(R._status===1)return R._result.default;throw R._result}var G=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},me={map:W,forEach:function(R,H,ee){W(R,function(){H.apply(this,arguments)},ee)},count:function(R){var H=0;return W(R,function(){H++}),H},toArray:function(R){return W(R,function(H){return H})||[]},only:function(R){if(!ne(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return Ye.Activity=b,Ye.Children=me,Ye.Component=L,Ye.Fragment=s,Ye.Profiler=o,Ye.PureComponent=I,Ye.StrictMode=r,Ye.Suspense=g,Ye.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=le,Ye.__COMPILER_RUNTIME={__proto__:null,c:function(R){return le.H.useMemoCache(R)}},Ye.cache=function(R){return function(){return R.apply(null,arguments)}},Ye.cacheSignal=function(){return null},Ye.cloneElement=function(R,H,ee){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var de=T({},R.props),Ee=R.key;if(H!=null)for(ke in H.key!==void 0&&(Ee=""+H.key),H)!ce.call(H,ke)||ke==="key"||ke==="__self"||ke==="__source"||ke==="ref"&&H.ref===void 0||(de[ke]=H[ke]);var ke=arguments.length-2;if(ke===1)de.children=ee;else if(1<ke){for(var Me=Array(ke),Fe=0;Fe<ke;Fe++)Me[Fe]=arguments[Fe+2];de.children=Me}return ve(R.type,Ee,de)},Ye.createContext=function(R){return R={$$typeof:h,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:c,_context:R},R},Ye.createElement=function(R,H,ee){var de,Ee={},ke=null;if(H!=null)for(de in H.key!==void 0&&(ke=""+H.key),H)ce.call(H,de)&&de!=="key"&&de!=="__self"&&de!=="__source"&&(Ee[de]=H[de]);var Me=arguments.length-2;if(Me===1)Ee.children=ee;else if(1<Me){for(var Fe=Array(Me),_e=0;_e<Me;_e++)Fe[_e]=arguments[_e+2];Ee.children=Fe}if(R&&R.defaultProps)for(de in Me=R.defaultProps,Me)Ee[de]===void 0&&(Ee[de]=Me[de]);return ve(R,ke,Ee)},Ye.createRef=function(){return{current:null}},Ye.forwardRef=function(R){return{$$typeof:f,render:R}},Ye.isValidElement=ne,Ye.lazy=function(R){return{$$typeof:y,_payload:{_status:-1,_result:R},_init:D}},Ye.memo=function(R,H){return{$$typeof:p,type:R,compare:H===void 0?null:H}},Ye.startTransition=function(R){var H=le.T,ee={};le.T=ee;try{var de=R(),Ee=le.S;Ee!==null&&Ee(ee,de),typeof de=="object"&&de!==null&&typeof de.then=="function"&&de.then(ie,G)}catch(ke){G(ke)}finally{H!==null&&ee.types!==null&&(H.types=ee.types),le.T=H}},Ye.unstable_useCacheRefresh=function(){return le.H.useCacheRefresh()},Ye.use=function(R){return le.H.use(R)},Ye.useActionState=function(R,H,ee){return le.H.useActionState(R,H,ee)},Ye.useCallback=function(R,H){return le.H.useCallback(R,H)},Ye.useContext=function(R){return le.H.useContext(R)},Ye.useDebugValue=function(){},Ye.useDeferredValue=function(R,H){return le.H.useDeferredValue(R,H)},Ye.useEffect=function(R,H){return le.H.useEffect(R,H)},Ye.useEffectEvent=function(R){return le.H.useEffectEvent(R)},Ye.useId=function(){return le.H.useId()},Ye.useImperativeHandle=function(R,H,ee){return le.H.useImperativeHandle(R,H,ee)},Ye.useInsertionEffect=function(R,H){return le.H.useInsertionEffect(R,H)},Ye.useLayoutEffect=function(R,H){return le.H.useLayoutEffect(R,H)},Ye.useMemo=function(R,H){return le.H.useMemo(R,H)},Ye.useOptimistic=function(R,H){return le.H.useOptimistic(R,H)},Ye.useReducer=function(R,H,ee){return le.H.useReducer(R,H,ee)},Ye.useRef=function(R){return le.H.useRef(R)},Ye.useState=function(R){return le.H.useState(R)},Ye.useSyncExternalStore=function(R,H,ee){return le.H.useSyncExternalStore(R,H,ee)},Ye.useTransition=function(){return le.H.useTransition()},Ye.version="19.2.6",Ye}var dy;function Um(){return dy||(dy=1,Lf.exports=aE()),Lf.exports}var v=Um();const xi=nE(v);var Bf={exports:{}},So={},Of={exports:{}},zf={};var fy;function lE(){return fy||(fy=1,(function(e){function t(B,W){var D=B.length;B.push(W);e:for(;0<D;){var G=D-1>>>1,me=B[G];if(0<o(me,W))B[G]=W,B[D]=me,D=G;else break e}}function s(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var W=B[0],D=B.pop();if(D!==W){B[0]=D;e:for(var G=0,me=B.length,R=me>>>1;G<R;){var H=2*(G+1)-1,ee=B[H],de=H+1,Ee=B[de];if(0>o(ee,D))de<me&&0>o(Ee,ee)?(B[G]=Ee,B[de]=D,G=de):(B[G]=ee,B[H]=D,G=H);else if(de<me&&0>o(Ee,D))B[G]=Ee,B[de]=D,G=de;else break e}}return W}function o(B,W){var D=B.sortIndex-W.sortIndex;return D!==0?D:B.id-W.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var h=Date,f=h.now();e.unstable_now=function(){return h.now()-f}}var g=[],p=[],y=1,b=null,w=3,S=!1,E=!1,T=!1,O=!1,L=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function U(B){for(var W=s(p);W!==null;){if(W.callback===null)r(p);else if(W.startTime<=B)r(p),W.sortIndex=W.expirationTime,t(g,W);else break;W=s(p)}}function Q(B){if(T=!1,U(B),!E)if(s(g)!==null)E=!0,ie||(ie=!0,se());else{var W=s(p);W!==null&&re(Q,W.startTime-B)}}var ie=!1,le=-1,ce=5,ve=-1;function we(){return O?!0:!(e.unstable_now()-ve<ce)}function ne(){if(O=!1,ie){var B=e.unstable_now();ve=B;var W=!0;try{e:{E=!1,T&&(T=!1,N(le),le=-1),S=!0;var D=w;try{t:{for(U(B),b=s(g);b!==null&&!(b.expirationTime>B&&we());){var G=b.callback;if(typeof G=="function"){b.callback=null,w=b.priorityLevel;var me=G(b.expirationTime<=B);if(B=e.unstable_now(),typeof me=="function"){b.callback=me,U(B),W=!0;break t}b===s(g)&&r(g),U(B)}else r(g);b=s(g)}if(b!==null)W=!0;else{var R=s(p);R!==null&&re(Q,R.startTime-B),W=!1}}break e}finally{b=null,w=D,S=!1}W=void 0}}finally{W?se():ie=!1}}}var se;if(typeof I=="function")se=function(){I(ne)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,F=V.port2;V.port1.onmessage=ne,se=function(){F.postMessage(null)}}else se=function(){L(ne,0)};function re(B,W){le=L(function(){B(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ce=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(B){switch(w){case 1:case 2:case 3:var W=3;break;default:W=w}var D=w;w=W;try{return B()}finally{w=D}},e.unstable_requestPaint=function(){O=!0},e.unstable_runWithPriority=function(B,W){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var D=w;w=B;try{return W()}finally{w=D}},e.unstable_scheduleCallback=function(B,W,D){var G=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?G+D:G):D=G,B){case 1:var me=-1;break;case 2:me=250;break;case 5:me=1073741823;break;case 4:me=1e4;break;default:me=5e3}return me=D+me,B={id:y++,callback:W,priorityLevel:B,startTime:D,expirationTime:me,sortIndex:-1},D>G?(B.sortIndex=D,t(p,B),s(g)===null&&B===s(p)&&(T?(N(le),le=-1):T=!0,re(Q,D-G))):(B.sortIndex=me,t(g,B),E||S||(E=!0,ie||(ie=!0,se()))),B},e.unstable_shouldYield=we,e.unstable_wrapCallback=function(B){var W=w;return function(){var D=w;w=W;try{return B.apply(this,arguments)}finally{w=D}}}})(zf)),zf}var py;function oE(){return py||(py=1,Of.exports=lE()),Of.exports}var jf={exports:{}},Yi={};var my;function cE(){if(my)return Yi;my=1;var e=Um();function t(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var r={d:{f:s,r:function(){throw Error(t(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},o=Symbol.for("react.portal");function c(g,p,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:g,containerInfo:p,implementation:y}}var h=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Yi.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Yi.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)},Yi.flushSync=function(g){var p=h.T,y=r.p;try{if(h.T=null,r.p=2,g)return g()}finally{h.T=p,r.p=y,r.d.f()}},Yi.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))},Yi.prefetchDNS=function(g){typeof g=="string"&&r.d.D(g)},Yi.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,b=f(y,p.crossOrigin),w=typeof p.integrity=="string"?p.integrity:void 0,S=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?r.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:b,integrity:w,fetchPriority:S}):y==="script"&&r.d.X(g,{crossOrigin:b,integrity:w,fetchPriority:S,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Yi.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=f(p.as,p.crossOrigin);r.d.M(g,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&r.d.M(g)},Yi.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,b=f(y,p.crossOrigin);r.d.L(g,y,{crossOrigin:b,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},Yi.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=f(p.as,p.crossOrigin);r.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else r.d.m(g)},Yi.requestFormReset=function(g){r.d.r(g)},Yi.unstable_batchedUpdates=function(g,p){return g(p)},Yi.useFormState=function(g,p,y){return h.H.useFormState(g,p,y)},Yi.useFormStatus=function(){return h.H.useHostTransitionStatus()},Yi.version="19.2.6",Yi}var gy;function b0(){if(gy)return jf.exports;gy=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(),jf.exports=cE(),jf.exports}var _y;function uE(){if(_y)return So;_y=1;var e=oE(),t=Um(),s=b0();function r(i){var n="https://react.dev/errors/"+i;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)n+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function c(i){var n=i,a=i;if(i.alternate)for(;n.return;)n=n.return;else{i=n;do n=i,(n.flags&4098)!==0&&(a=n.return),i=n.return;while(i)}return n.tag===3?a:null}function h(i){if(i.tag===13){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function f(i){if(i.tag===31){var n=i.memoizedState;if(n===null&&(i=i.alternate,i!==null&&(n=i.memoizedState)),n!==null)return n.dehydrated}return null}function g(i){if(c(i)!==i)throw Error(r(188))}function p(i){var n=i.alternate;if(!n){if(n=c(i),n===null)throw Error(r(188));return n!==i?null:i}for(var a=i,l=n;;){var u=a.return;if(u===null)break;var d=u.alternate;if(d===null){if(l=u.return,l!==null){a=l;continue}break}if(u.child===d.child){for(d=u.child;d;){if(d===a)return g(u),i;if(d===l)return g(u),n;d=d.sibling}throw Error(r(188))}if(a.return!==l.return)a=u,l=d;else{for(var _=!1,C=u.child;C;){if(C===a){_=!0,a=u,l=d;break}if(C===l){_=!0,l=u,a=d;break}C=C.sibling}if(!_){for(C=d.child;C;){if(C===a){_=!0,a=d,l=u;break}if(C===l){_=!0,l=d,a=u;break}C=C.sibling}if(!_)throw Error(r(189))}}if(a.alternate!==l)throw Error(r(190))}if(a.tag!==3)throw Error(r(188));return a.stateNode.current===a?i:n}function y(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i;for(i=i.child;i!==null;){if(n=y(i),n!==null)return n;i=i.sibling}return null}var b=Object.assign,w=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),I=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),ie=Symbol.for("react.suspense_list"),le=Symbol.for("react.memo"),ce=Symbol.for("react.lazy"),ve=Symbol.for("react.activity"),we=Symbol.for("react.memo_cache_sentinel"),ne=Symbol.iterator;function se(i){return i===null||typeof i!="object"?null:(i=ne&&i[ne]||i["@@iterator"],typeof i=="function"?i:null)}var V=Symbol.for("react.client.reference");function F(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===V?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case T:return"Fragment";case L:return"Profiler";case O:return"StrictMode";case Q:return"Suspense";case ie:return"SuspenseList";case ve:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case E:return"Portal";case I:return i.displayName||"Context";case N:return(i._context.displayName||"Context")+".Consumer";case U:var n=i.render;return i=i.displayName,i||(i=n.displayName||n.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case le:return n=i.displayName||null,n!==null?n:F(i.type)||"Memo";case ce:n=i._payload,i=i._init;try{return F(i(n))}catch{}}return null}var re=Array.isArray,B=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D={pending:!1,data:null,method:null,action:null},G=[],me=-1;function R(i){return{current:i}}function H(i){0>me||(i.current=G[me],G[me]=null,me--)}function ee(i,n){me++,G[me]=i.current,i.current=n}var de=R(null),Ee=R(null),ke=R(null),Me=R(null);function Fe(i,n){switch(ee(ke,n),ee(Ee,i),ee(de,null),n.nodeType){case 9:case 11:i=(i=n.documentElement)&&(i=i.namespaceURI)?Ab(i):0;break;default:if(i=n.tagName,n=n.namespaceURI)n=Ab(n),i=Lb(n,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}H(de),ee(de,i)}function _e(){H(de),H(Ee),H(ke)}function X(i){i.memoizedState!==null&&ee(Me,i);var n=de.current,a=Lb(n,i.type);n!==a&&(ee(Ee,i),ee(de,a))}function he(i){Ee.current===i&&(H(de),H(Ee)),Me.current===i&&(H(Me),go._currentValue=D)}var Ce,be;function De(i){if(Ce===void 0)try{throw Error()}catch(a){var n=a.stack.trim().match(/\n( *(at )?)/);Ce=n&&n[1]||"",be=-1<a.stack.indexOf(`
|
|
3
|
+
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
|
+
`+Ce+i+be}var Oe=!1;function Ie(i,n){if(!i||Oe)return"";Oe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(n){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(Z){var Y=Z}Reflect.construct(i,[],fe)}else{try{fe.call()}catch(Z){Y=Z}i.call(fe.prototype)}}else{try{throw Error()}catch(Z){Y=Z}(fe=i())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(Z){if(Z&&Y&&typeof Z.stack=="string")return[Z.stack,Y.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var d=l.DetermineComponentFrameRoot(),_=d[0],C=d[1];if(_&&C){var A=_.split(`
|
|
5
|
+
`),$=C.split(`
|
|
6
|
+
`);for(u=l=0;l<A.length&&!A[l].includes("DetermineComponentFrameRoot");)l++;for(;u<$.length&&!$[u].includes("DetermineComponentFrameRoot");)u++;if(l===A.length||u===$.length)for(l=A.length-1,u=$.length-1;1<=l&&0<=u&&A[l]!==$[u];)u--;for(;1<=l&&0<=u;l--,u--)if(A[l]!==$[u]){if(l!==1||u!==1)do if(l--,u--,0>u||A[l]!==$[u]){var ae=`
|
|
7
|
+
`+A[l].replace(" at new "," at ");return i.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",i.displayName)),ae}while(1<=l&&0<=u);break}}}finally{Oe=!1,Error.prepareStackTrace=a}return(a=i?i.displayName||i.name:"")?De(a):""}function oe(i,n){switch(i.tag){case 26:case 27:case 5:return De(i.type);case 16:return De("Lazy");case 13:return i.child!==n&&n!==null?De("Suspense Fallback"):De("Suspense");case 19:return De("SuspenseList");case 0:case 15:return Ie(i.type,!1);case 11:return Ie(i.type.render,!1);case 1:return Ie(i.type,!0);case 31:return De("Activity");default:return""}}function xe(i){try{var n="",a=null;do n+=oe(i,a),a=i,i=i.return;while(i);return n}catch(l){return`
|
|
8
|
+
Error generating stack: `+l.message+`
|
|
9
|
+
`+l.stack}}var Ae=Object.prototype.hasOwnProperty,ze=e.unstable_scheduleCallback,He=e.unstable_cancelCallback,gt=e.unstable_shouldYield,Xe=e.unstable_requestPaint,st=e.unstable_now,ei=e.unstable_getCurrentPriorityLevel,an=e.unstable_ImmediatePriority,ki=e.unstable_UserBlockingPriority,ti=e.unstable_NormalPriority,Ti=e.unstable_LowPriority,Jn=e.unstable_IdlePriority,K=e.log,$e=e.unstable_setDisableYieldValue,ot=null,wt=null;function li(i){if(typeof K=="function"&&$e(i),wt&&typeof wt.setStrictMode=="function")try{wt.setStrictMode(ot,i)}catch{}}var Dt=Math.clz32?Math.clz32:ts,ln=Math.log,es=Math.LN2;function ts(i){return i>>>=0,i===0?32:31-(ln(i)/es|0)|0}var Rt=256,Pi=262144,_t=4194304;function vt(i){var n=i&42;if(n!==0)return n;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Ct(i,n,a){var l=i.pendingLanes;if(l===0)return 0;var u=0,d=i.suspendedLanes,_=i.pingedLanes;i=i.warmLanes;var C=l&134217727;return C!==0?(l=C&~d,l!==0?u=vt(l):(_&=C,_!==0?u=vt(_):a||(a=C&~i,a!==0&&(u=vt(a))))):(C=l&~d,C!==0?u=vt(C):_!==0?u=vt(_):a||(a=l&~i,a!==0&&(u=vt(a)))),u===0?0:n!==0&&n!==u&&(n&d)===0&&(d=u&-u,a=n&-n,d>=a||d===32&&(a&4194048)!==0)?n:u}function Di(i,n){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&n)===0}function oi(i,n){switch(i){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function qt(){var i=_t;return _t<<=1,(_t&62914560)===0&&(_t=4194304),i}function ci(i){for(var n=[],a=0;31>a;a++)n.push(i);return n}function _i(i,n){i.pendingLanes|=n,n!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Ht(i,n,a,l,u,d){var _=i.pendingLanes;i.pendingLanes=a,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=a,i.entangledLanes&=a,i.errorRecoveryDisabledLanes&=a,i.shellSuspendCounter=0;var C=i.entanglements,A=i.expirationTimes,$=i.hiddenUpdates;for(a=_&~a;0<a;){var ae=31-Dt(a),fe=1<<ae;C[ae]=0,A[ae]=-1;var Y=$[ae];if(Y!==null)for($[ae]=null,ae=0;ae<Y.length;ae++){var Z=Y[ae];Z!==null&&(Z.lane&=-536870913)}a&=~fe}l!==0&&Ri(i,l,0),d!==0&&u===0&&i.tag!==0&&(i.suspendedLanes|=d&~(_&~n))}function Ri(i,n,a){i.pendingLanes|=n,i.suspendedLanes&=~n;var l=31-Dt(n);i.entangledLanes|=n,i.entanglements[l]=i.entanglements[l]|1073741824|a&261930}function ii(i,n){var a=i.entangledLanes|=n;for(i=i.entanglements;a;){var l=31-Dt(a),u=1<<l;u&n|i[l]&n&&(i[l]|=n),a&=~u}}function vi(i,n){var a=n&-n;return a=(a&42)!==0?1:_n(a),(a&(i.suspendedLanes|n))!==0?0:a}function _n(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 Gi(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function Zi(){var i=W.p;return i!==0?i:(i=window.event,i===void 0?32:iy(i.type))}function vn(i,n){var a=W.p;try{return W.p=i,n()}finally{W.p=a}}var $i=Math.random().toString(36).slice(2),It="__reactFiber$"+$i,bi="__reactProps$"+$i,Ln="__reactContainer$"+$i,Ur="__reactEvents$"+$i,Ll="__reactListeners$"+$i,Zs="__reactHandles$"+$i,Ta="__reactResources$"+$i,Es="__reactMarker$"+$i;function Bn(i){delete i[It],delete i[bi],delete i[Ur],delete i[Ll],delete i[Zs]}function Qi(i){var n=i[It];if(n)return n;for(var a=i.parentNode;a;){if(n=a[Ln]||a[It]){if(a=n.alternate,n.child!==null||a!==null&&a.child!==null)for(i=Ub(i);i!==null;){if(a=i[It])return a;i=Ub(i)}return n}i=a,a=i.parentNode}return null}function On(i){if(i=i[It]||i[Ln]){var n=i.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return i}return null}function Lt(i){var n=i.tag;if(n===5||n===26||n===27||n===6)return i.stateNode;throw Error(r(33))}function bn(i){var n=i[Ta];return n||(n=i[Ta]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Kt(i){i[Es]=!0}var ds=new Set,ui={};function zn(i,n){is(i,n),is(i+"Capture",n)}function is(i,n){for(ui[i]=n,i=0;i<n.length;i++)ds.add(n[i])}var Da=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ir={},Ra={};function Ma(i){return Ae.call(Ra,i)?!0:Ae.call(Ir,i)?!1:Da.test(i)?Ra[i]=!0:(Ir[i]=!0,!1)}function on(i,n,a){if(Ma(n))if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":i.removeAttribute(n);return;case"boolean":var l=n.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){i.removeAttribute(n);return}}i.setAttribute(n,""+a)}}function jn(i,n,a){if(a===null)i.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(n);return}i.setAttribute(n,""+a)}}function yn(i,n,a,l){if(l===null)i.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(a);return}i.setAttributeNS(n,a,""+l)}}function $t(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Kr(i){var n=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function rt(i,n,a){var l=Object.getOwnPropertyDescriptor(i.constructor.prototype,n);if(!i.hasOwnProperty(n)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var u=l.get,d=l.set;return Object.defineProperty(i,n,{configurable:!0,get:function(){return u.call(this)},set:function(_){a=""+_,d.call(this,_)}}),Object.defineProperty(i,n,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(_){a=""+_},stopTracking:function(){i._valueTracker=null,delete i[n]}}}}function ns(i){if(!i._valueTracker){var n=Kr(i)?"checked":"value";i._valueTracker=rt(i,n,""+i[n])}}function ks(i){if(!i)return!1;var n=i._valueTracker;if(!n)return!0;var a=n.getValue(),l="";return i&&(l=Kr(i)?i.checked?"true":"false":i.value),i=l,i!==a?(n.setValue(i),!0):!1}function ss(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var Na=/[\n"\\]/g;function Ui(i){return i.replace(Na,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function Wr(i,n,a,l,u,d,_,C){i.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?i.type=_:i.removeAttribute("type"),n!=null?_==="number"?(n===0&&i.value===""||i.value!=n)&&(i.value=""+$t(n)):i.value!==""+$t(n)&&(i.value=""+$t(n)):_!=="submit"&&_!=="reset"||i.removeAttribute("value"),n!=null?Fr(i,_,$t(n)):a!=null?Fr(i,_,$t(a)):l!=null&&i.removeAttribute("value"),u==null&&d!=null&&(i.defaultChecked=!!d),u!=null&&(i.checked=u&&typeof u!="function"&&typeof u!="symbol"),C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?i.name=""+$t(C):i.removeAttribute("name")}function Qs(i,n,a,l,u,d,_,C){if(d!=null&&typeof d!="function"&&typeof d!="symbol"&&typeof d!="boolean"&&(i.type=d),n!=null||a!=null){if(!(d!=="submit"&&d!=="reset"||n!=null)){ns(i);return}a=a!=null?""+$t(a):"",n=n!=null?""+$t(n):a,C||n===i.value||(i.value=n),i.defaultValue=n}l=l??u,l=typeof l!="function"&&typeof l!="symbol"&&!!l,i.checked=C?i.checked:!!l,i.defaultChecked=!!l,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(i.name=_),ns(i)}function Fr(i,n,a){n==="number"&&ss(i.ownerDocument)===i||i.defaultValue===""+a||(i.defaultValue=""+a)}function fs(i,n,a,l){if(i=i.options,n){n={};for(var u=0;u<a.length;u++)n["$"+a[u]]=!0;for(a=0;a<i.length;a++)u=n.hasOwnProperty("$"+i[a].value),i[a].selected!==u&&(i[a].selected=u),u&&l&&(i[a].defaultSelected=!0)}else{for(a=""+$t(a),n=null,u=0;u<i.length;u++){if(i[u].value===a){i[u].selected=!0,l&&(i[u].defaultSelected=!0);return}n!==null||i[u].disabled||(n=i[u])}n!==null&&(n.selected=!0)}}function Aa(i,n,a){if(n!=null&&(n=""+$t(n),n!==i.value&&(i.value=n),a==null)){i.defaultValue!==n&&(i.defaultValue=n);return}i.defaultValue=a!=null?""+$t(a):""}function Js(i,n,a,l){if(n==null){if(l!=null){if(a!=null)throw Error(r(92));if(re(l)){if(1<l.length)throw Error(r(93));l=l[0]}a=l}a==null&&(a=""),n=a}a=$t(n),i.defaultValue=a,l=i.textContent,l===a&&l!==""&&l!==null&&(i.value=l),ns(i)}function Ji(i,n){if(n){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=n;return}}i.textContent=n}var Bl=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 La(i,n,a){var l=n.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?i.setProperty(n,""):n==="float"?i.cssFloat="":i[n]="":l?i.setProperty(n,a):typeof a!="number"||a===0||Bl.has(n)?n==="float"?i.cssFloat=a:i[n]=(""+a).trim():i[n]=a+"px"}function Ts(i,n,a){if(n!=null&&typeof n!="object")throw Error(r(62));if(i=i.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||n!=null&&n.hasOwnProperty(l)||(l.indexOf("--")===0?i.setProperty(l,""):l==="float"?i.cssFloat="":i[l]="");for(var u in n)l=n[u],n.hasOwnProperty(u)&&a[u]!==l&&La(i,u,l)}else for(var d in n)n.hasOwnProperty(d)&&La(i,d,n[d])}function en(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 Hn=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),er=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function ps(i){return er.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Sn(){}var M=null;function J(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Be=null,Ke=null;function qe(i){var n=On(i);if(n&&(i=n.stateNode)){var a=i[bi]||null;e:switch(i=n.stateNode,n.type){case"input":if(Wr(i,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),n=a.name,a.type==="radio"&&n!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Ui(""+n)+'"][type="radio"]'),n=0;n<a.length;n++){var l=a[n];if(l!==i&&l.form===i.form){var u=l[bi]||null;if(!u)throw Error(r(90));Wr(l,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(n=0;n<a.length;n++)l=a[n],l.form===i.form&&ks(l)}break e;case"textarea":Aa(i,a.value,a.defaultValue);break e;case"select":n=a.value,n!=null&&fs(i,!!a.multiple,n,!1)}}}var Je=!1;function Bt(i,n,a){if(Je)return i(n,a);Je=!0;try{var l=i(n);return l}finally{if(Je=!1,(Be!==null||Ke!==null)&&(Jc(),Be&&(n=Be,i=Ke,Ke=Be=null,qe(n),i)))for(n=0;n<i.length;n++)qe(i[n])}}function Vt(i,n){var a=i.stateNode;if(a===null)return null;var l=a[bi]||null;if(l===null)return null;a=l[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(i=i.type,l=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!l;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(r(231,n,typeof a));return a}var dt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bt=!1;if(dt)try{var Vi={};Object.defineProperty(Vi,"passive",{get:function(){bt=!0}}),window.addEventListener("test",Vi,Vi),window.removeEventListener("test",Vi,Vi)}catch{bt=!1}var Yt=null,x=null,k=null;function j(){if(k)return k;var i,n=x,a=n.length,l,u="value"in Yt?Yt.value:Yt.textContent,d=u.length;for(i=0;i<a&&n[i]===u[i];i++);var _=a-i;for(l=1;l<=_&&n[a-l]===u[d-l];l++);return k=u.slice(i,1<l?1-l:void 0)}function te(i){var n=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&n===13&&(i=13)):i=n,i===10&&(i=13),32<=i||i===13?i:0}function ye(){return!0}function ge(){return!1}function Se(i){function n(a,l,u,d,_){this._reactName=a,this._targetInst=u,this.type=l,this.nativeEvent=d,this.target=_,this.currentTarget=null;for(var C in i)i.hasOwnProperty(C)&&(a=i[C],this[C]=a?a(d):d[C]);return this.isDefaultPrevented=(d.defaultPrevented!=null?d.defaultPrevented:d.returnValue===!1)?ye:ge,this.isPropagationStopped=ge,this}return b(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ye)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ye)},persist:function(){},isPersistent:ye}),n}var Pe={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},it=Se(Pe),Xt=b({},Pe,{view:0,detail:0}),ni=Se(Xt),Ba,Bh,Ol,_c=b({},Xt,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zh,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!==Ol&&(Ol&&i.type==="mousemove"?(Ba=i.screenX-Ol.screenX,Bh=i.screenY-Ol.screenY):Bh=Ba=0,Ol=i),Ba)},movementY:function(i){return"movementY"in i?i.movementY:Bh}}),Og=Se(_c),iC=b({},_c,{dataTransfer:0}),nC=Se(iC),sC=b({},Xt,{relatedTarget:0}),Oh=Se(sC),rC=b({},Pe,{animationName:0,elapsedTime:0,pseudoElement:0}),aC=Se(rC),lC=b({},Pe,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),oC=Se(lC),cC=b({},Pe,{data:0}),zg=Se(cC),uC={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hC={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"},dC={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fC(i){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(i):(i=dC[i])?!!n[i]:!1}function zh(){return fC}var pC=b({},Xt,{key:function(i){if(i.key){var n=uC[i.key]||i.key;if(n!=="Unidentified")return n}return i.type==="keypress"?(i=te(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?hC[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zh,charCode:function(i){return i.type==="keypress"?te(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?te(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),mC=Se(pC),gC=b({},_c,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),jg=Se(gC),_C=b({},Xt,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zh}),vC=Se(_C),bC=b({},Pe,{propertyName:0,elapsedTime:0,pseudoElement:0}),yC=Se(bC),SC=b({},_c,{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}),wC=Se(SC),CC=b({},Pe,{newState:0,oldState:0}),xC=Se(CC),EC=[9,13,27,32],jh=dt&&"CompositionEvent"in window,zl=null;dt&&"documentMode"in document&&(zl=document.documentMode);var kC=dt&&"TextEvent"in window&&!zl,Hg=dt&&(!jh||zl&&8<zl&&11>=zl),Pg=" ",Ug=!1;function Ig(i,n){switch(i){case"keyup":return EC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kg(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Oa=!1;function TC(i,n){switch(i){case"compositionend":return Kg(n);case"keypress":return n.which!==32?null:(Ug=!0,Pg);case"textInput":return i=n.data,i===Pg&&Ug?null:i;default:return null}}function DC(i,n){if(Oa)return i==="compositionend"||!jh&&Ig(i,n)?(i=j(),k=x=Yt=null,Oa=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Hg&&n.locale!=="ko"?null:n.data;default:return null}}var RC={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 Wg(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n==="input"?!!RC[i.type]:n==="textarea"}function Fg(i,n,a,l){Be?Ke?Ke.push(l):Ke=[l]:Be=l,n=au(n,"onChange"),0<n.length&&(a=new it("onChange","change",null,a,l),i.push({event:a,listeners:n}))}var jl=null,Hl=null;function MC(i){kb(i,0)}function vc(i){var n=Lt(i);if(ks(n))return i}function qg(i,n){if(i==="change")return n}var $g=!1;if(dt){var Hh;if(dt){var Ph="oninput"in document;if(!Ph){var Vg=document.createElement("div");Vg.setAttribute("oninput","return;"),Ph=typeof Vg.oninput=="function"}Hh=Ph}else Hh=!1;$g=Hh&&(!document.documentMode||9<document.documentMode)}function Yg(){jl&&(jl.detachEvent("onpropertychange",Xg),Hl=jl=null)}function Xg(i){if(i.propertyName==="value"&&vc(Hl)){var n=[];Fg(n,Hl,i,J(i)),Bt(MC,n)}}function NC(i,n,a){i==="focusin"?(Yg(),jl=n,Hl=a,jl.attachEvent("onpropertychange",Xg)):i==="focusout"&&Yg()}function AC(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return vc(Hl)}function LC(i,n){if(i==="click")return vc(n)}function BC(i,n){if(i==="input"||i==="change")return vc(n)}function OC(i,n){return i===n&&(i!==0||1/i===1/n)||i!==i&&n!==n}var wn=typeof Object.is=="function"?Object.is:OC;function Pl(i,n){if(wn(i,n))return!0;if(typeof i!="object"||i===null||typeof n!="object"||n===null)return!1;var a=Object.keys(i),l=Object.keys(n);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var u=a[l];if(!Ae.call(n,u)||!wn(i[u],n[u]))return!1}return!0}function Gg(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Zg(i,n){var a=Gg(i);i=0;for(var l;a;){if(a.nodeType===3){if(l=i+a.textContent.length,i<=n&&l>=n)return{node:a,offset:n-i};i=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Gg(a)}}function Qg(i,n){return i&&n?i===n?!0:i&&i.nodeType===3?!1:n&&n.nodeType===3?Qg(i,n.parentNode):"contains"in i?i.contains(n):i.compareDocumentPosition?!!(i.compareDocumentPosition(n)&16):!1:!1}function Jg(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var n=ss(i.document);n instanceof i.HTMLIFrameElement;){try{var a=typeof n.contentWindow.location.href=="string"}catch{a=!1}if(a)i=n.contentWindow;else break;n=ss(i.document)}return n}function Uh(i){var n=i&&i.nodeName&&i.nodeName.toLowerCase();return n&&(n==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||n==="textarea"||i.contentEditable==="true")}var zC=dt&&"documentMode"in document&&11>=document.documentMode,za=null,Ih=null,Ul=null,Kh=!1;function e_(i,n,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Kh||za==null||za!==ss(l)||(l=za,"selectionStart"in l&&Uh(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}),Ul&&Pl(Ul,l)||(Ul=l,l=au(Ih,"onSelect"),0<l.length&&(n=new it("onSelect","select",null,n,a),i.push({event:n,listeners:l}),n.target=za)))}function qr(i,n){var a={};return a[i.toLowerCase()]=n.toLowerCase(),a["Webkit"+i]="webkit"+n,a["Moz"+i]="moz"+n,a}var ja={animationend:qr("Animation","AnimationEnd"),animationiteration:qr("Animation","AnimationIteration"),animationstart:qr("Animation","AnimationStart"),transitionrun:qr("Transition","TransitionRun"),transitionstart:qr("Transition","TransitionStart"),transitioncancel:qr("Transition","TransitionCancel"),transitionend:qr("Transition","TransitionEnd")},Wh={},t_={};dt&&(t_=document.createElement("div").style,"AnimationEvent"in window||(delete ja.animationend.animation,delete ja.animationiteration.animation,delete ja.animationstart.animation),"TransitionEvent"in window||delete ja.transitionend.transition);function $r(i){if(Wh[i])return Wh[i];if(!ja[i])return i;var n=ja[i],a;for(a in n)if(n.hasOwnProperty(a)&&a in t_)return Wh[i]=n[a];return i}var i_=$r("animationend"),n_=$r("animationiteration"),s_=$r("animationstart"),jC=$r("transitionrun"),HC=$r("transitionstart"),PC=$r("transitioncancel"),r_=$r("transitionend"),a_=new Map,Fh="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Fh.push("scrollEnd");function rs(i,n){a_.set(i,n),zn(n,[i])}var bc=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Pn=[],Ha=0,qh=0;function yc(){for(var i=Ha,n=qh=Ha=0;n<i;){var a=Pn[n];Pn[n++]=null;var l=Pn[n];Pn[n++]=null;var u=Pn[n];Pn[n++]=null;var d=Pn[n];if(Pn[n++]=null,l!==null&&u!==null){var _=l.pending;_===null?u.next=u:(u.next=_.next,_.next=u),l.pending=u}d!==0&&l_(a,u,d)}}function Sc(i,n,a,l){Pn[Ha++]=i,Pn[Ha++]=n,Pn[Ha++]=a,Pn[Ha++]=l,qh|=l,i.lanes|=l,i=i.alternate,i!==null&&(i.lanes|=l)}function $h(i,n,a,l){return Sc(i,n,a,l),wc(i)}function Vr(i,n){return Sc(i,null,null,n),wc(i)}function l_(i,n,a){i.lanes|=a;var l=i.alternate;l!==null&&(l.lanes|=a);for(var u=!1,d=i.return;d!==null;)d.childLanes|=a,l=d.alternate,l!==null&&(l.childLanes|=a),d.tag===22&&(i=d.stateNode,i===null||i._visibility&1||(u=!0)),i=d,d=d.return;return i.tag===3?(d=i.stateNode,u&&n!==null&&(u=31-Dt(a),i=d.hiddenUpdates,l=i[u],l===null?i[u]=[n]:l.push(n),n.lane=a|536870912),d):null}function wc(i){if(50<oo)throw oo=0,tf=null,Error(r(185));for(var n=i.return;n!==null;)i=n,n=i.return;return i.tag===3?i.stateNode:null}var Pa={};function UC(i,n,a,l){this.tag=i,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Cn(i,n,a,l){return new UC(i,n,a,l)}function Vh(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ds(i,n){var a=i.alternate;return a===null?(a=Cn(i.tag,n,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=n,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&65011712,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,n=i.dependencies,a.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a.refCleanup=i.refCleanup,a}function o_(i,n){i.flags&=65011714;var a=i.alternate;return a===null?(i.childLanes=0,i.lanes=n,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,n=a.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),i}function Cc(i,n,a,l,u,d){var _=0;if(l=i,typeof i=="function")Vh(i)&&(_=1);else if(typeof i=="string")_=qx(i,a,de.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case ve:return i=Cn(31,a,n,u),i.elementType=ve,i.lanes=d,i;case T:return Yr(a.children,u,d,n);case O:_=8,u|=24;break;case L:return i=Cn(12,a,n,u|2),i.elementType=L,i.lanes=d,i;case Q:return i=Cn(13,a,n,u),i.elementType=Q,i.lanes=d,i;case ie:return i=Cn(19,a,n,u),i.elementType=ie,i.lanes=d,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case I:_=10;break e;case N:_=9;break e;case U:_=11;break e;case le:_=14;break e;case ce:_=16,l=null;break e}_=29,a=Error(r(130,i===null?"null":typeof i,"")),l=null}return n=Cn(_,a,n,u),n.elementType=i,n.type=l,n.lanes=d,n}function Yr(i,n,a,l){return i=Cn(7,i,l,n),i.lanes=a,i}function Yh(i,n,a){return i=Cn(6,i,null,n),i.lanes=a,i}function c_(i){var n=Cn(18,null,null,0);return n.stateNode=i,n}function Xh(i,n,a){return n=Cn(4,i.children!==null?i.children:[],i.key,n),n.lanes=a,n.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},n}var u_=new WeakMap;function Un(i,n){if(typeof i=="object"&&i!==null){var a=u_.get(i);return a!==void 0?a:(n={value:i,source:n,stack:xe(n)},u_.set(i,n),n)}return{value:i,source:n,stack:xe(n)}}var Ua=[],Ia=0,xc=null,Il=0,In=[],Kn=0,tr=null,ms=1,gs="";function Rs(i,n){Ua[Ia++]=Il,Ua[Ia++]=xc,xc=i,Il=n}function h_(i,n,a){In[Kn++]=ms,In[Kn++]=gs,In[Kn++]=tr,tr=i;var l=ms;i=gs;var u=32-Dt(l)-1;l&=~(1<<u),a+=1;var d=32-Dt(n)+u;if(30<d){var _=u-u%5;d=(l&(1<<_)-1).toString(32),l>>=_,u-=_,ms=1<<32-Dt(n)+u|a<<u|l,gs=d+i}else ms=1<<d|a<<u|l,gs=i}function Gh(i){i.return!==null&&(Rs(i,1),h_(i,1,0))}function Zh(i){for(;i===xc;)xc=Ua[--Ia],Ua[Ia]=null,Il=Ua[--Ia],Ua[Ia]=null;for(;i===tr;)tr=In[--Kn],In[Kn]=null,gs=In[--Kn],In[Kn]=null,ms=In[--Kn],In[Kn]=null}function d_(i,n){In[Kn++]=ms,In[Kn++]=gs,In[Kn++]=tr,ms=n.id,gs=n.overflow,tr=i}var Ii=null,Ot=null,ht=!1,ir=null,Wn=!1,Qh=Error(r(519));function nr(i){var n=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Kl(Un(n,i)),Qh}function f_(i){var n=i.stateNode,a=i.type,l=i.memoizedProps;switch(n[It]=i,n[bi]=l,a){case"dialog":lt("cancel",n),lt("close",n);break;case"iframe":case"object":case"embed":lt("load",n);break;case"video":case"audio":for(a=0;a<uo.length;a++)lt(uo[a],n);break;case"source":lt("error",n);break;case"img":case"image":case"link":lt("error",n),lt("load",n);break;case"details":lt("toggle",n);break;case"input":lt("invalid",n),Qs(n,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":lt("invalid",n);break;case"textarea":lt("invalid",n),Js(n,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||n.textContent===""+a||l.suppressHydrationWarning===!0||Mb(n.textContent,a)?(l.popover!=null&&(lt("beforetoggle",n),lt("toggle",n)),l.onScroll!=null&<("scroll",n),l.onScrollEnd!=null&<("scrollend",n),l.onClick!=null&&(n.onclick=Sn),n=!0):n=!1,n||nr(i,!0)}function p_(i){for(Ii=i.return;Ii;)switch(Ii.tag){case 5:case 31:case 13:Wn=!1;return;case 27:case 3:Wn=!0;return;default:Ii=Ii.return}}function Ka(i){if(i!==Ii)return!1;if(!ht)return p_(i),ht=!0,!1;var n=i.tag,a;if((a=n!==3&&n!==27)&&((a=n===5)&&(a=i.type,a=!(a!=="form"&&a!=="button")||_f(i.type,i.memoizedProps)),a=!a),a&&Ot&&nr(i),p_(i),n===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Ot=Pb(i)}else if(n===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));Ot=Pb(i)}else n===27?(n=Ot,_r(i.type)?(i=wf,wf=null,Ot=i):Ot=n):Ot=Ii?qn(i.stateNode.nextSibling):null;return!0}function Xr(){Ot=Ii=null,ht=!1}function Jh(){var i=ir;return i!==null&&(dn===null?dn=i:dn.push.apply(dn,i),ir=null),i}function Kl(i){ir===null?ir=[i]:ir.push(i)}var ed=R(null),Gr=null,Ms=null;function sr(i,n,a){ee(ed,n._currentValue),n._currentValue=a}function Ns(i){i._currentValue=ed.current,H(ed)}function td(i,n,a){for(;i!==null;){var l=i.alternate;if((i.childLanes&n)!==n?(i.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),i===a)break;i=i.return}}function id(i,n,a,l){var u=i.child;for(u!==null&&(u.return=i);u!==null;){var d=u.dependencies;if(d!==null){var _=u.child;d=d.firstContext;e:for(;d!==null;){var C=d;d=u;for(var A=0;A<n.length;A++)if(C.context===n[A]){d.lanes|=a,C=d.alternate,C!==null&&(C.lanes|=a),td(d.return,a,i),l||(_=null);break e}d=C.next}}else if(u.tag===18){if(_=u.return,_===null)throw Error(r(341));_.lanes|=a,d=_.alternate,d!==null&&(d.lanes|=a),td(_,a,i),_=null}else _=u.child;if(_!==null)_.return=u;else for(_=u;_!==null;){if(_===i){_=null;break}if(u=_.sibling,u!==null){u.return=_.return,_=u;break}_=_.return}u=_}}function Wa(i,n,a,l){i=null;for(var u=n,d=!1;u!==null;){if(!d){if((u.flags&524288)!==0)d=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var _=u.alternate;if(_===null)throw Error(r(387));if(_=_.memoizedProps,_!==null){var C=u.type;wn(u.pendingProps.value,_.value)||(i!==null?i.push(C):i=[C])}}else if(u===Me.current){if(_=u.alternate,_===null)throw Error(r(387));_.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(i!==null?i.push(go):i=[go])}u=u.return}i!==null&&id(n,i,a,l),n.flags|=262144}function Ec(i){for(i=i.firstContext;i!==null;){if(!wn(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function Zr(i){Gr=i,Ms=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Ki(i){return m_(Gr,i)}function kc(i,n){return Gr===null&&Zr(i),m_(i,n)}function m_(i,n){var a=n._currentValue;if(n={context:n,memoizedValue:a,next:null},Ms===null){if(i===null)throw Error(r(308));Ms=n,i.dependencies={lanes:0,firstContext:n},i.flags|=524288}else Ms=Ms.next=n;return a}var IC=typeof AbortController<"u"?AbortController:function(){var i=[],n=this.signal={aborted:!1,addEventListener:function(a,l){i.push(l)}};this.abort=function(){n.aborted=!0,i.forEach(function(a){return a()})}},KC=e.unstable_scheduleCallback,WC=e.unstable_NormalPriority,hi={$$typeof:I,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function nd(){return{controller:new IC,data:new Map,refCount:0}}function Wl(i){i.refCount--,i.refCount===0&&KC(WC,function(){i.controller.abort()})}var Fl=null,sd=0,Fa=0,qa=null;function FC(i,n){if(Fl===null){var a=Fl=[];sd=0,Fa=of(),qa={status:"pending",value:void 0,then:function(l){a.push(l)}}}return sd++,n.then(g_,g_),n}function g_(){if(--sd===0&&Fl!==null){qa!==null&&(qa.status="fulfilled");var i=Fl;Fl=null,Fa=0,qa=null;for(var n=0;n<i.length;n++)(0,i[n])()}}function qC(i,n){var a=[],l={status:"pending",value:null,reason:null,then:function(u){a.push(u)}};return i.then(function(){l.status="fulfilled",l.value=n;for(var u=0;u<a.length;u++)(0,a[u])(n)},function(u){for(l.status="rejected",l.reason=u,u=0;u<a.length;u++)(0,a[u])(void 0)}),l}var __=B.S;B.S=function(i,n){eb=st(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&FC(i,n),__!==null&&__(i,n)};var Qr=R(null);function rd(){var i=Qr.current;return i!==null?i:Mt.pooledCache}function Tc(i,n){n===null?ee(Qr,Qr.current):ee(Qr,n.pool)}function v_(){var i=rd();return i===null?null:{parent:hi._currentValue,pool:i}}var $a=Error(r(460)),ad=Error(r(474)),Dc=Error(r(542)),Rc={then:function(){}};function b_(i){return i=i.status,i==="fulfilled"||i==="rejected"}function y_(i,n,a){switch(a=i[a],a===void 0?i.push(n):a!==n&&(n.then(Sn,Sn),n=a),n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,w_(i),i;default:if(typeof n.status=="string")n.then(Sn,Sn);else{if(i=Mt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=n,i.status="pending",i.then(function(l){if(n.status==="pending"){var u=n;u.status="fulfilled",u.value=l}},function(l){if(n.status==="pending"){var u=n;u.status="rejected",u.reason=l}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw i=n.reason,w_(i),i}throw ea=n,$a}}function Jr(i){try{var n=i._init;return n(i._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ea=a,$a):a}}var ea=null;function S_(){if(ea===null)throw Error(r(459));var i=ea;return ea=null,i}function w_(i){if(i===$a||i===Dc)throw Error(r(483))}var Va=null,ql=0;function Mc(i){var n=ql;return ql+=1,Va===null&&(Va=[]),y_(Va,i,n)}function $l(i,n){n=n.props.ref,i.ref=n!==void 0?n:null}function Nc(i,n){throw n.$$typeof===w?Error(r(525)):(i=Object.prototype.toString.call(n),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":i)))}function C_(i){function n(P,z){if(i){var q=P.deletions;q===null?(P.deletions=[z],P.flags|=16):q.push(z)}}function a(P,z){if(!i)return null;for(;z!==null;)n(P,z),z=z.sibling;return null}function l(P){for(var z=new Map;P!==null;)P.key!==null?z.set(P.key,P):z.set(P.index,P),P=P.sibling;return z}function u(P,z){return P=Ds(P,z),P.index=0,P.sibling=null,P}function d(P,z,q){return P.index=q,i?(q=P.alternate,q!==null?(q=q.index,q<z?(P.flags|=67108866,z):q):(P.flags|=67108866,z)):(P.flags|=1048576,z)}function _(P){return i&&P.alternate===null&&(P.flags|=67108866),P}function C(P,z,q,ue){return z===null||z.tag!==6?(z=Yh(q,P.mode,ue),z.return=P,z):(z=u(z,q),z.return=P,z)}function A(P,z,q,ue){var Ue=q.type;return Ue===T?ae(P,z,q.props.children,ue,q.key):z!==null&&(z.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===ce&&Jr(Ue)===z.type)?(z=u(z,q.props),$l(z,q),z.return=P,z):(z=Cc(q.type,q.key,q.props,null,P.mode,ue),$l(z,q),z.return=P,z)}function $(P,z,q,ue){return z===null||z.tag!==4||z.stateNode.containerInfo!==q.containerInfo||z.stateNode.implementation!==q.implementation?(z=Xh(q,P.mode,ue),z.return=P,z):(z=u(z,q.children||[]),z.return=P,z)}function ae(P,z,q,ue,Ue){return z===null||z.tag!==7?(z=Yr(q,P.mode,ue,Ue),z.return=P,z):(z=u(z,q),z.return=P,z)}function fe(P,z,q){if(typeof z=="string"&&z!==""||typeof z=="number"||typeof z=="bigint")return z=Yh(""+z,P.mode,q),z.return=P,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case S:return q=Cc(z.type,z.key,z.props,null,P.mode,q),$l(q,z),q.return=P,q;case E:return z=Xh(z,P.mode,q),z.return=P,z;case ce:return z=Jr(z),fe(P,z,q)}if(re(z)||se(z))return z=Yr(z,P.mode,q,null),z.return=P,z;if(typeof z.then=="function")return fe(P,Mc(z),q);if(z.$$typeof===I)return fe(P,kc(P,z),q);Nc(P,z)}return null}function Y(P,z,q,ue){var Ue=z!==null?z.key:null;if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return Ue!==null?null:C(P,z,""+q,ue);if(typeof q=="object"&&q!==null){switch(q.$$typeof){case S:return q.key===Ue?A(P,z,q,ue):null;case E:return q.key===Ue?$(P,z,q,ue):null;case ce:return q=Jr(q),Y(P,z,q,ue)}if(re(q)||se(q))return Ue!==null?null:ae(P,z,q,ue,null);if(typeof q.then=="function")return Y(P,z,Mc(q),ue);if(q.$$typeof===I)return Y(P,z,kc(P,q),ue);Nc(P,q)}return null}function Z(P,z,q,ue,Ue){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return P=P.get(q)||null,C(z,P,""+ue,Ue);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case S:return P=P.get(ue.key===null?q:ue.key)||null,A(z,P,ue,Ue);case E:return P=P.get(ue.key===null?q:ue.key)||null,$(z,P,ue,Ue);case ce:return ue=Jr(ue),Z(P,z,q,ue,Ue)}if(re(ue)||se(ue))return P=P.get(q)||null,ae(z,P,ue,Ue,null);if(typeof ue.then=="function")return Z(P,z,q,Mc(ue),Ue);if(ue.$$typeof===I)return Z(P,z,q,kc(z,ue),Ue);Nc(z,ue)}return null}function Le(P,z,q,ue){for(var Ue=null,ft=null,je=z,Ze=z=0,ut=null;je!==null&&Ze<q.length;Ze++){je.index>Ze?(ut=je,je=null):ut=je.sibling;var pt=Y(P,je,q[Ze],ue);if(pt===null){je===null&&(je=ut);break}i&&je&&pt.alternate===null&&n(P,je),z=d(pt,z,Ze),ft===null?Ue=pt:ft.sibling=pt,ft=pt,je=ut}if(Ze===q.length)return a(P,je),ht&&Rs(P,Ze),Ue;if(je===null){for(;Ze<q.length;Ze++)je=fe(P,q[Ze],ue),je!==null&&(z=d(je,z,Ze),ft===null?Ue=je:ft.sibling=je,ft=je);return ht&&Rs(P,Ze),Ue}for(je=l(je);Ze<q.length;Ze++)ut=Z(je,P,Ze,q[Ze],ue),ut!==null&&(i&&ut.alternate!==null&&je.delete(ut.key===null?Ze:ut.key),z=d(ut,z,Ze),ft===null?Ue=ut:ft.sibling=ut,ft=ut);return i&&je.forEach(function(wr){return n(P,wr)}),ht&&Rs(P,Ze),Ue}function We(P,z,q,ue){if(q==null)throw Error(r(151));for(var Ue=null,ft=null,je=z,Ze=z=0,ut=null,pt=q.next();je!==null&&!pt.done;Ze++,pt=q.next()){je.index>Ze?(ut=je,je=null):ut=je.sibling;var wr=Y(P,je,pt.value,ue);if(wr===null){je===null&&(je=ut);break}i&&je&&wr.alternate===null&&n(P,je),z=d(wr,z,Ze),ft===null?Ue=wr:ft.sibling=wr,ft=wr,je=ut}if(pt.done)return a(P,je),ht&&Rs(P,Ze),Ue;if(je===null){for(;!pt.done;Ze++,pt=q.next())pt=fe(P,pt.value,ue),pt!==null&&(z=d(pt,z,Ze),ft===null?Ue=pt:ft.sibling=pt,ft=pt);return ht&&Rs(P,Ze),Ue}for(je=l(je);!pt.done;Ze++,pt=q.next())pt=Z(je,P,Ze,pt.value,ue),pt!==null&&(i&&pt.alternate!==null&&je.delete(pt.key===null?Ze:pt.key),z=d(pt,z,Ze),ft===null?Ue=pt:ft.sibling=pt,ft=pt);return i&&je.forEach(function(iE){return n(P,iE)}),ht&&Rs(P,Ze),Ue}function kt(P,z,q,ue){if(typeof q=="object"&&q!==null&&q.type===T&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case S:e:{for(var Ue=q.key;z!==null;){if(z.key===Ue){if(Ue=q.type,Ue===T){if(z.tag===7){a(P,z.sibling),ue=u(z,q.props.children),ue.return=P,P=ue;break e}}else if(z.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===ce&&Jr(Ue)===z.type){a(P,z.sibling),ue=u(z,q.props),$l(ue,q),ue.return=P,P=ue;break e}a(P,z);break}else n(P,z);z=z.sibling}q.type===T?(ue=Yr(q.props.children,P.mode,ue,q.key),ue.return=P,P=ue):(ue=Cc(q.type,q.key,q.props,null,P.mode,ue),$l(ue,q),ue.return=P,P=ue)}return _(P);case E:e:{for(Ue=q.key;z!==null;){if(z.key===Ue)if(z.tag===4&&z.stateNode.containerInfo===q.containerInfo&&z.stateNode.implementation===q.implementation){a(P,z.sibling),ue=u(z,q.children||[]),ue.return=P,P=ue;break e}else{a(P,z);break}else n(P,z);z=z.sibling}ue=Xh(q,P.mode,ue),ue.return=P,P=ue}return _(P);case ce:return q=Jr(q),kt(P,z,q,ue)}if(re(q))return Le(P,z,q,ue);if(se(q)){if(Ue=se(q),typeof Ue!="function")throw Error(r(150));return q=Ue.call(q),We(P,z,q,ue)}if(typeof q.then=="function")return kt(P,z,Mc(q),ue);if(q.$$typeof===I)return kt(P,z,kc(P,q),ue);Nc(P,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,z!==null&&z.tag===6?(a(P,z.sibling),ue=u(z,q),ue.return=P,P=ue):(a(P,z),ue=Yh(q,P.mode,ue),ue.return=P,P=ue),_(P)):a(P,z)}return function(P,z,q,ue){try{ql=0;var Ue=kt(P,z,q,ue);return Va=null,Ue}catch(je){if(je===$a||je===Dc)throw je;var ft=Cn(29,je,null,P.mode);return ft.lanes=ue,ft.return=P,ft}}}var ta=C_(!0),x_=C_(!1),rr=!1;function ld(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function od(i,n){i=i.updateQueue,n.updateQueue===i&&(n.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ar(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function lr(i,n,a){var l=i.updateQueue;if(l===null)return null;if(l=l.shared,(mt&2)!==0){var u=l.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),l.pending=n,n=wc(i),l_(i,null,a),n}return Sc(i,l,n,a),wc(i)}function Vl(i,n,a){if(n=n.updateQueue,n!==null&&(n=n.shared,(a&4194048)!==0)){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,ii(i,a)}}function cd(i,n){var a=i.updateQueue,l=i.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var u=null,d=null;if(a=a.firstBaseUpdate,a!==null){do{var _={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};d===null?u=d=_:d=d.next=_,a=a.next}while(a!==null);d===null?u=d=n:d=d.next=n}else u=d=n;a={baseState:l.baseState,firstBaseUpdate:u,lastBaseUpdate:d,shared:l.shared,callbacks:l.callbacks},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=n:i.next=n,a.lastBaseUpdate=n}var ud=!1;function Yl(){if(ud){var i=qa;if(i!==null)throw i}}function Xl(i,n,a,l){ud=!1;var u=i.updateQueue;rr=!1;var d=u.firstBaseUpdate,_=u.lastBaseUpdate,C=u.shared.pending;if(C!==null){u.shared.pending=null;var A=C,$=A.next;A.next=null,_===null?d=$:_.next=$,_=A;var ae=i.alternate;ae!==null&&(ae=ae.updateQueue,C=ae.lastBaseUpdate,C!==_&&(C===null?ae.firstBaseUpdate=$:C.next=$,ae.lastBaseUpdate=A))}if(d!==null){var fe=u.baseState;_=0,ae=$=A=null,C=d;do{var Y=C.lane&-536870913,Z=Y!==C.lane;if(Z?(ct&Y)===Y:(l&Y)===Y){Y!==0&&Y===Fa&&(ud=!0),ae!==null&&(ae=ae.next={lane:0,tag:C.tag,payload:C.payload,callback:null,next:null});e:{var Le=i,We=C;Y=n;var kt=a;switch(We.tag){case 1:if(Le=We.payload,typeof Le=="function"){fe=Le.call(kt,fe,Y);break e}fe=Le;break e;case 3:Le.flags=Le.flags&-65537|128;case 0:if(Le=We.payload,Y=typeof Le=="function"?Le.call(kt,fe,Y):Le,Y==null)break e;fe=b({},fe,Y);break e;case 2:rr=!0}}Y=C.callback,Y!==null&&(i.flags|=64,Z&&(i.flags|=8192),Z=u.callbacks,Z===null?u.callbacks=[Y]:Z.push(Y))}else Z={lane:Y,tag:C.tag,payload:C.payload,callback:C.callback,next:null},ae===null?($=ae=Z,A=fe):ae=ae.next=Z,_|=Y;if(C=C.next,C===null){if(C=u.shared.pending,C===null)break;Z=C,C=Z.next,Z.next=null,u.lastBaseUpdate=Z,u.shared.pending=null}}while(!0);ae===null&&(A=fe),u.baseState=A,u.firstBaseUpdate=$,u.lastBaseUpdate=ae,d===null&&(u.shared.lanes=0),dr|=_,i.lanes=_,i.memoizedState=fe}}function E_(i,n){if(typeof i!="function")throw Error(r(191,i));i.call(n)}function k_(i,n){var a=i.callbacks;if(a!==null)for(i.callbacks=null,i=0;i<a.length;i++)E_(a[i],n)}var Ya=R(null),Ac=R(0);function T_(i,n){i=Us,ee(Ac,i),ee(Ya,n),Us=i|n.baseLanes}function hd(){ee(Ac,Us),ee(Ya,Ya.current)}function dd(){Us=Ac.current,H(Ya),H(Ac)}var xn=R(null),Fn=null;function or(i){var n=i.alternate;ee(si,si.current&1),ee(xn,i),Fn===null&&(n===null||Ya.current!==null||n.memoizedState!==null)&&(Fn=i)}function fd(i){ee(si,si.current),ee(xn,i),Fn===null&&(Fn=i)}function D_(i){i.tag===22?(ee(si,si.current),ee(xn,i),Fn===null&&(Fn=i)):cr()}function cr(){ee(si,si.current),ee(xn,xn.current)}function En(i){H(xn),Fn===i&&(Fn=null),H(si)}var si=R(0);function Lc(i){for(var n=i;n!==null;){if(n.tag===13){var a=n.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||yf(a)||Sf(a)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var As=0,Ge=null,xt=null,di=null,Bc=!1,Xa=!1,ia=!1,Oc=0,Gl=0,Ga=null,$C=0;function Gt(){throw Error(r(321))}function pd(i,n){if(n===null)return!1;for(var a=0;a<n.length&&a<i.length;a++)if(!wn(i[a],n[a]))return!1;return!0}function md(i,n,a,l,u,d){return As=d,Ge=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,B.H=i===null||i.memoizedState===null?hv:Md,ia=!1,d=a(l,u),ia=!1,Xa&&(d=M_(n,a,l,u)),R_(i),d}function R_(i){B.H=Jl;var n=xt!==null&&xt.next!==null;if(As=0,di=xt=Ge=null,Bc=!1,Gl=0,Ga=null,n)throw Error(r(300));i===null||fi||(i=i.dependencies,i!==null&&Ec(i)&&(fi=!0))}function M_(i,n,a,l){Ge=i;var u=0;do{if(Xa&&(Ga=null),Gl=0,Xa=!1,25<=u)throw Error(r(301));if(u+=1,di=xt=null,i.updateQueue!=null){var d=i.updateQueue;d.lastEffect=null,d.events=null,d.stores=null,d.memoCache!=null&&(d.memoCache.index=0)}B.H=dv,d=n(a,l)}while(Xa);return d}function VC(){var i=B.H,n=i.useState()[0];return n=typeof n.then=="function"?Zl(n):n,i=i.useState()[0],(xt!==null?xt.memoizedState:null)!==i&&(Ge.flags|=1024),n}function gd(){var i=Oc!==0;return Oc=0,i}function _d(i,n,a){n.updateQueue=i.updateQueue,n.flags&=-2053,i.lanes&=~a}function vd(i){if(Bc){for(i=i.memoizedState;i!==null;){var n=i.queue;n!==null&&(n.pending=null),i=i.next}Bc=!1}As=0,di=xt=Ge=null,Xa=!1,Gl=Oc=0,Ga=null}function tn(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return di===null?Ge.memoizedState=di=i:di=di.next=i,di}function ri(){if(xt===null){var i=Ge.alternate;i=i!==null?i.memoizedState:null}else i=xt.next;var n=di===null?Ge.memoizedState:di.next;if(n!==null)di=n,xt=i;else{if(i===null)throw Ge.alternate===null?Error(r(467)):Error(r(310));xt=i,i={memoizedState:xt.memoizedState,baseState:xt.baseState,baseQueue:xt.baseQueue,queue:xt.queue,next:null},di===null?Ge.memoizedState=di=i:di=di.next=i}return di}function zc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Zl(i){var n=Gl;return Gl+=1,Ga===null&&(Ga=[]),i=y_(Ga,i,n),n=Ge,(di===null?n.memoizedState:di.next)===null&&(n=n.alternate,B.H=n===null||n.memoizedState===null?hv:Md),i}function jc(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Zl(i);if(i.$$typeof===I)return Ki(i)}throw Error(r(438,String(i)))}function bd(i){var n=null,a=Ge.updateQueue;if(a!==null&&(n=a.memoCache),n==null){var l=Ge.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(n={data:l.data.map(function(u){return u.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),a===null&&(a=zc(),Ge.updateQueue=a),a.memoCache=n,a=n.data[n.index],a===void 0)for(a=n.data[n.index]=Array(i),l=0;l<i;l++)a[l]=we;return n.index++,a}function Ls(i,n){return typeof n=="function"?n(i):n}function Hc(i){var n=ri();return yd(n,xt,i)}function yd(i,n,a){var l=i.queue;if(l===null)throw Error(r(311));l.lastRenderedReducer=a;var u=i.baseQueue,d=l.pending;if(d!==null){if(u!==null){var _=u.next;u.next=d.next,d.next=_}n.baseQueue=u=d,l.pending=null}if(d=i.baseState,u===null)i.memoizedState=d;else{n=u.next;var C=_=null,A=null,$=n,ae=!1;do{var fe=$.lane&-536870913;if(fe!==$.lane?(ct&fe)===fe:(As&fe)===fe){var Y=$.revertLane;if(Y===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null}),fe===Fa&&(ae=!0);else if((As&Y)===Y){$=$.next,Y===Fa&&(ae=!0);continue}else fe={lane:0,revertLane:$.revertLane,gesture:null,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},A===null?(C=A=fe,_=d):A=A.next=fe,Ge.lanes|=Y,dr|=Y;fe=$.action,ia&&a(d,fe),d=$.hasEagerState?$.eagerState:a(d,fe)}else Y={lane:fe,revertLane:$.revertLane,gesture:$.gesture,action:$.action,hasEagerState:$.hasEagerState,eagerState:$.eagerState,next:null},A===null?(C=A=Y,_=d):A=A.next=Y,Ge.lanes|=fe,dr|=fe;$=$.next}while($!==null&&$!==n);if(A===null?_=d:A.next=C,!wn(d,i.memoizedState)&&(fi=!0,ae&&(a=qa,a!==null)))throw a;i.memoizedState=d,i.baseState=_,i.baseQueue=A,l.lastRenderedState=d}return u===null&&(l.lanes=0),[i.memoizedState,l.dispatch]}function Sd(i){var n=ri(),a=n.queue;if(a===null)throw Error(r(311));a.lastRenderedReducer=i;var l=a.dispatch,u=a.pending,d=n.memoizedState;if(u!==null){a.pending=null;var _=u=u.next;do d=i(d,_.action),_=_.next;while(_!==u);wn(d,n.memoizedState)||(fi=!0),n.memoizedState=d,n.baseQueue===null&&(n.baseState=d),a.lastRenderedState=d}return[d,l]}function N_(i,n,a){var l=Ge,u=ri(),d=ht;if(d){if(a===void 0)throw Error(r(407));a=a()}else a=n();var _=!wn((xt||u).memoizedState,a);if(_&&(u.memoizedState=a,fi=!0),u=u.queue,xd(B_.bind(null,l,u,i),[i]),u.getSnapshot!==n||_||di!==null&&di.memoizedState.tag&1){if(l.flags|=2048,Za(9,{destroy:void 0},L_.bind(null,l,u,a,n),null),Mt===null)throw Error(r(349));d||(As&127)!==0||A_(l,n,a)}return a}function A_(i,n,a){i.flags|=16384,i={getSnapshot:n,value:a},n=Ge.updateQueue,n===null?(n=zc(),Ge.updateQueue=n,n.stores=[i]):(a=n.stores,a===null?n.stores=[i]:a.push(i))}function L_(i,n,a,l){n.value=a,n.getSnapshot=l,O_(n)&&z_(i)}function B_(i,n,a){return a(function(){O_(n)&&z_(i)})}function O_(i){var n=i.getSnapshot;i=i.value;try{var a=n();return!wn(i,a)}catch{return!0}}function z_(i){var n=Vr(i,2);n!==null&&fn(n,i,2)}function wd(i){var n=tn();if(typeof i=="function"){var a=i;if(i=a(),ia){li(!0);try{a()}finally{li(!1)}}}return n.memoizedState=n.baseState=i,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:i},n}function j_(i,n,a,l){return i.baseState=a,yd(i,xt,typeof l=="function"?l:Ls)}function YC(i,n,a,l,u){if(Ic(i))throw Error(r(485));if(i=n.action,i!==null){var d={payload:u,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(_){d.listeners.push(_)}};B.T!==null?a(!0):d.isTransition=!1,l(d),a=n.pending,a===null?(d.next=n.pending=d,H_(n,d)):(d.next=a.next,n.pending=a.next=d)}}function H_(i,n){var a=n.action,l=n.payload,u=i.state;if(n.isTransition){var d=B.T,_={};B.T=_;try{var C=a(u,l),A=B.S;A!==null&&A(_,C),P_(i,n,C)}catch($){Cd(i,n,$)}finally{d!==null&&_.types!==null&&(d.types=_.types),B.T=d}}else try{d=a(u,l),P_(i,n,d)}catch($){Cd(i,n,$)}}function P_(i,n,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){U_(i,n,l)},function(l){return Cd(i,n,l)}):U_(i,n,a)}function U_(i,n,a){n.status="fulfilled",n.value=a,I_(n),i.state=a,n=i.pending,n!==null&&(a=n.next,a===n?i.pending=null:(a=a.next,n.next=a,H_(i,a)))}function Cd(i,n,a){var l=i.pending;if(i.pending=null,l!==null){l=l.next;do n.status="rejected",n.reason=a,I_(n),n=n.next;while(n!==l)}i.action=null}function I_(i){i=i.listeners;for(var n=0;n<i.length;n++)(0,i[n])()}function K_(i,n){return n}function W_(i,n){if(ht){var a=Mt.formState;if(a!==null){e:{var l=Ge;if(ht){if(Ot){t:{for(var u=Ot,d=Wn;u.nodeType!==8;){if(!d){u=null;break t}if(u=qn(u.nextSibling),u===null){u=null;break t}}d=u.data,u=d==="F!"||d==="F"?u:null}if(u){Ot=qn(u.nextSibling),l=u.data==="F!";break e}}nr(l)}l=!1}l&&(n=a[0])}}return a=tn(),a.memoizedState=a.baseState=n,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:K_,lastRenderedState:n},a.queue=l,a=ov.bind(null,Ge,l),l.dispatch=a,l=wd(!1),d=Rd.bind(null,Ge,!1,l.queue),l=tn(),u={state:n,dispatch:null,action:i,pending:null},l.queue=u,a=YC.bind(null,Ge,u,d,a),u.dispatch=a,l.memoizedState=i,[n,a,!1]}function F_(i){var n=ri();return q_(n,xt,i)}function q_(i,n,a){if(n=yd(i,n,K_)[0],i=Hc(Ls)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var l=Zl(n)}catch(_){throw _===$a?Dc:_}else l=n;n=ri();var u=n.queue,d=u.dispatch;return a!==n.memoizedState&&(Ge.flags|=2048,Za(9,{destroy:void 0},XC.bind(null,u,a),null)),[l,d,i]}function XC(i,n){i.action=n}function $_(i){var n=ri(),a=xt;if(a!==null)return q_(n,a,i);ri(),n=n.memoizedState,a=ri();var l=a.queue.dispatch;return a.memoizedState=i,[n,l,!1]}function Za(i,n,a,l){return i={tag:i,create:a,deps:l,inst:n,next:null},n=Ge.updateQueue,n===null&&(n=zc(),Ge.updateQueue=n),a=n.lastEffect,a===null?n.lastEffect=i.next=i:(l=a.next,a.next=i,i.next=l,n.lastEffect=i),i}function V_(){return ri().memoizedState}function Pc(i,n,a,l){var u=tn();Ge.flags|=i,u.memoizedState=Za(1|n,{destroy:void 0},a,l===void 0?null:l)}function Uc(i,n,a,l){var u=ri();l=l===void 0?null:l;var d=u.memoizedState.inst;xt!==null&&l!==null&&pd(l,xt.memoizedState.deps)?u.memoizedState=Za(n,d,a,l):(Ge.flags|=i,u.memoizedState=Za(1|n,d,a,l))}function Y_(i,n){Pc(8390656,8,i,n)}function xd(i,n){Uc(2048,8,i,n)}function GC(i){Ge.flags|=4;var n=Ge.updateQueue;if(n===null)n=zc(),Ge.updateQueue=n,n.events=[i];else{var a=n.events;a===null?n.events=[i]:a.push(i)}}function X_(i){var n=ri().memoizedState;return GC({ref:n,nextImpl:i}),function(){if((mt&2)!==0)throw Error(r(440));return n.impl.apply(void 0,arguments)}}function G_(i,n){return Uc(4,2,i,n)}function Z_(i,n){return Uc(4,4,i,n)}function Q_(i,n){if(typeof n=="function"){i=i();var a=n(i);return function(){typeof a=="function"?a():n(null)}}if(n!=null)return i=i(),n.current=i,function(){n.current=null}}function J_(i,n,a){a=a!=null?a.concat([i]):null,Uc(4,4,Q_.bind(null,n,i),a)}function Ed(){}function ev(i,n){var a=ri();n=n===void 0?null:n;var l=a.memoizedState;return n!==null&&pd(n,l[1])?l[0]:(a.memoizedState=[i,n],i)}function tv(i,n){var a=ri();n=n===void 0?null:n;var l=a.memoizedState;if(n!==null&&pd(n,l[1]))return l[0];if(l=i(),ia){li(!0);try{i()}finally{li(!1)}}return a.memoizedState=[l,n],l}function kd(i,n,a){return a===void 0||(As&1073741824)!==0&&(ct&261930)===0?i.memoizedState=n:(i.memoizedState=a,i=ib(),Ge.lanes|=i,dr|=i,a)}function iv(i,n,a,l){return wn(a,n)?a:Ya.current!==null?(i=kd(i,a,l),wn(i,n)||(fi=!0),i):(As&42)===0||(As&1073741824)!==0&&(ct&261930)===0?(fi=!0,i.memoizedState=a):(i=ib(),Ge.lanes|=i,dr|=i,n)}function nv(i,n,a,l,u){var d=W.p;W.p=d!==0&&8>d?d:8;var _=B.T,C={};B.T=C,Rd(i,!1,n,a);try{var A=u(),$=B.S;if($!==null&&$(C,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var ae=qC(A,l);Ql(i,n,ae,Dn(i))}else Ql(i,n,l,Dn(i))}catch(fe){Ql(i,n,{then:function(){},status:"rejected",reason:fe},Dn())}finally{W.p=d,_!==null&&C.types!==null&&(_.types=C.types),B.T=_}}function ZC(){}function Td(i,n,a,l){if(i.tag!==5)throw Error(r(476));var u=sv(i).queue;nv(i,u,n,D,a===null?ZC:function(){return rv(i),a(l)})}function sv(i){var n=i.memoizedState;if(n!==null)return n;n={memoizedState:D,baseState:D,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:D},next:null};var a={};return n.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:a},next:null},i.memoizedState=n,i=i.alternate,i!==null&&(i.memoizedState=n),n}function rv(i){var n=sv(i);n.next===null&&(n=i.alternate.memoizedState),Ql(i,n.next.queue,{},Dn())}function Dd(){return Ki(go)}function av(){return ri().memoizedState}function lv(){return ri().memoizedState}function QC(i){for(var n=i.return;n!==null;){switch(n.tag){case 24:case 3:var a=Dn();i=ar(a);var l=lr(n,i,a);l!==null&&(fn(l,n,a),Vl(l,n,a)),n={cache:nd()},i.payload=n;return}n=n.return}}function JC(i,n,a){var l=Dn();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ic(i)?cv(n,a):(a=$h(i,n,a,l),a!==null&&(fn(a,i,l),uv(a,n,l)))}function ov(i,n,a){var l=Dn();Ql(i,n,a,l)}function Ql(i,n,a,l){var u={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Ic(i))cv(n,u);else{var d=i.alternate;if(i.lanes===0&&(d===null||d.lanes===0)&&(d=n.lastRenderedReducer,d!==null))try{var _=n.lastRenderedState,C=d(_,a);if(u.hasEagerState=!0,u.eagerState=C,wn(C,_))return Sc(i,n,u,0),Mt===null&&yc(),!1}catch{}if(a=$h(i,n,u,l),a!==null)return fn(a,i,l),uv(a,n,l),!0}return!1}function Rd(i,n,a,l){if(l={lane:2,revertLane:of(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ic(i)){if(n)throw Error(r(479))}else n=$h(i,a,l,2),n!==null&&fn(n,i,2)}function Ic(i){var n=i.alternate;return i===Ge||n!==null&&n===Ge}function cv(i,n){Xa=Bc=!0;var a=i.pending;a===null?n.next=n:(n.next=a.next,a.next=n),i.pending=n}function uv(i,n,a){if((a&4194048)!==0){var l=n.lanes;l&=i.pendingLanes,a|=l,n.lanes=a,ii(i,a)}}var Jl={readContext:Ki,use:jc,useCallback:Gt,useContext:Gt,useEffect:Gt,useImperativeHandle:Gt,useLayoutEffect:Gt,useInsertionEffect:Gt,useMemo:Gt,useReducer:Gt,useRef:Gt,useState:Gt,useDebugValue:Gt,useDeferredValue:Gt,useTransition:Gt,useSyncExternalStore:Gt,useId:Gt,useHostTransitionStatus:Gt,useFormState:Gt,useActionState:Gt,useOptimistic:Gt,useMemoCache:Gt,useCacheRefresh:Gt};Jl.useEffectEvent=Gt;var hv={readContext:Ki,use:jc,useCallback:function(i,n){return tn().memoizedState=[i,n===void 0?null:n],i},useContext:Ki,useEffect:Y_,useImperativeHandle:function(i,n,a){a=a!=null?a.concat([i]):null,Pc(4194308,4,Q_.bind(null,n,i),a)},useLayoutEffect:function(i,n){return Pc(4194308,4,i,n)},useInsertionEffect:function(i,n){Pc(4,2,i,n)},useMemo:function(i,n){var a=tn();n=n===void 0?null:n;var l=i();if(ia){li(!0);try{i()}finally{li(!1)}}return a.memoizedState=[l,n],l},useReducer:function(i,n,a){var l=tn();if(a!==void 0){var u=a(n);if(ia){li(!0);try{a(n)}finally{li(!1)}}}else u=n;return l.memoizedState=l.baseState=u,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},l.queue=i,i=i.dispatch=JC.bind(null,Ge,i),[l.memoizedState,i]},useRef:function(i){var n=tn();return i={current:i},n.memoizedState=i},useState:function(i){i=wd(i);var n=i.queue,a=ov.bind(null,Ge,n);return n.dispatch=a,[i.memoizedState,a]},useDebugValue:Ed,useDeferredValue:function(i,n){var a=tn();return kd(a,i,n)},useTransition:function(){var i=wd(!1);return i=nv.bind(null,Ge,i.queue,!0,!1),tn().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,n,a){var l=Ge,u=tn();if(ht){if(a===void 0)throw Error(r(407));a=a()}else{if(a=n(),Mt===null)throw Error(r(349));(ct&127)!==0||A_(l,n,a)}u.memoizedState=a;var d={value:a,getSnapshot:n};return u.queue=d,Y_(B_.bind(null,l,d,i),[i]),l.flags|=2048,Za(9,{destroy:void 0},L_.bind(null,l,d,a,n),null),a},useId:function(){var i=tn(),n=Mt.identifierPrefix;if(ht){var a=gs,l=ms;a=(l&~(1<<32-Dt(l)-1)).toString(32)+a,n="_"+n+"R_"+a,a=Oc++,0<a&&(n+="H"+a.toString(32)),n+="_"}else a=$C++,n="_"+n+"r_"+a.toString(32)+"_";return i.memoizedState=n},useHostTransitionStatus:Dd,useFormState:W_,useActionState:W_,useOptimistic:function(i){var n=tn();n.memoizedState=n.baseState=i;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=a,n=Rd.bind(null,Ge,!0,a),a.dispatch=n,[i,n]},useMemoCache:bd,useCacheRefresh:function(){return tn().memoizedState=QC.bind(null,Ge)},useEffectEvent:function(i){var n=tn(),a={impl:i};return n.memoizedState=a,function(){if((mt&2)!==0)throw Error(r(440));return a.impl.apply(void 0,arguments)}}},Md={readContext:Ki,use:jc,useCallback:ev,useContext:Ki,useEffect:xd,useImperativeHandle:J_,useInsertionEffect:G_,useLayoutEffect:Z_,useMemo:tv,useReducer:Hc,useRef:V_,useState:function(){return Hc(Ls)},useDebugValue:Ed,useDeferredValue:function(i,n){var a=ri();return iv(a,xt.memoizedState,i,n)},useTransition:function(){var i=Hc(Ls)[0],n=ri().memoizedState;return[typeof i=="boolean"?i:Zl(i),n]},useSyncExternalStore:N_,useId:av,useHostTransitionStatus:Dd,useFormState:F_,useActionState:F_,useOptimistic:function(i,n){var a=ri();return j_(a,xt,i,n)},useMemoCache:bd,useCacheRefresh:lv};Md.useEffectEvent=X_;var dv={readContext:Ki,use:jc,useCallback:ev,useContext:Ki,useEffect:xd,useImperativeHandle:J_,useInsertionEffect:G_,useLayoutEffect:Z_,useMemo:tv,useReducer:Sd,useRef:V_,useState:function(){return Sd(Ls)},useDebugValue:Ed,useDeferredValue:function(i,n){var a=ri();return xt===null?kd(a,i,n):iv(a,xt.memoizedState,i,n)},useTransition:function(){var i=Sd(Ls)[0],n=ri().memoizedState;return[typeof i=="boolean"?i:Zl(i),n]},useSyncExternalStore:N_,useId:av,useHostTransitionStatus:Dd,useFormState:$_,useActionState:$_,useOptimistic:function(i,n){var a=ri();return xt!==null?j_(a,xt,i,n):(a.baseState=i,[i,a.queue.dispatch])},useMemoCache:bd,useCacheRefresh:lv};dv.useEffectEvent=X_;function Nd(i,n,a,l){n=i.memoizedState,a=a(l,n),a=a==null?n:b({},n,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Ad={enqueueSetState:function(i,n,a){i=i._reactInternals;var l=Dn(),u=ar(l);u.payload=n,a!=null&&(u.callback=a),n=lr(i,u,l),n!==null&&(fn(n,i,l),Vl(n,i,l))},enqueueReplaceState:function(i,n,a){i=i._reactInternals;var l=Dn(),u=ar(l);u.tag=1,u.payload=n,a!=null&&(u.callback=a),n=lr(i,u,l),n!==null&&(fn(n,i,l),Vl(n,i,l))},enqueueForceUpdate:function(i,n){i=i._reactInternals;var a=Dn(),l=ar(a);l.tag=2,n!=null&&(l.callback=n),n=lr(i,l,a),n!==null&&(fn(n,i,a),Vl(n,i,a))}};function fv(i,n,a,l,u,d,_){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(l,d,_):n.prototype&&n.prototype.isPureReactComponent?!Pl(a,l)||!Pl(u,d):!0}function pv(i,n,a,l){i=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(a,l),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(a,l),n.state!==i&&Ad.enqueueReplaceState(n,n.state,null)}function na(i,n){var a=n;if("ref"in n){a={};for(var l in n)l!=="ref"&&(a[l]=n[l])}if(i=i.defaultProps){a===n&&(a=b({},a));for(var u in i)a[u]===void 0&&(a[u]=i[u])}return a}function mv(i){bc(i)}function gv(i){console.error(i)}function _v(i){bc(i)}function Kc(i,n){try{var a=i.onUncaughtError;a(n.value,{componentStack:n.stack})}catch(l){setTimeout(function(){throw l})}}function vv(i,n,a){try{var l=i.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function Ld(i,n,a){return a=ar(a),a.tag=3,a.payload={element:null},a.callback=function(){Kc(i,n)},a}function bv(i){return i=ar(i),i.tag=3,i}function yv(i,n,a,l){var u=a.type.getDerivedStateFromError;if(typeof u=="function"){var d=l.value;i.payload=function(){return u(d)},i.callback=function(){vv(n,a,l)}}var _=a.stateNode;_!==null&&typeof _.componentDidCatch=="function"&&(i.callback=function(){vv(n,a,l),typeof u!="function"&&(fr===null?fr=new Set([this]):fr.add(this));var C=l.stack;this.componentDidCatch(l.value,{componentStack:C!==null?C:""})})}function ex(i,n,a,l,u){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(n=a.alternate,n!==null&&Wa(n,a,u,!0),a=xn.current,a!==null){switch(a.tag){case 31:case 13:return Fn===null?eu():a.alternate===null&&Zt===0&&(Zt=3),a.flags&=-257,a.flags|=65536,a.lanes=u,l===Rc?a.flags|=16384:(n=a.updateQueue,n===null?a.updateQueue=new Set([l]):n.add(l),rf(i,l,u)),!1;case 22:return a.flags|=65536,l===Rc?a.flags|=16384:(n=a.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=n):(a=n.retryQueue,a===null?n.retryQueue=new Set([l]):a.add(l)),rf(i,l,u)),!1}throw Error(r(435,a.tag))}return rf(i,l,u),eu(),!1}if(ht)return n=xn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=u,l!==Qh&&(i=Error(r(422),{cause:l}),Kl(Un(i,a)))):(l!==Qh&&(n=Error(r(423),{cause:l}),Kl(Un(n,a))),i=i.current.alternate,i.flags|=65536,u&=-u,i.lanes|=u,l=Un(l,a),u=Ld(i.stateNode,l,u),cd(i,u),Zt!==4&&(Zt=2)),!1;var d=Error(r(520),{cause:l});if(d=Un(d,a),lo===null?lo=[d]:lo.push(d),Zt!==4&&(Zt=2),n===null)return!0;l=Un(l,a),a=n;do{switch(a.tag){case 3:return a.flags|=65536,i=u&-u,a.lanes|=i,i=Ld(a.stateNode,l,i),cd(a,i),!1;case 1:if(n=a.type,d=a.stateNode,(a.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||d!==null&&typeof d.componentDidCatch=="function"&&(fr===null||!fr.has(d))))return a.flags|=65536,u&=-u,a.lanes|=u,u=bv(u),yv(u,i,a,l),cd(a,u),!1}a=a.return}while(a!==null);return!1}var Bd=Error(r(461)),fi=!1;function Wi(i,n,a,l){n.child=i===null?x_(n,null,a,l):ta(n,i.child,a,l)}function Sv(i,n,a,l,u){a=a.render;var d=n.ref;if("ref"in l){var _={};for(var C in l)C!=="ref"&&(_[C]=l[C])}else _=l;return Zr(n),l=md(i,n,a,_,d,u),C=gd(),i!==null&&!fi?(_d(i,n,u),Bs(i,n,u)):(ht&&C&&Gh(n),n.flags|=1,Wi(i,n,l,u),n.child)}function wv(i,n,a,l,u){if(i===null){var d=a.type;return typeof d=="function"&&!Vh(d)&&d.defaultProps===void 0&&a.compare===null?(n.tag=15,n.type=d,Cv(i,n,d,l,u)):(i=Cc(a.type,null,l,n,n.mode,u),i.ref=n.ref,i.return=n,n.child=i)}if(d=i.child,!Kd(i,u)){var _=d.memoizedProps;if(a=a.compare,a=a!==null?a:Pl,a(_,l)&&i.ref===n.ref)return Bs(i,n,u)}return n.flags|=1,i=Ds(d,l),i.ref=n.ref,i.return=n,n.child=i}function Cv(i,n,a,l,u){if(i!==null){var d=i.memoizedProps;if(Pl(d,l)&&i.ref===n.ref)if(fi=!1,n.pendingProps=l=d,Kd(i,u))(i.flags&131072)!==0&&(fi=!0);else return n.lanes=i.lanes,Bs(i,n,u)}return Od(i,n,a,l,u)}function xv(i,n,a,l){var u=l.children,d=i!==null?i.memoizedState:null;if(i===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((n.flags&128)!==0){if(d=d!==null?d.baseLanes|a:a,i!==null){for(l=n.child=i.child,u=0;l!==null;)u=u|l.lanes|l.childLanes,l=l.sibling;l=u&~d}else l=0,n.child=null;return Ev(i,n,d,a,l)}if((a&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},i!==null&&Tc(n,d!==null?d.cachePool:null),d!==null?T_(n,d):hd(),D_(n);else return l=n.lanes=536870912,Ev(i,n,d!==null?d.baseLanes|a:a,a,l)}else d!==null?(Tc(n,d.cachePool),T_(n,d),cr(),n.memoizedState=null):(i!==null&&Tc(n,null),hd(),cr());return Wi(i,n,u,a),n.child}function eo(i,n){return i!==null&&i.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Ev(i,n,a,l,u){var d=rd();return d=d===null?null:{parent:hi._currentValue,pool:d},n.memoizedState={baseLanes:a,cachePool:d},i!==null&&Tc(n,null),hd(),D_(n),i!==null&&Wa(i,n,l,!0),n.childLanes=u,null}function Wc(i,n){return n=qc({mode:n.mode,children:n.children},i.mode),n.ref=i.ref,i.child=n,n.return=i,n}function kv(i,n,a){return ta(n,i.child,null,a),i=Wc(n,n.pendingProps),i.flags|=2,En(n),n.memoizedState=null,i}function tx(i,n,a){var l=n.pendingProps,u=(n.flags&128)!==0;if(n.flags&=-129,i===null){if(ht){if(l.mode==="hidden")return i=Wc(n,l),n.lanes=536870912,eo(null,i);if(fd(n),(i=Ot)?(i=Hb(i,Wn),i=i!==null&&i.data==="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:tr!==null?{id:ms,overflow:gs}:null,retryLane:536870912,hydrationErrors:null},a=c_(i),a.return=n,n.child=a,Ii=n,Ot=null)):i=null,i===null)throw nr(n);return n.lanes=536870912,null}return Wc(n,l)}var d=i.memoizedState;if(d!==null){var _=d.dehydrated;if(fd(n),u)if(n.flags&256)n.flags&=-257,n=kv(i,n,a);else if(n.memoizedState!==null)n.child=i.child,n.flags|=128,n=null;else throw Error(r(558));else if(fi||Wa(i,n,a,!1),u=(a&i.childLanes)!==0,fi||u){if(l=Mt,l!==null&&(_=vi(l,a),_!==0&&_!==d.retryLane))throw d.retryLane=_,Vr(i,_),fn(l,i,_),Bd;eu(),n=kv(i,n,a)}else i=d.treeContext,Ot=qn(_.nextSibling),Ii=n,ht=!0,ir=null,Wn=!1,i!==null&&d_(n,i),n=Wc(n,l),n.flags|=4096;return n}return i=Ds(i.child,{mode:l.mode,children:l.children}),i.ref=n.ref,n.child=i,i.return=n,i}function Fc(i,n){var a=n.ref;if(a===null)i!==null&&i.ref!==null&&(n.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(r(284));(i===null||i.ref!==a)&&(n.flags|=4194816)}}function Od(i,n,a,l,u){return Zr(n),a=md(i,n,a,l,void 0,u),l=gd(),i!==null&&!fi?(_d(i,n,u),Bs(i,n,u)):(ht&&l&&Gh(n),n.flags|=1,Wi(i,n,a,u),n.child)}function Tv(i,n,a,l,u,d){return Zr(n),n.updateQueue=null,a=M_(n,l,a,u),R_(i),l=gd(),i!==null&&!fi?(_d(i,n,d),Bs(i,n,d)):(ht&&l&&Gh(n),n.flags|=1,Wi(i,n,a,d),n.child)}function Dv(i,n,a,l,u){if(Zr(n),n.stateNode===null){var d=Pa,_=a.contextType;typeof _=="object"&&_!==null&&(d=Ki(_)),d=new a(l,d),n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=Ad,n.stateNode=d,d._reactInternals=n,d=n.stateNode,d.props=l,d.state=n.memoizedState,d.refs={},ld(n),_=a.contextType,d.context=typeof _=="object"&&_!==null?Ki(_):Pa,d.state=n.memoizedState,_=a.getDerivedStateFromProps,typeof _=="function"&&(Nd(n,a,_,l),d.state=n.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(_=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),_!==d.state&&Ad.enqueueReplaceState(d,d.state,null),Xl(n,l,d,u),Yl(),d.state=n.memoizedState),typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!0}else if(i===null){d=n.stateNode;var C=n.memoizedProps,A=na(a,C);d.props=A;var $=d.context,ae=a.contextType;_=Pa,typeof ae=="object"&&ae!==null&&(_=Ki(ae));var fe=a.getDerivedStateFromProps;ae=typeof fe=="function"||typeof d.getSnapshotBeforeUpdate=="function",C=n.pendingProps!==C,ae||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(C||$!==_)&&pv(n,d,l,_),rr=!1;var Y=n.memoizedState;d.state=Y,Xl(n,l,d,u),Yl(),$=n.memoizedState,C||Y!==$||rr?(typeof fe=="function"&&(Nd(n,a,fe,l),$=n.memoizedState),(A=rr||fv(n,a,A,l,Y,$,_))?(ae||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount()),typeof d.componentDidMount=="function"&&(n.flags|=4194308)):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=$),d.props=l,d.state=$,d.context=_,l=A):(typeof d.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{d=n.stateNode,od(i,n),_=n.memoizedProps,ae=na(a,_),d.props=ae,fe=n.pendingProps,Y=d.context,$=a.contextType,A=Pa,typeof $=="object"&&$!==null&&(A=Ki($)),C=a.getDerivedStateFromProps,($=typeof C=="function"||typeof d.getSnapshotBeforeUpdate=="function")||typeof d.UNSAFE_componentWillReceiveProps!="function"&&typeof d.componentWillReceiveProps!="function"||(_!==fe||Y!==A)&&pv(n,d,l,A),rr=!1,Y=n.memoizedState,d.state=Y,Xl(n,l,d,u),Yl();var Z=n.memoizedState;_!==fe||Y!==Z||rr||i!==null&&i.dependencies!==null&&Ec(i.dependencies)?(typeof C=="function"&&(Nd(n,a,C,l),Z=n.memoizedState),(ae=rr||fv(n,a,ae,l,Y,Z,A)||i!==null&&i.dependencies!==null&&Ec(i.dependencies))?($||typeof d.UNSAFE_componentWillUpdate!="function"&&typeof d.componentWillUpdate!="function"||(typeof d.componentWillUpdate=="function"&&d.componentWillUpdate(l,Z,A),typeof d.UNSAFE_componentWillUpdate=="function"&&d.UNSAFE_componentWillUpdate(l,Z,A)),typeof d.componentDidUpdate=="function"&&(n.flags|=4),typeof d.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&Y===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&Y===i.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=Z),d.props=l,d.state=Z,d.context=A,l=ae):(typeof d.componentDidUpdate!="function"||_===i.memoizedProps&&Y===i.memoizedState||(n.flags|=4),typeof d.getSnapshotBeforeUpdate!="function"||_===i.memoizedProps&&Y===i.memoizedState||(n.flags|=1024),l=!1)}return d=l,Fc(i,n),l=(n.flags&128)!==0,d||l?(d=n.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:d.render(),n.flags|=1,i!==null&&l?(n.child=ta(n,i.child,null,u),n.child=ta(n,null,a,u)):Wi(i,n,a,u),n.memoizedState=d.state,i=n.child):i=Bs(i,n,u),i}function Rv(i,n,a,l){return Xr(),n.flags|=256,Wi(i,n,a,l),n.child}var zd={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function jd(i){return{baseLanes:i,cachePool:v_()}}function Hd(i,n,a){return i=i!==null?i.childLanes&~a:0,n&&(i|=Tn),i}function Mv(i,n,a){var l=n.pendingProps,u=!1,d=(n.flags&128)!==0,_;if((_=d)||(_=i!==null&&i.memoizedState===null?!1:(si.current&2)!==0),_&&(u=!0,n.flags&=-129),_=(n.flags&32)!==0,n.flags&=-33,i===null){if(ht){if(u?or(n):cr(),(i=Ot)?(i=Hb(i,Wn),i=i!==null&&i.data!=="&"?i:null,i!==null&&(n.memoizedState={dehydrated:i,treeContext:tr!==null?{id:ms,overflow:gs}:null,retryLane:536870912,hydrationErrors:null},a=c_(i),a.return=n,n.child=a,Ii=n,Ot=null)):i=null,i===null)throw nr(n);return Sf(i)?n.lanes=32:n.lanes=536870912,null}var C=l.children;return l=l.fallback,u?(cr(),u=n.mode,C=qc({mode:"hidden",children:C},u),l=Yr(l,u,a,null),C.return=n,l.return=n,C.sibling=l,n.child=C,l=n.child,l.memoizedState=jd(a),l.childLanes=Hd(i,_,a),n.memoizedState=zd,eo(null,l)):(or(n),Pd(n,C))}var A=i.memoizedState;if(A!==null&&(C=A.dehydrated,C!==null)){if(d)n.flags&256?(or(n),n.flags&=-257,n=Ud(i,n,a)):n.memoizedState!==null?(cr(),n.child=i.child,n.flags|=128,n=null):(cr(),C=l.fallback,u=n.mode,l=qc({mode:"visible",children:l.children},u),C=Yr(C,u,a,null),C.flags|=2,l.return=n,C.return=n,l.sibling=C,n.child=l,ta(n,i.child,null,a),l=n.child,l.memoizedState=jd(a),l.childLanes=Hd(i,_,a),n.memoizedState=zd,n=eo(null,l));else if(or(n),Sf(C)){if(_=C.nextSibling&&C.nextSibling.dataset,_)var $=_.dgst;_=$,l=Error(r(419)),l.stack="",l.digest=_,Kl({value:l,source:null,stack:null}),n=Ud(i,n,a)}else if(fi||Wa(i,n,a,!1),_=(a&i.childLanes)!==0,fi||_){if(_=Mt,_!==null&&(l=vi(_,a),l!==0&&l!==A.retryLane))throw A.retryLane=l,Vr(i,l),fn(_,i,l),Bd;yf(C)||eu(),n=Ud(i,n,a)}else yf(C)?(n.flags|=192,n.child=i.child,n=null):(i=A.treeContext,Ot=qn(C.nextSibling),Ii=n,ht=!0,ir=null,Wn=!1,i!==null&&d_(n,i),n=Pd(n,l.children),n.flags|=4096);return n}return u?(cr(),C=l.fallback,u=n.mode,A=i.child,$=A.sibling,l=Ds(A,{mode:"hidden",children:l.children}),l.subtreeFlags=A.subtreeFlags&65011712,$!==null?C=Ds($,C):(C=Yr(C,u,a,null),C.flags|=2),C.return=n,l.return=n,l.sibling=C,n.child=l,eo(null,l),l=n.child,C=i.child.memoizedState,C===null?C=jd(a):(u=C.cachePool,u!==null?(A=hi._currentValue,u=u.parent!==A?{parent:A,pool:A}:u):u=v_(),C={baseLanes:C.baseLanes|a,cachePool:u}),l.memoizedState=C,l.childLanes=Hd(i,_,a),n.memoizedState=zd,eo(i.child,l)):(or(n),a=i.child,i=a.sibling,a=Ds(a,{mode:"visible",children:l.children}),a.return=n,a.sibling=null,i!==null&&(_=n.deletions,_===null?(n.deletions=[i],n.flags|=16):_.push(i)),n.child=a,n.memoizedState=null,a)}function Pd(i,n){return n=qc({mode:"visible",children:n},i.mode),n.return=i,i.child=n}function qc(i,n){return i=Cn(22,i,null,n),i.lanes=0,i}function Ud(i,n,a){return ta(n,i.child,null,a),i=Pd(n,n.pendingProps.children),i.flags|=2,n.memoizedState=null,i}function Nv(i,n,a){i.lanes|=n;var l=i.alternate;l!==null&&(l.lanes|=n),td(i.return,n,a)}function Id(i,n,a,l,u,d){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:u,treeForkCount:d}:(_.isBackwards=n,_.rendering=null,_.renderingStartTime=0,_.last=l,_.tail=a,_.tailMode=u,_.treeForkCount=d)}function Av(i,n,a){var l=n.pendingProps,u=l.revealOrder,d=l.tail;l=l.children;var _=si.current,C=(_&2)!==0;if(C?(_=_&1|2,n.flags|=128):_&=1,ee(si,_),Wi(i,n,l,a),l=ht?Il:0,!C&&i!==null&&(i.flags&128)!==0)e:for(i=n.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Nv(i,a,n);else if(i.tag===19)Nv(i,a,n);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break e;for(;i.sibling===null;){if(i.return===null||i.return===n)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(u){case"forwards":for(a=n.child,u=null;a!==null;)i=a.alternate,i!==null&&Lc(i)===null&&(u=a),a=a.sibling;a=u,a===null?(u=n.child,n.child=null):(u=a.sibling,a.sibling=null),Id(n,!1,u,a,d,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,u=n.child,n.child=null;u!==null;){if(i=u.alternate,i!==null&&Lc(i)===null){n.child=u;break}i=u.sibling,u.sibling=a,a=u,u=i}Id(n,!0,a,null,d,l);break;case"together":Id(n,!1,null,null,void 0,l);break;default:n.memoizedState=null}return n.child}function Bs(i,n,a){if(i!==null&&(n.dependencies=i.dependencies),dr|=n.lanes,(a&n.childLanes)===0)if(i!==null){if(Wa(i,n,a,!1),(a&n.childLanes)===0)return null}else return null;if(i!==null&&n.child!==i.child)throw Error(r(153));if(n.child!==null){for(i=n.child,a=Ds(i,i.pendingProps),n.child=a,a.return=n;i.sibling!==null;)i=i.sibling,a=a.sibling=Ds(i,i.pendingProps),a.return=n;a.sibling=null}return n.child}function Kd(i,n){return(i.lanes&n)!==0?!0:(i=i.dependencies,!!(i!==null&&Ec(i)))}function ix(i,n,a){switch(n.tag){case 3:Fe(n,n.stateNode.containerInfo),sr(n,hi,i.memoizedState.cache),Xr();break;case 27:case 5:X(n);break;case 4:Fe(n,n.stateNode.containerInfo);break;case 10:sr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,fd(n),null;break;case 13:var l=n.memoizedState;if(l!==null)return l.dehydrated!==null?(or(n),n.flags|=128,null):(a&n.child.childLanes)!==0?Mv(i,n,a):(or(n),i=Bs(i,n,a),i!==null?i.sibling:null);or(n);break;case 19:var u=(i.flags&128)!==0;if(l=(a&n.childLanes)!==0,l||(Wa(i,n,a,!1),l=(a&n.childLanes)!==0),u){if(l)return Av(i,n,a);n.flags|=128}if(u=n.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),ee(si,si.current),l)break;return null;case 22:return n.lanes=0,xv(i,n,a,n.pendingProps);case 24:sr(n,hi,i.memoizedState.cache)}return Bs(i,n,a)}function Lv(i,n,a){if(i!==null)if(i.memoizedProps!==n.pendingProps)fi=!0;else{if(!Kd(i,a)&&(n.flags&128)===0)return fi=!1,ix(i,n,a);fi=(i.flags&131072)!==0}else fi=!1,ht&&(n.flags&1048576)!==0&&h_(n,Il,n.index);switch(n.lanes=0,n.tag){case 16:e:{var l=n.pendingProps;if(i=Jr(n.elementType),n.type=i,typeof i=="function")Vh(i)?(l=na(i,l),n.tag=1,n=Dv(null,n,i,l,a)):(n.tag=0,n=Od(null,n,i,l,a));else{if(i!=null){var u=i.$$typeof;if(u===U){n.tag=11,n=Sv(null,n,i,l,a);break e}else if(u===le){n.tag=14,n=wv(null,n,i,l,a);break e}}throw n=F(i)||i,Error(r(306,n,""))}}return n;case 0:return Od(i,n,n.type,n.pendingProps,a);case 1:return l=n.type,u=na(l,n.pendingProps),Dv(i,n,l,u,a);case 3:e:{if(Fe(n,n.stateNode.containerInfo),i===null)throw Error(r(387));l=n.pendingProps;var d=n.memoizedState;u=d.element,od(i,n),Xl(n,l,null,a);var _=n.memoizedState;if(l=_.cache,sr(n,hi,l),l!==d.cache&&id(n,[hi],a,!0),Yl(),l=_.element,d.isDehydrated)if(d={element:l,isDehydrated:!1,cache:_.cache},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){n=Rv(i,n,l,a);break e}else if(l!==u){u=Un(Error(r(424)),n),Kl(u),n=Rv(i,n,l,a);break e}else for(i=n.stateNode.containerInfo,i.nodeType===9?i=i.body:i=i.nodeName==="HTML"?i.ownerDocument.body:i,Ot=qn(i.firstChild),Ii=n,ht=!0,ir=null,Wn=!0,a=x_(n,null,l,a),n.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Xr(),l===u){n=Bs(i,n,a);break e}Wi(i,n,l,a)}n=n.child}return n;case 26:return Fc(i,n),i===null?(a=Fb(n.type,null,n.pendingProps,null))?n.memoizedState=a:ht||(a=n.type,i=n.pendingProps,l=lu(ke.current).createElement(a),l[It]=n,l[bi]=i,Fi(l,a,i),Kt(l),n.stateNode=l):n.memoizedState=Fb(n.type,i.memoizedProps,n.pendingProps,i.memoizedState),null;case 27:return X(n),i===null&&ht&&(l=n.stateNode=Ib(n.type,n.pendingProps,ke.current),Ii=n,Wn=!0,u=Ot,_r(n.type)?(wf=u,Ot=qn(l.firstChild)):Ot=u),Wi(i,n,n.pendingProps.children,a),Fc(i,n),i===null&&(n.flags|=4194304),n.child;case 5:return i===null&&ht&&((u=l=Ot)&&(l=Ax(l,n.type,n.pendingProps,Wn),l!==null?(n.stateNode=l,Ii=n,Ot=qn(l.firstChild),Wn=!1,u=!0):u=!1),u||nr(n)),X(n),u=n.type,d=n.pendingProps,_=i!==null?i.memoizedProps:null,l=d.children,_f(u,d)?l=null:_!==null&&_f(u,_)&&(n.flags|=32),n.memoizedState!==null&&(u=md(i,n,VC,null,null,a),go._currentValue=u),Fc(i,n),Wi(i,n,l,a),n.child;case 6:return i===null&&ht&&((i=a=Ot)&&(a=Lx(a,n.pendingProps,Wn),a!==null?(n.stateNode=a,Ii=n,Ot=null,i=!0):i=!1),i||nr(n)),null;case 13:return Mv(i,n,a);case 4:return Fe(n,n.stateNode.containerInfo),l=n.pendingProps,i===null?n.child=ta(n,null,l,a):Wi(i,n,l,a),n.child;case 11:return Sv(i,n,n.type,n.pendingProps,a);case 7:return Wi(i,n,n.pendingProps,a),n.child;case 8:return Wi(i,n,n.pendingProps.children,a),n.child;case 12:return Wi(i,n,n.pendingProps.children,a),n.child;case 10:return l=n.pendingProps,sr(n,n.type,l.value),Wi(i,n,l.children,a),n.child;case 9:return u=n.type._context,l=n.pendingProps.children,Zr(n),u=Ki(u),l=l(u),n.flags|=1,Wi(i,n,l,a),n.child;case 14:return wv(i,n,n.type,n.pendingProps,a);case 15:return Cv(i,n,n.type,n.pendingProps,a);case 19:return Av(i,n,a);case 31:return tx(i,n,a);case 22:return xv(i,n,a,n.pendingProps);case 24:return Zr(n),l=Ki(hi),i===null?(u=rd(),u===null&&(u=Mt,d=nd(),u.pooledCache=d,d.refCount++,d!==null&&(u.pooledCacheLanes|=a),u=d),n.memoizedState={parent:l,cache:u},ld(n),sr(n,hi,u)):((i.lanes&a)!==0&&(od(i,n),Xl(n,null,null,a),Yl()),u=i.memoizedState,d=n.memoizedState,u.parent!==l?(u={parent:l,cache:l},n.memoizedState=u,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=u),sr(n,hi,l)):(l=d.cache,sr(n,hi,l),l!==u.cache&&id(n,[hi],a,!0))),Wi(i,n,n.pendingProps.children,a),n.child;case 29:throw n.pendingProps}throw Error(r(156,n.tag))}function Os(i){i.flags|=4}function Wd(i,n,a,l,u){if((n=(i.mode&32)!==0)&&(n=!1),n){if(i.flags|=16777216,(u&335544128)===u)if(i.stateNode.complete)i.flags|=8192;else if(ab())i.flags|=8192;else throw ea=Rc,ad}else i.flags&=-16777217}function Bv(i,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!Xb(n))if(ab())i.flags|=8192;else throw ea=Rc,ad}function $c(i,n){n!==null&&(i.flags|=4),i.flags&16384&&(n=i.tag!==22?qt():536870912,i.lanes|=n,tl|=n)}function to(i,n){if(!ht)switch(i.tailMode){case"hidden":n=i.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?n||i.tail===null?i.tail=null:i.tail.sibling=null:l.sibling=null}}function zt(i){var n=i.alternate!==null&&i.alternate.child===i.child,a=0,l=0;if(n)for(var u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags&65011712,l|=u.flags&65011712,u.return=i,u=u.sibling;else for(u=i.child;u!==null;)a|=u.lanes|u.childLanes,l|=u.subtreeFlags,l|=u.flags,u.return=i,u=u.sibling;return i.subtreeFlags|=l,i.childLanes=a,n}function nx(i,n,a){var l=n.pendingProps;switch(Zh(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return zt(n),null;case 1:return zt(n),null;case 3:return a=n.stateNode,l=null,i!==null&&(l=i.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),Ns(hi),_e(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(i===null||i.child===null)&&(Ka(n)?Os(n):i===null||i.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Jh())),zt(n),null;case 26:var u=n.type,d=n.memoizedState;return i===null?(Os(n),d!==null?(zt(n),Bv(n,d)):(zt(n),Wd(n,u,null,l,a))):d?d!==i.memoizedState?(Os(n),zt(n),Bv(n,d)):(zt(n),n.flags&=-16777217):(i=i.memoizedProps,i!==l&&Os(n),zt(n),Wd(n,u,i,l,a)),null;case 27:if(he(n),a=ke.current,u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&Os(n);else{if(!l){if(n.stateNode===null)throw Error(r(166));return zt(n),null}i=de.current,Ka(n)?f_(n):(i=Ib(u,l,a),n.stateNode=i,Os(n))}return zt(n),null;case 5:if(he(n),u=n.type,i!==null&&n.stateNode!=null)i.memoizedProps!==l&&Os(n);else{if(!l){if(n.stateNode===null)throw Error(r(166));return zt(n),null}if(d=de.current,Ka(n))f_(n);else{var _=lu(ke.current);switch(d){case 1:d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":d=_.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":d=_.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":d=_.createElement("div"),d.innerHTML="<script><\/script>",d=d.removeChild(d.firstChild);break;case"select":d=typeof l.is=="string"?_.createElement("select",{is:l.is}):_.createElement("select"),l.multiple?d.multiple=!0:l.size&&(d.size=l.size);break;default:d=typeof l.is=="string"?_.createElement(u,{is:l.is}):_.createElement(u)}}d[It]=n,d[bi]=l;e:for(_=n.child;_!==null;){if(_.tag===5||_.tag===6)d.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===n)break e;for(;_.sibling===null;){if(_.return===null||_.return===n)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}n.stateNode=d;e:switch(Fi(d,u,l),u){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Os(n)}}return zt(n),Wd(n,n.type,i===null?null:i.memoizedProps,n.pendingProps,a),null;case 6:if(i&&n.stateNode!=null)i.memoizedProps!==l&&Os(n);else{if(typeof l!="string"&&n.stateNode===null)throw Error(r(166));if(i=ke.current,Ka(n)){if(i=n.stateNode,a=n.memoizedProps,l=null,u=Ii,u!==null)switch(u.tag){case 27:case 5:l=u.memoizedProps}i[It]=n,i=!!(i.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||Mb(i.nodeValue,a)),i||nr(n,!0)}else i=lu(i).createTextNode(l),i[It]=n,n.stateNode=i}return zt(n),null;case 31:if(a=n.memoizedState,i===null||i.memoizedState!==null){if(l=Ka(n),a!==null){if(i===null){if(!l)throw Error(r(318));if(i=n.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[It]=n}else Xr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;zt(n),i=!1}else a=Jh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=a),i=!0;if(!i)return n.flags&256?(En(n),n):(En(n),null);if((n.flags&128)!==0)throw Error(r(558))}return zt(n),null;case 13:if(l=n.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(u=Ka(n),l!==null&&l.dehydrated!==null){if(i===null){if(!u)throw Error(r(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(r(317));u[It]=n}else Xr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;zt(n),u=!1}else u=Jh(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(En(n),n):(En(n),null)}return En(n),(n.flags&128)!==0?(n.lanes=a,n):(a=l!==null,i=i!==null&&i.memoizedState!==null,a&&(l=n.child,u=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(u=l.alternate.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==u&&(l.flags|=2048)),a!==i&&a&&(n.child.flags|=8192),$c(n,n.updateQueue),zt(n),null);case 4:return _e(),i===null&&df(n.stateNode.containerInfo),zt(n),null;case 10:return Ns(n.type),zt(n),null;case 19:if(H(si),l=n.memoizedState,l===null)return zt(n),null;if(u=(n.flags&128)!==0,d=l.rendering,d===null)if(u)to(l,!1);else{if(Zt!==0||i!==null&&(i.flags&128)!==0)for(i=n.child;i!==null;){if(d=Lc(i),d!==null){for(n.flags|=128,to(l,!1),i=d.updateQueue,n.updateQueue=i,$c(n,i),n.subtreeFlags=0,i=a,a=n.child;a!==null;)o_(a,i),a=a.sibling;return ee(si,si.current&1|2),ht&&Rs(n,l.treeForkCount),n.child}i=i.sibling}l.tail!==null&&st()>Zc&&(n.flags|=128,u=!0,to(l,!1),n.lanes=4194304)}else{if(!u)if(i=Lc(d),i!==null){if(n.flags|=128,u=!0,i=i.updateQueue,n.updateQueue=i,$c(n,i),to(l,!0),l.tail===null&&l.tailMode==="hidden"&&!d.alternate&&!ht)return zt(n),null}else 2*st()-l.renderingStartTime>Zc&&a!==536870912&&(n.flags|=128,u=!0,to(l,!1),n.lanes=4194304);l.isBackwards?(d.sibling=n.child,n.child=d):(i=l.last,i!==null?i.sibling=d:n.child=d,l.last=d)}return l.tail!==null?(i=l.tail,l.rendering=i,l.tail=i.sibling,l.renderingStartTime=st(),i.sibling=null,a=si.current,ee(si,u?a&1|2:a&1),ht&&Rs(n,l.treeForkCount),i):(zt(n),null);case 22:case 23:return En(n),dd(),l=n.memoizedState!==null,i!==null?i.memoizedState!==null!==l&&(n.flags|=8192):l&&(n.flags|=8192),l?(a&536870912)!==0&&(n.flags&128)===0&&(zt(n),n.subtreeFlags&6&&(n.flags|=8192)):zt(n),a=n.updateQueue,a!==null&&$c(n,a.retryQueue),a=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),l=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),l!==a&&(n.flags|=2048),i!==null&&H(Qr),null;case 24:return a=null,i!==null&&(a=i.memoizedState.cache),n.memoizedState.cache!==a&&(n.flags|=2048),Ns(hi),zt(n),null;case 25:return null;case 30:return null}throw Error(r(156,n.tag))}function sx(i,n){switch(Zh(n),n.tag){case 1:return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 3:return Ns(hi),_e(),i=n.flags,(i&65536)!==0&&(i&128)===0?(n.flags=i&-65537|128,n):null;case 26:case 27:case 5:return he(n),null;case 31:if(n.memoizedState!==null){if(En(n),n.alternate===null)throw Error(r(340));Xr()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 13:if(En(n),i=n.memoizedState,i!==null&&i.dehydrated!==null){if(n.alternate===null)throw Error(r(340));Xr()}return i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 19:return H(si),null;case 4:return _e(),null;case 10:return Ns(n.type),null;case 22:case 23:return En(n),dd(),i!==null&&H(Qr),i=n.flags,i&65536?(n.flags=i&-65537|128,n):null;case 24:return Ns(hi),null;case 25:return null;default:return null}}function Ov(i,n){switch(Zh(n),n.tag){case 3:Ns(hi),_e();break;case 26:case 27:case 5:he(n);break;case 4:_e();break;case 31:n.memoizedState!==null&&En(n);break;case 13:En(n);break;case 19:H(si);break;case 10:Ns(n.type);break;case 22:case 23:En(n),dd(),i!==null&&H(Qr);break;case 24:Ns(hi)}}function io(i,n){try{var a=n.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var u=l.next;a=u;do{if((a.tag&i)===i){l=void 0;var d=a.create,_=a.inst;l=d(),_.destroy=l}a=a.next}while(a!==u)}}catch(C){St(n,n.return,C)}}function ur(i,n,a){try{var l=n.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){var _=l.inst,C=_.destroy;if(C!==void 0){_.destroy=void 0,u=n;var A=a,$=C;try{$()}catch(ae){St(u,A,ae)}}}l=l.next}while(l!==d)}}catch(ae){St(n,n.return,ae)}}function zv(i){var n=i.updateQueue;if(n!==null){var a=i.stateNode;try{k_(n,a)}catch(l){St(i,i.return,l)}}}function jv(i,n,a){a.props=na(i.type,i.memoizedProps),a.state=i.memoizedState;try{a.componentWillUnmount()}catch(l){St(i,n,l)}}function no(i,n){try{var a=i.ref;if(a!==null){switch(i.tag){case 26:case 27:case 5:var l=i.stateNode;break;case 30:l=i.stateNode;break;default:l=i.stateNode}typeof a=="function"?i.refCleanup=a(l):a.current=l}}catch(u){St(i,n,u)}}function _s(i,n){var a=i.ref,l=i.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(u){St(i,n,u)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(u){St(i,n,u)}else a.current=null}function Hv(i){var n=i.type,a=i.memoizedProps,l=i.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(u){St(i,i.return,u)}}function Fd(i,n,a){try{var l=i.stateNode;kx(l,i.type,a,n),l[bi]=n}catch(u){St(i,i.return,u)}}function Pv(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&_r(i.type)||i.tag===4}function qd(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||Pv(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&_r(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function $d(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(i,n):(n=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,n.appendChild(i),a=a._reactRootContainer,a!=null||n.onclick!==null||(n.onclick=Sn));else if(l!==4&&(l===27&&_r(i.type)&&(a=i.stateNode,n=null),i=i.child,i!==null))for($d(i,n,a),i=i.sibling;i!==null;)$d(i,n,a),i=i.sibling}function Vc(i,n,a){var l=i.tag;if(l===5||l===6)i=i.stateNode,n?a.insertBefore(i,n):a.appendChild(i);else if(l!==4&&(l===27&&_r(i.type)&&(a=i.stateNode),i=i.child,i!==null))for(Vc(i,n,a),i=i.sibling;i!==null;)Vc(i,n,a),i=i.sibling}function Uv(i){var n=i.stateNode,a=i.memoizedProps;try{for(var l=i.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);Fi(n,l,a),n[It]=i,n[bi]=a}catch(d){St(i,i.return,d)}}var zs=!1,pi=!1,Vd=!1,Iv=typeof WeakSet=="function"?WeakSet:Set,Mi=null;function rx(i,n){if(i=i.containerInfo,mf=pu,i=Jg(i),Uh(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var u=l.anchorOffset,d=l.focusNode;l=l.focusOffset;try{a.nodeType,d.nodeType}catch{a=null;break e}var _=0,C=-1,A=-1,$=0,ae=0,fe=i,Y=null;t:for(;;){for(var Z;fe!==a||u!==0&&fe.nodeType!==3||(C=_+u),fe!==d||l!==0&&fe.nodeType!==3||(A=_+l),fe.nodeType===3&&(_+=fe.nodeValue.length),(Z=fe.firstChild)!==null;)Y=fe,fe=Z;for(;;){if(fe===i)break t;if(Y===a&&++$===u&&(C=_),Y===d&&++ae===l&&(A=_),(Z=fe.nextSibling)!==null)break;fe=Y,Y=fe.parentNode}fe=Z}a=C===-1||A===-1?null:{start:C,end:A}}else a=null}a=a||{start:0,end:0}}else a=null;for(gf={focusedElem:i,selectionRange:a},pu=!1,Mi=n;Mi!==null;)if(n=Mi,i=n.child,(n.subtreeFlags&1028)!==0&&i!==null)i.return=n,Mi=i;else for(;Mi!==null;){switch(n=Mi,d=n.alternate,i=n.flags,n.tag){case 0:if((i&4)!==0&&(i=n.updateQueue,i=i!==null?i.events:null,i!==null))for(a=0;a<i.length;a++)u=i[a],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&d!==null){i=void 0,a=n,u=d.memoizedProps,d=d.memoizedState,l=a.stateNode;try{var Le=na(a.type,u);i=l.getSnapshotBeforeUpdate(Le,d),l.__reactInternalSnapshotBeforeUpdate=i}catch(We){St(a,a.return,We)}}break;case 3:if((i&1024)!==0){if(i=n.stateNode.containerInfo,a=i.nodeType,a===9)bf(i);else if(a===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":bf(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=n.sibling,i!==null){i.return=n.return,Mi=i;break}Mi=n.return}}function Kv(i,n,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Hs(i,a),l&4&&io(5,a);break;case 1:if(Hs(i,a),l&4)if(i=a.stateNode,n===null)try{i.componentDidMount()}catch(_){St(a,a.return,_)}else{var u=na(a.type,n.memoizedProps);n=n.memoizedState;try{i.componentDidUpdate(u,n,i.__reactInternalSnapshotBeforeUpdate)}catch(_){St(a,a.return,_)}}l&64&&zv(a),l&512&&no(a,a.return);break;case 3:if(Hs(i,a),l&64&&(i=a.updateQueue,i!==null)){if(n=null,a.child!==null)switch(a.child.tag){case 27:case 5:n=a.child.stateNode;break;case 1:n=a.child.stateNode}try{k_(i,n)}catch(_){St(a,a.return,_)}}break;case 27:n===null&&l&4&&Uv(a);case 26:case 5:Hs(i,a),n===null&&l&4&&Hv(a),l&512&&no(a,a.return);break;case 12:Hs(i,a);break;case 31:Hs(i,a),l&4&&qv(i,a);break;case 13:Hs(i,a),l&4&&$v(i,a),l&64&&(i=a.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(a=px.bind(null,a),Bx(i,a))));break;case 22:if(l=a.memoizedState!==null||zs,!l){n=n!==null&&n.memoizedState!==null||pi,u=zs;var d=pi;zs=l,(pi=n)&&!d?Ps(i,a,(a.subtreeFlags&8772)!==0):Hs(i,a),zs=u,pi=d}break;case 30:break;default:Hs(i,a)}}function Wv(i){var n=i.alternate;n!==null&&(i.alternate=null,Wv(n)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(n=i.stateNode,n!==null&&Bn(n)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var Pt=null,cn=!1;function js(i,n,a){for(a=a.child;a!==null;)Fv(i,n,a),a=a.sibling}function Fv(i,n,a){if(wt&&typeof wt.onCommitFiberUnmount=="function")try{wt.onCommitFiberUnmount(ot,a)}catch{}switch(a.tag){case 26:pi||_s(a,n),js(i,n,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:pi||_s(a,n);var l=Pt,u=cn;_r(a.type)&&(Pt=a.stateNode,cn=!1),js(i,n,a),fo(a.stateNode),Pt=l,cn=u;break;case 5:pi||_s(a,n);case 6:if(l=Pt,u=cn,Pt=null,js(i,n,a),Pt=l,cn=u,Pt!==null)if(cn)try{(Pt.nodeType===9?Pt.body:Pt.nodeName==="HTML"?Pt.ownerDocument.body:Pt).removeChild(a.stateNode)}catch(d){St(a,n,d)}else try{Pt.removeChild(a.stateNode)}catch(d){St(a,n,d)}break;case 18:Pt!==null&&(cn?(i=Pt,zb(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,a.stateNode),cl(i)):zb(Pt,a.stateNode));break;case 4:l=Pt,u=cn,Pt=a.stateNode.containerInfo,cn=!0,js(i,n,a),Pt=l,cn=u;break;case 0:case 11:case 14:case 15:ur(2,a,n),pi||ur(4,a,n),js(i,n,a);break;case 1:pi||(_s(a,n),l=a.stateNode,typeof l.componentWillUnmount=="function"&&jv(a,n,l)),js(i,n,a);break;case 21:js(i,n,a);break;case 22:pi=(l=pi)||a.memoizedState!==null,js(i,n,a),pi=l;break;default:js(i,n,a)}}function qv(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{cl(i)}catch(a){St(n,n.return,a)}}}function $v(i,n){if(n.memoizedState===null&&(i=n.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{cl(i)}catch(a){St(n,n.return,a)}}function ax(i){switch(i.tag){case 31:case 13:case 19:var n=i.stateNode;return n===null&&(n=i.stateNode=new Iv),n;case 22:return i=i.stateNode,n=i._retryCache,n===null&&(n=i._retryCache=new Iv),n;default:throw Error(r(435,i.tag))}}function Yc(i,n){var a=ax(i);n.forEach(function(l){if(!a.has(l)){a.add(l);var u=mx.bind(null,i,l);l.then(u,u)}})}function un(i,n){var a=n.deletions;if(a!==null)for(var l=0;l<a.length;l++){var u=a[l],d=i,_=n,C=_;e:for(;C!==null;){switch(C.tag){case 27:if(_r(C.type)){Pt=C.stateNode,cn=!1;break e}break;case 5:Pt=C.stateNode,cn=!1;break e;case 3:case 4:Pt=C.stateNode.containerInfo,cn=!0;break e}C=C.return}if(Pt===null)throw Error(r(160));Fv(d,_,u),Pt=null,cn=!1,d=u.alternate,d!==null&&(d.return=null),u.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Vv(n,i),n=n.sibling}var as=null;function Vv(i,n){var a=i.alternate,l=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:un(n,i),hn(i),l&4&&(ur(3,i,i.return),io(3,i),ur(5,i,i.return));break;case 1:un(n,i),hn(i),l&512&&(pi||a===null||_s(a,a.return)),l&64&&zs&&(i=i.updateQueue,i!==null&&(l=i.callbacks,l!==null&&(a=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var u=as;if(un(n,i),hn(i),l&512&&(pi||a===null||_s(a,a.return)),l&4){var d=a!==null?a.memoizedState:null;if(l=i.memoizedState,a===null)if(l===null)if(i.stateNode===null){e:{l=i.type,a=i.memoizedProps,u=u.ownerDocument||u;t:switch(l){case"title":d=u.getElementsByTagName("title")[0],(!d||d[Es]||d[It]||d.namespaceURI==="http://www.w3.org/2000/svg"||d.hasAttribute("itemprop"))&&(d=u.createElement(l),u.head.insertBefore(d,u.querySelector("head > title"))),Fi(d,l,a),d[It]=i,Kt(d),l=d;break e;case"link":var _=Vb("link","href",u).get(l+(a.href||""));if(_){for(var C=0;C<_.length;C++)if(d=_[C],d.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&d.getAttribute("rel")===(a.rel==null?null:a.rel)&&d.getAttribute("title")===(a.title==null?null:a.title)&&d.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){_.splice(C,1);break t}}d=u.createElement(l),Fi(d,l,a),u.head.appendChild(d);break;case"meta":if(_=Vb("meta","content",u).get(l+(a.content||""))){for(C=0;C<_.length;C++)if(d=_[C],d.getAttribute("content")===(a.content==null?null:""+a.content)&&d.getAttribute("name")===(a.name==null?null:a.name)&&d.getAttribute("property")===(a.property==null?null:a.property)&&d.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&d.getAttribute("charset")===(a.charSet==null?null:a.charSet)){_.splice(C,1);break t}}d=u.createElement(l),Fi(d,l,a),u.head.appendChild(d);break;default:throw Error(r(468,l))}d[It]=i,Kt(d),l=d}i.stateNode=l}else Yb(u,i.type,i.stateNode);else i.stateNode=$b(u,l,i.memoizedProps);else d!==l?(d===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):d.count--,l===null?Yb(u,i.type,i.stateNode):$b(u,l,i.memoizedProps)):l===null&&i.stateNode!==null&&Fd(i,i.memoizedProps,a.memoizedProps)}break;case 27:un(n,i),hn(i),l&512&&(pi||a===null||_s(a,a.return)),a!==null&&l&4&&Fd(i,i.memoizedProps,a.memoizedProps);break;case 5:if(un(n,i),hn(i),l&512&&(pi||a===null||_s(a,a.return)),i.flags&32){u=i.stateNode;try{Ji(u,"")}catch(Le){St(i,i.return,Le)}}l&4&&i.stateNode!=null&&(u=i.memoizedProps,Fd(i,u,a!==null?a.memoizedProps:u)),l&1024&&(Vd=!0);break;case 6:if(un(n,i),hn(i),l&4){if(i.stateNode===null)throw Error(r(162));l=i.memoizedProps,a=i.stateNode;try{a.nodeValue=l}catch(Le){St(i,i.return,Le)}}break;case 3:if(uu=null,u=as,as=ou(n.containerInfo),un(n,i),as=u,hn(i),l&4&&a!==null&&a.memoizedState.isDehydrated)try{cl(n.containerInfo)}catch(Le){St(i,i.return,Le)}Vd&&(Vd=!1,Yv(i));break;case 4:l=as,as=ou(i.stateNode.containerInfo),un(n,i),hn(i),as=l;break;case 12:un(n,i),hn(i);break;case 31:un(n,i),hn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Yc(i,l)));break;case 13:un(n,i),hn(i),i.child.flags&8192&&i.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Gc=st()),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Yc(i,l)));break;case 22:u=i.memoizedState!==null;var A=a!==null&&a.memoizedState!==null,$=zs,ae=pi;if(zs=$||u,pi=ae||A,un(n,i),pi=ae,zs=$,hn(i),l&8192)e:for(n=i.stateNode,n._visibility=u?n._visibility&-2:n._visibility|1,u&&(a===null||A||zs||pi||sa(i)),a=null,n=i;;){if(n.tag===5||n.tag===26){if(a===null){A=a=n;try{if(d=A.stateNode,u)_=d.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{C=A.stateNode;var fe=A.memoizedProps.style,Y=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;C.style.display=Y==null||typeof Y=="boolean"?"":(""+Y).trim()}}catch(Le){St(A,A.return,Le)}}}else if(n.tag===6){if(a===null){A=n;try{A.stateNode.nodeValue=u?"":A.memoizedProps}catch(Le){St(A,A.return,Le)}}}else if(n.tag===18){if(a===null){A=n;try{var Z=A.stateNode;u?jb(Z,!0):jb(A.stateNode,!1)}catch(Le){St(A,A.return,Le)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===i)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===i)break e;for(;n.sibling===null;){if(n.return===null||n.return===i)break e;a===n&&(a=null),n=n.return}a===n&&(a=null),n.sibling.return=n.return,n=n.sibling}l&4&&(l=i.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,Yc(i,a))));break;case 19:un(n,i),hn(i),l&4&&(l=i.updateQueue,l!==null&&(i.updateQueue=null,Yc(i,l)));break;case 30:break;case 21:break;default:un(n,i),hn(i)}}function hn(i){var n=i.flags;if(n&2){try{for(var a,l=i.return;l!==null;){if(Pv(l)){a=l;break}l=l.return}if(a==null)throw Error(r(160));switch(a.tag){case 27:var u=a.stateNode,d=qd(i);Vc(i,d,u);break;case 5:var _=a.stateNode;a.flags&32&&(Ji(_,""),a.flags&=-33);var C=qd(i);Vc(i,C,_);break;case 3:case 4:var A=a.stateNode.containerInfo,$=qd(i);$d(i,$,A);break;default:throw Error(r(161))}}catch(ae){St(i,i.return,ae)}i.flags&=-3}n&4096&&(i.flags&=-4097)}function Yv(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var n=i;Yv(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),i=i.sibling}}function Hs(i,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Kv(i,n.alternate,n),n=n.sibling}function sa(i){for(i=i.child;i!==null;){var n=i;switch(n.tag){case 0:case 11:case 14:case 15:ur(4,n,n.return),sa(n);break;case 1:_s(n,n.return);var a=n.stateNode;typeof a.componentWillUnmount=="function"&&jv(n,n.return,a),sa(n);break;case 27:fo(n.stateNode);case 26:case 5:_s(n,n.return),sa(n);break;case 22:n.memoizedState===null&&sa(n);break;case 30:sa(n);break;default:sa(n)}i=i.sibling}}function Ps(i,n,a){for(a=a&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var l=n.alternate,u=i,d=n,_=d.flags;switch(d.tag){case 0:case 11:case 15:Ps(u,d,a),io(4,d);break;case 1:if(Ps(u,d,a),l=d,u=l.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch($){St(l,l.return,$)}if(l=d,u=l.updateQueue,u!==null){var C=l.stateNode;try{var A=u.shared.hiddenCallbacks;if(A!==null)for(u.shared.hiddenCallbacks=null,u=0;u<A.length;u++)E_(A[u],C)}catch($){St(l,l.return,$)}}a&&_&64&&zv(d),no(d,d.return);break;case 27:Uv(d);case 26:case 5:Ps(u,d,a),a&&l===null&&_&4&&Hv(d),no(d,d.return);break;case 12:Ps(u,d,a);break;case 31:Ps(u,d,a),a&&_&4&&qv(u,d);break;case 13:Ps(u,d,a),a&&_&4&&$v(u,d);break;case 22:d.memoizedState===null&&Ps(u,d,a),no(d,d.return);break;case 30:break;default:Ps(u,d,a)}n=n.sibling}}function Yd(i,n){var a=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(a=i.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==a&&(i!=null&&i.refCount++,a!=null&&Wl(a))}function Xd(i,n){i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Wl(i))}function ls(i,n,a,l){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Xv(i,n,a,l),n=n.sibling}function Xv(i,n,a,l){var u=n.flags;switch(n.tag){case 0:case 11:case 15:ls(i,n,a,l),u&2048&&io(9,n);break;case 1:ls(i,n,a,l);break;case 3:ls(i,n,a,l),u&2048&&(i=null,n.alternate!==null&&(i=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==i&&(n.refCount++,i!=null&&Wl(i)));break;case 12:if(u&2048){ls(i,n,a,l),i=n.stateNode;try{var d=n.memoizedProps,_=d.id,C=d.onPostCommit;typeof C=="function"&&C(_,n.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(A){St(n,n.return,A)}}else ls(i,n,a,l);break;case 31:ls(i,n,a,l);break;case 13:ls(i,n,a,l);break;case 23:break;case 22:d=n.stateNode,_=n.alternate,n.memoizedState!==null?d._visibility&2?ls(i,n,a,l):so(i,n):d._visibility&2?ls(i,n,a,l):(d._visibility|=2,Qa(i,n,a,l,(n.subtreeFlags&10256)!==0||!1)),u&2048&&Yd(_,n);break;case 24:ls(i,n,a,l),u&2048&&Xd(n.alternate,n);break;default:ls(i,n,a,l)}}function Qa(i,n,a,l,u){for(u=u&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var d=i,_=n,C=a,A=l,$=_.flags;switch(_.tag){case 0:case 11:case 15:Qa(d,_,C,A,u),io(8,_);break;case 23:break;case 22:var ae=_.stateNode;_.memoizedState!==null?ae._visibility&2?Qa(d,_,C,A,u):so(d,_):(ae._visibility|=2,Qa(d,_,C,A,u)),u&&$&2048&&Yd(_.alternate,_);break;case 24:Qa(d,_,C,A,u),u&&$&2048&&Xd(_.alternate,_);break;default:Qa(d,_,C,A,u)}n=n.sibling}}function so(i,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var a=i,l=n,u=l.flags;switch(l.tag){case 22:so(a,l),u&2048&&Yd(l.alternate,l);break;case 24:so(a,l),u&2048&&Xd(l.alternate,l);break;default:so(a,l)}n=n.sibling}}var ro=8192;function Ja(i,n,a){if(i.subtreeFlags&ro)for(i=i.child;i!==null;)Gv(i,n,a),i=i.sibling}function Gv(i,n,a){switch(i.tag){case 26:Ja(i,n,a),i.flags&ro&&i.memoizedState!==null&&$x(a,as,i.memoizedState,i.memoizedProps);break;case 5:Ja(i,n,a);break;case 3:case 4:var l=as;as=ou(i.stateNode.containerInfo),Ja(i,n,a),as=l;break;case 22:i.memoizedState===null&&(l=i.alternate,l!==null&&l.memoizedState!==null?(l=ro,ro=16777216,Ja(i,n,a),ro=l):Ja(i,n,a));break;default:Ja(i,n,a)}}function Zv(i){var n=i.alternate;if(n!==null&&(i=n.child,i!==null)){n.child=null;do n=i.sibling,i.sibling=null,i=n;while(i!==null)}}function ao(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];Mi=l,Jv(l,i)}Zv(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Qv(i),i=i.sibling}function Qv(i){switch(i.tag){case 0:case 11:case 15:ao(i),i.flags&2048&&ur(9,i,i.return);break;case 3:ao(i);break;case 12:ao(i);break;case 22:var n=i.stateNode;i.memoizedState!==null&&n._visibility&2&&(i.return===null||i.return.tag!==13)?(n._visibility&=-3,Xc(i)):ao(i);break;default:ao(i)}}function Xc(i){var n=i.deletions;if((i.flags&16)!==0){if(n!==null)for(var a=0;a<n.length;a++){var l=n[a];Mi=l,Jv(l,i)}Zv(i)}for(i=i.child;i!==null;){switch(n=i,n.tag){case 0:case 11:case 15:ur(8,n,n.return),Xc(n);break;case 22:a=n.stateNode,a._visibility&2&&(a._visibility&=-3,Xc(n));break;default:Xc(n)}i=i.sibling}}function Jv(i,n){for(;Mi!==null;){var a=Mi;switch(a.tag){case 0:case 11:case 15:ur(8,a,n);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Wl(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,Mi=l;else e:for(a=i;Mi!==null;){l=Mi;var u=l.sibling,d=l.return;if(Wv(l),l===a){Mi=null;break e}if(u!==null){u.return=d,Mi=u;break e}Mi=d}}}var lx={getCacheForType:function(i){var n=Ki(hi),a=n.data.get(i);return a===void 0&&(a=i(),n.data.set(i,a)),a},cacheSignal:function(){return Ki(hi).controller.signal}},ox=typeof WeakMap=="function"?WeakMap:Map,mt=0,Mt=null,at=null,ct=0,yt=0,kn=null,hr=!1,el=!1,Gd=!1,Us=0,Zt=0,dr=0,ra=0,Zd=0,Tn=0,tl=0,lo=null,dn=null,Qd=!1,Gc=0,eb=0,Zc=1/0,Qc=null,fr=null,yi=0,pr=null,il=null,Is=0,Jd=0,ef=null,tb=null,oo=0,tf=null;function Dn(){return(mt&2)!==0&&ct!==0?ct&-ct:B.T!==null?of():Zi()}function ib(){if(Tn===0)if((ct&536870912)===0||ht){var i=Pi;Pi<<=1,(Pi&3932160)===0&&(Pi=262144),Tn=i}else Tn=536870912;return i=xn.current,i!==null&&(i.flags|=32),Tn}function fn(i,n,a){(i===Mt&&(yt===2||yt===9)||i.cancelPendingCommit!==null)&&(nl(i,0),mr(i,ct,Tn,!1)),_i(i,a),((mt&2)===0||i!==Mt)&&(i===Mt&&((mt&2)===0&&(ra|=a),Zt===4&&mr(i,ct,Tn,!1)),vs(i))}function nb(i,n,a){if((mt&6)!==0)throw Error(r(327));var l=!a&&(n&127)===0&&(n&i.expiredLanes)===0||Di(i,n),u=l?hx(i,n):sf(i,n,!0),d=l;do{if(u===0){el&&!l&&mr(i,n,0,!1);break}else{if(a=i.current.alternate,d&&!cx(a)){u=sf(i,n,!1),d=!1;continue}if(u===2){if(d=n,i.errorRecoveryDisabledLanes&d)var _=0;else _=i.pendingLanes&-536870913,_=_!==0?_:_&536870912?536870912:0;if(_!==0){n=_;e:{var C=i;u=lo;var A=C.current.memoizedState.isDehydrated;if(A&&(nl(C,_).flags|=256),_=sf(C,_,!1),_!==2){if(Gd&&!A){C.errorRecoveryDisabledLanes|=d,ra|=d,u=4;break e}d=dn,dn=u,d!==null&&(dn===null?dn=d:dn.push.apply(dn,d))}u=_}if(d=!1,u!==2)continue}}if(u===1){nl(i,0),mr(i,n,0,!0);break}e:{switch(l=i,d=u,d){case 0:case 1:throw Error(r(345));case 4:if((n&4194048)!==n)break;case 6:mr(l,n,Tn,!hr);break e;case 2:dn=null;break;case 3:case 5:break;default:throw Error(r(329))}if((n&62914560)===n&&(u=Gc+300-st(),10<u)){if(mr(l,n,Tn,!hr),Ct(l,0,!0)!==0)break e;Is=n,l.timeoutHandle=Bb(sb.bind(null,l,a,dn,Qc,Qd,n,Tn,ra,tl,hr,d,"Throttled",-0,0),u);break e}sb(l,a,dn,Qc,Qd,n,Tn,ra,tl,hr,d,null,-0,0)}}break}while(!0);vs(i)}function sb(i,n,a,l,u,d,_,C,A,$,ae,fe,Y,Z){if(i.timeoutHandle=-1,fe=n.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Sn},Gv(n,d,fe);var Le=(d&62914560)===d?Gc-st():(d&4194048)===d?eb-st():0;if(Le=Vx(fe,Le),Le!==null){Is=d,i.cancelPendingCommit=Le(db.bind(null,i,n,d,a,l,u,_,C,A,ae,fe,null,Y,Z)),mr(i,d,_,!$);return}}db(i,n,d,a,l,u,_,C,A)}function cx(i){for(var n=i;;){var a=n.tag;if((a===0||a===11||a===15)&&n.flags&16384&&(a=n.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var u=a[l],d=u.getSnapshot;u=u.value;try{if(!wn(d(),u))return!1}catch{return!1}}if(a=n.child,n.subtreeFlags&16384&&a!==null)a.return=n,n=a;else{if(n===i)break;for(;n.sibling===null;){if(n.return===null||n.return===i)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function mr(i,n,a,l){n&=~Zd,n&=~ra,i.suspendedLanes|=n,i.pingedLanes&=~n,l&&(i.warmLanes|=n),l=i.expirationTimes;for(var u=n;0<u;){var d=31-Dt(u),_=1<<d;l[d]=-1,u&=~_}a!==0&&Ri(i,a,n)}function Jc(){return(mt&6)===0?(co(0),!1):!0}function nf(){if(at!==null){if(yt===0)var i=at.return;else i=at,Ms=Gr=null,vd(i),Va=null,ql=0,i=at;for(;i!==null;)Ov(i.alternate,i),i=i.return;at=null}}function nl(i,n){var a=i.timeoutHandle;a!==-1&&(i.timeoutHandle=-1,Rx(a)),a=i.cancelPendingCommit,a!==null&&(i.cancelPendingCommit=null,a()),Is=0,nf(),Mt=i,at=a=Ds(i.current,null),ct=n,yt=0,kn=null,hr=!1,el=Di(i,n),Gd=!1,tl=Tn=Zd=ra=dr=Zt=0,dn=lo=null,Qd=!1,(n&8)!==0&&(n|=n&32);var l=i.entangledLanes;if(l!==0)for(i=i.entanglements,l&=n;0<l;){var u=31-Dt(l),d=1<<u;n|=i[u],l&=~d}return Us=n,yc(),a}function rb(i,n){Ge=null,B.H=Jl,n===$a||n===Dc?(n=S_(),yt=3):n===ad?(n=S_(),yt=4):yt=n===Bd?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,kn=n,at===null&&(Zt=1,Kc(i,Un(n,i.current)))}function ab(){var i=xn.current;return i===null?!0:(ct&4194048)===ct?Fn===null:(ct&62914560)===ct||(ct&536870912)!==0?i===Fn:!1}function lb(){var i=B.H;return B.H=Jl,i===null?Jl:i}function ob(){var i=B.A;return B.A=lx,i}function eu(){Zt=4,hr||(ct&4194048)!==ct&&xn.current!==null||(el=!0),(dr&134217727)===0&&(ra&134217727)===0||Mt===null||mr(Mt,ct,Tn,!1)}function sf(i,n,a){var l=mt;mt|=2;var u=lb(),d=ob();(Mt!==i||ct!==n)&&(Qc=null,nl(i,n)),n=!1;var _=Zt;e:do try{if(yt!==0&&at!==null){var C=at,A=kn;switch(yt){case 8:nf(),_=6;break e;case 3:case 2:case 9:case 6:xn.current===null&&(n=!0);var $=yt;if(yt=0,kn=null,sl(i,C,A,$),a&&el){_=0;break e}break;default:$=yt,yt=0,kn=null,sl(i,C,A,$)}}ux(),_=Zt;break}catch(ae){rb(i,ae)}while(!0);return n&&i.shellSuspendCounter++,Ms=Gr=null,mt=l,B.H=u,B.A=d,at===null&&(Mt=null,ct=0,yc()),_}function ux(){for(;at!==null;)cb(at)}function hx(i,n){var a=mt;mt|=2;var l=lb(),u=ob();Mt!==i||ct!==n?(Qc=null,Zc=st()+500,nl(i,n)):el=Di(i,n);e:do try{if(yt!==0&&at!==null){n=at;var d=kn;t:switch(yt){case 1:yt=0,kn=null,sl(i,n,d,1);break;case 2:case 9:if(b_(d)){yt=0,kn=null,ub(n);break}n=function(){yt!==2&&yt!==9||Mt!==i||(yt=7),vs(i)},d.then(n,n);break e;case 3:yt=7;break e;case 4:yt=5;break e;case 7:b_(d)?(yt=0,kn=null,ub(n)):(yt=0,kn=null,sl(i,n,d,7));break;case 5:var _=null;switch(at.tag){case 26:_=at.memoizedState;case 5:case 27:var C=at;if(_?Xb(_):C.stateNode.complete){yt=0,kn=null;var A=C.sibling;if(A!==null)at=A;else{var $=C.return;$!==null?(at=$,tu($)):at=null}break t}}yt=0,kn=null,sl(i,n,d,5);break;case 6:yt=0,kn=null,sl(i,n,d,6);break;case 8:nf(),Zt=6;break e;default:throw Error(r(462))}}dx();break}catch(ae){rb(i,ae)}while(!0);return Ms=Gr=null,B.H=l,B.A=u,mt=a,at!==null?0:(Mt=null,ct=0,yc(),Zt)}function dx(){for(;at!==null&&!gt();)cb(at)}function cb(i){var n=Lv(i.alternate,i,Us);i.memoizedProps=i.pendingProps,n===null?tu(i):at=n}function ub(i){var n=i,a=n.alternate;switch(n.tag){case 15:case 0:n=Tv(a,n,n.pendingProps,n.type,void 0,ct);break;case 11:n=Tv(a,n,n.pendingProps,n.type.render,n.ref,ct);break;case 5:vd(n);default:Ov(a,n),n=at=o_(n,Us),n=Lv(a,n,Us)}i.memoizedProps=i.pendingProps,n===null?tu(i):at=n}function sl(i,n,a,l){Ms=Gr=null,vd(n),Va=null,ql=0;var u=n.return;try{if(ex(i,u,n,a,ct)){Zt=1,Kc(i,Un(a,i.current)),at=null;return}}catch(d){if(u!==null)throw at=u,d;Zt=1,Kc(i,Un(a,i.current)),at=null;return}n.flags&32768?(ht||l===1?i=!0:el||(ct&536870912)!==0?i=!1:(hr=i=!0,(l===2||l===9||l===3||l===6)&&(l=xn.current,l!==null&&l.tag===13&&(l.flags|=16384))),hb(n,i)):tu(n)}function tu(i){var n=i;do{if((n.flags&32768)!==0){hb(n,hr);return}i=n.return;var a=nx(n.alternate,n,Us);if(a!==null){at=a;return}if(n=n.sibling,n!==null){at=n;return}at=n=i}while(n!==null);Zt===0&&(Zt=5)}function hb(i,n){do{var a=sx(i.alternate,i);if(a!==null){a.flags&=32767,at=a;return}if(a=i.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!n&&(i=i.sibling,i!==null)){at=i;return}at=i=a}while(i!==null);Zt=6,at=null}function db(i,n,a,l,u,d,_,C,A){i.cancelPendingCommit=null;do iu();while(yi!==0);if((mt&6)!==0)throw Error(r(327));if(n!==null){if(n===i.current)throw Error(r(177));if(d=n.lanes|n.childLanes,d|=qh,Ht(i,a,d,_,C,A),i===Mt&&(at=Mt=null,ct=0),il=n,pr=i,Is=a,Jd=d,ef=u,tb=l,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,gx(ti,function(){return _b(),null})):(i.callbackNode=null,i.callbackPriority=0),l=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||l){l=B.T,B.T=null,u=W.p,W.p=2,_=mt,mt|=4;try{rx(i,n,a)}finally{mt=_,W.p=u,B.T=l}}yi=1,fb(),pb(),mb()}}function fb(){if(yi===1){yi=0;var i=pr,n=il,a=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||a){a=B.T,B.T=null;var l=W.p;W.p=2;var u=mt;mt|=4;try{Vv(n,i);var d=gf,_=Jg(i.containerInfo),C=d.focusedElem,A=d.selectionRange;if(_!==C&&C&&C.ownerDocument&&Qg(C.ownerDocument.documentElement,C)){if(A!==null&&Uh(C)){var $=A.start,ae=A.end;if(ae===void 0&&(ae=$),"selectionStart"in C)C.selectionStart=$,C.selectionEnd=Math.min(ae,C.value.length);else{var fe=C.ownerDocument||document,Y=fe&&fe.defaultView||window;if(Y.getSelection){var Z=Y.getSelection(),Le=C.textContent.length,We=Math.min(A.start,Le),kt=A.end===void 0?We:Math.min(A.end,Le);!Z.extend&&We>kt&&(_=kt,kt=We,We=_);var P=Zg(C,We),z=Zg(C,kt);if(P&&z&&(Z.rangeCount!==1||Z.anchorNode!==P.node||Z.anchorOffset!==P.offset||Z.focusNode!==z.node||Z.focusOffset!==z.offset)){var q=fe.createRange();q.setStart(P.node,P.offset),Z.removeAllRanges(),We>kt?(Z.addRange(q),Z.extend(z.node,z.offset)):(q.setEnd(z.node,z.offset),Z.addRange(q))}}}}for(fe=[],Z=C;Z=Z.parentNode;)Z.nodeType===1&&fe.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof C.focus=="function"&&C.focus(),C=0;C<fe.length;C++){var ue=fe[C];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}pu=!!mf,gf=mf=null}finally{mt=u,W.p=l,B.T=a}}i.current=n,yi=2}}function pb(){if(yi===2){yi=0;var i=pr,n=il,a=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||a){a=B.T,B.T=null;var l=W.p;W.p=2;var u=mt;mt|=4;try{Kv(i,n.alternate,n)}finally{mt=u,W.p=l,B.T=a}}yi=3}}function mb(){if(yi===4||yi===3){yi=0,Xe();var i=pr,n=il,a=Is,l=tb;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?yi=5:(yi=0,il=pr=null,gb(i,i.pendingLanes));var u=i.pendingLanes;if(u===0&&(fr=null),Gi(a),n=n.stateNode,wt&&typeof wt.onCommitFiberRoot=="function")try{wt.onCommitFiberRoot(ot,n,void 0,(n.current.flags&128)===128)}catch{}if(l!==null){n=B.T,u=W.p,W.p=2,B.T=null;try{for(var d=i.onRecoverableError,_=0;_<l.length;_++){var C=l[_];d(C.value,{componentStack:C.stack})}}finally{B.T=n,W.p=u}}(Is&3)!==0&&iu(),vs(i),u=i.pendingLanes,(a&261930)!==0&&(u&42)!==0?i===tf?oo++:(oo=0,tf=i):oo=0,co(0)}}function gb(i,n){(i.pooledCacheLanes&=n)===0&&(n=i.pooledCache,n!=null&&(i.pooledCache=null,Wl(n)))}function iu(){return fb(),pb(),mb(),_b()}function _b(){if(yi!==5)return!1;var i=pr,n=Jd;Jd=0;var a=Gi(Is),l=B.T,u=W.p;try{W.p=32>a?32:a,B.T=null,a=ef,ef=null;var d=pr,_=Is;if(yi=0,il=pr=null,Is=0,(mt&6)!==0)throw Error(r(331));var C=mt;if(mt|=4,Qv(d.current),Xv(d,d.current,_,a),mt=C,co(0,!1),wt&&typeof wt.onPostCommitFiberRoot=="function")try{wt.onPostCommitFiberRoot(ot,d)}catch{}return!0}finally{W.p=u,B.T=l,gb(i,n)}}function vb(i,n,a){n=Un(a,n),n=Ld(i.stateNode,n,2),i=lr(i,n,2),i!==null&&(_i(i,2),vs(i))}function St(i,n,a){if(i.tag===3)vb(i,i,a);else for(;n!==null;){if(n.tag===3){vb(n,i,a);break}else if(n.tag===1){var l=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(fr===null||!fr.has(l))){i=Un(a,i),a=bv(2),l=lr(n,a,2),l!==null&&(yv(a,l,n,i),_i(l,2),vs(l));break}}n=n.return}}function rf(i,n,a){var l=i.pingCache;if(l===null){l=i.pingCache=new ox;var u=new Set;l.set(n,u)}else u=l.get(n),u===void 0&&(u=new Set,l.set(n,u));u.has(a)||(Gd=!0,u.add(a),i=fx.bind(null,i,n,a),n.then(i,i))}function fx(i,n,a){var l=i.pingCache;l!==null&&l.delete(n),i.pingedLanes|=i.suspendedLanes&a,i.warmLanes&=~a,Mt===i&&(ct&a)===a&&(Zt===4||Zt===3&&(ct&62914560)===ct&&300>st()-Gc?(mt&2)===0&&nl(i,0):Zd|=a,tl===ct&&(tl=0)),vs(i)}function bb(i,n){n===0&&(n=qt()),i=Vr(i,n),i!==null&&(_i(i,n),vs(i))}function px(i){var n=i.memoizedState,a=0;n!==null&&(a=n.retryLane),bb(i,a)}function mx(i,n){var a=0;switch(i.tag){case 31:case 13:var l=i.stateNode,u=i.memoizedState;u!==null&&(a=u.retryLane);break;case 19:l=i.stateNode;break;case 22:l=i.stateNode._retryCache;break;default:throw Error(r(314))}l!==null&&l.delete(n),bb(i,a)}function gx(i,n){return ze(i,n)}var nu=null,rl=null,af=!1,su=!1,lf=!1,gr=0;function vs(i){i!==rl&&i.next===null&&(rl===null?nu=rl=i:rl=rl.next=i),su=!0,af||(af=!0,vx())}function co(i,n){if(!lf&&su){lf=!0;do for(var a=!1,l=nu;l!==null;){if(i!==0){var u=l.pendingLanes;if(u===0)var d=0;else{var _=l.suspendedLanes,C=l.pingedLanes;d=(1<<31-Dt(42|i)+1)-1,d&=u&~(_&~C),d=d&201326741?d&201326741|1:d?d|2:0}d!==0&&(a=!0,Cb(l,d))}else d=ct,d=Ct(l,l===Mt?d:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(d&3)===0||Di(l,d)||(a=!0,Cb(l,d));l=l.next}while(a);lf=!1}}function _x(){yb()}function yb(){su=af=!1;var i=0;gr!==0&&Dx()&&(i=gr);for(var n=st(),a=null,l=nu;l!==null;){var u=l.next,d=Sb(l,n);d===0?(l.next=null,a===null?nu=u:a.next=u,u===null&&(rl=a)):(a=l,(i!==0||(d&3)!==0)&&(su=!0)),l=u}yi!==0&&yi!==5||co(i),gr!==0&&(gr=0)}function Sb(i,n){for(var a=i.suspendedLanes,l=i.pingedLanes,u=i.expirationTimes,d=i.pendingLanes&-62914561;0<d;){var _=31-Dt(d),C=1<<_,A=u[_];A===-1?((C&a)===0||(C&l)!==0)&&(u[_]=oi(C,n)):A<=n&&(i.expiredLanes|=C),d&=~C}if(n=Mt,a=ct,a=Ct(i,i===n?a:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l=i.callbackNode,a===0||i===n&&(yt===2||yt===9)||i.cancelPendingCommit!==null)return l!==null&&l!==null&&He(l),i.callbackNode=null,i.callbackPriority=0;if((a&3)===0||Di(i,a)){if(n=a&-a,n===i.callbackPriority)return n;switch(l!==null&&He(l),Gi(a)){case 2:case 8:a=ki;break;case 32:a=ti;break;case 268435456:a=Jn;break;default:a=ti}return l=wb.bind(null,i),a=ze(a,l),i.callbackPriority=n,i.callbackNode=a,n}return l!==null&&l!==null&&He(l),i.callbackPriority=2,i.callbackNode=null,2}function wb(i,n){if(yi!==0&&yi!==5)return i.callbackNode=null,i.callbackPriority=0,null;var a=i.callbackNode;if(iu()&&i.callbackNode!==a)return null;var l=ct;return l=Ct(i,i===Mt?l:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),l===0?null:(nb(i,l,n),Sb(i,st()),i.callbackNode!=null&&i.callbackNode===a?wb.bind(null,i):null)}function Cb(i,n){if(iu())return null;nb(i,n,!0)}function vx(){Mx(function(){(mt&6)!==0?ze(an,_x):yb()})}function of(){if(gr===0){var i=Fa;i===0&&(i=Rt,Rt<<=1,(Rt&261888)===0&&(Rt=256)),gr=i}return gr}function xb(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:ps(""+i)}function Eb(i,n){var a=n.ownerDocument.createElement("input");return a.name=n.name,a.value=n.value,i.id&&a.setAttribute("form",i.id),n.parentNode.insertBefore(a,n),i=new FormData(i),a.parentNode.removeChild(a),i}function bx(i,n,a,l,u){if(n==="submit"&&a&&a.stateNode===u){var d=xb((u[bi]||null).action),_=l.submitter;_&&(n=(n=_[bi]||null)?xb(n.formAction):_.getAttribute("formAction"),n!==null&&(d=n,_=null));var C=new it("action","action",null,l,u);i.push({event:C,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(gr!==0){var A=_?Eb(u,_):new FormData(u);Td(a,{pending:!0,data:A,method:u.method,action:d},null,A)}}else typeof d=="function"&&(C.preventDefault(),A=_?Eb(u,_):new FormData(u),Td(a,{pending:!0,data:A,method:u.method,action:d},d,A))},currentTarget:u}]})}}for(var cf=0;cf<Fh.length;cf++){var uf=Fh[cf],yx=uf.toLowerCase(),Sx=uf[0].toUpperCase()+uf.slice(1);rs(yx,"on"+Sx)}rs(i_,"onAnimationEnd"),rs(n_,"onAnimationIteration"),rs(s_,"onAnimationStart"),rs("dblclick","onDoubleClick"),rs("focusin","onFocus"),rs("focusout","onBlur"),rs(jC,"onTransitionRun"),rs(HC,"onTransitionStart"),rs(PC,"onTransitionCancel"),rs(r_,"onTransitionEnd"),is("onMouseEnter",["mouseout","mouseover"]),is("onMouseLeave",["mouseout","mouseover"]),is("onPointerEnter",["pointerout","pointerover"]),is("onPointerLeave",["pointerout","pointerover"]),zn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),zn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),zn("onBeforeInput",["compositionend","keypress","textInput","paste"]),zn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),zn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),zn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var uo="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(" "),wx=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(uo));function kb(i,n){n=(n&4)!==0;for(var a=0;a<i.length;a++){var l=i[a],u=l.event;l=l.listeners;e:{var d=void 0;if(n)for(var _=l.length-1;0<=_;_--){var C=l[_],A=C.instance,$=C.currentTarget;if(C=C.listener,A!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=$;try{d(u)}catch(ae){bc(ae)}u.currentTarget=null,d=A}else for(_=0;_<l.length;_++){if(C=l[_],A=C.instance,$=C.currentTarget,C=C.listener,A!==d&&u.isPropagationStopped())break e;d=C,u.currentTarget=$;try{d(u)}catch(ae){bc(ae)}u.currentTarget=null,d=A}}}}function lt(i,n){var a=n[Ur];a===void 0&&(a=n[Ur]=new Set);var l=i+"__bubble";a.has(l)||(Tb(n,i,2,!1),a.add(l))}function hf(i,n,a){var l=0;n&&(l|=4),Tb(a,i,l,n)}var ru="_reactListening"+Math.random().toString(36).slice(2);function df(i){if(!i[ru]){i[ru]=!0,ds.forEach(function(a){a!=="selectionchange"&&(wx.has(a)||hf(a,!1,i),hf(a,!0,i))});var n=i.nodeType===9?i:i.ownerDocument;n===null||n[ru]||(n[ru]=!0,hf("selectionchange",!1,n))}}function Tb(i,n,a,l){switch(iy(n)){case 2:var u=Gx;break;case 8:u=Zx;break;default:u=Tf}a=u.bind(null,n,a,i),u=void 0,!bt||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(u=!0),l?u!==void 0?i.addEventListener(n,a,{capture:!0,passive:u}):i.addEventListener(n,a,!0):u!==void 0?i.addEventListener(n,a,{passive:u}):i.addEventListener(n,a,!1)}function ff(i,n,a,l,u){var d=l;if((n&1)===0&&(n&2)===0&&l!==null)e:for(;;){if(l===null)return;var _=l.tag;if(_===3||_===4){var C=l.stateNode.containerInfo;if(C===u)break;if(_===4)for(_=l.return;_!==null;){var A=_.tag;if((A===3||A===4)&&_.stateNode.containerInfo===u)return;_=_.return}for(;C!==null;){if(_=Qi(C),_===null)return;if(A=_.tag,A===5||A===6||A===26||A===27){l=d=_;continue e}C=C.parentNode}}l=l.return}Bt(function(){var $=d,ae=J(a),fe=[];e:{var Y=a_.get(i);if(Y!==void 0){var Z=it,Le=i;switch(i){case"keypress":if(te(a)===0)break e;case"keydown":case"keyup":Z=mC;break;case"focusin":Le="focus",Z=Oh;break;case"focusout":Le="blur",Z=Oh;break;case"beforeblur":case"afterblur":Z=Oh;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Z=Og;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Z=nC;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Z=vC;break;case i_:case n_:case s_:Z=aC;break;case r_:Z=yC;break;case"scroll":case"scrollend":Z=ni;break;case"wheel":Z=wC;break;case"copy":case"cut":case"paste":Z=oC;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Z=jg;break;case"toggle":case"beforetoggle":Z=xC}var We=(n&4)!==0,kt=!We&&(i==="scroll"||i==="scrollend"),P=We?Y!==null?Y+"Capture":null:Y;We=[];for(var z=$,q;z!==null;){var ue=z;if(q=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||q===null||P===null||(ue=Vt(z,P),ue!=null&&We.push(ho(z,ue,q))),kt)break;z=z.return}0<We.length&&(Y=new Z(Y,Le,null,a,ae),fe.push({event:Y,listeners:We}))}}if((n&7)===0){e:{if(Y=i==="mouseover"||i==="pointerover",Z=i==="mouseout"||i==="pointerout",Y&&a!==M&&(Le=a.relatedTarget||a.fromElement)&&(Qi(Le)||Le[Ln]))break e;if((Z||Y)&&(Y=ae.window===ae?ae:(Y=ae.ownerDocument)?Y.defaultView||Y.parentWindow:window,Z?(Le=a.relatedTarget||a.toElement,Z=$,Le=Le?Qi(Le):null,Le!==null&&(kt=c(Le),We=Le.tag,Le!==kt||We!==5&&We!==27&&We!==6)&&(Le=null)):(Z=null,Le=$),Z!==Le)){if(We=Og,ue="onMouseLeave",P="onMouseEnter",z="mouse",(i==="pointerout"||i==="pointerover")&&(We=jg,ue="onPointerLeave",P="onPointerEnter",z="pointer"),kt=Z==null?Y:Lt(Z),q=Le==null?Y:Lt(Le),Y=new We(ue,z+"leave",Z,a,ae),Y.target=kt,Y.relatedTarget=q,ue=null,Qi(ae)===$&&(We=new We(P,z+"enter",Le,a,ae),We.target=q,We.relatedTarget=kt,ue=We),kt=ue,Z&&Le)t:{for(We=Cx,P=Z,z=Le,q=0,ue=P;ue;ue=We(ue))q++;ue=0;for(var Ue=z;Ue;Ue=We(Ue))ue++;for(;0<q-ue;)P=We(P),q--;for(;0<ue-q;)z=We(z),ue--;for(;q--;){if(P===z||z!==null&&P===z.alternate){We=P;break t}P=We(P),z=We(z)}We=null}else We=null;Z!==null&&Db(fe,Y,Z,We,!1),Le!==null&&kt!==null&&Db(fe,kt,Le,We,!0)}}e:{if(Y=$?Lt($):window,Z=Y.nodeName&&Y.nodeName.toLowerCase(),Z==="select"||Z==="input"&&Y.type==="file")var ft=qg;else if(Wg(Y))if($g)ft=BC;else{ft=AC;var je=NC}else Z=Y.nodeName,!Z||Z.toLowerCase()!=="input"||Y.type!=="checkbox"&&Y.type!=="radio"?$&&en($.elementType)&&(ft=qg):ft=LC;if(ft&&(ft=ft(i,$))){Fg(fe,ft,a,ae);break e}je&&je(i,Y,$),i==="focusout"&&$&&Y.type==="number"&&$.memoizedProps.value!=null&&Fr(Y,"number",Y.value)}switch(je=$?Lt($):window,i){case"focusin":(Wg(je)||je.contentEditable==="true")&&(za=je,Ih=$,Ul=null);break;case"focusout":Ul=Ih=za=null;break;case"mousedown":Kh=!0;break;case"contextmenu":case"mouseup":case"dragend":Kh=!1,e_(fe,a,ae);break;case"selectionchange":if(zC)break;case"keydown":case"keyup":e_(fe,a,ae)}var Ze;if(jh)e:{switch(i){case"compositionstart":var ut="onCompositionStart";break e;case"compositionend":ut="onCompositionEnd";break e;case"compositionupdate":ut="onCompositionUpdate";break e}ut=void 0}else Oa?Ig(i,a)&&(ut="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(ut="onCompositionStart");ut&&(Hg&&a.locale!=="ko"&&(Oa||ut!=="onCompositionStart"?ut==="onCompositionEnd"&&Oa&&(Ze=j()):(Yt=ae,x="value"in Yt?Yt.value:Yt.textContent,Oa=!0)),je=au($,ut),0<je.length&&(ut=new zg(ut,i,null,a,ae),fe.push({event:ut,listeners:je}),Ze?ut.data=Ze:(Ze=Kg(a),Ze!==null&&(ut.data=Ze)))),(Ze=kC?TC(i,a):DC(i,a))&&(ut=au($,"onBeforeInput"),0<ut.length&&(je=new zg("onBeforeInput","beforeinput",null,a,ae),fe.push({event:je,listeners:ut}),je.data=Ze)),bx(fe,i,$,a,ae)}kb(fe,n)})}function ho(i,n,a){return{instance:i,listener:n,currentTarget:a}}function au(i,n){for(var a=n+"Capture",l=[];i!==null;){var u=i,d=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||d===null||(u=Vt(i,a),u!=null&&l.unshift(ho(i,u,d)),u=Vt(i,n),u!=null&&l.push(ho(i,u,d))),i.tag===3)return l;i=i.return}return[]}function Cx(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function Db(i,n,a,l,u){for(var d=n._reactName,_=[];a!==null&&a!==l;){var C=a,A=C.alternate,$=C.stateNode;if(C=C.tag,A!==null&&A===l)break;C!==5&&C!==26&&C!==27||$===null||(A=$,u?($=Vt(a,d),$!=null&&_.unshift(ho(a,$,A))):u||($=Vt(a,d),$!=null&&_.push(ho(a,$,A)))),a=a.return}_.length!==0&&i.push({event:n,listeners:_})}var xx=/\r\n?/g,Ex=/\u0000|\uFFFD/g;function Rb(i){return(typeof i=="string"?i:""+i).replace(xx,`
|
|
10
|
+
`).replace(Ex,"")}function Mb(i,n){return n=Rb(n),Rb(i)===n}function Et(i,n,a,l,u,d){switch(a){case"children":typeof l=="string"?n==="body"||n==="textarea"&&l===""||Ji(i,l):(typeof l=="number"||typeof l=="bigint")&&n!=="body"&&Ji(i,""+l);break;case"className":jn(i,"class",l);break;case"tabIndex":jn(i,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":jn(i,a,l);break;case"style":Ts(i,l,d);break;case"data":if(n!=="object"){jn(i,"data",l);break}case"src":case"href":if(l===""&&(n!=="a"||a!=="href")){i.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=ps(""+l),i.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){i.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof d=="function"&&(a==="formAction"?(n!=="input"&&Et(i,n,"name",u.name,u,null),Et(i,n,"formEncType",u.formEncType,u,null),Et(i,n,"formMethod",u.formMethod,u,null),Et(i,n,"formTarget",u.formTarget,u,null)):(Et(i,n,"encType",u.encType,u,null),Et(i,n,"method",u.method,u,null),Et(i,n,"target",u.target,u,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){i.removeAttribute(a);break}l=ps(""+l),i.setAttribute(a,l);break;case"onClick":l!=null&&(i.onclick=Sn);break;case"onScroll":l!=null&<("scroll",i);break;case"onScrollEnd":l!=null&<("scrollend",i);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"multiple":i.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":i.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){i.removeAttribute("xlink:href");break}a=ps(""+l),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""+l):i.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,""):i.removeAttribute(a);break;case"capture":case"download":l===!0?i.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?i.setAttribute(a,l):i.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?i.setAttribute(a,l):i.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?i.removeAttribute(a):i.setAttribute(a,l);break;case"popover":lt("beforetoggle",i),lt("toggle",i),on(i,"popover",l);break;case"xlinkActuate":yn(i,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":yn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":yn(i,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":yn(i,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":yn(i,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":yn(i,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":yn(i,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":yn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":yn(i,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":on(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=Hn.get(a)||a,on(i,a,l))}}function pf(i,n,a,l,u,d){switch(a){case"style":Ts(i,l,d);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(r(61));if(a=l.__html,a!=null){if(u.children!=null)throw Error(r(60));i.innerHTML=a}}break;case"children":typeof l=="string"?Ji(i,l):(typeof l=="number"||typeof l=="bigint")&&Ji(i,""+l);break;case"onScroll":l!=null&<("scroll",i);break;case"onScrollEnd":l!=null&<("scrollend",i);break;case"onClick":l!=null&&(i.onclick=Sn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ui.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(u=a.endsWith("Capture"),n=a.slice(2,u?a.length-7:void 0),d=i[bi]||null,d=d!=null?d[a]:null,typeof d=="function"&&i.removeEventListener(n,d,u),typeof l=="function")){typeof d!="function"&&d!==null&&(a in i?i[a]=null:i.hasAttribute(a)&&i.removeAttribute(a)),i.addEventListener(n,l,u);break e}a in i?i[a]=l:l===!0?i.setAttribute(a,""):on(i,a,l)}}}function Fi(i,n,a){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":lt("error",i),lt("load",i);var l=!1,u=!1,d;for(d in a)if(a.hasOwnProperty(d)){var _=a[d];if(_!=null)switch(d){case"src":l=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,n));default:Et(i,n,d,_,a,null)}}u&&Et(i,n,"srcSet",a.srcSet,a,null),l&&Et(i,n,"src",a.src,a,null);return;case"input":lt("invalid",i);var C=d=_=u=null,A=null,$=null;for(l in a)if(a.hasOwnProperty(l)){var ae=a[l];if(ae!=null)switch(l){case"name":u=ae;break;case"type":_=ae;break;case"checked":A=ae;break;case"defaultChecked":$=ae;break;case"value":d=ae;break;case"defaultValue":C=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(r(137,n));break;default:Et(i,n,l,ae,a,null)}}Qs(i,d,C,A,$,_,u,!1);return;case"select":lt("invalid",i),l=_=d=null;for(u in a)if(a.hasOwnProperty(u)&&(C=a[u],C!=null))switch(u){case"value":d=C;break;case"defaultValue":_=C;break;case"multiple":l=C;default:Et(i,n,u,C,a,null)}n=d,a=_,i.multiple=!!l,n!=null?fs(i,!!l,n,!1):a!=null&&fs(i,!!l,a,!0);return;case"textarea":lt("invalid",i),d=u=l=null;for(_ in a)if(a.hasOwnProperty(_)&&(C=a[_],C!=null))switch(_){case"value":l=C;break;case"defaultValue":u=C;break;case"children":d=C;break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(r(91));break;default:Et(i,n,_,C,a,null)}Js(i,l,u,d);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":Et(i,n,A,l,a,null));return;case"dialog":lt("beforetoggle",i),lt("toggle",i),lt("cancel",i),lt("close",i);break;case"iframe":case"object":lt("load",i);break;case"video":case"audio":for(l=0;l<uo.length;l++)lt(uo[l],i);break;case"image":lt("error",i),lt("load",i);break;case"details":lt("toggle",i);break;case"embed":case"source":case"link":lt("error",i),lt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for($ in a)if(a.hasOwnProperty($)&&(l=a[$],l!=null))switch($){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,n));default:Et(i,n,$,l,a,null)}return;default:if(en(n)){for(ae in a)a.hasOwnProperty(ae)&&(l=a[ae],l!==void 0&&pf(i,n,ae,l,a,void 0));return}}for(C in a)a.hasOwnProperty(C)&&(l=a[C],l!=null&&Et(i,n,C,l,a,null))}function kx(i,n,a,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,d=null,_=null,C=null,A=null,$=null,ae=null;for(Z in a){var fe=a[Z];if(a.hasOwnProperty(Z)&&fe!=null)switch(Z){case"checked":break;case"value":break;case"defaultValue":A=fe;default:l.hasOwnProperty(Z)||Et(i,n,Z,null,l,fe)}}for(var Y in l){var Z=l[Y];if(fe=a[Y],l.hasOwnProperty(Y)&&(Z!=null||fe!=null))switch(Y){case"type":d=Z;break;case"name":u=Z;break;case"checked":$=Z;break;case"defaultChecked":ae=Z;break;case"value":_=Z;break;case"defaultValue":C=Z;break;case"children":case"dangerouslySetInnerHTML":if(Z!=null)throw Error(r(137,n));break;default:Z!==fe&&Et(i,n,Y,Z,l,fe)}}Wr(i,_,C,A,$,ae,d,u);return;case"select":Z=_=C=Y=null;for(d in a)if(A=a[d],a.hasOwnProperty(d)&&A!=null)switch(d){case"value":break;case"multiple":Z=A;default:l.hasOwnProperty(d)||Et(i,n,d,null,l,A)}for(u in l)if(d=l[u],A=a[u],l.hasOwnProperty(u)&&(d!=null||A!=null))switch(u){case"value":Y=d;break;case"defaultValue":C=d;break;case"multiple":_=d;default:d!==A&&Et(i,n,u,d,l,A)}n=C,a=_,l=Z,Y!=null?fs(i,!!a,Y,!1):!!l!=!!a&&(n!=null?fs(i,!!a,n,!0):fs(i,!!a,a?[]:"",!1));return;case"textarea":Z=Y=null;for(C in a)if(u=a[C],a.hasOwnProperty(C)&&u!=null&&!l.hasOwnProperty(C))switch(C){case"value":break;case"children":break;default:Et(i,n,C,null,l,u)}for(_ in l)if(u=l[_],d=a[_],l.hasOwnProperty(_)&&(u!=null||d!=null))switch(_){case"value":Y=u;break;case"defaultValue":Z=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(r(91));break;default:u!==d&&Et(i,n,_,u,l,d)}Aa(i,Y,Z);return;case"option":for(var Le in a)Y=a[Le],a.hasOwnProperty(Le)&&Y!=null&&!l.hasOwnProperty(Le)&&(Le==="selected"?i.selected=!1:Et(i,n,Le,null,l,Y));for(A in l)Y=l[A],Z=a[A],l.hasOwnProperty(A)&&Y!==Z&&(Y!=null||Z!=null)&&(A==="selected"?i.selected=Y&&typeof Y!="function"&&typeof Y!="symbol":Et(i,n,A,Y,l,Z));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var We in a)Y=a[We],a.hasOwnProperty(We)&&Y!=null&&!l.hasOwnProperty(We)&&Et(i,n,We,null,l,Y);for($ in l)if(Y=l[$],Z=a[$],l.hasOwnProperty($)&&Y!==Z&&(Y!=null||Z!=null))switch($){case"children":case"dangerouslySetInnerHTML":if(Y!=null)throw Error(r(137,n));break;default:Et(i,n,$,Y,l,Z)}return;default:if(en(n)){for(var kt in a)Y=a[kt],a.hasOwnProperty(kt)&&Y!==void 0&&!l.hasOwnProperty(kt)&&pf(i,n,kt,void 0,l,Y);for(ae in l)Y=l[ae],Z=a[ae],!l.hasOwnProperty(ae)||Y===Z||Y===void 0&&Z===void 0||pf(i,n,ae,Y,l,Z);return}}for(var P in a)Y=a[P],a.hasOwnProperty(P)&&Y!=null&&!l.hasOwnProperty(P)&&Et(i,n,P,null,l,Y);for(fe in l)Y=l[fe],Z=a[fe],!l.hasOwnProperty(fe)||Y===Z||Y==null&&Z==null||Et(i,n,fe,Y,l,Z)}function Nb(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Tx(){if(typeof performance.getEntriesByType=="function"){for(var i=0,n=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var u=a[l],d=u.transferSize,_=u.initiatorType,C=u.duration;if(d&&C&&Nb(_)){for(_=0,C=u.responseEnd,l+=1;l<a.length;l++){var A=a[l],$=A.startTime;if($>C)break;var ae=A.transferSize,fe=A.initiatorType;ae&&Nb(fe)&&(A=A.responseEnd,_+=ae*(A<C?1:(C-$)/(A-$)))}if(--l,n+=8*(d+_)/(u.duration/1e3),i++,10<i)break}}if(0<i)return n/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var mf=null,gf=null;function lu(i){return i.nodeType===9?i:i.ownerDocument}function Ab(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 Lb(i,n){if(i===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&n==="foreignObject"?0:i}function _f(i,n){return i==="textarea"||i==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var vf=null;function Dx(){var i=window.event;return i&&i.type==="popstate"?i===vf?!1:(vf=i,!0):(vf=null,!1)}var Bb=typeof setTimeout=="function"?setTimeout:void 0,Rx=typeof clearTimeout=="function"?clearTimeout:void 0,Ob=typeof Promise=="function"?Promise:void 0,Mx=typeof queueMicrotask=="function"?queueMicrotask:typeof Ob<"u"?function(i){return Ob.resolve(null).then(i).catch(Nx)}:Bb;function Nx(i){setTimeout(function(){throw i})}function _r(i){return i==="head"}function zb(i,n){var a=n,l=0;do{var u=a.nextSibling;if(i.removeChild(a),u&&u.nodeType===8)if(a=u.data,a==="/$"||a==="/&"){if(l===0){i.removeChild(u),cl(n);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")fo(i.ownerDocument.documentElement);else if(a==="head"){a=i.ownerDocument.head,fo(a);for(var d=a.firstChild;d;){var _=d.nextSibling,C=d.nodeName;d[Es]||C==="SCRIPT"||C==="STYLE"||C==="LINK"&&d.rel.toLowerCase()==="stylesheet"||a.removeChild(d),d=_}}else a==="body"&&fo(i.ownerDocument.body);a=u}while(a);cl(n)}function jb(i,n){var a=i;i=0;do{var l=a.nextSibling;if(a.nodeType===1?n?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(n?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(i===0)break;i--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||i++;a=l}while(a)}function bf(i){var n=i.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var a=n;switch(n=n.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":bf(a),Bn(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}i.removeChild(a)}}function Ax(i,n,a,l){for(;i.nodeType===1;){var u=a;if(i.nodeName.toLowerCase()!==n.toLowerCase()){if(!l&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(l){if(!i[Es])switch(n){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(d=i.getAttribute("rel"),d==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(d!==u.rel||i.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||i.getAttribute("title")!==(u.title==null?null:u.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(d=i.getAttribute("src"),(d!==(u.src==null?null:u.src)||i.getAttribute("type")!==(u.type==null?null:u.type)||i.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&d&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(n==="input"&&i.type==="hidden"){var d=u.name==null?null:""+u.name;if(u.type==="hidden"&&i.getAttribute("name")===d)return i}else return i;if(i=qn(i.nextSibling),i===null)break}return null}function Lx(i,n,a){if(n==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!a||(i=qn(i.nextSibling),i===null))return null;return i}function Hb(i,n){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!n||(i=qn(i.nextSibling),i===null))return null;return i}function yf(i){return i.data==="$?"||i.data==="$~"}function Sf(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function Bx(i,n){var a=i.ownerDocument;if(i.data==="$~")i._reactRetry=n;else if(i.data!=="$?"||a.readyState!=="loading")n();else{var l=function(){n(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),i._reactRetry=l}}function qn(i){for(;i!=null;i=i.nextSibling){var n=i.nodeType;if(n===1||n===3)break;if(n===8){if(n=i.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return i}var wf=null;function Pb(i){i=i.nextSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"||a==="/&"){if(n===0)return qn(i.nextSibling);n--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||n++}i=i.nextSibling}return null}function Ub(i){i=i.previousSibling;for(var n=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(n===0)return i;n--}else a!=="/$"&&a!=="/&"||n++}i=i.previousSibling}return null}function Ib(i,n,a){switch(n=lu(a),i){case"html":if(i=n.documentElement,!i)throw Error(r(452));return i;case"head":if(i=n.head,!i)throw Error(r(453));return i;case"body":if(i=n.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function fo(i){for(var n=i.attributes;n.length;)i.removeAttributeNode(n[0]);Bn(i)}var $n=new Map,Kb=new Set;function ou(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Ks=W.d;W.d={f:Ox,r:zx,D:jx,C:Hx,L:Px,m:Ux,X:Kx,S:Ix,M:Wx};function Ox(){var i=Ks.f(),n=Jc();return i||n}function zx(i){var n=On(i);n!==null&&n.tag===5&&n.type==="form"?rv(n):Ks.r(i)}var al=typeof document>"u"?null:document;function Wb(i,n,a){var l=al;if(l&&typeof n=="string"&&n){var u=Ui(n);u='link[rel="'+i+'"][href="'+u+'"]',typeof a=="string"&&(u+='[crossorigin="'+a+'"]'),Kb.has(u)||(Kb.add(u),i={rel:i,crossOrigin:a,href:n},l.querySelector(u)===null&&(n=l.createElement("link"),Fi(n,"link",i),Kt(n),l.head.appendChild(n)))}}function jx(i){Ks.D(i),Wb("dns-prefetch",i,null)}function Hx(i,n){Ks.C(i,n),Wb("preconnect",i,n)}function Px(i,n,a){Ks.L(i,n,a);var l=al;if(l&&i&&n){var u='link[rel="preload"][as="'+Ui(n)+'"]';n==="image"&&a&&a.imageSrcSet?(u+='[imagesrcset="'+Ui(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(u+='[imagesizes="'+Ui(a.imageSizes)+'"]')):u+='[href="'+Ui(i)+'"]';var d=u;switch(n){case"style":d=ll(i);break;case"script":d=ol(i)}$n.has(d)||(i=b({rel:"preload",href:n==="image"&&a&&a.imageSrcSet?void 0:i,as:n},a),$n.set(d,i),l.querySelector(u)!==null||n==="style"&&l.querySelector(po(d))||n==="script"&&l.querySelector(mo(d))||(n=l.createElement("link"),Fi(n,"link",i),Kt(n),l.head.appendChild(n)))}}function Ux(i,n){Ks.m(i,n);var a=al;if(a&&i){var l=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+Ui(l)+'"][href="'+Ui(i)+'"]',d=u;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":d=ol(i)}if(!$n.has(d)&&(i=b({rel:"modulepreload",href:i},n),$n.set(d,i),a.querySelector(u)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(mo(d)))return}l=a.createElement("link"),Fi(l,"link",i),Kt(l),a.head.appendChild(l)}}}function Ix(i,n,a){Ks.S(i,n,a);var l=al;if(l&&i){var u=bn(l).hoistableStyles,d=ll(i);n=n||"default";var _=u.get(d);if(!_){var C={loading:0,preload:null};if(_=l.querySelector(po(d)))C.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":n},a),(a=$n.get(d))&&Cf(i,a);var A=_=l.createElement("link");Kt(A),Fi(A,"link",i),A._p=new Promise(function($,ae){A.onload=$,A.onerror=ae}),A.addEventListener("load",function(){C.loading|=1}),A.addEventListener("error",function(){C.loading|=2}),C.loading|=4,cu(_,n,l)}_={type:"stylesheet",instance:_,count:1,state:C},u.set(d,_)}}}function Kx(i,n){Ks.X(i,n);var a=al;if(a&&i){var l=bn(a).hoistableScripts,u=ol(i),d=l.get(u);d||(d=a.querySelector(mo(u)),d||(i=b({src:i,async:!0},n),(n=$n.get(u))&&xf(i,n),d=a.createElement("script"),Kt(d),Fi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function Wx(i,n){Ks.M(i,n);var a=al;if(a&&i){var l=bn(a).hoistableScripts,u=ol(i),d=l.get(u);d||(d=a.querySelector(mo(u)),d||(i=b({src:i,async:!0,type:"module"},n),(n=$n.get(u))&&xf(i,n),d=a.createElement("script"),Kt(d),Fi(d,"link",i),a.head.appendChild(d)),d={type:"script",instance:d,count:1,state:null},l.set(u,d))}}function Fb(i,n,a,l){var u=(u=ke.current)?ou(u):null;if(!u)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(n=ll(a.href),a=bn(u).hoistableStyles,l=a.get(n),l||(l={type:"style",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){i=ll(a.href);var d=bn(u).hoistableStyles,_=d.get(i);if(_||(u=u.ownerDocument||u,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(i,_),(d=u.querySelector(po(i)))&&!d._p&&(_.instance=d,_.state.loading=5),$n.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},$n.set(i,a),d||Fx(u,i,a,_.state))),n&&l===null)throw Error(r(528,""));return _}if(n&&l!==null)throw Error(r(529,""));return null;case"script":return n=a.async,a=a.src,typeof a=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=ol(a),a=bn(u).hoistableScripts,l=a.get(n),l||(l={type:"script",instance:null,count:0,state:null},a.set(n,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ll(i){return'href="'+Ui(i)+'"'}function po(i){return'link[rel="stylesheet"]['+i+"]"}function qb(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function Fx(i,n,a,l){i.querySelector('link[rel="preload"][as="style"]['+n+"]")?l.loading=1:(n=i.createElement("link"),l.preload=n,n.addEventListener("load",function(){return l.loading|=1}),n.addEventListener("error",function(){return l.loading|=2}),Fi(n,"link",a),Kt(n),i.head.appendChild(n))}function ol(i){return'[src="'+Ui(i)+'"]'}function mo(i){return"script[async]"+i}function $b(i,n,a){if(n.count++,n.instance===null)switch(n.type){case"style":var l=i.querySelector('style[data-href~="'+Ui(a.href)+'"]');if(l)return n.instance=l,Kt(l),l;var u=b({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(i.ownerDocument||i).createElement("style"),Kt(l),Fi(l,"style",u),cu(l,a.precedence,i),n.instance=l;case"stylesheet":u=ll(a.href);var d=i.querySelector(po(u));if(d)return n.state.loading|=4,n.instance=d,Kt(d),d;l=qb(a),(u=$n.get(u))&&Cf(l,u),d=(i.ownerDocument||i).createElement("link"),Kt(d);var _=d;return _._p=new Promise(function(C,A){_.onload=C,_.onerror=A}),Fi(d,"link",l),n.state.loading|=4,cu(d,a.precedence,i),n.instance=d;case"script":return d=ol(a.src),(u=i.querySelector(mo(d)))?(n.instance=u,Kt(u),u):(l=a,(u=$n.get(d))&&(l=b({},a),xf(l,u)),i=i.ownerDocument||i,u=i.createElement("script"),Kt(u),Fi(u,"link",l),i.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(r(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(l=n.instance,n.state.loading|=4,cu(l,a.precedence,i));return n.instance}function cu(i,n,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=l.length?l[l.length-1]:null,d=u,_=0;_<l.length;_++){var C=l[_];if(C.dataset.precedence===n)d=C;else if(d!==u)break}d?d.parentNode.insertBefore(i,d.nextSibling):(n=a.nodeType===9?a.head:a,n.insertBefore(i,n.firstChild))}function Cf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.title==null&&(i.title=n.title)}function xf(i,n){i.crossOrigin==null&&(i.crossOrigin=n.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=n.referrerPolicy),i.integrity==null&&(i.integrity=n.integrity)}var uu=null;function Vb(i,n,a){if(uu===null){var l=new Map,u=uu=new Map;u.set(a,l)}else u=uu,l=u.get(a),l||(l=new Map,u.set(a,l));if(l.has(i))return l;for(l.set(i,null),a=a.getElementsByTagName(i),u=0;u<a.length;u++){var d=a[u];if(!(d[Es]||d[It]||i==="link"&&d.getAttribute("rel")==="stylesheet")&&d.namespaceURI!=="http://www.w3.org/2000/svg"){var _=d.getAttribute(n)||"";_=i+_;var C=l.get(_);C?C.push(d):l.set(_,[d])}}return l}function Yb(i,n,a){i=i.ownerDocument||i,i.head.insertBefore(a,n==="title"?i.querySelector("head > title"):null)}function qx(i,n,a){if(a===1||n.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;return n.rel==="stylesheet"?(i=n.disabled,typeof n.precedence=="string"&&i==null):!0;case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Xb(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function $x(i,n,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var u=ll(l.href),d=n.querySelector(po(u));if(d){n=d._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(i.count++,i=hu.bind(i),n.then(i,i)),a.state.loading|=4,a.instance=d,Kt(d);return}d=n.ownerDocument||n,l=qb(l),(u=$n.get(u))&&Cf(l,u),d=d.createElement("link"),Kt(d);var _=d;_._p=new Promise(function(C,A){_.onload=C,_.onerror=A}),Fi(d,"link",l),a.instance=d}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(a,n),(n=a.state.preload)&&(a.state.loading&3)===0&&(i.count++,a=hu.bind(i),n.addEventListener("load",a),n.addEventListener("error",a))}}var Ef=0;function Vx(i,n){return i.stylesheets&&i.count===0&&fu(i,i.stylesheets),0<i.count||0<i.imgCount?function(a){var l=setTimeout(function(){if(i.stylesheets&&fu(i,i.stylesheets),i.unsuspend){var d=i.unsuspend;i.unsuspend=null,d()}},6e4+n);0<i.imgBytes&&Ef===0&&(Ef=62500*Tx());var u=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&fu(i,i.stylesheets),i.unsuspend)){var d=i.unsuspend;i.unsuspend=null,d()}},(i.imgBytes>Ef?50:800)+n);return i.unsuspend=a,function(){i.unsuspend=null,clearTimeout(l),clearTimeout(u)}}:null}function hu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)fu(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var du=null;function fu(i,n){i.stylesheets=null,i.unsuspend!==null&&(i.count++,du=new Map,n.forEach(Yx,i),du=null,hu.call(i))}function Yx(i,n){if(!(n.state.loading&4)){var a=du.get(i);if(a)var l=a.get(null);else{a=new Map,du.set(i,a);for(var u=i.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;d<u.length;d++){var _=u[d];(_.nodeName==="LINK"||_.getAttribute("media")!=="not all")&&(a.set(_.dataset.precedence,_),l=_)}l&&a.set(null,l)}u=n.instance,_=u.getAttribute("data-precedence"),d=a.get(_)||l,d===l&&a.set(null,u),a.set(_,u),this.count++,l=hu.bind(this),u.addEventListener("load",l),u.addEventListener("error",l),d?d.parentNode.insertBefore(u,d.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(u,i.firstChild)),n.state.loading|=4}}var go={$$typeof:I,Provider:null,Consumer:null,_currentValue:D,_currentValue2:D,_threadCount:0};function Xx(i,n,a,l,u,d,_,C,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=ci(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ci(0),this.hiddenUpdates=ci(null),this.identifierPrefix=l,this.onUncaughtError=u,this.onCaughtError=d,this.onRecoverableError=_,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function Gb(i,n,a,l,u,d,_,C,A,$,ae,fe){return i=new Xx(i,n,a,_,A,$,ae,fe,C),n=1,d===!0&&(n|=24),d=Cn(3,null,null,n),i.current=d,d.stateNode=i,n=nd(),n.refCount++,i.pooledCache=n,n.refCount++,d.memoizedState={element:l,isDehydrated:a,cache:n},ld(d),i}function Zb(i){return i?(i=Pa,i):Pa}function Qb(i,n,a,l,u,d){u=Zb(u),l.context===null?l.context=u:l.pendingContext=u,l=ar(n),l.payload={element:a},d=d===void 0?null:d,d!==null&&(l.callback=d),a=lr(i,l,n),a!==null&&(fn(a,i,n),Vl(a,i,n))}function Jb(i,n){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<n?a:n}}function kf(i,n){Jb(i,n),(i=i.alternate)&&Jb(i,n)}function ey(i){if(i.tag===13||i.tag===31){var n=Vr(i,67108864);n!==null&&fn(n,i,67108864),kf(i,67108864)}}function ty(i){if(i.tag===13||i.tag===31){var n=Dn();n=_n(n);var a=Vr(i,n);a!==null&&fn(a,i,n),kf(i,n)}}var pu=!0;function Gx(i,n,a,l){var u=B.T;B.T=null;var d=W.p;try{W.p=2,Tf(i,n,a,l)}finally{W.p=d,B.T=u}}function Zx(i,n,a,l){var u=B.T;B.T=null;var d=W.p;try{W.p=8,Tf(i,n,a,l)}finally{W.p=d,B.T=u}}function Tf(i,n,a,l){if(pu){var u=Df(l);if(u===null)ff(i,n,l,mu,a),ny(i,l);else if(Jx(u,i,n,a,l))l.stopPropagation();else if(ny(i,l),n&4&&-1<Qx.indexOf(i)){for(;u!==null;){var d=On(u);if(d!==null)switch(d.tag){case 3:if(d=d.stateNode,d.current.memoizedState.isDehydrated){var _=vt(d.pendingLanes);if(_!==0){var C=d;for(C.pendingLanes|=2,C.entangledLanes|=2;_;){var A=1<<31-Dt(_);C.entanglements[1]|=A,_&=~A}vs(d),(mt&6)===0&&(Zc=st()+500,co(0))}}break;case 31:case 13:C=Vr(d,2),C!==null&&fn(C,d,2),Jc(),kf(d,2)}if(d=Df(l),d===null&&ff(i,n,l,mu,a),d===u)break;u=d}u!==null&&l.stopPropagation()}else ff(i,n,l,null,a)}}function Df(i){return i=J(i),Rf(i)}var mu=null;function Rf(i){if(mu=null,i=Qi(i),i!==null){var n=c(i);if(n===null)i=null;else{var a=n.tag;if(a===13){if(i=h(n),i!==null)return i;i=null}else if(a===31){if(i=f(n),i!==null)return i;i=null}else if(a===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;i=null}else n!==i&&(i=null)}}return mu=i,null}function iy(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(ei()){case an:return 2;case ki:return 8;case ti:case Ti:return 32;case Jn:return 268435456;default:return 32}default:return 32}}var Mf=!1,vr=null,br=null,yr=null,_o=new Map,vo=new Map,Sr=[],Qx="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 ny(i,n){switch(i){case"focusin":case"focusout":vr=null;break;case"dragenter":case"dragleave":br=null;break;case"mouseover":case"mouseout":yr=null;break;case"pointerover":case"pointerout":_o.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":vo.delete(n.pointerId)}}function bo(i,n,a,l,u,d){return i===null||i.nativeEvent!==d?(i={blockedOn:n,domEventName:a,eventSystemFlags:l,nativeEvent:d,targetContainers:[u]},n!==null&&(n=On(n),n!==null&&ey(n)),i):(i.eventSystemFlags|=l,n=i.targetContainers,u!==null&&n.indexOf(u)===-1&&n.push(u),i)}function Jx(i,n,a,l,u){switch(n){case"focusin":return vr=bo(vr,i,n,a,l,u),!0;case"dragenter":return br=bo(br,i,n,a,l,u),!0;case"mouseover":return yr=bo(yr,i,n,a,l,u),!0;case"pointerover":var d=u.pointerId;return _o.set(d,bo(_o.get(d)||null,i,n,a,l,u)),!0;case"gotpointercapture":return d=u.pointerId,vo.set(d,bo(vo.get(d)||null,i,n,a,l,u)),!0}return!1}function sy(i){var n=Qi(i.target);if(n!==null){var a=c(n);if(a!==null){if(n=a.tag,n===13){if(n=h(a),n!==null){i.blockedOn=n,vn(i.priority,function(){ty(a)});return}}else if(n===31){if(n=f(a),n!==null){i.blockedOn=n,vn(i.priority,function(){ty(a)});return}}else if(n===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function gu(i){if(i.blockedOn!==null)return!1;for(var n=i.targetContainers;0<n.length;){var a=Df(i.nativeEvent);if(a===null){a=i.nativeEvent;var l=new a.constructor(a.type,a);M=l,a.target.dispatchEvent(l),M=null}else return n=On(a),n!==null&&ey(n),i.blockedOn=a,!1;n.shift()}return!0}function ry(i,n,a){gu(i)&&a.delete(n)}function eE(){Mf=!1,vr!==null&&gu(vr)&&(vr=null),br!==null&&gu(br)&&(br=null),yr!==null&&gu(yr)&&(yr=null),_o.forEach(ry),vo.forEach(ry)}function _u(i,n){i.blockedOn===n&&(i.blockedOn=null,Mf||(Mf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,eE)))}var vu=null;function ay(i){vu!==i&&(vu=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){vu===i&&(vu=null);for(var n=0;n<i.length;n+=3){var a=i[n],l=i[n+1],u=i[n+2];if(typeof l!="function"){if(Rf(l||a)===null)continue;break}var d=On(a);d!==null&&(i.splice(n,3),n-=3,Td(d,{pending:!0,data:u,method:a.method,action:l},l,u))}}))}function cl(i){function n(A){return _u(A,i)}vr!==null&&_u(vr,i),br!==null&&_u(br,i),yr!==null&&_u(yr,i),_o.forEach(n),vo.forEach(n);for(var a=0;a<Sr.length;a++){var l=Sr[a];l.blockedOn===i&&(l.blockedOn=null)}for(;0<Sr.length&&(a=Sr[0],a.blockedOn===null);)sy(a),a.blockedOn===null&&Sr.shift();if(a=(i.ownerDocument||i).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var u=a[l],d=a[l+1],_=u[bi]||null;if(typeof d=="function")_||ay(a);else if(_){var C=null;if(d&&d.hasAttribute("formAction")){if(u=d,_=d[bi]||null)C=_.formAction;else if(Rf(u)!==null)continue}else C=_.action;typeof C=="function"?a[l+1]=C:(a.splice(l,3),l-=3),ay(a)}}}function ly(){function i(d){d.canIntercept&&d.info==="react-transition"&&d.intercept({handler:function(){return new Promise(function(_){return u=_})},focusReset:"manual",scroll:"manual"})}function n(){u!==null&&(u(),u=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var d=navigation.currentEntry;d&&d.url!=null&&navigation.navigate(d.url,{state:d.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,u=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),u!==null&&(u(),u=null)}}}function Nf(i){this._internalRoot=i}bu.prototype.render=Nf.prototype.render=function(i){var n=this._internalRoot;if(n===null)throw Error(r(409));var a=n.current,l=Dn();Qb(a,l,i,n,null,null)},bu.prototype.unmount=Nf.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var n=i.containerInfo;Qb(i.current,2,null,i,null,null),Jc(),n[Ln]=null}};function bu(i){this._internalRoot=i}bu.prototype.unstable_scheduleHydration=function(i){if(i){var n=Zi();i={blockedOn:null,target:i,priority:n};for(var a=0;a<Sr.length&&n!==0&&n<Sr[a].priority;a++);Sr.splice(a,0,i),a===0&&sy(i)}};var oy=t.version;if(oy!=="19.2.6")throw Error(r(527,oy,"19.2.6"));W.findDOMNode=function(i){var n=i._reactInternals;if(n===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=p(n),i=i!==null?y(i):null,i=i===null?null:i.stateNode,i};var tE={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var yu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yu.isDisabled&&yu.supportsFiber)try{ot=yu.inject(tE),wt=yu}catch{}}return So.createRoot=function(i,n){if(!o(i))throw Error(r(299));var a=!1,l="",u=mv,d=gv,_=_v;return n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onUncaughtError!==void 0&&(u=n.onUncaughtError),n.onCaughtError!==void 0&&(d=n.onCaughtError),n.onRecoverableError!==void 0&&(_=n.onRecoverableError)),n=Gb(i,1,!1,null,null,a,l,null,u,d,_,ly),i[Ln]=n.current,df(i),new Nf(n)},So.hydrateRoot=function(i,n,a){if(!o(i))throw Error(r(299));var l=!1,u="",d=mv,_=gv,C=_v,A=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(d=a.onUncaughtError),a.onCaughtError!==void 0&&(_=a.onCaughtError),a.onRecoverableError!==void 0&&(C=a.onRecoverableError),a.formState!==void 0&&(A=a.formState)),n=Gb(i,1,!0,n,a??null,l,u,A,d,_,C,ly),n.context=Zb(null),a=n.current,l=Dn(),l=_n(l),u=ar(l),u.callback=null,lr(a,u,l),a=l,n.current.lanes=a,_i(n,a),vs(n),i[Ln]=n.current,df(i),new bu(n)},So.version="19.2.6",So}var vy;function hE(){if(vy)return Bf.exports;vy=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(),Bf.exports=uE(),Bf.exports}var dE=hE();class cs extends Error{constructor(t,s){super(s),this.status=t,this.name="ApiError"}status}function ph(e=fetch){return{getSession:(t={})=>Ne(e,`/api/auth/session${Wo(t)}`),setupPassword:t=>Ne(e,"/api/auth/password",nt("POST",t)),login:t=>Ne(e,"/api/auth/login",nt("POST",t)),reauth:t=>Ne(e,"/api/auth/reauth",nt("POST",t)),logout:()=>Ne(e,"/api/auth/logout",{method:"POST",credentials:"same-origin"}),sendClientDiagnostics:t=>Ne(e,"/api/client-diagnostics",nt("POST",t)),setupTotp:()=>Ne(e,"/api/auth/totp/setup",{method:"POST",credentials:"same-origin"}),activateTotp:t=>Ne(e,"/api/auth/totp/activate",nt("POST",t)),disableTotp:()=>Ne(e,"/api/auth/totp",{method:"DELETE",credentials:"same-origin"}),listDevices:()=>Ne(e,"/api/auth/devices"),revokeDevice:async t=>{await fl(e,`/api/auth/devices/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listNetworks:()=>Ne(e,"/api/auth/networks"),addNetwork:t=>Ne(e,"/api/auth/networks",nt("POST",t)),removeNetwork:async t=>{await fl(e,`/api/auth/networks/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},listAgents:()=>Ne(e,"/api/agents"),getDistributedCallSettings:()=>Ne(e,"/api/distcalls/settings"),updateDistributedCallSettings:t=>Ne(e,"/api/distcalls/settings",nt("PUT",t)),addAgent:t=>Ne(e,"/api/agents",nt("POST",t)),reorderAgents:t=>Ne(e,"/api/agents/order",nt("PUT",{serverIds:t})),renameAgent:(t,s)=>Ne(e,`/api/agents/${encodeURIComponent(t)}`,nt("PATCH",{name:s})),getMainInfo:()=>Ne(e,"/api/main"),renameMain:t=>Ne(e,"/api/main",nt("PATCH",{name:t})),removeAgent:async t=>{await fl(e,`/api/agents/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},uninstallAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/uninstall`,{method:"POST",credentials:"same-origin"}),pingAgent:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/ping`),getMainStats:()=>Ne(e,"/api/stats"),getAgentStats:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/stats`),getVersion:()=>Ne(e,"/api/version"),checkUpdate:()=>Ne(e,"/api/update/check",{method:"POST",credentials:"same-origin"}),runUpdate:()=>Ne(e,"/api/update",{method:"POST",credentials:"same-origin"}),getAgentVersion:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/version`),checkAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update/check`,{method:"POST",credentials:"same-origin"}),runAgentUpdate:t=>Ne(e,`/api/agents/${encodeURIComponent(t)}/update`,{method:"POST",credentials:"same-origin"}),listTerminals:()=>Ne(e,"/api/terminals"),getTerminalLayout:()=>Ne(e,"/api/terminal-layout"),saveTerminalLayout:t=>Ne(e,"/api/terminal-layout",nt("PUT",t)),createFileRoot:t=>Ne(e,"/api/files/root",nt("POST",t)),listFiles:t=>Ne(e,"/api/files/list",nt("POST",t)),readFile:t=>Ne(e,"/api/files/read",nt("POST",t)),writeFile:t=>Ne(e,"/api/files/write",nt("POST",t)),createFileEntry:t=>Ne(e,"/api/files/create",nt("POST",t)),moveFileEntry:t=>Ne(e,"/api/files/move",nt("POST",t)),previewDeleteFileEntry:t=>Ne(e,"/api/files/delete-preview",nt("POST",t)),deleteFileEntry:t=>Ne(e,"/api/files/delete",nt("POST",t)),openFileInTerminal:t=>Ne(e,"/api/files/open",nt("POST",t)),previewFile:t=>y0(e,"/api/files/preview",nt("POST",t)),createTerminal:(t={})=>Ne(e,"/api/terminals",nt("POST",t)),closeTerminal:async t=>{await fl(e,`/api/terminals/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})},renameTerminal:(t,s)=>Ne(e,`/api/terminals/${encodeURIComponent(t)}`,nt("PATCH",{title:s})),getTerminalHistory:(t,s={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/history${Wo(s)}`),getTerminalTranscriptHistory:(t,s={})=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-history${Wo(s)}`),getTerminalTranscriptSource:t=>Ne(e,`/api/terminals/${encodeURIComponent(t)}/transcript-source`),listNotificationAssets:()=>Ne(e,"/api/notification-assets"),uploadNotificationAsset:t=>{const s=new FormData;return s.append("asset",t),Ne(e,"/api/notification-assets",{method:"POST",credentials:"same-origin",body:s})},updateNotificationAssetSelection:t=>Ne(e,"/api/notification-assets/selection",nt("PUT",t)),deleteNotificationAsset:async t=>{await fl(e,`/api/notification-assets/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"})}}}function Go(e,t=fetch){const s=r=>e?`/api/agents/${encodeURIComponent(e)}/${r}`:`/api/${r}`;return{isAgent:e!==null,listTerminals:()=>Ne(t,s("terminals")),createTerminal:(r={})=>Ne(t,s("terminals"),nt("POST",r)),closeTerminal:async r=>{await fl(t,s(`terminals/${encodeURIComponent(r)}`),{method:"DELETE",credentials:"same-origin"})},renameTerminal:(r,o)=>Ne(t,s(`terminals/${encodeURIComponent(r)}`),nt("PATCH",{title:o})),getTerminalHistory:(r,o={})=>Ne(t,`${s(`terminals/${encodeURIComponent(r)}/history`)}${Wo(o)}`),getTerminalTranscriptHistory:(r,o={})=>Ne(t,`${s(`terminals/${encodeURIComponent(r)}/transcript-history`)}${Wo(o)}`),getTerminalTranscriptSource:r=>Ne(t,s(`terminals/${encodeURIComponent(r)}/transcript-source`)),getTerminalLayout:()=>Ne(t,s("terminal-layout")),saveTerminalLayout:r=>Ne(t,s("terminal-layout"),nt("PUT",r)),createFileRoot:r=>Ne(t,s("files/root"),nt("POST",r)),listFiles:r=>Ne(t,s("files/list"),nt("POST",r)),readFile:r=>Ne(t,s("files/read"),nt("POST",r)),writeFile:r=>Ne(t,s("files/write"),nt("POST",r)),createFileEntry:r=>Ne(t,s("files/create"),nt("POST",r)),moveFileEntry:r=>Ne(t,s("files/move"),nt("POST",r)),previewDeleteFileEntry:r=>Ne(t,s("files/delete-preview"),nt("POST",r)),deleteFileEntry:r=>Ne(t,s("files/delete"),nt("POST",r)),openFileInTerminal:r=>Ne(t,s("files/open"),nt("POST",r)),previewFile:r=>y0(t,s("files/preview"),nt("POST",r)),createWebSocketUrl:(r,o=window.location.href)=>fE(s(`terminals/${encodeURIComponent(r)}/ws`),o)}}function fE(e,t){const s=new URL(t);return s.protocol=s.protocol==="https:"?"wss:":"ws:",s.pathname=e,s.search="",s.hash="",s.toString()}function nt(e,t){return{method:e,headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(t)}}function Wo(e){const t=new URLSearchParams;e.beforeLine!==void 0&&t.set("beforeLine",String(e.beforeLine)),e.cursor!==void 0&&t.set("cursor",e.cursor),e.limit!==void 0&&t.set("limit",String(e.limit)),e.maxLines!==void 0&&t.set("maxLines",String(e.maxLines)),e.includeTools!==void 0&&t.set("includeTools",e.includeTools?"true":"false"),e.invalidationSource!==void 0&&t.set("invalidationSource",e.invalidationSource);const s=t.toString();return s?`?${s}`:""}async function Ne(e,t,s){const r=await e(t,s??{credentials:"same-origin"});await Im(r);try{return await r.json()}catch{throw new cs(r.status,"invalid_json_response")}}async function fl(e,t,s){const r=await e(t,s);await Im(r)}async function y0(e,t,s){const r=await e(t,s);return await Im(r),r.blob()}async function Im(e){if(e.ok)return;let t=e.statusText||`HTTP ${e.status}`;try{const s=await e.json(),r=typeof s.error=="string"?s.error:s.message;typeof r=="string"&&r.trim()&&(t=r)}catch{}throw new cs(e.status,t)}const Km="nterminal.theme.id",S0="nterminal.theme.accent",mp="nterminal:theme",Vu=[{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",...by({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",...by({foreground:"#25211d",foregroundMuted:"#62584e",line:"#e2ddd4",red:"#a8323d",green:"#26744d",yellow:"#875600",blue:"#176a94",magenta:"#8b4b80",cyan:"#276f68"})}}],yl="midnight";function mh(e){return Vu.some(t=>t.id===e)?e:yl}function Wm(e){return Vu.find(t=>t.id===e)??Vu[0]}function Or(){if(typeof window>"u")return yl;try{const e=window.localStorage.getItem(Km);return e?mh(e):vE(window.localStorage.getItem(S0))}catch{return yl}}function pE(e){const t=mh(e);if(typeof window<"u"){try{window.localStorage.setItem(Km,t)}catch{}Fm(t),window.dispatchEvent(new CustomEvent(mp,{detail:t}))}return t}function Fm(e=Or()){if(typeof document>"u")return;const t=Wm(mh(e)),s=document.documentElement;s.dataset.ntTheme=t.id,s.style.setProperty("color-scheme",t.mode),Qe(s,"--nt-bg",t.tokens.bg),Qe(s,"--nt-bg-2",t.tokens.bg2),Qe(s,"--nt-bg-sidebar",t.tokens.bgSidebar),Qe(s,"--nt-line",t.tokens.line),Qe(s,"--nt-line-2",t.tokens.line2),Qe(s,"--nt-fg",t.tokens.fg),Qe(s,"--nt-fg-2",t.tokens.fg2),Qe(s,"--nt-fg-3",t.tokens.fg3),Qe(s,"--nt-fg-4",t.tokens.fg4),Qe(s,"--nt-accent",t.tokens.accent),Qe(s,"--nt-accent-soft",t.tokens.accentSoft),Qe(s,"--nt-accent-glow",t.tokens.accentGlow),Qe(s,"--nt-on-accent",t.tokens.onAccent),Qe(s,"--nt-ok",t.tokens.ok),Qe(s,"--nt-danger",t.tokens.danger),Qe(s,"--nt-on-danger",t.tokens.onDanger),Qe(s,"--nt-danger-soft",t.tokens.dangerSoft),Qe(s,"--nt-danger-line",t.tokens.dangerLine),Qe(s,"--nt-warning",t.tokens.warning),Qe(s,"--nt-warn",t.tokens.warning),Qe(s,"--nt-warning-soft",t.tokens.warningSoft),Qe(s,"--nt-warning-glow",t.tokens.warningGlow),Qe(s,"--nt-scrim",t.tokens.scrim),Qe(s,"--nt-scrim-soft",t.tokens.scrimSoft),Qe(s,"--nt-shadow",t.tokens.shadow),Qe(s,"--nt-shadow-strong",t.tokens.shadowStrong),Qe(s,"--nt-floating-bg",t.tokens.floatingBg),Qe(s,"--nt-floating-bg-strong",t.tokens.floatingBgStrong),Qe(s,"--nt-floating-bg-hover",t.tokens.floatingBgHover),Qe(s,"--nt-subtle-fill",t.tokens.subtleFill),Qe(s,"--nt-hover-fill",t.tokens.hoverFill),Qe(s,"--nt-scrollbar-thumb",t.tokens.scrollbarThumb),Qe(s,"--nt-scrollbar-thumb-hover",t.tokens.scrollbarThumbHover),Qe(s,"--nt-transcript-user",t.tokens.transcriptUser),Qe(s,"--nt-transcript-assistant",t.tokens.transcriptAssistant),Qe(s,"--nt-transcript-tool",t.tokens.transcriptTool),Qe(s,"--nt-transcript-command",t.tokens.transcriptCommand),Qe(s,"--nt-transcript-code",t.tokens.transcriptCode),Qe(s,"--nt-transcript-search",t.tokens.transcriptSearch),Qe(s,"--nt-transcript-on-search",t.tokens.transcriptOnSearch),Qe(s,"--nt-qr-bg",t.tokens.qrBg)}function mE(e=Or()){return Wm(mh(e)).xterm}function qm(e){if(typeof window>"u")return()=>{};const t=s=>{(s.key===Km||s.key===S0)&&(Fm(Or()),e())};return window.addEventListener(mp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(mp,e),window.removeEventListener("storage",t)}}function Qe(e,t,s){e.style.setProperty(t,s)}function by(e){const t=gE(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 gE(e){const t=[];for(let s=16;s<=e;s+=1)t.push(_E(s));return t}function _E(e){if(e>=16&&e<=231){const t=e-16,s=[0,95,135,175,215,255],r=s[Math.floor(t/36)%6],o=s[Math.floor(t/6)%6],c=s[t%6];return yy(r,o,c)}if(e>=232&&e<=255){const t=8+(e-232)*10;return yy(t,t,t)}return"#000000"}function yy(e,t,s){return`#${Hf(e)}${Hf(t)}${Hf(s)}`}function Hf(e){return e.toString(16).padStart(2,"0")}function vE(e){return e==="signal-red"?"signal-red":yl}function w0(){const e=v.useSyncExternalStore(qm,Or,()=>yl);return Wm(e).mode==="light"?"-light":""}function C0({size:e=22}){const t=w0();return m.jsx("img",{className:"nterminal-mark",src:`/brand/nterminal-mark${t}.svg`,width:e,height:e,alt:"","aria-hidden":"true"})}function x0({height:e=18}){const t=w0(),s=Math.round(243/34*e);return m.jsx("img",{className:"nterminal-wordmark",src:`/brand/nterminal-wordmark${t}.svg`,width:s,height:e,alt:"NTerminal"})}var Lo=b0();const gh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function kl(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function $m(e){return"nodeType"in e}function gn(e){var t,s;return e?kl(e)?e:$m(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function Vm(e){const{Document:t}=gn(e);return e instanceof t}function oc(e){return kl(e)?!1:e instanceof gn(e).HTMLElement}function E0(e){return e instanceof gn(e).SVGElement}function Tl(e){return e?kl(e)?e.document:$m(e)?Vm(e)?e:oc(e)||E0(e)?e.ownerDocument:document:document:document}const zr=gh?v.useLayoutEffect:v.useEffect;function Ym(e){const t=v.useRef(e);return zr(()=>{t.current=e}),v.useCallback(function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function bE(){const e=v.useRef(null),t=v.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),s=v.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function Zo(e,t){t===void 0&&(t=[e]);const s=v.useRef(e);return zr(()=>{s.current!==e&&(s.current=e)},t),s}function cc(e,t){const s=v.useRef();return v.useMemo(()=>{const r=e(s.current);return s.current=r,r},[...t])}function Yu(e){const t=Ym(e),s=v.useRef(null),r=v.useCallback(o=>{o!==s.current&&t?.(o,s.current),s.current=o},[]);return[s,r]}function gp(e){const t=v.useRef();return v.useEffect(()=>{t.current=e},[e]),t.current}let Pf={};function _h(e,t){return v.useMemo(()=>{if(t)return t;const s=Pf[e]==null?0:Pf[e]+1;return Pf[e]=s,e+"-"+s},[e,t])}function k0(e){return function(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];return r.reduce((c,h)=>{const f=Object.entries(h);for(const[g,p]of f){const y=c[g];y!=null&&(c[g]=y+e*p)}return c},{...t})}}const vl=k0(1),Xu=k0(-1);function yE(e){return"clientX"in e&&"clientY"in e}function T0(e){if(!e)return!1;const{KeyboardEvent:t}=gn(e.target);return t&&e instanceof t}function SE(e){if(!e)return!1;const{TouchEvent:t}=gn(e.target);return t&&e instanceof t}function _p(e){if(SE(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return yE(e)?{x:e.clientX,y:e.clientY}:null}const vp=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[vp.Translate.toString(e),vp.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:r}=e;return t+" "+s+"ms "+r}}}),Sy="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function wE(e){return e.matches(Sy)?e:e.querySelector(Sy)}const CE={display:"none"};function xE(e){let{id:t,value:s}=e;return xi.createElement("div",{id:t,style:CE},s)}function EE(e){let{id:t,announcement:s,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return xi.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},s)}function kE(){const[e,t]=v.useState("");return{announce:v.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const D0=v.createContext(null);function TE(e){const t=v.useContext(D0);v.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function DE(){const[e]=v.useState(()=>new Set),t=v.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[v.useCallback(r=>{let{type:o,event:c}=r;e.forEach(h=>{var f;return(f=h[o])==null?void 0:f.call(h,c)})},[e]),t]}const RE={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
|
+
`},ME={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was moved over droppable area "+s.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was dropped over droppable area "+s.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function NE(e){let{announcements:t=ME,container:s,hiddenTextDescribedById:r,screenReaderInstructions:o=RE}=e;const{announce:c,announcement:h}=kE(),f=_h("DndLiveRegion"),[g,p]=v.useState(!1);if(v.useEffect(()=>{p(!0)},[]),TE(v.useMemo(()=>({onDragStart(b){let{active:w}=b;c(t.onDragStart({active:w}))},onDragMove(b){let{active:w,over:S}=b;t.onDragMove&&c(t.onDragMove({active:w,over:S}))},onDragOver(b){let{active:w,over:S}=b;c(t.onDragOver({active:w,over:S}))},onDragEnd(b){let{active:w,over:S}=b;c(t.onDragEnd({active:w,over:S}))},onDragCancel(b){let{active:w,over:S}=b;c(t.onDragCancel({active:w,over:S}))}}),[c,t])),!g)return null;const y=xi.createElement(xi.Fragment,null,xi.createElement(xE,{id:r,value:o.draggable}),xi.createElement(EE,{id:f,announcement:h}));return s?Lo.createPortal(y,s):y}var Ci;(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"})(Ci||(Ci={}));function Gu(){}function wy(e,t){return v.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function AE(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return v.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const us=Object.freeze({x:0,y:0});function LE(e,t){let{data:{value:s}}=e,{data:{value:r}}=t;return r-s}function BE(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function OE(e,t){const s=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),h=o-r,f=c-s;if(r<o&&s<c){const g=t.width*t.height,p=e.width*e.height,y=h*f,b=y/(g+p-y);return Number(b.toFixed(4))}return 0}const zE=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:r}=e;const o=[];for(const c of r){const{id:h}=c,f=s.get(h);if(f){const g=OE(f,t);g>0&&o.push({id:h,data:{droppableContainer:c,value:g}})}}return o.sort(LE)};function jE(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function R0(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:us}function HE(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),c=1;c<r;c++)o[c-1]=arguments[c];return o.reduce((h,f)=>({...h,top:h.top+e*f.y,bottom:h.bottom+e*f.y,left:h.left+e*f.x,right:h.right+e*f.x}),{...s})}}const PE=HE(1);function UE(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 IE(e,t,s){const r=UE(t);if(!r)return e;const{scaleX:o,scaleY:c,x:h,y:f}=r,g=e.left-h-(1-o)*parseFloat(s),p=e.top-f-(1-c)*parseFloat(s.slice(s.indexOf(" ")+1)),y=o?e.width/o:e.width,b=c?e.height/c:e.height;return{width:y,height:b,top:p,right:g+y,bottom:p+b,left:g}}const KE={ignoreTransform:!1};function uc(e,t){t===void 0&&(t=KE);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:p,transformOrigin:y}=gn(e).getComputedStyle(e);p&&(s=IE(s,p,y))}const{top:r,left:o,width:c,height:h,bottom:f,right:g}=s;return{top:r,left:o,width:c,height:h,bottom:f,right:g}}function Cy(e){return uc(e,{ignoreTransform:!0})}function WE(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function FE(e,t){return t===void 0&&(t=gn(e).getComputedStyle(e)),t.position==="fixed"}function qE(e,t){t===void 0&&(t=gn(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?s.test(c):!1})}function Xm(e,t){const s=[];function r(o){if(t!=null&&s.length>=t||!o)return s;if(Vm(o)&&o.scrollingElement!=null&&!s.includes(o.scrollingElement))return s.push(o.scrollingElement),s;if(!oc(o)||E0(o)||s.includes(o))return s;const c=gn(e).getComputedStyle(o);return o!==e&&qE(o,c)&&s.push(o),FE(o,c)?s:r(o.parentNode)}return e?r(e):s}function M0(e){const[t]=Xm(e,1);return t??null}function Uf(e){return!gh||!e?null:kl(e)?e:$m(e)?Vm(e)||e===Tl(e).scrollingElement?window:oc(e)?e:null:null}function N0(e){return kl(e)?e.scrollX:e.scrollLeft}function A0(e){return kl(e)?e.scrollY:e.scrollTop}function bp(e){return{x:N0(e),y:A0(e)}}var Li;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Li||(Li={}));function L0(e){return!gh||!e?!1:e===document.scrollingElement}function B0(e){const t={x:0,y:0},s=L0(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,h=e.scrollTop>=r.y,f=e.scrollLeft>=r.x;return{isTop:o,isLeft:c,isBottom:h,isRight:f,maxScroll:r,minScroll:t}}const $E={x:.2,y:.2};function VE(e,t,s,r,o){let{top:c,left:h,right:f,bottom:g}=s;r===void 0&&(r=10),o===void 0&&(o=$E);const{isTop:p,isBottom:y,isLeft:b,isRight:w}=B0(e),S={x:0,y:0},E={x:0,y:0},T={height:t.height*o.y,width:t.width*o.x};return!p&&c<=t.top+T.height?(S.y=Li.Backward,E.y=r*Math.abs((t.top+T.height-c)/T.height)):!y&&g>=t.bottom-T.height&&(S.y=Li.Forward,E.y=r*Math.abs((t.bottom-T.height-g)/T.height)),!w&&f>=t.right-T.width?(S.x=Li.Forward,E.x=r*Math.abs((t.right-T.width-f)/T.width)):!b&&h<=t.left+T.width&&(S.x=Li.Backward,E.x=r*Math.abs((t.left+T.width-h)/T.width)),{direction:S,speed:E}}function YE(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:h}=window;return{top:0,left:0,right:c,bottom:h,width:c,height:h}}const{top:t,left:s,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:s,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function O0(e){return e.reduce((t,s)=>vl(t,bp(s)),us)}function XE(e){return e.reduce((t,s)=>t+N0(s),0)}function GE(e){return e.reduce((t,s)=>t+A0(s),0)}function ZE(e,t){if(t===void 0&&(t=uc),!e)return;const{top:s,left:r,bottom:o,right:c}=t(e);M0(e)&&(o<=0||c<=0||s>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const QE=[["x",["left","right"],XE],["y",["top","bottom"],GE]];class Gm{constructor(t,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Xm(s),o=O0(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,h,f]of QE)for(const g of h)Object.defineProperty(this,g,{get:()=>{const p=f(r),y=o[c]-p;return this.rect[g]+y},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Fo{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...s)})},this.target=t}add(t,s,r){var o;(o=this.target)==null||o.addEventListener(t,s,r),this.listeners.push([t,s,r])}}function JE(e){const{EventTarget:t}=gn(e);return e instanceof t?e:Tl(e)}function If(e,t){const s=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(s**2+r**2)>t:"x"in t&&"y"in t?s>t.x&&r>t.y:"x"in t?s>t.x:"y"in t?r>t.y:!1}var Xn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Xn||(Xn={}));function xy(e){e.preventDefault()}function ek(e){e.stopPropagation()}var At;(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"})(At||(At={}));const z0={start:[At.Space,At.Enter],cancel:[At.Esc],end:[At.Space,At.Enter,At.Tab]},tk=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case At.Right:return{...s,x:s.x+25};case At.Left:return{...s,x:s.x-25};case At.Down:return{...s,y:s.y+25};case At.Up:return{...s,y:s.y-25}}};class j0{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:s}}=t;this.props=t,this.listeners=new Fo(Tl(s)),this.windowListeners=new Fo(gn(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Xn.Resize,this.handleCancel),this.windowListeners.add(Xn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Xn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,r=t.node.current;r&&ZE(r),s(us)}handleKeyDown(t){if(T0(t)){const{active:s,context:r,options:o}=this.props,{keyboardCodes:c=z0,coordinateGetter:h=tk,scrollBehavior:f="smooth"}=o,{code:g}=t;if(c.end.includes(g)){this.handleEnd(t);return}if(c.cancel.includes(g)){this.handleCancel(t);return}const{collisionRect:p}=r.current,y=p?{x:p.left,y:p.top}:us;this.referenceCoordinates||(this.referenceCoordinates=y);const b=h(t,{active:s,context:r.current,currentCoordinates:y});if(b){const w=Xu(b,y),S={x:0,y:0},{scrollableAncestors:E}=r.current;for(const T of E){const O=t.code,{isTop:L,isRight:N,isLeft:I,isBottom:U,maxScroll:Q,minScroll:ie}=B0(T),le=YE(T),ce={x:Math.min(O===At.Right?le.right-le.width/2:le.right,Math.max(O===At.Right?le.left:le.left+le.width/2,b.x)),y:Math.min(O===At.Down?le.bottom-le.height/2:le.bottom,Math.max(O===At.Down?le.top:le.top+le.height/2,b.y))},ve=O===At.Right&&!N||O===At.Left&&!I,we=O===At.Down&&!U||O===At.Up&&!L;if(ve&&ce.x!==b.x){const ne=T.scrollLeft+w.x,se=O===At.Right&&ne<=Q.x||O===At.Left&&ne>=ie.x;if(se&&!w.y){T.scrollTo({left:ne,behavior:f});return}se?S.x=T.scrollLeft-ne:S.x=O===At.Right?T.scrollLeft-Q.x:T.scrollLeft-ie.x,S.x&&T.scrollBy({left:-S.x,behavior:f});break}else if(we&&ce.y!==b.y){const ne=T.scrollTop+w.y,se=O===At.Down&&ne<=Q.y||O===At.Up&&ne>=ie.y;if(se&&!w.x){T.scrollTo({top:ne,behavior:f});return}se?S.y=T.scrollTop-ne:S.y=O===At.Down?T.scrollTop-Q.y:T.scrollTop-ie.y,S.y&&T.scrollBy({top:-S.y,behavior:f});break}}this.handleMove(t,vl(Xu(b,this.referenceCoordinates),S))}}}handleMove(t,s){const{onMove:r}=this.props;t.preventDefault(),r(s)}handleEnd(t){const{onEnd:s}=this.props;t.preventDefault(),this.detach(),s()}handleCancel(t){const{onCancel:s}=this.props;t.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}j0.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:r=z0,onActivation:o}=t,{active:c}=s;const{code:h}=e.nativeEvent;if(r.start.includes(h)){const f=c.activatorNode.current;return f&&e.target!==f?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Ey(e){return!!(e&&"distance"in e)}function ky(e){return!!(e&&"delay"in e)}class Zm{constructor(t,s,r){var o;r===void 0&&(r=JE(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=s;const{event:c}=t,{target:h}=c;this.props=t,this.events=s,this.document=Tl(h),this.documentListeners=new Fo(this.document),this.listeners=new Fo(r),this.windowListeners=new Fo(gn(h)),this.initialCoordinates=(o=_p(c))!=null?o:us,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:s,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(Xn.Resize,this.handleCancel),this.windowListeners.add(Xn.DragStart,xy),this.windowListeners.add(Xn.VisibilityChange,this.handleCancel),this.windowListeners.add(Xn.ContextMenu,xy),this.documentListeners.add(Xn.Keydown,this.handleKeydown),s){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ky(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(Ey(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,s){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:t}=this,{onStart:s}=this.props;t&&(this.activated=!0,this.documentListeners.add(Xn.Click,ek,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Xn.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:r,initialCoordinates:o,props:c}=this,{onMove:h,options:{activationConstraint:f}}=c;if(!o)return;const g=(s=_p(t))!=null?s:us,p=Xu(o,g);if(!r&&f){if(Ey(f)){if(f.tolerance!=null&&If(p,f.tolerance))return this.handleCancel();if(If(p,f.distance))return this.handleStart()}if(ky(f)&&If(p,f.tolerance))return this.handleCancel();this.handlePending(f,p);return}t.cancelable&&t.preventDefault(),h(g)}handleEnd(){const{onAbort:t,onEnd:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleCancel(){const{onAbort:t,onCancel:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleKeydown(t){t.code===At.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ik={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class H0 extends Zm{constructor(t){const{event:s}=t,r=Tl(s.target);super(t,ik,r)}}H0.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return!s.isPrimary||s.button!==0?!1:(r?.({event:s}),!0)}}];const nk={move:{name:"mousemove"},end:{name:"mouseup"}};var yp;(function(e){e[e.RightClick=2]="RightClick"})(yp||(yp={}));class P0 extends Zm{constructor(t){super(t,nk,Tl(t.event.target))}}P0.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return s.button===yp.RightClick?!1:(r?.({event:s}),!0)}}];const Kf={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class U0 extends Zm{constructor(t){super(t,Kf)}static setup(){return window.addEventListener(Kf.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Kf.move.name,t)};function t(){}}}U0.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;const{touches:o}=s;return o.length>1?!1:(r?.({event:s}),!0)}}];var qo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(qo||(qo={}));var Zu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Zu||(Zu={}));function sk(e){let{acceleration:t,activator:s=qo.Pointer,canScroll:r,draggingRect:o,enabled:c,interval:h=5,order:f=Zu.TreeOrder,pointerCoordinates:g,scrollableAncestors:p,scrollableAncestorRects:y,delta:b,threshold:w}=e;const S=ak({delta:b,disabled:!c}),[E,T]=bE(),O=v.useRef({x:0,y:0}),L=v.useRef({x:0,y:0}),N=v.useMemo(()=>{switch(s){case qo.Pointer:return g?{top:g.y,bottom:g.y,left:g.x,right:g.x}:null;case qo.DraggableRect:return o}},[s,o,g]),I=v.useRef(null),U=v.useCallback(()=>{const ie=I.current;if(!ie)return;const le=O.current.x*L.current.x,ce=O.current.y*L.current.y;ie.scrollBy(le,ce)},[]),Q=v.useMemo(()=>f===Zu.TreeOrder?[...p].reverse():p,[f,p]);v.useEffect(()=>{if(!c||!p.length||!N){T();return}for(const ie of Q){if(r?.(ie)===!1)continue;const le=p.indexOf(ie),ce=y[le];if(!ce)continue;const{direction:ve,speed:we}=VE(ie,ce,N,t,w);for(const ne of["x","y"])S[ne][ve[ne]]||(we[ne]=0,ve[ne]=0);if(we.x>0||we.y>0){T(),I.current=ie,E(U,h),O.current=we,L.current=ve;return}}O.current={x:0,y:0},L.current={x:0,y:0},T()},[t,U,r,T,c,h,JSON.stringify(N),JSON.stringify(S),E,p,Q,y,JSON.stringify(w)])}const rk={x:{[Li.Backward]:!1,[Li.Forward]:!1},y:{[Li.Backward]:!1,[Li.Forward]:!1}};function ak(e){let{delta:t,disabled:s}=e;const r=gp(t);return cc(o=>{if(s||!r||!o)return rk;const c={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Li.Backward]:o.x[Li.Backward]||c.x===-1,[Li.Forward]:o.x[Li.Forward]||c.x===1},y:{[Li.Backward]:o.y[Li.Backward]||c.y===-1,[Li.Forward]:o.y[Li.Forward]||c.y===1}}},[s,t,r])}function lk(e,t){const s=t!=null?e.get(t):void 0,r=s?s.node.current:null;return cc(o=>{var c;return t==null?null:(c=r??o)!=null?c:null},[r,t])}function ok(e,t){return v.useMemo(()=>e.reduce((s,r)=>{const{sensor:o}=r,c=o.activators.map(h=>({eventName:h.eventName,handler:t(h.handler,r)}));return[...s,...c]},[]),[e,t])}var Qo;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Qo||(Qo={}));var Sp;(function(e){e.Optimized="optimized"})(Sp||(Sp={}));const Ty=new Map;function ck(e,t){let{dragging:s,dependencies:r,config:o}=t;const[c,h]=v.useState(null),{frequency:f,measure:g,strategy:p}=o,y=v.useRef(e),b=O(),w=Zo(b),S=v.useCallback(function(L){L===void 0&&(L=[]),!w.current&&h(N=>N===null?L:N.concat(L.filter(I=>!N.includes(I))))},[w]),E=v.useRef(null),T=cc(L=>{if(b&&!s)return Ty;if(!L||L===Ty||y.current!==e||c!=null){const N=new Map;for(let I of e){if(!I)continue;if(c&&c.length>0&&!c.includes(I.id)&&I.rect.current){N.set(I.id,I.rect.current);continue}const U=I.node.current,Q=U?new Gm(g(U),U):null;I.rect.current=Q,Q&&N.set(I.id,Q)}return N}return L},[e,c,s,b,g]);return v.useEffect(()=>{y.current=e},[e]),v.useEffect(()=>{b||S()},[s,b]),v.useEffect(()=>{c&&c.length>0&&h(null)},[JSON.stringify(c)]),v.useEffect(()=>{b||typeof f!="number"||E.current!==null||(E.current=setTimeout(()=>{S(),E.current=null},f))},[f,b,S,...r]),{droppableRects:T,measureDroppableContainers:S,measuringScheduled:c!=null};function O(){switch(p){case Qo.Always:return!1;case Qo.BeforeDragging:return s;default:return!s}}}function I0(e,t){return cc(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function uk(e,t){return I0(e,t)}function hk(e){let{callback:t,disabled:s}=e;const r=Ym(t),o=v.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(r)},[r,s]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function vh(e){let{callback:t,disabled:s}=e;const r=Ym(t),o=v.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(r)},[s]);return v.useEffect(()=>()=>o?.disconnect(),[o]),o}function dk(e){return new Gm(uc(e),e)}function Dy(e,t,s){t===void 0&&(t=dk);const[r,o]=v.useState(null);function c(){o(g=>{if(!e)return null;if(e.isConnected===!1){var p;return(p=g??s)!=null?p:null}const y=t(e);return JSON.stringify(g)===JSON.stringify(y)?g:y})}const h=hk({callback(g){if(e)for(const p of g){const{type:y,target:b}=p;if(y==="childList"&&b instanceof HTMLElement&&b.contains(e)){c();break}}}}),f=vh({callback:c});return zr(()=>{c(),e?(f?.observe(e),h?.observe(document.body,{childList:!0,subtree:!0})):(f?.disconnect(),h?.disconnect())},[e]),r}function fk(e){const t=I0(e);return R0(e,t)}const Ry=[];function pk(e){const t=v.useRef(e),s=cc(r=>e?r&&r!==Ry&&e&&t.current&&e.parentNode===t.current.parentNode?r:Xm(e):Ry,[e]);return v.useEffect(()=>{t.current=e},[e]),s}function mk(e){const[t,s]=v.useState(null),r=v.useRef(e),o=v.useCallback(c=>{const h=Uf(c.target);h&&s(f=>f?(f.set(h,bp(h)),new Map(f)):null)},[]);return v.useEffect(()=>{const c=r.current;if(e!==c){h(c);const f=e.map(g=>{const p=Uf(g);return p?(p.addEventListener("scroll",o,{passive:!0}),[p,bp(p)]):null}).filter(g=>g!=null);s(f.length?new Map(f):null),r.current=e}return()=>{h(e),h(c)};function h(f){f.forEach(g=>{const p=Uf(g);p?.removeEventListener("scroll",o)})}},[o,e]),v.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,h)=>vl(c,h),us):O0(e):us,[e,t])}function My(e,t){t===void 0&&(t=[]);const s=v.useRef(null);return v.useEffect(()=>{s.current=null},t),v.useEffect(()=>{const r=e!==us;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?Xu(e,s.current):us}function gk(e){v.useEffect(()=>{if(!gh)return;const t=e.map(s=>{let{sensor:r}=s;return r.setup==null?void 0:r.setup()});return()=>{for(const s of t)s?.()}},e.map(t=>{let{sensor:s}=t;return s}))}function _k(e,t){return v.useMemo(()=>e.reduce((s,r)=>{let{eventName:o,handler:c}=r;return s[o]=h=>{c(h,t)},s},{}),[e,t])}function K0(e){return v.useMemo(()=>e?WE(e):null,[e])}const Ny=[];function vk(e,t){t===void 0&&(t=uc);const[s]=e,r=K0(s?gn(s):null),[o,c]=v.useState(Ny);function h(){c(()=>e.length?e.map(g=>L0(g)?r:new Gm(t(g),g)):Ny)}const f=vh({callback:h});return zr(()=>{f?.disconnect(),h(),e.forEach(g=>f?.observe(g))},[e]),o}function bk(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return oc(t)?t:e}function yk(e){let{measure:t}=e;const[s,r]=v.useState(null),o=v.useCallback(p=>{for(const{target:y}of p)if(oc(y)){r(b=>{const w=t(y);return b?{...b,width:w.width,height:w.height}:w});break}},[t]),c=vh({callback:o}),h=v.useCallback(p=>{const y=bk(p);c?.disconnect(),y&&c?.observe(y),r(y?t(y):null)},[t,c]),[f,g]=Yu(h);return v.useMemo(()=>({nodeRef:f,rect:s,setRef:g}),[s,f,g])}const Sk=[{sensor:H0,options:{}},{sensor:j0,options:{}}],wk={current:{}},Bu={draggable:{measure:Cy},droppable:{measure:Cy,strategy:Qo.WhileDragging,frequency:Sp.Optimized},dragOverlay:{measure:uc}};class $o extends Map{get(t){var s;return t!=null&&(s=super.get(t))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:s}=t;return!s})}getNodeFor(t){var s,r;return(s=(r=this.get(t))==null?void 0:r.node.current)!=null?s:void 0}}const Ck={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new $o,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Gu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bu,measureDroppableContainers:Gu,windowRect:null,measuringScheduled:!1},xk={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Gu,draggableNodes:new Map,over:null,measureDroppableContainers:Gu},bh=v.createContext(xk),Ek=v.createContext(Ck);function kk(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new $o}}}function Tk(e,t){switch(t.type){case Ci.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ci.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 Ci.DragEnd:case Ci.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ci.RegisterDroppable:{const{element:s}=t,{id:r}=s,o=new $o(e.droppable.containers);return o.set(r,s),{...e,droppable:{...e.droppable,containers:o}}}case Ci.SetDroppableDisabled:{const{id:s,key:r,disabled:o}=t,c=e.droppable.containers.get(s);if(!c||r!==c.key)return e;const h=new $o(e.droppable.containers);return h.set(s,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:h}}}case Ci.UnregisterDroppable:{const{id:s,key:r}=t,o=e.droppable.containers.get(s);if(!o||r!==o.key)return e;const c=new $o(e.droppable.containers);return c.delete(s),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function Dk(e){let{disabled:t}=e;const{active:s,activatorEvent:r,draggableNodes:o}=v.useContext(bh),c=gp(r),h=gp(s?.id);return v.useEffect(()=>{if(!t&&!r&&c&&h!=null){if(!T0(c)||document.activeElement===c.target)return;const f=o.get(h);if(!f)return;const{activatorNode:g,node:p}=f;if(!g.current&&!p.current)return;requestAnimationFrame(()=>{for(const y of[g.current,p.current]){if(!y)continue;const b=wE(y);if(b){b.focus();break}}})}},[r,t,o,h,c]),null}function Rk(e,t){let{transform:s,...r}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...r}),s):s}function Mk(e){return v.useMemo(()=>({draggable:{...Bu.draggable,...e?.draggable},droppable:{...Bu.droppable,...e?.droppable},dragOverlay:{...Bu.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Nk(e){let{activeNode:t,measure:s,initialRect:r,config:o=!0}=e;const c=v.useRef(!1),{x:h,y:f}=typeof o=="boolean"?{x:o,y:o}:o;zr(()=>{if(!h&&!f||!t){c.current=!1;return}if(c.current||!r)return;const p=t?.node.current;if(!p||p.isConnected===!1)return;const y=s(p),b=R0(y,r);if(h||(b.x=0),f||(b.y=0),c.current=!0,Math.abs(b.x)>0||Math.abs(b.y)>0){const w=M0(p);w&&w.scrollBy({top:b.y,left:b.x})}},[t,h,f,r,s])}const W0=v.createContext({...us,scaleX:1,scaleY:1});var Rr;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Rr||(Rr={}));const Ak=v.memo(function(t){var s,r,o,c;let{id:h,accessibility:f,autoScroll:g=!0,children:p,sensors:y=Sk,collisionDetection:b=zE,measuring:w,modifiers:S,...E}=t;const T=v.useReducer(Tk,void 0,kk),[O,L]=T,[N,I]=DE(),[U,Q]=v.useState(Rr.Uninitialized),ie=U===Rr.Initialized,{draggable:{active:le,nodes:ce,translate:ve},droppable:{containers:we}}=O,ne=le!=null?ce.get(le):null,se=v.useRef({initial:null,translated:null}),V=v.useMemo(()=>{var _t;return le!=null?{id:le,data:(_t=ne?.data)!=null?_t:wk,rect:se}:null},[le,ne]),F=v.useRef(null),[re,B]=v.useState(null),[W,D]=v.useState(null),G=Zo(E,Object.values(E)),me=_h("DndDescribedBy",h),R=v.useMemo(()=>we.getEnabled(),[we]),H=Mk(w),{droppableRects:ee,measureDroppableContainers:de,measuringScheduled:Ee}=ck(R,{dragging:ie,dependencies:[ve.x,ve.y],config:H.droppable}),ke=lk(ce,le),Me=v.useMemo(()=>W?_p(W):null,[W]),Fe=Pi(),_e=uk(ke,H.draggable.measure);Nk({activeNode:le!=null?ce.get(le):null,config:Fe.layoutShiftCompensation,initialRect:_e,measure:H.draggable.measure});const X=Dy(ke,H.draggable.measure,_e),he=Dy(ke?ke.parentElement:null),Ce=v.useRef({activatorEvent:null,active:null,activeNode:ke,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:ce,draggingNode:null,draggingNodeRect:null,droppableContainers:we,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),be=we.getNodeFor((s=Ce.current.over)==null?void 0:s.id),De=yk({measure:H.dragOverlay.measure}),Oe=(r=De.nodeRef.current)!=null?r:ke,Ie=ie?(o=De.rect)!=null?o:X:null,oe=!!(De.nodeRef.current&&De.rect),xe=fk(oe?null:X),Ae=K0(Oe?gn(Oe):null),ze=pk(ie?be??ke:null),He=vk(ze),gt=Rk(S,{transform:{x:ve.x-xe.x,y:ve.y-xe.y,scaleX:1,scaleY:1},activatorEvent:W,active:V,activeNodeRect:X,containerNodeRect:he,draggingNodeRect:Ie,over:Ce.current.over,overlayNodeRect:De.rect,scrollableAncestors:ze,scrollableAncestorRects:He,windowRect:Ae}),Xe=Me?vl(Me,ve):null,st=mk(ze),ei=My(st),an=My(st,[X]),ki=vl(gt,ei),ti=Ie?PE(Ie,gt):null,Ti=V&&ti?b({active:V,collisionRect:ti,droppableRects:ee,droppableContainers:R,pointerCoordinates:Xe}):null,Jn=BE(Ti,"id"),[K,$e]=v.useState(null),ot=oe?gt:vl(gt,an),wt=jE(ot,(c=K?.rect)!=null?c:null,X),li=v.useRef(null),Dt=v.useCallback((_t,vt)=>{let{sensor:Ct,options:Di}=vt;if(F.current==null)return;const oi=ce.get(F.current);if(!oi)return;const qt=_t.nativeEvent,ci=new Ct({active:F.current,activeNode:oi,event:qt,options:Di,context:Ce,onAbort(Ht){if(!ce.get(Ht))return;const{onDragAbort:ii}=G.current,vi={id:Ht};ii?.(vi),N({type:"onDragAbort",event:vi})},onPending(Ht,Ri,ii,vi){if(!ce.get(Ht))return;const{onDragPending:Gi}=G.current,Zi={id:Ht,constraint:Ri,initialCoordinates:ii,offset:vi};Gi?.(Zi),N({type:"onDragPending",event:Zi})},onStart(Ht){const Ri=F.current;if(Ri==null)return;const ii=ce.get(Ri);if(!ii)return;const{onDragStart:vi}=G.current,_n={activatorEvent:qt,active:{id:Ri,data:ii.data,rect:se}};Lo.unstable_batchedUpdates(()=>{vi?.(_n),Q(Rr.Initializing),L({type:Ci.DragStart,initialCoordinates:Ht,active:Ri}),N({type:"onDragStart",event:_n}),B(li.current),D(qt)})},onMove(Ht){L({type:Ci.DragMove,coordinates:Ht})},onEnd:_i(Ci.DragEnd),onCancel:_i(Ci.DragCancel)});li.current=ci;function _i(Ht){return async function(){const{active:ii,collisions:vi,over:_n,scrollAdjustedTranslate:Gi}=Ce.current;let Zi=null;if(ii&&Gi){const{cancelDrop:vn}=G.current;Zi={activatorEvent:qt,active:ii,collisions:vi,delta:Gi,over:_n},Ht===Ci.DragEnd&&typeof vn=="function"&&await Promise.resolve(vn(Zi))&&(Ht=Ci.DragCancel)}F.current=null,Lo.unstable_batchedUpdates(()=>{L({type:Ht}),Q(Rr.Uninitialized),$e(null),B(null),D(null),li.current=null;const vn=Ht===Ci.DragEnd?"onDragEnd":"onDragCancel";if(Zi){const $i=G.current[vn];$i?.(Zi),N({type:vn,event:Zi})}})}}},[ce]),ln=v.useCallback((_t,vt)=>(Ct,Di)=>{const oi=Ct.nativeEvent,qt=ce.get(Di);if(F.current!==null||!qt||oi.dndKit||oi.defaultPrevented)return;const ci={active:qt};_t(Ct,vt.options,ci)===!0&&(oi.dndKit={capturedBy:vt.sensor},F.current=Di,Dt(Ct,vt))},[ce,Dt]),es=ok(y,ln);gk(y),zr(()=>{X&&U===Rr.Initializing&&Q(Rr.Initialized)},[X,U]),v.useEffect(()=>{const{onDragMove:_t}=G.current,{active:vt,activatorEvent:Ct,collisions:Di,over:oi}=Ce.current;if(!vt||!Ct)return;const qt={active:vt,activatorEvent:Ct,collisions:Di,delta:{x:ki.x,y:ki.y},over:oi};Lo.unstable_batchedUpdates(()=>{_t?.(qt),N({type:"onDragMove",event:qt})})},[ki.x,ki.y]),v.useEffect(()=>{const{active:_t,activatorEvent:vt,collisions:Ct,droppableContainers:Di,scrollAdjustedTranslate:oi}=Ce.current;if(!_t||F.current==null||!vt||!oi)return;const{onDragOver:qt}=G.current,ci=Di.get(Jn),_i=ci&&ci.rect.current?{id:ci.id,rect:ci.rect.current,data:ci.data,disabled:ci.disabled}:null,Ht={active:_t,activatorEvent:vt,collisions:Ct,delta:{x:oi.x,y:oi.y},over:_i};Lo.unstable_batchedUpdates(()=>{$e(_i),qt?.(Ht),N({type:"onDragOver",event:Ht})})},[Jn]),zr(()=>{Ce.current={activatorEvent:W,active:V,activeNode:ke,collisionRect:ti,collisions:Ti,droppableRects:ee,draggableNodes:ce,draggingNode:Oe,draggingNodeRect:Ie,droppableContainers:we,over:K,scrollableAncestors:ze,scrollAdjustedTranslate:ki},se.current={initial:Ie,translated:ti}},[V,ke,Ti,ti,ce,Oe,Ie,ee,we,K,ze,ki]),sk({...Fe,delta:ve,draggingRect:ti,pointerCoordinates:Xe,scrollableAncestors:ze,scrollableAncestorRects:He});const ts=v.useMemo(()=>({active:V,activeNode:ke,activeNodeRect:X,activatorEvent:W,collisions:Ti,containerNodeRect:he,dragOverlay:De,draggableNodes:ce,droppableContainers:we,droppableRects:ee,over:K,measureDroppableContainers:de,scrollableAncestors:ze,scrollableAncestorRects:He,measuringConfiguration:H,measuringScheduled:Ee,windowRect:Ae}),[V,ke,X,W,Ti,he,De,ce,we,ee,K,de,ze,He,H,Ee,Ae]),Rt=v.useMemo(()=>({activatorEvent:W,activators:es,active:V,activeNodeRect:X,ariaDescribedById:{draggable:me},dispatch:L,draggableNodes:ce,over:K,measureDroppableContainers:de}),[W,es,V,X,L,me,ce,K,de]);return xi.createElement(D0.Provider,{value:I},xi.createElement(bh.Provider,{value:Rt},xi.createElement(Ek.Provider,{value:ts},xi.createElement(W0.Provider,{value:wt},p)),xi.createElement(Dk,{disabled:f?.restoreFocus===!1})),xi.createElement(NE,{...f,hiddenTextDescribedById:me}));function Pi(){const _t=re?.autoScrollEnabled===!1,vt=typeof g=="object"?g.enabled===!1:g===!1,Ct=ie&&!_t&&!vt;return typeof g=="object"?{...g,enabled:Ct}:{enabled:Ct}}}),Lk=v.createContext(null),Ay="button",Bk="Draggable";function F0(e){let{id:t,data:s,disabled:r=!1,attributes:o}=e;const c=_h(Bk),{activators:h,activatorEvent:f,active:g,activeNodeRect:p,ariaDescribedById:y,draggableNodes:b,over:w}=v.useContext(bh),{role:S=Ay,roleDescription:E="draggable",tabIndex:T=0}=o??{},O=g?.id===t,L=v.useContext(O?W0:Lk),[N,I]=Yu(),[U,Q]=Yu(),ie=_k(h,t),le=Zo(s);zr(()=>(b.set(t,{id:t,key:c,node:N,activatorNode:U,data:le}),()=>{const ve=b.get(t);ve&&ve.key===c&&b.delete(t)}),[b,t]);const ce=v.useMemo(()=>({role:S,tabIndex:T,"aria-disabled":r,"aria-pressed":O&&S===Ay?!0:void 0,"aria-roledescription":E,"aria-describedby":y.draggable}),[r,S,T,O,E,y.draggable]);return{active:g,activatorEvent:f,activeNodeRect:p,attributes:ce,isDragging:O,listeners:r?void 0:ie,node:N,over:w,setNodeRef:I,setActivatorNodeRef:Q,transform:L}}const Ok="Droppable",zk={timeout:25};function Qm(e){let{data:t,disabled:s=!1,id:r,resizeObserverConfig:o}=e;const c=_h(Ok),{active:h,dispatch:f,over:g,measureDroppableContainers:p}=v.useContext(bh),y=v.useRef({disabled:s}),b=v.useRef(!1),w=v.useRef(null),S=v.useRef(null),{disabled:E,updateMeasurementsFor:T,timeout:O}={...zk,...o},L=Zo(T??r),N=v.useCallback(()=>{if(!b.current){b.current=!0;return}S.current!=null&&clearTimeout(S.current),S.current=setTimeout(()=>{p(Array.isArray(L.current)?L.current:[L.current]),S.current=null},O)},[O]),I=vh({callback:N,disabled:E||!h}),U=v.useCallback((ce,ve)=>{I&&(ve&&(I.unobserve(ve),b.current=!1),ce&&I.observe(ce))},[I]),[Q,ie]=Yu(U),le=Zo(t);return v.useEffect(()=>{!I||!Q.current||(I.disconnect(),b.current=!1,I.observe(Q.current))},[Q,I]),v.useEffect(()=>(f({type:Ci.RegisterDroppable,element:{id:r,key:c,disabled:s,node:Q,rect:w,data:le}}),()=>f({type:Ci.UnregisterDroppable,key:c,id:r})),[r]),v.useEffect(()=>{s!==y.current.disabled&&(f({type:Ci.SetDroppableDisabled,id:r,key:c,disabled:s}),y.current.disabled=s)},[r,c,s,f]),{active:h,rect:w,isOver:g?.id===r,node:Q,over:g,setNodeRef:ie}}const jk=128,Hk=512,Dl=100,Pk="too_many_detached_terminals",Uk=64,Ik=4096;function q0(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>jk)return null;const s=t.workspaces.map(Kk);return s.some(r=>r===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:s}}function $0(e){if(!e||typeof e!="object")return!1;const t=e;return Array.isArray(t.workspaces)?t.workspaces.some(s=>{if(!s||typeof s!="object")return!1;const r=s.detachedTerminalIds;return Array.isArray(r)&&r.length>Dl}):!1}function Kk(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>Hk)return null;const s=t.tabs.map(Wk);if(s.some(o=>o===null))return null;const r=Vk(t.detachedTerminalIds,Dl);return r===null?null:{id:t.id,title:t.title,defaultCwd:$k(t.defaultCwd),detachedTerminalIds:r,activeTabId:t.activeTabId,tabs:s}}function Wk(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const s=Fk(t.root);return s?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:s}:null}function Fk(e){if(!e||typeof e!="object")return null;let t=0;return wp(e,1,()=>(t+=1,t<=Ik))}function wp(e,t,s){if(!e||typeof e!="object"||t>Uk||!s())return null;const r=e;if(r.type==="pane")return typeof r.terminalId=="string"?{type:"pane",terminalId:r.terminalId}:null;if(r.type!=="split"||r.direction!=="horizontal"&&r.direction!=="vertical")return null;const o=wp(r.first,t+1,s),c=wp(r.second,t+1,s);return!o||!c?null:{type:"split",direction:r.direction,ratio:qk(r.ratio),first:o,second:c}}function qk(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function $k(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Vk(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>t)return null;const s=new Set,r=[];for(const o of e)typeof o!="string"||!o||s.has(o)||(s.add(o),r.push(o));return r}const V0=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}],Nr="__main__";function Yk(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function Xk(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Ly="Local",Gk=3e4,Zk=2,Qk=6,Y0="nterminal.serverList.viewMode.v1";function Jk(){try{return window.localStorage.getItem(Y0)==="list"?"list":"stats"}catch{return"stats"}}function e2(e){try{window.localStorage.setItem(Y0,e)}catch{}}function ca(e,t){const s=[Nr,...t.map(h=>h.id)],r=new Set(s),o=new Set,c=[];for(const h of e??[])!r.has(h)||o.has(h)||(o.add(h),c.push(h));for(const h of s)o.has(h)||c.push(h);return c}function t2(e,t){const s=new Map(e.map(r=>[r.id,r]));return ca(t,e).flatMap(r=>{if(r===Nr)return[{kind:"main",id:Nr}];const o=s.get(r);return o?[{kind:"agent",id:r,agent:o}]:[]})}function By(e,t){return e.length===t.length&&e.every((s,r)=>s===t[r])}function X0(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Zn(e.cpuPercent)} ${Jm(e)}`,`MEM ${Zn(e.memoryPercent)} ${Ys(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Zn(e.diskPercent)} ${Ys(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Zn(e.swapPercent)} ${Ys(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function i2(e){if(!(e===void 0||e==="error"))return[`CPU ${Zn(e.cpuPercent)} (${Jm(e)})`,`RAM ${Zn(e.memoryPercent)} (${Ys(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Zn(e.diskPercent)} (${Ys(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Zn(e.swapPercent)} (${Ys(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function n2(e,t){const s=X0(t);return`${e}${s?` — ${s}`:""}. Double-click to rename.`}function Zn(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function Jm(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${Cp(e.cpuPercent/100*t)}/${t} cores`}function Ys(e,t){return!Oy(e)||!Oy(t)?"–/–":s2(e,t)}function s2(e,t){const s=t>=1073741824?"GB":t>=1048576?"MB":"KB",r=s==="GB"?1024**3:s==="MB"?1024**2:1024;return`${Cp(e/r)}/${Cp(t/r)} ${s}`}function Cp(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Oy(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Su(e){return typeof e!="number"||!Number.isFinite(e)?"normal":e>95?"danger":e>90?"warning":"normal"}function r2(e){return[{label:"CPU",percent:Zn(e.cpuPercent),detail:Jm(e),tone:Su(e.cpuPercent)},{label:"MEM",percent:Zn(e.memoryPercent),detail:Ys(e.memoryUsedBytes,e.memoryTotalBytes),tone:Su(e.memoryPercent)},{label:"DISK",percent:Zn(e.diskPercent),detail:Ys(e.diskUsedBytes,e.diskTotalBytes),tone:Su(e.diskPercent)},{label:"SWAP",percent:Zn(e.swapPercent),detail:Ys(e.swapUsedBytes,e.swapTotalBytes),tone:Su(e.swapPercent)}]}function a2({entry:e}){return e==="error"?m.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?m.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t}),m.jsx("span",{className:"server-list-stat-value",children:"–"})]}),m.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):m.jsx("span",{className:"server-list-stats server-list-stats-grid",title:i2(e),children:r2(e).map(t=>m.jsxs("span",{className:"server-list-stat-cell",children:[m.jsxs("span",{className:"server-list-stat-head",children:[m.jsx("span",{className:"server-list-stat-label",children:t.label}),m.jsx("span",{className:"server-list-stat-value","data-tone":t.tone,children:t.percent})]}),m.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function zy({api:e,activeAgentId:t,onSelectServer:s,onSessionInvalid:r,refreshToken:o=0,renderServerChildren:c,compact:h=!1}){const[f,g]=v.useState([]),[p,y]=v.useState([Nr]),[b,w]=v.useState(null),[S,E]=v.useState(null),[T,O]=v.useState(""),L=v.useRef(null),[N,I]=v.useState(()=>Jk()),[U,Q]=v.useState(null),[ie,le]=v.useState(null),[ce,ve]=v.useState({}),we=v.useRef({}),ne=v.useRef(0),se=v.useRef([]),V=v.useRef([Nr]),F=v.useRef(null);v.useEffect(()=>{se.current=f},[f]),v.useEffect(()=>{const X=ca(p,f);V.current=X,By(X,p)||y(X)},[f,p]),v.useEffect(()=>{let X=!1;return e.listAgents().then(he=>{X||(g(he.agents),y(ca(he.serverOrder,he.agents)))}).catch(()=>{}),e.getMainInfo().then(he=>{X||w(he.name)}).catch(()=>{}),()=>{X=!0}},[e,o]),v.useEffect(()=>{S&&(L.current?.focus(),L.current?.select())},[S]),v.useEffect(()=>{let X=!1;function he(){const be=[{key:"__main__",load:()=>e.getMainStats()},...f.map(Oe=>({key:Oe.id,load:()=>e.getAgentStats(Oe.id)}))],De=new Set(be.map(Oe=>Oe.key));for(const Oe of Object.keys(we.current))De.has(Oe)||delete we.current[Oe];ve(Oe=>{const Ie={};for(const oe of De)oe in Oe&&(Ie[oe]=Oe[oe]);return Ie});for(const Oe of be)Oe.load().then(Ie=>{X||(we.current[Oe.key]=0,ve(oe=>De.has(Oe.key)?{...oe,[Oe.key]:Ie}:oe))}).catch(Ie=>{if(X)return;if(Ie instanceof cs&&Ie.status===401&&Oe.key==="__main__"){r?.({source:"main-stats-401",status:401,activeAgentId:null});return}const oe=(we.current[Oe.key]??0)+1;we.current[Oe.key]=oe,oe>=Zk&&ve(xe=>De.has(Oe.key)?{...xe,[Oe.key]:"error"}:xe)})}he();const Ce=window.setInterval(he,Gk);return()=>{X=!0,window.clearInterval(Ce)}},[e,f,r]);function re(X){X==="main"?(O(b??""),E({kind:"main"})):(O(X.name),E({kind:"agent",id:X.id}))}async function B(){if(!S)return;const X=T.trim(),he=S;if(E(null),he.kind==="main"){const Ce=X||"";try{const be=await e.renameMain(Ce);w(be.name)}catch{}}else{if(!X)return;const Ce=f.find(be=>be.id===he.id)?.name;g(be=>be.map(De=>De.id===he.id?{...De,name:X}:De));try{await e.renameAgent(he.id,X)}catch{Ce!==void 0&&g(be=>be.map(De=>De.id===he.id?{...De,name:Ce}:De))}}}function W(){E(null)}function D(X){I(X),e2(X)}function G(X,he,Ce){if(X===he)return;const be=ca(V.current,se.current),De=be.findIndex(He=>He===X),Oe=be.findIndex(He=>He===he);if(De<0||Oe<0)return;const Ie=[...be],[oe]=Ie.splice(De,1);if(!oe)return;const xe=Ie.findIndex(He=>He===he);if(xe<0)return;const Ae=Ce==="before"?xe:xe+1;if(Ie.splice(Ae,0,oe),By(Ie,be))return;const ze=ne.current+1;ne.current=ze,V.current=Ie,y(Ie),e.reorderAgents(Ie).then(He=>{if(ne.current===ze){se.current=He.agents;const gt=ca(He.serverOrder,He.agents);V.current=gt,g(He.agents),y(gt)}}).catch(async()=>{if(ne.current===ze)try{const He=await e.listAgents();if(ne.current===ze){se.current=He.agents;const gt=ca(He.serverOrder,He.agents);V.current=gt,g(He.agents),y(gt)}}catch{ne.current===ze&&(V.current=be,y(be))}})}function me(X,he){const Ce=ca(V.current,se.current),be=Ce.findIndex(Oe=>Oe===X),De=Ce[be+he];be<0||!De||G(X,De,he<0?"before":"after")}function R(X,he){he.pointerType==="mouse"&&he.button!==0||(he.stopPropagation(),F.current={sourceId:X,pointerId:he.pointerId,startX:he.clientX,startY:he.clientY,active:!1,targetId:null,placement:"after"},he.currentTarget.setPointerCapture?.(he.pointerId))}function H(X){const he=F.current;if(!he||he.pointerId!==X.pointerId)return;const Ce=Math.hypot(X.clientX-he.startX,X.clientY-he.startY);if(!he.active){if(Ce<Qk)return;he.active=!0,Q(he.sourceId)}const De=document.elementFromPoint(X.clientX,X.clientY)?.closest("[data-server-id]"),Oe=De?.dataset.serverId??null;if(!De||!Oe||Oe===he.sourceId){he.targetId=null,le(null);return}const Ie=De.getBoundingClientRect(),oe=X.clientY<Ie.top+Ie.height/2?"before":"after";he.targetId=Oe,he.placement=oe,le({serverId:Oe,placement:oe})}function ee(X){const he=F.current;!he||he.pointerId!==X.pointerId||(X.stopPropagation(),X.currentTarget.releasePointerCapture?.(X.pointerId),F.current=null,Q(null),le(null),he.active&&he.targetId&&G(he.sourceId,he.targetId,he.placement))}function de(X){const he=F.current;he&&he.pointerId===X.pointerId&&X.currentTarget.releasePointerCapture?.(X.pointerId),F.current=null,Q(null),le(null)}const Ee=b?.trim()||Ly,ke=S?.kind==="main",Me=N==="stats",Fe=t2(f,p),_e=Fe.length>1;return h?m.jsx("div",{className:"server-list server-list--compact",children:Fe.map(X=>{const he=X.kind==="main",Ce=he?Ee:X.agent.name,be=he?Nr:X.id,De=ce[be],Oe=X0(De);return m.jsxs("button",{type:"button",className:`server-list-chip${(he?t===null:t===X.id)?" server-list-chip--active":""}`,onClick:()=>s(he?null:X.id),"aria-label":Ce,title:`${Ce}${Oe?` — ${Oe}`:""}`,children:[m.jsx("span",{className:"server-list-chip-initial",children:Xk(Ce)}),m.jsx("span",{className:"server-list-chip-pip","data-status":Yk(De)})]},X.id)})}):m.jsxs("div",{className:`server-list server-list--${N}`,children:[m.jsxs("div",{className:"server-list-toolbar","aria-label":"Server list display",children:[m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":N==="list",onClick:()=>D("list"),title:"Show server names only",children:"List"}),m.jsx("button",{type:"button",className:"server-list-view-button","aria-pressed":N==="stats",onClick:()=>D("stats"),title:"Show resource usage",children:"Stats"})]}),Fe.map(X=>{const he=X.kind==="main",Ce=he?Ee:X.agent.name,be=he?Nr:X.id,De=he?t===null:t===X.id,Oe=he?ke:S?.kind==="agent"&&S.id===X.id,Ie=c?.({agentId:he?null:X.id,serverId:X.id,label:Ce,active:De}),oe=ie?.serverId===X.id&&U!==X.id?` server-list-section--drop-target server-list-section--drop-${ie.placement}`:"";return m.jsxs("section",{className:`server-list-section${oe}`,"aria-label":`${Ce} server`,children:[m.jsx("div",{className:["server-list-row",U===X.id?"server-list-row--dragging":"",ie?.serverId===X.id&&U!==X.id?"server-list-row--drop-target":""].filter(Boolean).join(" "),"data-server-id":X.id,children:Oe?m.jsxs(m.Fragment,{children:[_e?m.jsx("span",{className:"server-list-drag-spacer","aria-hidden":"true"}):null,m.jsx("form",{className:"server-list-editor",onSubmit:xe=>{xe.preventDefault(),B()},children:m.jsx("input",{ref:L,"aria-label":he?"Rename main server":`Rename ${Ce}`,value:T,onChange:xe=>O(xe.target.value),onBlur:()=>{B()},onKeyDown:xe=>{xe.key==="Escape"&&(xe.preventDefault(),W())},placeholder:he?Ly:void 0})})]}):m.jsxs(m.Fragment,{children:[_e?m.jsx("button",{type:"button",className:"server-list-drag-handle","data-server-drag-handle":X.id,title:"Drag to reorder","aria-label":`Reorder ${Ce}`,"aria-grabbed":U===X.id,onPointerDown:xe=>R(X.id,xe),onPointerMove:H,onPointerUp:ee,onPointerCancel:de,onKeyDown:xe=>{(xe.key==="ArrowUp"||xe.key==="ArrowDown")&&(xe.preventDefault(),xe.stopPropagation(),me(X.id,xe.key==="ArrowUp"?-1:1))},onClick:xe=>xe.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:`server-list-item${De?" server-list-item--active":""}`,onClick:()=>s(he?null:X.id),onDoubleClick:xe=>{xe.preventDefault(),re(he?"main":{id:X.id,name:Ce})},title:n2(Ce,ce[be]),children:[m.jsxs("span",{className:"server-list-item-header",children:[m.jsx("span",{className:"server-list-dot"}),m.jsx("span",{className:"server-list-name",title:he?void 0:X.agent.url,children:Ce})]}),Me?m.jsx(a2,{entry:ce[be]}):null]})]})}),Ie?m.jsx("div",{className:"server-list-children",children:Ie}):null]},X.id)})]})}function l2({api:e}){const[t,s]=v.useState([]),[r,o]=v.useState([]),[c,h]=v.useState(!1),[f,g]=v.useState(null),[p,y]=v.useState(""),[b,w]=v.useState("");async function S(){try{const[L,N,I]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);s(L.devices),o(N.networks),h(I.totpEnabled),g(null)}catch(L){g(L instanceof Error?L.message:"Failed to load")}}v.useEffect(()=>{S()},[]);async function E(L){await e.revokeDevice(L),await S()}async function T(L){await e.removeNetwork(L),await S()}async function O(L){L.preventDefault(),g(null);try{await e.addNetwork({value:p.trim(),label:b.trim()}),y(""),w(""),await S()}catch(N){g(N instanceof Error?N.message:"Failed to add network")}}return m.jsxs(m.Fragment,{children:[f?m.jsx("p",{className:"form-error",children:f}):null,m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted devices"}),m.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?m.jsx("p",{className:"muted",children:"No trusted devices."}):m.jsx("ul",{className:"security-list",children:t.map(L=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsxs("span",{className:"security-item-label",children:[L.label,L.current?m.jsx("span",{className:"security-badge",children:"this device"}):null]}),m.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(L.lastSeenAt).toLocaleString()]})]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{E(L.id)},children:"revoke"})]},L.id))})]}),m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Trusted networks"}),m.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),r.length===0?m.jsx("p",{className:"muted",children:"No trusted networks."}):m.jsx("ul",{className:"security-list",children:r.map(L=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:L.value}),L.label!==L.value?m.jsx("span",{className:"security-item-meta",children:L.label}):null]}),m.jsx("button",{type:"button",className:"security-remove",onClick:()=>{T(L.id)},children:"remove"})]},L.id))}),m.jsxs("form",{className:"security-add-form",onSubmit:O,children:[m.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:p,onChange:L=>y(L.currentTarget.value),required:!0}),m.jsx("input",{type:"text",placeholder:"Label (optional)",value:b,onChange:L=>w(L.currentTarget.value)}),m.jsx("button",{type:"submit",disabled:!p.trim(),children:"Add"})]})]}),c?m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Two-factor authentication"}),m.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),m.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await S()},children:"Disable 2FA"})]}):null]})}const eg="nterminal.clientDiagnostics.v1",G0=150,o2=24,c2=160;let jy=!1,wo=null;function u2(){jy||typeof window>"u"||(jy=!0,Nn("page.load",{navigation:C2(),visibility:document.visibilityState,online:navigator.onLine,viewport:Q0(),standalone:w2()}),document.addEventListener("visibilitychange",()=>{Nn("page.visibility",{visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pageshow",e=>{Nn("page.show",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("pagehide",e=>{Nn("page.hide",{persisted:e.persisted,visibility:document.visibilityState,online:navigator.onLine})}),window.addEventListener("online",()=>Nn("network.online")),window.addEventListener("offline",()=>Nn("network.offline")),window.addEventListener("focus",()=>Nn("window.focus")),window.addEventListener("blur",()=>Nn("window.blur")),window.addEventListener("error",e=>{Nn("runtime.error",{message:e.message,source:x2(e.filename),line:e.lineno||null})}),window.addEventListener("unhandledrejection",e=>{Nn("runtime.unhandledrejection",{reason:E2(e.reason)})}))}function Nn(e,t={}){const s={at:new Date().toISOString(),event:Sh(e,80),data:Z0({...t,visibility:t.visibility??y2(),online:t.online??S2(),viewport:t.viewport??Q0()})},r=fa();return r.push(s),p2(r.slice(-G0)),s}function fa(){try{const e=window.localStorage.getItem(eg);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.map(m2).filter(s=>s!==null).slice(-G0):[]}catch{return[]}}function h2(){try{window.localStorage.removeItem(eg)}catch{}}function d2(){const e=fa();return JSON.stringify({generatedAt:new Date().toISOString(),eventCount:e.length,events:e},null,2)}async function f2(){const e=d2();return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),!0):k2(e)}async function yh(e,t=fetch){if(wo)return wo;const s=fa(),r={reason:Sh(e,80),events:s},o=JSON.stringify(r);wo=(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 wo}finally{wo=null}}function p2(e){try{window.localStorage.setItem(eg,JSON.stringify(e))}catch{}}function m2(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.at!="string"||typeof t.event!="string"?null:{at:t.at.slice(0,40),event:Sh(t.event,80),...t.data&&typeof t.data=="object"?{data:Z0(t.data)}:{}}}function Z0(e){const t={};for(const[s,r]of Object.entries(e).slice(0,o2)){const o=Sh(s,64);if(!o||g2(o))continue;const c=_2(r);c!==void 0&&(t[o]=c)}return t}function g2(e){return/(?:password|secret|token|cookie|authorization|sessionid|session_id|nterminal_session|nterminal_device)/i.test(e)}function _2(e){if(typeof e=="string")return v2(e,c2);if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="boolean"||e===null)return e}function Sh(e,t){return e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,t)}function v2(e,t){return b2(e).replace(/[\r\n\t]+/g," ").replace(/[^\x20-\x7E]/g,"_").slice(0,t)}function b2(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 y2(){return typeof document>"u"?void 0:document.visibilityState}function S2(){return typeof navigator>"u"?void 0:navigator.onLine}function Q0(){if(typeof window>"u")return;const e=window.innerWidth||0;return e<640?"mobile":e<1024?"tablet":"desktop"}function w2(){return typeof window>"u"?!1:window.matchMedia?.("(display-mode: standalone)").matches===!0||navigator.standalone===!0}function C2(){return performance.getEntriesByType?.("navigation")?.[0]?.type??"unknown"}function x2(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 E2(e){return e instanceof Error?e.message||e.name:typeof e=="string"?e:typeof e}function k2(e){const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.left="-9999px",document.body.appendChild(t),t.select();let s=!1;try{s=document.execCommand("copy")}finally{document.body.removeChild(t)}return s}const J0="nterminal.notifications.completionEnabled",tg="nterminal.notifications.completionToastEnabled",ig="nterminal.notifications.completionToastDurationSeconds",ng="nterminal.notifications.completionToastPersistent",xp="nterminal:completion-toast-display",Vo=6.5,Ep=2,kp=60;function wh(){return typeof window<"u"&&"Notification"in window}function ew(){try{return window.localStorage.getItem(J0)==="true"}catch{return!1}}function Hy(e){try{window.localStorage.setItem(J0,e?"true":"false")}catch{}}function ba(){return{enabled:M2(),durationSeconds:R2(),persistUntilDismissed:N2()}}function T2(e){if(typeof window<"u"){try{window.localStorage.setItem(tg,e?"true":"false")}catch{}rg()}return ba()}function Py(e){const t=iw(e);if(typeof window<"u"){try{window.localStorage.setItem(ig,String(t))}catch{}rg()}return ba()}function D2(e){if(typeof window<"u"){try{window.localStorage.setItem(ng,e?"true":"false")}catch{}rg()}return ba()}function tw(e){if(typeof window>"u")return()=>{};const t=s=>{(s.key===tg||s.key===ig||s.key===ng)&&e()};return window.addEventListener(xp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(xp,e),window.removeEventListener("storage",t)}}function sg(){return wh()?window.Notification.permission:"unsupported"}function R2(){if(typeof window>"u")return Vo;try{const e=window.localStorage.getItem(ig);return e===null?Vo:iw(Number(e))}catch{return Vo}}function M2(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(tg)!=="false"}catch{return!0}}function N2(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(ng)==="true"}catch{return!1}}function iw(e){if(!Number.isFinite(e))return Vo;const t=Math.round(e*2)/2;return Math.max(Ep,Math.min(kp,t))}function rg(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(xp))}async function A2(){if(!wh())return"unsupported";try{return await window.Notification.requestPermission()}catch{return sg()}}function L2(e){if(!wh()||sg()!=="granted"||!ew()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const B2=1500,ag="nterminal.terminal.fontSize",lg="nterminal.terminal.fontFamily",Tp="nterminal:terminal-font-size",Dp="nterminal:terminal-font-family",Rp=11,Mp=20,ma=14,Qu=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],Sl="meslo";Np(Sl);async function Wf(e=ma,t=Sl){if(typeof document>"u"||!document.fonts)return;const s=rw(t).webFontFamilies;if(s.length===0)return;const r=Promise.all(s.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([r,new Promise(o=>{globalThis.setTimeout(o,B2)})])}function nw(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return ma;const s=Math.round(t);return Math.max(Rp,Math.min(Mp,s))}function sw(e){return Qu.some(t=>t.id===e)?e:Sl}function Np(e){return rw(e).cssFamily}function rw(e){return Qu.find(t=>t.id===e)??Qu[0]}function Ap(){if(typeof window>"u")return ma;try{const e=window.localStorage.getItem(ag);return e?nw(e):ma}catch{return ma}}function Lp(){if(typeof window>"u")return Sl;try{return sw(window.localStorage.getItem(lg))}catch{return Sl}}function wu(e){const t=nw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(ag,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Tp,{detail:t})),t}function O2(e){const t=sw(e);if(typeof window>"u")return t;try{window.localStorage.setItem(lg,t)}catch{}return window.dispatchEvent(new CustomEvent(Dp,{detail:t})),t}function aw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===ag&&e()};return window.addEventListener(Tp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Tp,e),window.removeEventListener("storage",t)}}function lw(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===lg&&e()};return window.addEventListener(Dp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Dp,e),window.removeEventListener("storage",t)}}const og="nterminal.terminal.showScrollProgress",Bp="nterminal:terminal-scroll-progress";function Op(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(og)!=="false"}catch{return!0}}function z2(e){if(typeof window<"u"){try{window.localStorage.setItem(og,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(Bp,{detail:e}))}return e}function ow(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===og&&e()};return window.addEventListener(Bp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Bp,e),window.removeEventListener("storage",t)}}const cg="nterminal.shortcuts.workspace.v1",zp="nterminal:workspace-shortcuts",Jo=[{id:"server.previous",label:"Previous workspace",group:"Workspaces"},{id:"server.next",label:"Next workspace",group:"Workspaces"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"},{id:"history.toggle",label:"Toggle view history",group:"Panes",requiresPrimaryModifier:!0}],Ch={"server.previous":Ai("ArrowUp",{ctrlKey:!0}),"server.next":Ai("ArrowDown",{ctrlKey:!0}),"tab.previous":Ai("ArrowLeft",{ctrlKey:!0}),"tab.next":Ai("ArrowRight",{ctrlKey:!0}),"tab.index":Ai("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Ai("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Ai("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Ai("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Ai("KeyH",{altKey:!0})},j2={"server.previous":Ai("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Ai("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Ai("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Ai("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Ai("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Ai("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Ai("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Ai("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"history.toggle":Ai("KeyH",{altKey:!0})};function ya(){const e=hw(Ch);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(cg);if(!t)return e;const s=JSON.parse(t);for(const r of Jo){const o=s[r.id];if(q2(o)){const c=dw(o,r);F2(c,j2[r.id])||(e[r.id]=c)}}}catch{return e}return e}function Uy(){return JSON.stringify(ya())}function H2(e,t){const s=ya(),r=Jo.find(o=>o.id===e);return r&&(s[e]=dw(t,r),dg(s)),s}function P2(e){const t=ya();return t[e]={...Ch[e]},dg(t),t}function U2(){const e=hw(Ch);return dg(e),e}function ug(e){if(typeof window>"u")return()=>{};const t=s=>{s.key===cg&&e()};return window.addEventListener(zp,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zp,e),window.removeEventListener("storage",t)}}function I2(e,t){const s=mw(e);return!s||V2(s)||t.indexed&&pw(e)===null||t.requiresPrimaryModifier&&!fw(e)?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":s}}function cw(e){const t=ya();for(const s of Jo){const r=t[s.id];if(!(!r||!$2(e,r))){if(s.indexed){if(r.code!=="Digit")continue;const o=pw(e);if(o!==null)return{id:s.id,index:o};continue}if(mw(e)===r.code)return{id:s.id,index:null}}}return null}function hg(e){return uw(ya()[e])}function uw(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(Y2(e.code)),t.join("+")}const K2=()=>hg("split.right"),W2=()=>hg("split.down");function Ai(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function hw(e){return Object.fromEntries(Object.entries(e).map(([t,s])=>[t,{...s}]))}function F2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function dg(e){if(!(typeof window>"u")){try{window.localStorage.setItem(cg,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(zp))}}function dw(e,t){return t.requiresPrimaryModifier&&!fw(e)?{...Ch[t.id]}:{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function fw(e){return e.ctrlKey||e.altKey||e.metaKey}function q2(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 $2(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function pw(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 mw(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 V2(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function Y2(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const s=/^Key([A-Z])$/.exec(e);if(s?.[1])return s[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const X2="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 G2(e="nterminal",t=new Date){return{reason:"permission",message:X2,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart-after-update`,detectedAt:t.toISOString()}}function Z2(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 gw=3600*1e3,Q2="local",jp=new Set,Lr=new Map;let jr={checking:!1,hasUpdates:!1,lastCheckedAt:null},fg=null,Yo=null,Ju=0,Dr=null;function J2(e){return jp.add(e),()=>{jp.delete(e)}}function Iy(){return jr}function eT(e){const t=rT();fg=e,pg(),Hp(e,t);const s=()=>{if(document.visibilityState!=="visible"||!Hr(e,t))return;const r=jr.lastCheckedAt;(r===null||Date.now()-r>=gw)&&Hp(e,t)};return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),Hr(e,t)&&sT()}}function tT(e,t){Lr.set(e,_w(t)),wl({...jr,hasUpdates:mg(),lastCheckedAt:Date.now()})}function Ff(e){e===void 0?Lr.clear():Lr.set(e,!1),wl({...jr,hasUpdates:mg()})}async function Hp(e,t){if(!Hr(e,t))return;if(Dr&&Dr.api===e&&Dr.runId===t)return Dr.promise;wl({...jr,checking:!0});const s=iT(e,t).finally(()=>{Dr?.promise===s&&(Dr=null),Hr(e,t)&&(wl({...jr,checking:!1,lastCheckedAt:Date.now()}),nT(e,t))});return Dr={api:e,runId:t,promise:s},s}async function iT(e,t){try{const s=await e.listAgents();if(!Hr(e,t))return;const r=[{key:Q2,check:()=>e.checkUpdate()},...s.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(r.map(async c=>{try{const h=await c.check();o.set(c.key,_w(h))}catch{o.set(c.key,Lr.get(c.key)??!1)}})),!Hr(e,t))return;Lr.clear();for(const[c,h]of o)Lr.set(c,h);wl({...jr,hasUpdates:mg()})}catch{}}function nT(e,t){Hr(e,t)&&(pg(),Yo=window.setTimeout(()=>{Yo=null,Hr(e,t)&&Hp(e,t)},gw))}function sT(){Ju+=1,pg(),fg=null,Dr=null,Lr.clear(),wl({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function pg(){Yo!==null&&(window.clearTimeout(Yo),Yo=null)}function rT(){return Ju+=1,Ju}function Hr(e,t){return fg===e&&Ju===t}function _w(e){return e.updateAvailable===!0}function mg(){return Array.from(Lr.values()).some(Boolean)}function wl(e){jr=e;for(const t of Array.from(jp))t()}const aT=e=>new Promise(t=>setTimeout(t,e));function lT({api:e,onAgentRemoved:t}){const[s,r]=v.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=v.useState({}),[h,f]=v.useState(!1),[g,p]=v.useState(null),[y,b]=v.useState(!1),[w,S]=v.useState(null),[E,T]=v.useState(!1),[O,L]=v.useState(null);function N(D,G){c(me=>({...me,[D]:{...me[D],...G}}))}const I=D=>D.id===null?e.getVersion():e.getAgentVersion(D.id),U=D=>D.id===null?e.checkUpdate():e.checkAgentUpdate(D.id),Q=D=>D.id===null?e.runUpdate():e.runAgentUpdate(D.id);v.useEffect(()=>{let D=!1;e.listAgents().then(me=>{if(D)return;const R=[{key:"local",id:null,name:"Local (main)"},...me.agents.map(H=>({key:H.id,id:H.id,name:H.name}))];r(R);for(const H of R)I(H).then(ee=>N(H.key,{version:ee,manualUpdate:ee.manualUpdate??null})).catch(ee=>N(H.key,{error:ee instanceof Error?ee.message:"unreachable"}))}).catch(()=>{});const G=e.getDistributedCallSettings;return typeof G=="function"&&G().then(me=>{D||S(me)}).catch(me=>{D||L(me instanceof Error?me.message:"failed to load distributed call settings")}),()=>{D=!0}},[]);async function ie(D){N(D.key,{busy:!0,status:"checking…",error:void 0});try{const G=await U(D);tT(D.key,G),N(D.key,{latestVersion:G.latestVersion,updateAvailable:G.updateAvailable,status:V(G),...G.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(G){N(D.key,{busy:!1,error:G instanceof Error?G.message:"check failed"})}}async function le(){f(!0),await Promise.all(s.map(D=>ie(D))),f(!1)}async function ce(D,G){const me=Date.now()+18e4;for(;Date.now()<me;){await aT(3e3);try{const R=await I(D);if(G&&R.runningVersion!==G.runningVersion)return R}catch{}}return null}async function ve(D){let G=o[D.key]?.version;if(!G)try{G=await I(D),N(D.key,{version:G,manualUpdate:G.manualUpdate??null})}catch(H){return N(D.key,{busy:!1,error:H instanceof Error?H.message:"version check failed"}),"failed"}N(D.key,{busy:!0,status:"updating…",error:void 0});let me;try{me=await Q(D)}catch(H){return N(D.key,{busy:!1,error:H instanceof Error?H.message:"update failed"}),"failed"}if(!me.ok){const H=me.manualUpdate??(Z2(me.message)?G2():null);return H?(N(D.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:H}),"manual"):(N(D.key,{busy:!1,status:void 0,error:me.message}),"failed")}if(!me.changed)return N(D.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),Ff(D.key),"unchanged";N(D.key,{status:"restarting…"});const R=await ce(D,G);return R?(N(D.key,{busy:!1,version:R,updateAvailable:!1,status:"updated",manualUpdate:R.manualUpdate??null}),Ff(D.key),D.id===null&&(b(!0),p("Main server updated. Reload the page to use the new client.")),"updated"):(N(D.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function we(D){if(!(D.id===null||!window.confirm([`Delete secondary server "${D.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
|
|
15
|
+
`)))){N(D.key,{busy:!0,status:"deleting…",error:void 0}),p(null);try{const me=await e.uninstallAgent(D.id);r(R=>R.filter(H=>H.key!==D.key)),c(R=>{const H={...R};return delete H[D.key],H}),Ff(D.key),t?.(D.id),p(me.message)}catch(me){N(D.key,{busy:!1,status:void 0,error:me instanceof Error?me.message:"delete failed"})}}}async function ne(){f(!0),p(null);const D=s.filter(de=>de.id!==null),G=s.find(de=>de.id===null),me=await Promise.all(D.map(de=>ve(de))),R=me.filter(de=>de==="failed").length;let H=me.filter(de=>de==="manual").length,ee=null;if(G&&(ee=await ve(G),ee==="manual"&&(H+=1),ee==="updated")){R>0&&p("Main server updated. Reload the page to use the new client. Some secondary servers failed; check their rows and retry."),f(!1);return}R>0&&H>0?p("Some servers failed and some need manual update. Check each marked row."):R>0?p("Some secondary servers failed to update. Check their rows and retry."):H>0&&p("Some servers need manual update. Copy and run the command shown on each marked server."),f(!1)}function se(D){return D?D.error?D.error:D.status?D.status:D.manualUpdate?"manual update required":D.version?`v${D.version.version}`:"…":"…"}function V(D){return D.error?D.error:typeof D.updateAvailable=="boolean"?D.updateAvailable?`latest v${D.latestVersion??"available"}`:"up to date":"unknown"}function F(D){const G=D?.version;return G?`npm package v${G.runningVersion}`:""}async function re(D,G){try{await oT(G),N(D,{copiedCommand:!0}),window.setTimeout(()=>N(D,{copiedCommand:!1}),1800)}catch(me){N(D,{error:me instanceof Error?me.message:"copy failed"})}}async function B(D){if(!(!w||E)){T(!0),L(null);try{const G=await e.updateDistributedCallSettings(D);S(G)}catch(G){L(G instanceof Error?G.message:"failed to save distributed call settings")}finally{T(!1)}}}function W(D,G){if(!w)return;const me=new Set(w.settings.workerIds);G?me.add(D):me.delete(D),B({workerIds:Array.from(me)})}return m.jsxs("section",{className:"security-section",children:[m.jsx("h3",{children:"Servers"}),m.jsxs("div",{className:"update-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{le()},disabled:h,children:"Check for updates"}),m.jsx("button",{type:"button",onClick:()=>{ne()},disabled:h,children:"Update all"})]}),g?m.jsx("p",{className:"settings-status",children:g}):null,y?m.jsxs("div",{className:"server-reload-required",role:"status",children:[m.jsx("span",{children:"Main server update is ready."}),m.jsx("button",{type:"button",onClick:()=>window.location.reload(),children:"Reload page"})]}):null,m.jsxs("div",{className:"server-addon-panel",children:[m.jsxs("div",{className:"server-addon-header",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:"Distributed calls"}),m.jsx("span",{className:"security-item-meta",children:"Programmatic worker fan-out for trusted NTerminal servers."})]}),m.jsxs("label",{className:"auth-checkbox server-addon-toggle",children:[m.jsx("input",{type:"checkbox",checked:w?.settings.enabled??!1,disabled:!w||E,onChange:D=>{B({enabled:D.currentTarget.checked})}}),"Enabled"]})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:w?.settings.allowPrivateTargets??!1,disabled:!w||E||!(w?.settings.enabled??!1),onChange:D=>{B({allowPrivateTargets:D.currentTarget.checked})}}),"Allow private network targets when the CLI also requests it"]}),w?m.jsx("div",{className:"server-addon-workers","aria-label":"Distributed call workers",children:w.workers.map(D=>m.jsxs("label",{className:"auth-checkbox server-addon-worker",children:[m.jsx("input",{type:"checkbox",checked:D.enabled,disabled:E||!w.settings.enabled,onChange:G=>W(D.id,G.currentTarget.checked)}),m.jsx("span",{children:D.id===Nr?"Local (main)":D.name})]},D.id))}):null,O?m.jsx("p",{className:"settings-status settings-status-error",children:O}):null]}),m.jsx("ul",{className:"security-list",children:s.map(D=>{const G=o[D.key],me=F(G),R=G?.manualUpdate??null,H=G?.version!==void 0&&G?.updateAvailable!==!1&&!G?.busy&&!h,ee=D.id!==null&&!G?.busy&&!h;return m.jsxs("li",{children:[m.jsxs("div",{className:"server-row-main",children:[m.jsxs("div",{children:[m.jsx("span",{className:"security-item-label",children:D.name}),m.jsxs("span",{className:"security-item-meta",children:[me?`${me} — `:"",se(G)]})]}),R?m.jsxs("div",{className:"server-manual-update",children:[m.jsx("span",{children:R.message}),m.jsxs("div",{className:"server-manual-command",children:[m.jsx("code",{children:R.command}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{re(D.key,R.command)},children:G?.copiedCommand?"Copied":"Copy"})]})]}):null]}),m.jsxs("div",{className:"server-row-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{ve(D)},disabled:!H,children:G?.busy?"…":"Update"}),D.id!==null?m.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{we(D)},disabled:!ee,children:"Delete"}):null]})]},D.key)})})]})}async function oT(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 Cu=[{id:"appearance",label:"Appearance"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"diagnostics",label:"Diagnostics"},{id:"servers",label:"Servers"}];function cT({onClose:e,api:t,updateAvailable:s=!1,onNotificationAssetsChanged:r,onAgentRemoved:o}){const c=v.useMemo(()=>t??ph(),[t]),[h,f]=v.useState(()=>Ap()),[g,p]=v.useState(()=>Lp()),[y,b]=v.useState(()=>Op()),[w,S]=v.useState(()=>Or()),[E,T]=v.useState(()=>ya()),[O,L]=v.useState(null),[N,I]=v.useState(null),[U,Q]=v.useState("appearance"),[ie,le]=v.useState(()=>ew()),[ce,ve]=v.useState(()=>ba()),[we,ne]=v.useState(()=>sg()),[se,V]=v.useState([]),[F,re]=v.useState([]),[B,W]=v.useState([]),[D,G]=v.useState(5*1024*1024),[me,R]=v.useState(!1),[H,ee]=v.useState(null),[de,Ee]=v.useState(()=>fa()),[ke,Me]=v.useState(!1),[Fe,_e]=v.useState(null),X=v.useRef(null),he=v.useRef(null),Ce=v.useRef({appearance:null,shortcuts:null,notifications:null,security:null,diagnostics:null,servers:null}),be=v.useMemo(()=>new Set(F),[F]),De=!fT(F,B);v.useEffect(()=>aw(()=>f(Ap())),[]),v.useEffect(()=>lw(()=>p(Lp())),[]),v.useEffect(()=>ow(()=>b(Op())),[]),v.useEffect(()=>qm(()=>S(Or())),[]),v.useEffect(()=>ug(()=>T(ya())),[]),v.useEffect(()=>tw(()=>ve(ba())),[]),v.useEffect(()=>{const K=()=>Ee(fa());K();const $e=window.setInterval(K,1500);return()=>window.clearInterval($e)},[]),v.useEffect(()=>{if(!O)return;const K=Jo.find(ot=>ot.id===O);if(!K)return;const $e=ot=>{if(ot.preventDefault(),ot.stopPropagation(),ot.key==="Escape"){L(null),I(null);return}const wt=I2(ot,K);if(!wt){I(dT(K));return}T(H2(O,wt)),L(null),I(null)};return window.addEventListener("keydown",$e,!0),()=>window.removeEventListener("keydown",$e,!0)},[O]),v.useEffect(()=>{let K=!1;return c.listNotificationAssets().then($e=>{K||He($e)}).catch($e=>{K||ee(ul($e))}),()=>{K=!0}},[c]);function Oe(K){f(wu(Number(K)))}function Ie(K){ve(Py(Number(K)))}function oe(K){Q(K);const $e=he.current,ot=Ce.current[K];if(!$e||!ot)return;const wt=Math.max(0,Ky(ot,$e)-12);typeof $e.scrollTo=="function"?$e.scrollTo({top:wt,behavior:"smooth"}):$e.scrollTop=wt}function xe(){const K=he.current;if(!K)return;if(K.scrollTop+K.clientHeight>=K.scrollHeight-2){Q(Cu[Cu.length-1].id);return}let $e="appearance";const ot=K.scrollTop+Math.min(180,Math.max(48,K.clientHeight*.28));for(const wt of Cu){const li=Ce.current[wt.id];li&&Ky(li,K)<=ot&&($e=wt.id)}Q($e)}function Ae(K){T(P2(K)),L(null),I(null)}function ze(){T(U2()),L(null),I(null)}function He(K){const $e=K.assets.filter(ot=>ot.enabled).map(ot=>ot.id);V(K.assets),re($e),W($e),G(K.maxFileBytes),ee(null)}async function gt(){if(ie){Hy(!1),le(!1);return}let K=we;K==="default"&&(K=await A2(),ne(K)),K==="granted"&&(Hy(!0),le(!0))}async function Xe(K){const $e=K?.[0];if($e){if($e.size>D){ee(`File must be ${qf(D)} or smaller.`),ei();return}if($e.type!=="video/mp4"&&$e.type!=="video/webm"){ee("Upload an MP4 or WebM video."),ei();return}R(!0),ee(null);try{await c.uploadNotificationAsset($e),He(await c.listNotificationAssets()),r?.()}catch(ot){ee(ul(ot))}finally{R(!1),ei()}}}async function st(K){R(!0),ee(null);try{await c.deleteNotificationAsset(K),He(await c.listNotificationAssets()),r?.()}catch($e){ee(ul($e))}finally{R(!1)}}function ei(){X.current&&(X.current.value="")}function an(K,$e){const ot=new Set(F);if($e?ot.add(K):ot.delete(K),ot.size===0){ee("Keep at least one toast video selected.");return}ee(null),re(Array.from(ot))}async function ki(){if(F.length===0){ee("Keep at least one toast video selected.");return}R(!0),ee(null);try{const K=await c.updateNotificationAssetSelection({enabledAssetIds:F});He(K),r?.()}catch(K){ee(ul(K))}finally{R(!1)}}async function ti(){_e(null),Me(!0);try{const K=await f2();_e(K?"Diagnostics copied.":"Copy failed in this browser."),Ee(fa())}catch(K){_e(ul(K))}finally{Me(!1)}}async function Ti(){_e(null),Me(!0);try{const K=await yh("manual-settings");_e(`Sent ${K.accepted} diagnostic events.`),Ee(fa())}catch(K){_e(ul(K))}finally{Me(!1)}}function Jn(){h2(),Ee([]),_e("Diagnostics cleared.")}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:m.jsxs("div",{className:"security-panel settings-panel",onClick:K=>K.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{children:"Settings"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),m.jsxs("div",{className:"settings-layout",children:[m.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Cu.map(K=>m.jsxs("button",{type:"button","data-active":U===K.id?"true":"false","aria-current":U===K.id?"true":void 0,onClick:()=>oe(K.id),children:[K.label,K.id==="servers"&&s?m.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},K.id))}),m.jsxs("div",{ref:he,className:"settings-content",onScroll:xe,children:[m.jsxs("section",{id:"settings-appearance",ref:K=>{Ce.current.appearance=K},className:"security-section settings-section",children:[m.jsx("h3",{children:"Appearance"}),m.jsx("div",{className:"settings-section-heading",children:m.jsxs("div",{children:[m.jsx("span",{className:"settings-control-title",children:"Theme"}),m.jsx("p",{className:"muted settings-control-description",children:"Choose the workspace and terminal color preset."})]})}),m.jsx("div",{className:"settings-theme-picker",role:"radiogroup","aria-label":"Interface theme",children:Vu.map(K=>m.jsxs("button",{type:"button",className:"settings-theme-card",role:"radio","aria-checked":w===K.id,"data-active":w===K.id?"true":"false",onClick:()=>S(pE(K.id)),style:{"--settings-theme-bg":K.tokens.bg,"--settings-theme-bg-2":K.tokens.bg2,"--settings-theme-sidebar":K.tokens.bgSidebar,"--settings-theme-line":K.tokens.line,"--settings-theme-fg":K.tokens.fg,"--settings-theme-fg-2":K.tokens.fg2,"--settings-theme-accent":K.tokens.accent,"--settings-theme-xterm-bg":K.xterm.background,"--settings-theme-xterm-fg":K.xterm.foreground,"--settings-theme-xterm-selection":K.xterm.selectionBackground},children:[m.jsxs("span",{className:"settings-theme-preview","aria-hidden":"true",children:[m.jsxs("span",{className:"settings-theme-preview-sidebar",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-main",children:[m.jsxs("span",{className:"settings-theme-preview-tabs",children:[m.jsx("span",{}),m.jsx("span",{})]}),m.jsxs("span",{className:"settings-theme-preview-terminal",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})]})]}),m.jsxs("span",{className:"settings-theme-card-copy",children:[m.jsx("strong",{children:K.label}),m.jsx("small",{children:K.description})]})]},K.id))}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font size"}),m.jsxs("span",{className:"settings-control-value",children:[h,"px"]}),m.jsx("input",{type:"range",min:Rp,max:Mp,step:1,value:h,"aria-label":"Terminal font size",onChange:K=>Oe(K.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row",children:[m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(wu(h-1)),children:"-"}),m.jsx("input",{type:"number",min:Rp,max:Mp,step:1,value:h,"aria-label":"Terminal font size value",onChange:K=>Oe(K.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>f(wu(h+1)),children:"+"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>f(wu(ma)),children:"Reset"})]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Font family"}),m.jsx("select",{value:g,"aria-label":"Terminal font family",onChange:K=>p(O2(K.currentTarget.value)),children:Qu.map(K=>m.jsx("option",{value:K.id,children:K.label},K.id))})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:y,onChange:K=>b(z2(K.currentTarget.checked))}),"Show scroll progress"]})]}),m.jsxs("section",{id:"settings-shortcuts",ref:K=>{Ce.current.shortcuts=K},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsx("h3",{children:"Shortcuts"}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:ze,children:"Reset all"})]}),m.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),N?m.jsx("p",{className:"settings-error",children:N}):null,m.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:Jo.map(K=>{const $e=O===K.id;return m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("span",{className:"settings-shortcut-label",children:K.label}),m.jsx("span",{className:"settings-shortcut-group",children:K.group})]}),m.jsxs("div",{className:"settings-shortcut-actions",children:[m.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":$e?"true":"false",onClick:()=>{L(K.id),I(null)},children:$e?"Press keys…":uw(E[K.id])}),m.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Ae(K.id),children:"Reset"})]})]},K.id)})})]}),m.jsxs("section",{id:"settings-notifications",ref:K=>{Ce.current.notifications=K},className:"security-section settings-section",children:[m.jsx("h3",{children:"Notifications"}),wh()?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:ie&&we==="granted",onChange:()=>{gt()},disabled:we==="denied"}),"System notification when page is hidden"]}),we==="denied"?m.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):m.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):m.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:ce.enabled,onChange:K=>ve(T2(K.currentTarget.checked))}),"Show animated completion toast"]}),m.jsxs("label",{className:"settings-control",children:[m.jsx("span",{children:"Toast duration"}),m.jsx("span",{className:"settings-control-value",children:ce.persistUntilDismissed?"Until closed":`${ce.durationSeconds}s`}),m.jsx("input",{type:"range",min:Ep,max:kp,step:.5,value:ce.durationSeconds,disabled:!ce.enabled||ce.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:K=>Ie(K.currentTarget.value)})]}),m.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[m.jsx("input",{type:"number",min:Ep,max:kp,step:.5,value:ce.durationSeconds,disabled:!ce.enabled||ce.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:K=>Ie(K.currentTarget.value)}),m.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!ce.enabled||ce.persistUntilDismissed,onClick:()=>ve(Py(Vo)),children:"Reset"})]}),m.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[m.jsx("input",{type:"checkbox",checked:ce.persistUntilDismissed,disabled:!ce.enabled,onChange:K=>ve(D2(K.currentTarget.checked))}),"Keep toast until dismissed"]}),m.jsxs("div",{className:"settings-assets-header",children:[m.jsx("span",{children:"Toast videos"}),m.jsxs("span",{children:[qf(D)," max"]})]}),m.jsx("input",{ref:X,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:K=>{Xe(K.currentTarget.files)}}),m.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:me,onClick:()=>X.current?.click(),children:"Upload video"}),H?m.jsx("p",{className:"settings-error",children:H}):null,se.length>0?m.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:se.map(K=>m.jsxs("li",{"data-enabled":be.has(K.id)?"true":"false",children:[m.jsxs("label",{className:"settings-asset-choice",children:[m.jsx("input",{type:"checkbox",checked:be.has(K.id),disabled:me,"aria-label":`Use ${K.filename}`,onChange:$e=>an(K.id,$e.currentTarget.checked)}),m.jsx("video",{src:K.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),m.jsxs("span",{className:"settings-asset-copy",children:[m.jsx("span",{children:K.filename}),m.jsx("small",{children:K.source==="built-in"?"Built-in":qf(K.size)})]})]}),K.source==="uploaded"?m.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:me,"aria-label":`Delete ${K.filename}`,onClick:()=>{st(K.id)},children:"x"}):null]},K.id))}):m.jsx("p",{className:"muted",children:"Built-in videos will be used."}),m.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:me||se.length===0||!De,onClick:()=>{ki()},children:"Save selected videos"})]}),m.jsx("div",{id:"settings-security",ref:K=>{Ce.current.security=K},className:"settings-section-group",children:m.jsx(l2,{api:c})}),m.jsxs("section",{id:"settings-diagnostics",ref:K=>{Ce.current.diagnostics=K},className:"security-section settings-section",children:[m.jsxs("div",{className:"settings-section-heading",children:[m.jsxs("div",{children:[m.jsx("h3",{children:"Diagnostics"}),m.jsx("p",{className:"muted settings-control-description",children:"Recent browser lifecycle and auth transition events for troubleshooting."})]}),m.jsx("span",{className:"settings-diagnostics-count",children:de.length})]}),m.jsxs("div",{className:"settings-diagnostics-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",disabled:ke||de.length===0,onClick:()=>{ti()},children:"Copy"}),m.jsx("button",{type:"button",className:"secondary-button",disabled:ke||de.length===0,onClick:()=>{Ti()},children:"Send"}),m.jsx("button",{type:"button",className:"secondary-button",disabled:ke||de.length===0,onClick:Jn,children:"Clear"})]}),Fe?m.jsx("p",{className:"settings-status",children:Fe}):null,de.length>0?m.jsx("ol",{className:"settings-diagnostics-list","aria-label":"Recent diagnostics",children:de.slice(-8).reverse().map((K,$e)=>m.jsxs("li",{children:[m.jsx("span",{children:uT(K.at)}),m.jsx("strong",{children:K.event}),K.data?m.jsx("code",{children:hT(K.data)}):null]},`${K.at}:${K.event}:${$e}`))}):m.jsx("p",{className:"muted",children:"No diagnostics recorded yet."})]}),m.jsx("div",{id:"settings-servers",ref:K=>{Ce.current.servers=K},className:"settings-section-group",children:m.jsx(lT,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function Ky(e,t){const s=e.getBoundingClientRect(),r=t.getBoundingClientRect();return s.top-r.top+t.scrollTop}function qf(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 ul(e){return e instanceof Error?e.message:"Request failed."}function uT(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function hT(e){return Object.entries(e).slice(0,5).map(([t,s])=>`${t}=${String(s)}`).join(" ")}function dT(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 fT(e,t){if(e.length!==t.length)return!1;const s=new Set(t);return e.every(r=>s.has(r))}class aa extends Error{constructor(t,s){super(s),this.status=t,this.name="UploadClientError"}status}function pT(e){const t=e.createXhr?.()??new XMLHttpRequest,s=new FormData,r=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));s.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:r}));for(const[o,c]of e.files.entries())s.append(`file${o}`,c.file);return new Promise((o,c)=>{let h=!1;const f=()=>{e.signal?.removeEventListener("abort",y)},g=b=>{h||(h=!0,f(),o(b))},p=b=>{h||(h=!0,f(),c(b))},y=()=>{t.abort(),p(new aa(0,"Upload aborted."))};if(e.signal?.aborted){p(new aa(0,"Upload aborted."));return}e.signal?.addEventListener("abort",y,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=b=>{if(e.onProgress){if(b.lengthComputable&&b.total>0){e.onProgress({loaded:b.loaded,total:b.total,percent:Math.round(b.loaded/b.total*100)});return}e.onProgress({loaded:b.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{g(JSON.parse(t.responseText))}catch{p(new aa(t.status,"Invalid upload response."))}return}p(new aa(t.status,mT(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>p(new aa(0,"Upload failed.")),t.onabort=()=>p(new aa(0,"Upload aborted.")),t.ontimeout=()=>p(new aa(0,"Upload timed out.")),t.send(s)})}function mT(e,t){try{const s=JSON.parse(e),r=typeof s.error=="string"?s.error:s.message;if(typeof r=="string"&&r.trim())return r}catch{}return t}const gT="modulepreload",_T=function(e){return"/"+e},Wy={},gg=function(t,s,r){let o=Promise.resolve();if(s&&s.length>0){let g=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),f=h?.nonce||h?.getAttribute("nonce");o=g(s.map(p=>{if(p=_T(p),p in Wy)return;Wy[p]=!0;const y=p.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${b}`))return;const w=document.createElement("link");if(w.rel=y?"stylesheet":gT,y||(w.as="script"),w.crossOrigin="",w.href=p,f&&w.setAttribute("nonce",f),document.head.appendChild(w),y)return new Promise((S,E)=>{w.addEventListener("load",S),w.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${p}`)))})}))}function c(h){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=h,window.dispatchEvent(f),!f.defaultPrevented)throw h}return o.then(h=>{for(const f of h||[])f.status==="rejected"&&c(f.reason);return t().catch(c)})},vT=v.lazy(()=>gg(()=>import("./MarkdownPreview-pEj4ukXa.js"),__vite__mapDeps([0,1])));function bT({api:e,activeTerminalId:t,activeTerminalCwd:s,workspaceRootPath:r=null,onOpenFile:o}){const[c,h]=v.useState(null),[f,g]=v.useState(""),[p,y]=v.useState({}),[b,w]=v.useState(()=>new Set),[S,E]=v.useState(null),[T,O]=v.useState({type:"empty"}),[L,N]=v.useState("idle"),[I,U]=v.useState(null),Q=v.useRef(null),ie=v.useRef(null),le=v.useRef(!1),ce=v.useRef(0),ve=v.useRef(null);ve.current===null&&t&&(ve.current=t);const we=ve.current,ne=r?ST(r):t?Fy(t,s):null,se=c?[c.rootPath,f].filter(Boolean).join("/"):"",V=S?.path??null;v.useEffect(()=>(le.current=!0,()=>{le.current=!1,ce.current+=1,he()}),[]),v.useEffect(()=>{ve.current=t,ie.current=null,F(ne)},[e]),v.useEffect(()=>{r&&ne!==ie.current&&re(r,ne)},[r,ne]),v.useEffect(()=>{if(r||!we||t!==we)return;const oe=Fy(we,s);oe!==ie.current&&B(we,oe)},[we,t,s,r]);async function F(oe=ne){if(r){await re(r,oe);return}await B(t,oe)}async function re(oe,xe=ne){const Ae=Ce();if(ie.current=xe,he(),h(null),g(""),y({}),w(new Set),E(null),O({type:"empty"}),U(null),!oe){N("idle");return}N("loading");try{const ze=await e.createFileRoot({path:oe});if(!be(Ae))return;h({rootToken:ze.rootToken,rootPath:ze.rootPath});const He=await e.listFiles({rootToken:ze.rootToken,path:""});if(!be(Ae))return;G(He),N("idle")}catch(ze){be(Ae)&&(U(Ws(ze)),N("idle"))}}async function B(oe,xe=ne){const Ae=Ce();if(ie.current=xe,he(),h(null),g(""),y({}),w(new Set),E(null),O({type:"empty"}),U(null),!oe){N("idle");return}N("loading");try{const ze=await e.createFileRoot({terminalId:oe});if(!be(Ae))return;h({rootToken:ze.rootToken,rootPath:ze.rootPath});const He=await e.listFiles({rootToken:ze.rootToken,path:""});if(!be(Ae))return;G(He),N("idle")}catch(ze){if(await De(ze,Ae))return;be(Ae)&&(U(Ws(ze)),N("idle"))}}async function W(oe=f,xe=c){if(!xe)return;const Ae=Ce();N("loading"),U(null);try{const ze=await e.listFiles({rootToken:xe.rootToken,path:oe});if(!be(Ae))return;G(ze),N("idle")}catch(ze){if(await De(ze,Ae))return;be(Ae)&&(U(Ws(ze)),N("idle"))}}async function D(){if(r){await re(r,ne);return}ve.current=t,await B(t,ne)}function G(oe){y(xe=>({...xe,[oe.path]:wT(oe.entries)}))}async function me(oe){if(!(!$f(oe)||!c)){if(E(oe),U(null),oe.kind==="directory"){g(oe.path),X(),await H(oe);return}if(g(la(oe.path)),oe.editable){await de(oe);return}oe.previewKind!=="none"&&await ke(oe,oe.previewKind)}}async function R(oe){if(!(!$f(oe)||!c)){if(E(oe),U(null),oe.kind==="directory"){g(oe.path),X(),await H(oe);return}if(g(la(oe.path)),oe.editable){await Ee(oe);return}oe.previewKind!=="none"&&await ke(oe,oe.previewKind)}}async function H(oe){if(b.has(oe.path)){w(xe=>{const Ae=new Set(xe);return Ae.delete(oe.path),Ae});return}w(xe=>new Set(xe).add(oe.path)),await W(oe.path)}function ee(oe,xe){oe.key==="Enter"&&(oe.preventDefault(),R(xe))}async function de(oe){if(!c)return;const xe=Ce();N("loading"),he();try{const Ae=await e.readFile({rootToken:c.rootToken,path:oe.path});if(!be(xe))return;O({type:"text-preview",file:oe,read:Ae}),N("idle")}catch(Ae){if(await De(Ae,xe))return;be(xe)&&(U(Ws(Ae)),N("idle"))}}async function Ee(oe){if(!c)return;const xe=Ce();N("loading");try{await o({rootToken:c.rootToken,path:oe.path,...t?{terminalId:t}:{}}),be(xe)&&N("idle")}catch(Ae){if(await De(Ae,xe))return;be(xe)&&(U(Ws(Ae)),N("idle"))}}async function ke(oe,xe){if(!c)return;const Ae=Ce();N("loading"),he();try{const ze=await e.previewFile({rootToken:c.rootToken,path:oe.path});if(!be(Ae))return;const He=URL.createObjectURL(ze);if(!be(Ae)){URL.revokeObjectURL(He);return}Q.current=He,O({type:"preview",file:oe,previewKind:xe,url:He}),N("idle")}catch(ze){if(await De(ze,Ae))return;be(Ae)&&(U(Ws(ze)),N("idle"))}}async function Me(oe){if(!c)return;const xe=oe==="file"?"New file":"New folder",Ae=window.prompt(xe,""),ze=S?S.kind==="directory"?S.path:la(S.path):f,He=qy(Ae,ze);if(He){U(null);try{const gt=await e.createFileEntry({rootToken:c.rootToken,path:He,kind:oe});E(gt.entry),await W(ze)}catch(gt){if(await De(gt))return;U(Ws(gt))}}}async function Fe(){if(!c||!S)return;const oe=window.prompt("Move selected entry",S.path),xe=qy(oe,"");if(!xe||xe===S.path)return;const Ae=la(S.path),ze=la(xe);U(null);try{const He=await e.moveFileEntry({rootToken:c.rootToken,sourcePath:S.path,destinationPath:xe});E(He.entry),g(He.entry.kind==="directory"?He.entry.path:la(He.entry.path)),X(),await W(Ae),ze!==Ae&&await W(ze)}catch(He){if(await De(He))return;U(Ws(He))}}async function _e(){if(!c||!S)return;const oe=S.path,xe=la(oe);U(null);try{const Ae=await e.previewDeleteFileEntry({rootToken:c.rootToken,path:S.path}),ze=Ae.descendantCount>0?` and ${Ae.descendantCount} nested item${Ae.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${Ae.path}${ze}?`))return;await e.deleteFileEntry({rootToken:c.rootToken,path:S.path,previewToken:Ae.previewToken}),E(null),g(xe),w(He=>{const gt=new Set(He);for(const Xe of He)(Xe===oe||Xe.startsWith(`${oe}/`))&>.delete(Xe);return gt}),X(),await W(xe)}catch(Ae){if(await De(Ae))return;U(Ws(Ae))}}function X(){ce.current+=1,he(),O({type:"empty"})}function he(){Q.current&&(URL.revokeObjectURL(Q.current),Q.current=null)}function Ce(){return ce.current+=1,ce.current}function be(oe){return le.current&&oe===ce.current}async function De(oe,xe){return CT(oe)?(xe!==void 0&&!be(xe)||await F(ne),!0):!1}function Oe(oe,xe){const Ae=$f(oe),ze=oe.kind==="directory"&&b.has(oe.path),He=p[oe.path]??[],gt={"--file-tree-depth":xe};return m.jsxs(xi.Fragment,{children:[m.jsxs("button",{type:"button",className:"file-entry-button","data-kind":oe.kind,"data-expanded":ze,"data-active":V===oe.path,disabled:!Ae,style:gt,"aria-expanded":oe.kind==="directory"?ze:void 0,"aria-label":`${oe.kind==="directory"?"Open folder":"Open file"} ${oe.name}`,title:oe.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{me(oe)},onDoubleClick:()=>{R(oe)},onKeyDown:Xe=>ee(Xe,oe),children:[m.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:oe.kind==="directory"?ze?"▾":"▸":""}),m.jsx("span",{className:"file-entry-name",children:oe.name}),m.jsx("small",{children:yT(oe)})]}),ze?m.jsx("div",{className:"file-tree-children",role:"group",children:He.map(Xe=>Oe(Xe,xe+1))}):null]},oe.path)}const Ie=p[""]??[];return m.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[m.jsxs("header",{className:"file-explorer-header",children:[m.jsx("div",{className:"file-explorer-path",title:se,children:se||"No active pane"}),m.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[m.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!r&&!t,onClick:()=>{D()},children:"↻"}),m.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!c,onClick:()=>{Me("file")},children:"+"}),m.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!c,onClick:()=>{Me("directory")},children:"▣"})]})]}),I?m.jsx("div",{className:"file-explorer-alert",role:"alert",children:I}):null,m.jsxs("div",{className:"file-explorer-layout",children:[m.jsx("div",{className:"file-tree","aria-label":se?`Files in ${se}`:"Files",children:Ie.map(oe=>Oe(oe,0))}),m.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[m.jsxs("div",{className:"file-detail-header",children:[m.jsx("strong",{children:S?.name??"detail"}),m.jsxs("div",{className:"file-detail-actions",children:[m.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!S,onClick:()=>{Fe()},children:"Move"}),m.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!S,onClick:()=>{_e()},children:"Delete"})]})]}),L==="loading"?m.jsx("div",{className:"file-detail-empty",children:"loading"}):null,T.type==="empty"&&L!=="loading"?m.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,T.type==="preview"?m.jsxs("div",{className:"file-preview-frame",children:[T.previewKind==="image"?m.jsx("img",{src:T.url,alt:T.file.name}):null,T.previewKind==="pdf"?m.jsx("iframe",{src:T.url,title:T.file.name}):null]}):null,T.type==="text-preview"&&T.read.language==="markdown"?m.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${T.file.name}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:m.jsx(vT,{content:T.read.content})})}):null,T.type==="text-preview"&&T.read.language==="text"?m.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${T.file.name}`,children:T.read.content}):null]})]})]})}function $f(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function yT(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function Fy(e,t){return`${e}\0${t??""}`}function ST(e){return`workspace\0${e}`}function wT(e){return[...e].sort((t,s)=>t.kind==="directory"&&s.kind!=="directory"?-1:t.kind!=="directory"&&s.kind==="directory"?1:t.name.localeCompare(s.name))}function la(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function qy(e,t){if(e===null)return null;const s=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return s?!t||s.includes("/")?s:`${t}/${s}`:null}function Ws(e){return e instanceof Error?e.message:"Request failed"}function CT(e){return e instanceof cs&&e.status===409&&e.message==="terminal_cwd_changed"}const xT=v.lazy(()=>gg(()=>import("./MarkdownPreview-pEj4ukXa.js"),__vite__mapDeps([0,1])));function $y({api:e,editor:t,canClose:s,onClose:r}){const[o,c]=v.useState(t.read),[h,f]=v.useState(t.read.content),[g,p]=v.useState("idle"),[y,b]=v.useState(null),[w,S]=v.useState(!1),[E,T]=v.useState("edit"),O=v.useRef(t),L=v.useRef(t.read),N=v.useRef(t.read.content),I=v.useRef(!1),U=v.useRef(!1),Q=v.useRef(0),ie=h!==o.content&&g!=="saving"&&!w;v.useEffect(()=>(U.current=!0,()=>{U.current=!1,Q.current+=1}),[]),v.useEffect(()=>{Q.current+=1,I.current=!1,O.current=t,L.current=t.read,N.current=t.read.content,c(t.read),f(t.read.content),p("idle"),b(null),S(!1),T("edit")},[t.id,t.read]),v.useEffect(()=>{O.current=t},[t]),v.useEffect(()=>{L.current=o},[o]),v.useEffect(()=>{N.current=h},[h]),v.useEffect(()=>{if(h===o.content||w)return;const ne=window.setInterval(()=>{!I.current&&N.current!==L.current.content&&le()},1e3);return()=>window.clearInterval(ne)},[h===o.content,w,t.id]);async function le(){if(I.current)return;const ne=N.current,se=L.current;if(ne===se.content)return;const V=O.current,F=Q.current;I.current=!0,p("saving"),b(null),S(!1);try{const re=await e.writeFile({rootToken:V.rootToken,path:V.path,content:ne,expectedVersion:se.version});if(!U.current||F!==Q.current)return;const B={...se,content:ne,version:re.version};L.current=B,c(B),p(N.current===ne?"saved":"idle")}catch(re){if(!U.current||F!==Q.current)return;if(re instanceof cs&&re.status===409){S(!0),p("idle");return}b(ET(re)),p("idle")}finally{F===Q.current&&(I.current=!1)}}const ce=g==="saving"?"saving":g==="saved"?"saved":o.language,ve=o.language==="markdown",we=ve&&E==="preview";return m.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[m.jsxs("header",{className:"editor-pane-header",children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("strong",{children:t.title}),m.jsx("span",{className:"terminal-pane-spacer"}),m.jsx("span",{className:"terminal-pane-state",children:ce}),m.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!ie,onClick:()=>{le()},children:"Save"}),ve?m.jsx("button",{type:"button","aria-label":`${we?"Edit":"Preview"} ${t.title}`,onClick:()=>T(ne=>ne==="preview"?"edit":"preview"),children:we?"Edit":"Preview"}):null,s?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:r,children:"x"}):null]}),y?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:y}):null,w?m.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,we?m.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:m.jsx(v.Suspense,{fallback:m.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:m.jsx(xT,{content:h})})}):m.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:h,onChange:ne=>{const se=ne.target.value;N.current=se,f(se),p("idle"),b(null),S(!1)}})]})}function ET(e){return e instanceof Error?e.message:"Request failed"}var kT=2,TT=1,DT=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),o=Math.max(0,parseInt(s.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),h={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},f=h.top+h.bottom,g=h.right+h.left,p=r-f,y=o-g-t;return{cols:Math.max(kT,Math.floor(y/e.css.cell.width)),rows:Math.max(TT,Math.floor(p/e.css.cell.height))}}};var vw=Object.defineProperty,RT=Object.getOwnPropertyDescriptor,MT=(e,t)=>{for(var s in t)vw(e,s,{get:t[s],enumerable:!0})},Jt=(e,t,s,r)=>{for(var o=r>1?void 0:r?RT(t,s):t,c=e.length-1,h;c>=0;c--)(h=e[c])&&(o=(r?h(t,s,o):h(o))||o);return r&&o&&vw(t,s,o),o},Re=(e,t)=>(s,r)=>t(s,r,e),Vy="Terminal input",Pp={get:()=>Vy,set:e=>Vy=e},Yy="Too much output to announce, navigate to rows manually to read",Up={get:()=>Yy,set:e=>Yy=e};function NT(e){return e.replace(/\r?\n/g,"\r")}function AT(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function LT(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function BT(e,t,s,r){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");bw(o,t,s,r)}}function bw(e,t,s,r){e=NT(e),e=AT(e,s.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function yw(e,t,s){let r=s.getBoundingClientRect(),o=e.clientX-r.left-10,c=e.clientY-r.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function Xy(e,t,s,r,o){yw(e,t,s),o&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Mr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function xh(e,t=0,s=e.length){let r="";for(let o=t;o<s;++o){let c=e[o];c>65535?(c-=65536,r+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):r+=String.fromCharCode(c)}return r}var OT=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[r++]=(this._interim-55296)*1024+c-56320+65536:(t[r++]=this._interim,t[r++]=c),this._interim=0}for(let c=o;c<s;++c){let h=e.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=s)return this._interim=h,r;let f=e.charCodeAt(c);56320<=f&&f<=57343?t[r++]=(h-55296)*1024+f-56320+65536:(t[r++]=h,t[r++]=f);continue}h!==65279&&(t[r++]=h)}return r}},zT=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,o,c,h,f,g=0,p=0;if(this.interim[0]){let w=!1,S=this.interim[0];S&=(S&224)===192?31:(S&240)===224?15:7;let E=0,T;for(;(T=this.interim[++E]&63)&&E<4;)S<<=6,S|=T;let O=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,L=O-E;for(;p<L;){if(p>=s)return 0;if(T=e[p++],(T&192)!==128){p--,w=!0;break}else this.interim[E++]=T,S<<=6,S|=T&63}w||(O===2?S<128?p--:t[r++]=S:O===3?S<2048||S>=55296&&S<=57343||S===65279||(t[r++]=S):S<65536||S>1114111||(t[r++]=S)),this.interim.fill(0)}let y=s-4,b=p;for(;b<s;){for(;b<y&&!((o=e[b])&128)&&!((c=e[b+1])&128)&&!((h=e[b+2])&128)&&!((f=e[b+3])&128);)t[r++]=o,t[r++]=c,t[r++]=h,t[r++]=f,b+=4;if(o=e[b++],o<128)t[r++]=o;else if((o&224)===192){if(b>=s)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(g=(o&31)<<6|c&63,g<128){b--;continue}t[r++]=g}else if((o&240)===224){if(b>=s)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=s)return this.interim[0]=o,this.interim[1]=c,r;if(h=e[b++],(h&192)!==128){b--;continue}if(g=(o&15)<<12|(c&63)<<6|h&63,g<2048||g>=55296&&g<=57343||g===65279)continue;t[r++]=g}else if((o&248)===240){if(b>=s)return this.interim[0]=o,r;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=s)return this.interim[0]=o,this.interim[1]=c,r;if(h=e[b++],(h&192)!==128){b--;continue}if(b>=s)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=h,r;if(f=e[b++],(f&192)!==128){b--;continue}if(g=(o&7)<<18|(c&63)<<12|(h&63)<<6|f&63,g<65536||g>1114111)continue;t[r++]=g}}return r}},Sw="",Ar=" ",hc=class ww{constructor(){this.fg=0,this.bg=0,this.extended=new eh}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new ww;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},eh=class Cw{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Cw(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Qn=class xw extends hc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new eh,this.combinedData=""}static fromCharData(t){let s=new xw;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Mr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let r=t[1].charCodeAt(0);if(55296<=r&&r<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(r-55296)*1024+o-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Gy="di$target",Ip="di$dependencies",Vf=new Map;function jT(e){return e[Ip]||[]}function Hi(e){if(Vf.has(e))return Vf.get(e);let t=function(s,r,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");HT(t,s,o)};return t._id=e,Vf.set(e,t),t}function HT(e,t,s){t[Gy]===t?t[Ip].push({id:e,index:s}):(t[Ip]=[{id:e,index:s}],t[Gy]=t)}var sn=Hi("BufferService"),Ew=Hi("CoreMouseService"),xa=Hi("CoreService"),PT=Hi("CharsetService"),_g=Hi("InstantiationService"),kw=Hi("LogService"),rn=Hi("OptionsService"),Tw=Hi("OscLinkService"),UT=Hi("UnicodeService"),dc=Hi("DecorationService"),Kp=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],o=this._optionsService.rawOptions.linkHandler,c=new Qn,h=s.getTrimmedLength(),f=-1,g=-1,p=!1;for(let y=0;y<h;y++)if(!(g===-1&&!s.hasContent(y))){if(s.loadCell(y,c),c.hasExtendedAttrs()&&c.extended.urlId)if(g===-1){g=y,f=c.extended.urlId;continue}else p=c.extended.urlId!==f;else g!==-1&&(p=!0);if(p||g!==-1&&y===h-1){let b=this._oscLinkService.getLinkData(f)?.uri;if(b){let w={start:{x:g+1,y:e},end:{x:y+(!p&&y===h-1?1:0),y:e}},S=!1;if(!o?.allowNonHttpProtocols)try{let E=new URL(b);["http:","https:"].includes(E.protocol)||(S=!0)}catch{S=!0}S||r.push({text:b,range:w,activate:(E,T)=>o?o.activate(E,T,w):IT(E,T),hover:(E,T)=>o?.hover?.(E,T,w),leave:(E,T)=>o?.leave?.(E,T,w)})}p=!1,c.hasExtendedAttrs()&&c.extended.urlId?(g=y,f=c.extended.urlId):(g=-1,f=-1)}}t(r)}};Kp=Jt([Re(0,sn),Re(1,rn),Re(2,Tw)],Kp);function IT(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
16
|
+
|
|
17
|
+
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Eh=Hi("CharSizeService"),Xs=Hi("CoreBrowserService"),vg=Hi("MouseService"),Gs=Hi("RenderService"),KT=Hi("SelectionService"),Dw=Hi("CharacterJoinerService"),Rl=Hi("ThemeService"),Rw=Hi("LinkProviderService"),WT=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Zy.isErrorNoTelemetry(e)?new Zy(e.message+`
|
|
18
|
+
|
|
19
|
+
`+e.stack):new Error(e.message+`
|
|
20
|
+
|
|
21
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},FT=new WT;function Ou(e){qT(e)||FT.onUnexpectedError(e)}var Wp="Canceled";function qT(e){return e instanceof $T?!0:e instanceof Error&&e.name===Wp&&e.message===Wp}var $T=class extends Error{constructor(){super(Wp),this.name=this.message}};function VT(e){return new Error(`Illegal argument: ${e}`)}var Zy=class Fp extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Fp)return t;let s=new Fp;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},qp=class Mw extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Mw.prototype)}};function Rn(e,t=0){return e[e.length-(1+t)]}var YT;(e=>{function t(c){return c<0}e.isLessThan=t;function s(c){return c<=0}e.isLessThanOrEqual=s;function r(c){return c>0}e.isGreaterThan=r;function o(c){return c===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(YT||={});function XT(e,t){let s=this,r=!1,o;return function(){return r||(r=!0,t||(o=e.apply(s,arguments))),o}}var Nw;(e=>{function t(U){return U&&typeof U=="object"&&typeof U[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function r(){return s}e.empty=r;function*o(U){yield U}e.single=o;function c(U){return t(U)?U:o(U)}e.wrap=c;function h(U){return U||s}e.from=h;function*f(U){for(let Q=U.length-1;Q>=0;Q--)yield U[Q]}e.reverse=f;function g(U){return!U||U[Symbol.iterator]().next().done===!0}e.isEmpty=g;function p(U){return U[Symbol.iterator]().next().value}e.first=p;function y(U,Q){let ie=0;for(let le of U)if(Q(le,ie++))return!0;return!1}e.some=y;function b(U,Q){for(let ie of U)if(Q(ie))return ie}e.find=b;function*w(U,Q){for(let ie of U)Q(ie)&&(yield ie)}e.filter=w;function*S(U,Q){let ie=0;for(let le of U)yield Q(le,ie++)}e.map=S;function*E(U,Q){let ie=0;for(let le of U)yield*Q(le,ie++)}e.flatMap=E;function*T(...U){for(let Q of U)yield*Q}e.concat=T;function O(U,Q,ie){let le=ie;for(let ce of U)le=Q(le,ce);return le}e.reduce=O;function*L(U,Q,ie=U.length){for(Q<0&&(Q+=U.length),ie<0?ie+=U.length:ie>U.length&&(ie=U.length);Q<ie;Q++)yield U[Q]}e.slice=L;function N(U,Q=Number.POSITIVE_INFINITY){let ie=[];if(Q===0)return[ie,U];let le=U[Symbol.iterator]();for(let ce=0;ce<Q;ce++){let ve=le.next();if(ve.done)return[ie,e.empty()];ie.push(ve.value)}return[ie,{[Symbol.iterator](){return le}}]}e.consume=N;async function I(U){let Q=[];for await(let ie of U)Q.push(ie);return Promise.resolve(Q)}e.asyncToArray=I})(Nw||={});function Sa(e){if(Nw.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(r){t.push(r)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function GT(...e){return Ut(()=>Sa(e))}function Ut(e){return{dispose:XT(()=>{e()})}}var Aw=class Lw{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{Sa(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?Lw.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)}};Aw.DISABLE_DISPOSED_WARNING=!1;var Br=Aw,tt=class{constructor(){this._store=new Br,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};tt.None=Object.freeze({dispose(){}});var Cl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Vs=typeof window=="object"?window:globalThis,$p=class Vp{constructor(t){this.element=t,this.next=Vp.Undefined,this.prev=Vp.Undefined}};$p.Undefined=new $p(void 0);var Wt=$p,Qy=class{constructor(){this._first=Wt.Undefined,this._last=Wt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Wt.Undefined}clear(){let e=this._first;for(;e!==Wt.Undefined;){let t=e.next;e.prev=Wt.Undefined,e.next=Wt.Undefined,e=t}this._first=Wt.Undefined,this._last=Wt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new Wt(e);if(this._first===Wt.Undefined)this._first=s,this._last=s;else if(t){let o=this._last;this._last=s,s.prev=o,o.next=s}else{let o=this._first;this._first=s,s.next=o,o.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==Wt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Wt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Wt.Undefined&&e.next!==Wt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Wt.Undefined&&e.next===Wt.Undefined?(this._first=Wt.Undefined,this._last=Wt.Undefined):e.next===Wt.Undefined?(this._last=this._last.prev,this._last.next=Wt.Undefined):e.prev===Wt.Undefined&&(this._first=this._first.next,this._first.prev=Wt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Wt.Undefined;)yield e.element,e=e.next}},ZT=globalThis.performance&&typeof globalThis.performance.now=="function",QT=class Bw{static create(t){return new Bw(t)}constructor(t){this._now=ZT&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},qi;(e=>{e.None=()=>tt.None;function t(se,V){return b(se,()=>{},0,void 0,!0,void 0,V)}e.defer=t;function s(se){return(V,F=null,re)=>{let B=!1,W;return W=se(D=>{if(!B)return W?W.dispose():B=!0,V.call(F,D)},null,re),B&&W.dispose(),W}}e.once=s;function r(se,V,F){return p((re,B=null,W)=>se(D=>re.call(B,V(D)),null,W),F)}e.map=r;function o(se,V,F){return p((re,B=null,W)=>se(D=>{V(D),re.call(B,D)},null,W),F)}e.forEach=o;function c(se,V,F){return p((re,B=null,W)=>se(D=>V(D)&&re.call(B,D),null,W),F)}e.filter=c;function h(se){return se}e.signal=h;function f(...se){return(V,F=null,re)=>{let B=GT(...se.map(W=>W(D=>V.call(F,D))));return y(B,re)}}e.any=f;function g(se,V,F,re){let B=F;return r(se,W=>(B=V(B,W),B),re)}e.reduce=g;function p(se,V){let F,re={onWillAddFirstListener(){F=se(B.fire,B)},onDidRemoveLastListener(){F?.dispose()}},B=new Te(re);return V?.add(B),B.event}function y(se,V){return V instanceof Array?V.push(se):V&&V.add(se),se}function b(se,V,F=100,re=!1,B=!1,W,D){let G,me,R,H=0,ee,de={leakWarningThreshold:W,onWillAddFirstListener(){G=se(ke=>{H++,me=V(me,ke),re&&!R&&(Ee.fire(me),me=void 0),ee=()=>{let Me=me;me=void 0,R=void 0,(!re||H>1)&&Ee.fire(Me),H=0},typeof F=="number"?(clearTimeout(R),R=setTimeout(ee,F)):R===void 0&&(R=0,queueMicrotask(ee))})},onWillRemoveListener(){B&&H>0&&ee?.()},onDidRemoveLastListener(){ee=void 0,G.dispose()}},Ee=new Te(de);return D?.add(Ee),Ee.event}e.debounce=b;function w(se,V=0,F){return e.debounce(se,(re,B)=>re?(re.push(B),re):[B],V,void 0,!0,void 0,F)}e.accumulate=w;function S(se,V=(re,B)=>re===B,F){let re=!0,B;return c(se,W=>{let D=re||!V(W,B);return re=!1,B=W,D},F)}e.latch=S;function E(se,V,F){return[e.filter(se,V,F),e.filter(se,re=>!V(re),F)]}e.split=E;function T(se,V=!1,F=[],re){let B=F.slice(),W=se(me=>{B?B.push(me):G.fire(me)});re&&re.add(W);let D=()=>{B?.forEach(me=>G.fire(me)),B=null},G=new Te({onWillAddFirstListener(){W||(W=se(me=>G.fire(me)),re&&re.add(W))},onDidAddFirstListener(){B&&(V?setTimeout(D):D())},onDidRemoveLastListener(){W&&W.dispose(),W=null}});return re&&re.add(G),G.event}e.buffer=T;function O(se,V){return(F,re,B)=>{let W=V(new N);return se(function(D){let G=W.evaluate(D);G!==L&&F.call(re,G)},void 0,B)}}e.chain=O;let L=Symbol("HaltChainable");class N{constructor(){this.steps=[]}map(V){return this.steps.push(V),this}forEach(V){return this.steps.push(F=>(V(F),F)),this}filter(V){return this.steps.push(F=>V(F)?F:L),this}reduce(V,F){let re=F;return this.steps.push(B=>(re=V(re,B),re)),this}latch(V=(F,re)=>F===re){let F=!0,re;return this.steps.push(B=>{let W=F||!V(B,re);return F=!1,re=B,W?B:L}),this}evaluate(V){for(let F of this.steps)if(V=F(V),V===L)break;return V}}function I(se,V,F=re=>re){let re=(...G)=>D.fire(F(...G)),B=()=>se.on(V,re),W=()=>se.removeListener(V,re),D=new Te({onWillAddFirstListener:B,onDidRemoveLastListener:W});return D.event}e.fromNodeEventEmitter=I;function U(se,V,F=re=>re){let re=(...G)=>D.fire(F(...G)),B=()=>se.addEventListener(V,re),W=()=>se.removeEventListener(V,re),D=new Te({onWillAddFirstListener:B,onDidRemoveLastListener:W});return D.event}e.fromDOMEventEmitter=U;function Q(se){return new Promise(V=>s(se)(V))}e.toPromise=Q;function ie(se){let V=new Te;return se.then(F=>{V.fire(F)},()=>{V.fire(void 0)}).finally(()=>{V.dispose()}),V.event}e.fromPromise=ie;function le(se,V){return se(F=>V.fire(F))}e.forward=le;function ce(se,V,F){return V(F),se(re=>V(re))}e.runAndSubscribe=ce;class ve{constructor(V,F){this._observable=V,this._counter=0,this._hasChanged=!1;let re={onWillAddFirstListener:()=>{V.addObserver(this)},onDidRemoveLastListener:()=>{V.removeObserver(this)}};this.emitter=new Te(re),F&&F.add(this.emitter)}beginUpdate(V){this._counter++}handlePossibleChange(V){}handleChange(V,F){this._hasChanged=!0}endUpdate(V){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function we(se,V){return new ve(se,V).emitter.event}e.fromObservable=we;function ne(se){return(V,F,re)=>{let B=0,W=!1,D={beginUpdate(){B++},endUpdate(){B--,B===0&&(se.reportChanges(),W&&(W=!1,V.call(F)))},handlePossibleChange(){},handleChange(){W=!0}};se.addObserver(D),se.reportChanges();let G={dispose(){se.removeObserver(D)}};return re instanceof Br?re.add(G):Array.isArray(re)&&re.push(G),G}}e.fromObservableLight=ne})(qi||={});var Yp=class Xp{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Xp._idPool++}`,Xp.all.add(this)}start(t){this._stopWatch=new QT,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Yp.all=new Set,Yp._idPool=0;var JT=Yp,eD=-1,Ow=class zw{constructor(t,s,r=(zw._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,s){let r=this.threshold;if(r<=0||s<r)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=r*.5;let[c,h]=this.getMostFrequentStack(),f=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${h}):`;console.warn(f),console.warn(c);let g=new nD(f,c);this._errorHandler(g)}return()=>{let c=this._stacks.get(t.value)||0;this._stacks.set(t.value,c-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[r,o]of this._stacks)(!t||s<o)&&(t=[r,o],s=o);return t}};Ow._idPool=1;var tD=Ow,iD=class jw{constructor(t){this.value=t}static create(){let t=new Error;return new jw(t.stack??"")}print(){console.warn(this.value.split(`
|
|
22
|
+
`).slice(2).join(`
|
|
23
|
+
`))}},nD=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},sD=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},rD=0,Yf=class{constructor(e){this.value=e,this.id=rD++}},aD=2,lD,Te=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new tD(e?.onListenerError??Ou,this._options?.leakWarningThreshold??eD):void 0,this._perfMon=this._options?._profName?new JT(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let h=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(h);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],g=new sD(`${h}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(this._options?.onListenerError||Ou)(g),tt.None}if(this._disposed)return tt.None;t&&(e=e.bind(t));let r=new Yf(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=iD.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Yf?(this._deliveryQueue??=new oD,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let c=Ut(()=>{o?.(),this._removeListener(r)});return s instanceof Br?s.add(c):Array.isArray(s)&&s.push(c),c},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[s]=void 0;let r=this._deliveryQueue.current===this;if(this._size*aD<=t.length){let o=0;for(let c=0;c<t.length;c++)t[c]?t[o++]=t[c]:r&&(this._deliveryQueue.end--,o<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=o}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||Ou;if(!s){e.value(t);return}try{e.value(t)}catch(r){s(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Yf)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},oD=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Gp=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(r,t),this._onDidChangeZoomLevel.fire(r)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let r=this.getWindowId(s);this.mapWindowIdToFullScreen.set(r,t),this._onDidChangeFullscreen.fire(r)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Gp.INSTANCE=new Gp;var bg=Gp;function cD(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}bg.INSTANCE.onDidChangeZoomLevel;function uD(e){return bg.INSTANCE.getZoomFactor(e)}bg.INSTANCE.onDidChangeFullscreen;var Ml=typeof navigator=="object"?navigator.userAgent:"",Zp=Ml.indexOf("Firefox")>=0,hD=Ml.indexOf("AppleWebKit")>=0,yg=Ml.indexOf("Chrome")>=0,dD=!yg&&Ml.indexOf("Safari")>=0;Ml.indexOf("Electron/")>=0;Ml.indexOf("Android")>=0;var Xf=!1;if(typeof Vs.matchMedia=="function"){let e=Vs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Vs.matchMedia("(display-mode: fullscreen)");Xf=e.matches,cD(Vs,e,({matches:s})=>{Xf&&t.matches||(Xf=s)})}var pl="en",Qp=!1,Jp=!1,zu=!1,Hw=!1,xu,ju=pl,Jy=pl,fD,qs,ga=globalThis,An;typeof ga.vscode<"u"&&typeof ga.vscode.process<"u"?An=ga.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(An=process);var pD=typeof An?.versions?.electron=="string",mD=pD&&An?.type==="renderer";if(typeof An=="object"){Qp=An.platform==="win32",Jp=An.platform==="darwin",zu=An.platform==="linux",zu&&An.env.SNAP&&An.env.SNAP_REVISION,An.env.CI||An.env.BUILD_ARTIFACTSTAGINGDIRECTORY,xu=pl,ju=pl;let e=An.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);xu=t.userLocale,Jy=t.osLocale,ju=t.resolvedLanguage||pl,fD=t.languagePack?.translationsConfigFile}catch{}Hw=!0}else typeof navigator=="object"&&!mD?(qs=navigator.userAgent,Qp=qs.indexOf("Windows")>=0,Jp=qs.indexOf("Macintosh")>=0,(qs.indexOf("Macintosh")>=0||qs.indexOf("iPad")>=0||qs.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,zu=qs.indexOf("Linux")>=0,qs?.indexOf("Mobi")>=0,ju=globalThis._VSCODE_NLS_LANGUAGE||pl,xu=navigator.language.toLowerCase(),Jy=xu):console.error("Unable to resolve platform.");var Pw=Qp,Cs=Jp,gD=zu,eS=Hw,xs=qs,Cr=ju,_D;(e=>{function t(){return Cr}e.value=t;function s(){return Cr.length===2?Cr==="en":Cr.length>=3?Cr[0]==="e"&&Cr[1]==="n"&&Cr[2]==="-":!1}e.isDefaultVariant=s;function r(){return Cr==="en"}e.isDefault=r})(_D||={});var vD=typeof ga.postMessage=="function"&&!ga.importScripts;(()=>{if(vD){let e=[];ga.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let r=0,o=e.length;r<o;r++){let c=e[r];if(c.id===s.data.vscodeScheduleAsyncWork){e.splice(r,1),c.callback();return}}});let t=0;return s=>{let r=++t;e.push({id:r,callback:s}),ga.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})();var bD=!!(xs&&xs.indexOf("Chrome")>=0);xs&&xs.indexOf("Firefox")>=0;!bD&&xs&&xs.indexOf("Safari")>=0;xs&&xs.indexOf("Edg/")>=0;xs&&xs.indexOf("Android")>=0;var hl=typeof navigator=="object"?navigator:{};eS||document.queryCommandSupported&&document.queryCommandSupported("copy")||hl&&hl.clipboard&&hl.clipboard.writeText,eS||hl&&hl.clipboard&&hl.clipboard.readText;var Sg=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Gf=new Sg,tS=new Sg,iS=new Sg,yD=new Array(230),Uw;(e=>{function t(f){return Gf.keyCodeToStr(f)}e.toString=t;function s(f){return Gf.strToKeyCode(f)}e.fromString=s;function r(f){return tS.keyCodeToStr(f)}e.toUserSettingsUS=r;function o(f){return iS.keyCodeToStr(f)}e.toUserSettingsGeneral=o;function c(f){return tS.strToKeyCode(f)||iS.strToKeyCode(f)}e.fromUserSettings=c;function h(f){if(f>=98&&f<=113)return null;switch(f){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Gf.keyCodeToStr(f)}e.toElectronAccelerator=h})(Uw||={});var SD=class Iw{constructor(t,s,r,o,c){this.ctrlKey=t,this.shiftKey=s,this.altKey=r,this.metaKey=o,this.keyCode=c}equals(t){return t instanceof Iw&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",r=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${s}${r}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new wD([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},wD=class{constructor(e){if(e.length===0)throw VT("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function CD(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return Uw.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Zp)switch(t){case 59:return 85;case 60:if(gD)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Cs)return 57;break}else if(hD&&(Cs&&t===93||!Cs&&t===92))return 57;return yD[t]||0}var xD=Cs?256:2048,ED=512,kD=1024,TD=Cs?2048:256,nS=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=CD(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|=xD),this.altKey&&(t|=ED),this.shiftKey&&(t|=kD),this.metaKey&&(t|=TD),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new SD(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},sS=new WeakMap;function DD(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var RD=class{static getSameOriginWindowChain(e){let t=sS.get(e);if(!t){t=[],sS.set(e,t);let s=e,r;do r=DD(s),r?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=r;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,r=0,o=this.getSameOriginWindowChain(e);for(let c of o){let h=c.window.deref();if(s+=h?.scrollY??0,r+=h?.scrollX??0,h===t||!c.iframeElement)break;let f=c.iframeElement.getBoundingClientRect();s+=f.top,r+=f.left}return{top:s,left:r}}},Eu=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=RD.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},rS=class{constructor(e,t=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let r=!1;if(yg){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,h=e.view?.devicePixelRatio||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*h):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Zp&&!Cs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")dD&&Pw?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*h):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let f=e;f.deltaMode===f.DOM_DELTA_LINE?Zp&&!Cs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Kw=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),MD;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof ND?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:qi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Kw})})(MD||={});var ND=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?Kw:(this._emitter||(this._emitter=new Te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},wg=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new qp("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new qp("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},AD=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new qp("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=Ut(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},LD;(e=>{async function t(r){let o,c=await Promise.all(r.map(h=>h.then(f=>f,f=>{o||(o=f)})));if(typeof o<"u")throw o;return c}e.settled=t;function s(r){return new Promise(async(o,c)=>{try{await r(o,c)}catch(h){c(h)}})}e.withAsyncBody=s})(LD||={});var aS=class Yn{static fromArray(t){return new Yn(s=>{s.emitMany(t)})}static fromPromise(t){return new Yn(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Yn(async s=>{await Promise.all(t.map(async r=>s.emitOne(await r)))})}static merge(t){return new Yn(async s=>{await Promise.all(t.map(async r=>{for await(let o of r)s.emitOne(o)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new Te,queueMicrotask(async()=>{let r={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(r)),this.resolve()}catch(o){this.reject(o)}finally{r.emitOne=void 0,r.emitMany=void 0,r.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await qi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new Yn(async r=>{for await(let o of t)r.emitOne(s(o))})}map(t){return Yn.map(this,t)}static filter(t,s){return new Yn(async r=>{for await(let o of t)s(o)&&r.emitOne(o)})}filter(t){return Yn.filter(this,t)}static coalesce(t){return Yn.filter(t,s=>!!s)}coalesce(){return Yn.coalesce(this)}static async toPromise(t){let s=[];for await(let r of t)s.push(r);return s}toPromise(){return Yn.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};aS.EMPTY=aS.fromArray([]);var{getWindow:ws,getWindowId:BD,onDidRegisterWindow:OD}=(function(){let e=new Map,t={window:Vs,disposables:new Br};e.set(Vs.vscodeWindowId,t);let s=new Te,r=new Te,o=new Te;function c(h,f){return(typeof h=="number"?e.get(h):void 0)??(f?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:r.event,registerWindow(h){if(e.has(h.vscodeWindowId))return tt.None;let f=new Br,g={window:h,disposables:f.add(new Br)};return e.set(h.vscodeWindowId,g),f.add(Ut(()=>{e.delete(h.vscodeWindowId),r.fire(h)})),f.add(Ve(h,Ni.BEFORE_UNLOAD,()=>{o.fire(h)})),s.fire(g),f},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(h){return h.vscodeWindowId},hasWindow(h){return e.has(h)},getWindowById:c,getWindow(h){let f=h;if(f?.ownerDocument?.defaultView)return f.ownerDocument.defaultView.window;let g=h;return g?.view?g.view.window:Vs},getDocument(h){return ws(h).document}}})(),zD=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ve(e,t,s,r){return new zD(e,t,s,r)}var lS=function(e,t,s,r){return Ve(e,t,s,r)},Cg,jD=class extends AD{constructor(e){super(),this.defaultTarget=e&&ws(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},oS=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){Ou(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,r=new Map,o=c=>{s.set(c,!1);let h=e.get(c)??[];for(t.set(c,h),e.set(c,[]),r.set(c,!0);h.length>0;)h.sort(oS.sort),h.shift().execute();r.set(c,!1)};Cg=(c,h,f=0)=>{let g=BD(c),p=new oS(h,f),y=e.get(g);return y||(y=[],e.set(g,y)),y.push(p),s.get(g)||(s.set(g,!0),c.requestAnimationFrame(()=>o(g))),p}})();function HD(e){let t=e.getBoundingClientRect(),s=ws(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Ni={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"},PD=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=pn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=pn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=pn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=pn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=pn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=pn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=pn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=pn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=pn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=pn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=pn(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=pn(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=pn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=pn(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 pn(e){return typeof e=="number"?`${e}px`:e}function Xo(e){return new PD(e)}var Ww=class{constructor(){this._hooks=new Br,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,r,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=o;let c=e;try{e.setPointerCapture(t),this._hooks.add(Ut(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{c=ws(e)}this._hooks.add(Ve(c,Ni.POINTER_MOVE,h=>{if(h.buttons!==s){this.stopMonitoring(!0);return}h.preventDefault(),this._pointerMoveCallback(h)})),this._hooks.add(Ve(c,Ni.POINTER_UP,h=>this.stopMonitoring(!0)))}};function UD(e,t,s){let r=null,o=null;if(typeof s.value=="function"?(r="value",o=s.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(r="get",o=s.get),!o)throw new Error("not supported");let c=`$memoize$${t}`;s[r]=function(...h){return this.hasOwnProperty(c)||Object.defineProperty(this,c,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,h)}),this[c]}}var Ss;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Ss||={});var Bo=class Xi extends tt{constructor(){super(),this.dispatched=!1,this.targets=new Qy,this.ignoreTargets=new Qy,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(qi.runAndSubscribe(OD,({window:t,disposables:s})=>{s.add(Ve(t.document,"touchstart",r=>this.onTouchStart(r),{passive:!1})),s.add(Ve(t.document,"touchend",r=>this.onTouchEnd(t,r))),s.add(Ve(t.document,"touchmove",r=>this.onTouchMove(r),{passive:!1}))},{window:Vs,disposables:this._store}))}static addTarget(t){if(!Xi.isTouchDevice())return tt.None;Xi.INSTANCE||(Xi.INSTANCE=new Xi);let s=Xi.INSTANCE.targets.push(t);return Ut(s)}static ignoreTarget(t){if(!Xi.isTouchDevice())return tt.None;Xi.INSTANCE||(Xi.INSTANCE=new Xi);let s=Xi.INSTANCE.ignoreTargets.push(t);return Ut(s)}static isTouchDevice(){return"ontouchstart"in Vs||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let r=0,o=t.targetTouches.length;r<o;r++){let c=t.targetTouches.item(r);this.activeTouches[c.identifier]={id:c.identifier,initialTarget:c.target,initialTimeStamp:s,initialPageX:c.pageX,initialPageY:c.pageY,rollingTimestamps:[s],rollingPageX:[c.pageX],rollingPageY:[c.pageY]};let h=this.newGestureEvent(Ss.Start,c.target);h.pageX=c.pageX,h.pageY=c.pageY,this.dispatchEvent(h)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let r=Date.now(),o=Object.keys(this.activeTouches).length;for(let c=0,h=s.changedTouches.length;c<h;c++){let f=s.changedTouches.item(c);if(!this.activeTouches.hasOwnProperty(String(f.identifier))){console.warn("move of an UNKNOWN touch",f);continue}let g=this.activeTouches[f.identifier],p=Date.now()-g.initialTimeStamp;if(p<Xi.HOLD_DELAY&&Math.abs(g.initialPageX-Rn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Rn(g.rollingPageY))<30){let y=this.newGestureEvent(Ss.Tap,g.initialTarget);y.pageX=Rn(g.rollingPageX),y.pageY=Rn(g.rollingPageY),this.dispatchEvent(y)}else if(p>=Xi.HOLD_DELAY&&Math.abs(g.initialPageX-Rn(g.rollingPageX))<30&&Math.abs(g.initialPageY-Rn(g.rollingPageY))<30){let y=this.newGestureEvent(Ss.Contextmenu,g.initialTarget);y.pageX=Rn(g.rollingPageX),y.pageY=Rn(g.rollingPageY),this.dispatchEvent(y)}else if(o===1){let y=Rn(g.rollingPageX),b=Rn(g.rollingPageY),w=Rn(g.rollingTimestamps)-g.rollingTimestamps[0],S=y-g.rollingPageX[0],E=b-g.rollingPageY[0],T=[...this.targets].filter(O=>g.initialTarget instanceof Node&&O.contains(g.initialTarget));this.inertia(t,T,r,Math.abs(S)/w,S>0?1:-1,y,Math.abs(E)/w,E>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(Ss.End,g.initialTarget)),delete this.activeTouches[f.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let r=document.createEvent("CustomEvent");return r.initEvent(t,!1,!0),r.initialTarget=s,r.tapCount=0,r}dispatchEvent(t){if(t.type===Ss.Tap){let s=new Date().getTime(),r=0;s-this._lastSetTapCountTime>Xi.CLEAR_TAP_COUNT_TIME?r=1:r=2,this._lastSetTapCountTime=s,t.tapCount=r}else(t.type===Ss.Change||t.type===Ss.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let r of this.ignoreTargets)if(r.contains(t.initialTarget))return;let s=[];for(let r of this.targets)if(r.contains(t.initialTarget)){let o=0,c=t.initialTarget;for(;c&&c!==r;)o++,c=c.parentElement;s.push([o,r])}s.sort((r,o)=>r[0]-o[0]);for(let[r,o]of s)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,r,o,c,h,f,g,p){this.handle=Cg(t,()=>{let y=Date.now(),b=y-r,w=0,S=0,E=!0;o+=Xi.SCROLL_FRICTION*b,f+=Xi.SCROLL_FRICTION*b,o>0&&(E=!1,w=c*o*b),f>0&&(E=!1,S=g*f*b);let T=this.newGestureEvent(Ss.Change);T.translationX=w,T.translationY=S,s.forEach(O=>O.dispatchEvent(T)),E||this.inertia(t,s,y,o,c,h+w,f,g,p+S)})}onTouchMove(t){let s=Date.now();for(let r=0,o=t.changedTouches.length;r<o;r++){let c=t.changedTouches.item(r);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("end of an UNKNOWN touch",c);continue}let h=this.activeTouches[c.identifier],f=this.newGestureEvent(Ss.Change,h.initialTarget);f.translationX=c.pageX-Rn(h.rollingPageX),f.translationY=c.pageY-Rn(h.rollingPageY),f.pageX=c.pageX,f.pageY=c.pageY,this.dispatchEvent(f),h.rollingPageX.length>3&&(h.rollingPageX.shift(),h.rollingPageY.shift(),h.rollingTimestamps.shift()),h.rollingPageX.push(c.pageX),h.rollingPageY.push(c.pageY),h.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Bo.SCROLL_FRICTION=-.005,Bo.HOLD_DELAY=700,Bo.CLEAR_TAP_COUNT_TIME=400,Jt([UD],Bo,"isTouchDevice",1);var ID=Bo,xg=class extends tt{onclick(e,t){this._register(Ve(e,Ni.CLICK,s=>t(new Eu(ws(e),s))))}onmousedown(e,t){this._register(Ve(e,Ni.MOUSE_DOWN,s=>t(new Eu(ws(e),s))))}onmouseover(e,t){this._register(Ve(e,Ni.MOUSE_OVER,s=>t(new Eu(ws(e),s))))}onmouseleave(e,t){this._register(Ve(e,Ni.MOUSE_LEAVE,s=>t(new Eu(ws(e),s))))}onkeydown(e,t){this._register(Ve(e,Ni.KEY_DOWN,s=>t(new nS(s))))}onkeyup(e,t){this._register(Ve(e,Ni.KEY_UP,s=>t(new nS(s))))}oninput(e,t){this._register(Ve(e,Ni.INPUT,t))}onblur(e,t){this._register(Ve(e,Ni.BLUR,t))}onfocus(e,t){this._register(Ve(e,Ni.FOCUS,t))}onchange(e,t){this._register(Ve(e,Ni.CHANGE,t))}ignoreGesture(e){return ID.ignoreTarget(e)}},cS=11,KD=class extends xg{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=cS+"px",this.domNode.style.height=cS+"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 Ww),this._register(lS(this.bgDomNode,Ni.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(lS(this.domNode,Ni.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new jD),this._pointerdownScheduleRepeatTimer=this._register(new wg)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ws(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},WD=class em{constructor(t,s,r,o,c,h,f){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,r=r|0,o=o|0,c=c|0,h=h|0,f=f|0),this.rawScrollLeft=o,this.rawScrollTop=f,s<0&&(s=0),o+s>r&&(o=r-s),o<0&&(o=0),c<0&&(c=0),f+c>h&&(f=h-c),f<0&&(f=0),this.width=s,this.scrollWidth=r,this.scrollLeft=o,this.height=c,this.scrollHeight=h,this.scrollTop=f}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new em(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new em(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let r=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,c=this.scrollLeft!==t.scrollLeft,h=this.height!==t.height,f=this.scrollHeight!==t.scrollHeight,g=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:r,scrollWidthChanged:o,scrollLeftChanged:c,heightChanged:h,scrollHeightChanged:f,scrollTopChanged:g}}},FD=class extends tt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new WD(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let r;t?r=new hS(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):r=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=hS.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},uS=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Zf(e,t){let s=t-e;return function(r){return e+s*VD(r)}}function qD(e,t,s){return function(r){return r<s?e(r/s):t((r-s)/(1-s))}}var hS=class tm{constructor(t,s,r,o){this.from=t,this.to=s,this.duration=o,this.startTime=r,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,r){if(Math.abs(t-s)>2.5*r){let o,c;return t<s?(o=t+.75*r,c=s-.75*r):(o=t-.75*r,c=s+.75*r),qD(Zf(t,o),Zf(c,s),.33)}return Zf(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let r=this.scrollLeft(s),o=this.scrollTop(s);return new uS(r,o,!1)}return new uS(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,r){return tm.start(t,s,r)}static start(t,s,r){r=r+10;let o=Date.now()-10;return new tm(t,s,o,r)}};function $D(e){return Math.pow(e,3)}function VD(e){return 1-$D(1-e)}var YD=class extends tt{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new wg)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},XD=140,Fw=class extends xg{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new YD(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Ww),this._shouldRender=!0,this.domNode=Xo(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(Ve(this.domNode.domNode,Ni.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new KD(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=Xo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ve(this.slider.domNode,Ni.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);s<=o&&o<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let o=HD(this.domNode.domNode);t=e.pageX-o.left,s=e.pageY-o.top}let r=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let c=this._sliderOrthogonalPointerPosition(o),h=Math.abs(c-s);if(Pw&&h>XD){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let f=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(f))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},qw=class im{constructor(t,s,r,o,c,h){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(r),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=c,this._scrollPosition=h,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new im(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,r,o,c){let h=Math.max(0,r-t),f=Math.max(0,h-2*s),g=o>0&&o>r;if(!g)return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(f),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(r*f/o))),y=(f-p)/(o-r),b=c*y;return{computedAvailableSize:Math.round(h),computedIsNeeded:g,computedSliderSize:Math.round(p),computedSliderRatio:y,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=im._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,r=this._scrollPosition;return s<this._computedSliderPosition?r-=this._visibleSize:r+=this._visibleSize,r}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},GD=class extends Fw{constructor(e,t,s){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new qw(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}},ZD=class extends Fw{constructor(e,t,s){let r=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new qw(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}},QD=500,dS=50,JD=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},nm=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,r=1,o=this._rear;do{let c=o===this._front?t:Math.pow(2,-r);if(t-=c,s+=this._memory[o].score*c,o===this._front)break;o=(this._capacity+o-1)%this._capacity,r++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(yg){let s=ws(t.browserEvent),r=uD(s);this.accept(Date.now(),t.deltaX*r,t.deltaY*r)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,r){let o=null,c=new JD(t,s,r);this._front===-1&&this._rear===-1?(this._memory[0]=c,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=c),c.score=this._computeScore(c,o)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let r=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(r+=.25),s){let o=Math.abs(t.deltaX),c=Math.abs(t.deltaY),h=Math.abs(s.deltaX),f=Math.abs(s.deltaY),g=Math.max(Math.min(o,h),1),p=Math.max(Math.min(c,f),1),y=Math.max(o,h),b=Math.max(c,f);y%g===0&&b%p===0&&(r-=.5)}return Math.min(Math.max(r,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};nm.INSTANCE=new nm;var eR=nm,tR=class extends xg{constructor(e,t,s){super(),this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Te),this.onWillScroll=this._onWillScroll.event,this._options=nR(t),this._scrollable=s,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let r={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new ZD(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new GD(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=Xo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Xo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Xo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,o=>this._onMouseOver(o)),this.onmouseleave(this._listenOnDomNode,o=>this._onMouseLeave(o)),this._hideTimeout=this._register(new wg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Sa(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,Cs&&(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 rS(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Sa(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new rS(s))};this._mouseWheelToDispose.push(Ve(this._listenOnDomNode,Ni.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=eR.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let h=!Cs&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let f=this._scrollable.getFutureScrollPosition(),g={};if(o){let p=dS*o,y=f.scrollTop-(p<0?Math.floor(p):Math.ceil(p));this._verticalScrollbar.writeScrollPosition(g,y)}if(c){let p=dS*c,y=f.scrollLeft-(p<0?Math.floor(p):Math.ceil(p));this._horizontalScrollbar.writeScrollPosition(g,y)}g=this._scrollable.validateScrollPosition(g),(f.scrollLeft!==g.scrollLeft||f.scrollTop!==g.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(g):this._scrollable.setScrollPositionNow(g),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,r=s?" left":"",o=t?" top":"",c=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${c}${o}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),QD)}},iR=class extends tR{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function nR(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,Cs&&(t.className+=" mac"),t}var sm=class extends tt{constructor(e,t,s,r,o,c,h,f){super(),this._bufferService=s,this._optionsService=h,this._renderService=f,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let g=this._register(new FD({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>Cg(r.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{g.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new iR(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},g)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(qi.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Ut(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Ut(()=>this._styleElement.remove())),this._register(qi.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
24
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(p=>this._handleScroll(p)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};sm=Jt([Re(2,sn),Re(3,Xs),Re(4,Ew),Re(5,Rl),Re(6,rn),Re(7,Gs)],sm);var rm=class extends tt{constructor(e,t,s,r,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=r,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(Ut(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};rm=Jt([Re(1,sn),Re(2,Xs),Re(3,dc),Re(4,Gs)],rm);var sR=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},bs={full:0,left:0,center:0,right:0},xr={full:0,left:0,center:0,right:0},Co={full:0,left:0,center:0,right:0},th=class extends tt{constructor(e,t,s,r,o,c,h,f){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=o,this._optionsService=c,this._themeService=h,this._coreBrowserService=f,this._colorZoneStore=new sR,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(Ut(()=>this._canvas?.remove()));let g=this._canvas.getContext("2d");if(g)this._ctx=g;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);xr.full=this._canvas.width,xr.left=e,xr.center=t,xr.right=e,this._refreshDrawHeightConstants(),Co.full=1,Co.left=1,Co.center=1+xr.left,Co.right=1+xr.left+xr.center}_refreshDrawHeightConstants(){bs.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);bs.left=t,bs.center=t,bs.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*bs.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(Co[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-bs[e.position||"full"]/2),xr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+bs[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};th=Jt([Re(2,sn),Re(3,dc),Re(4,Gs),Re(5,rn),Re(6,Rl),Re(7,Xs)],th);var pe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
25
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(pe||={});var Hu;(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=""))(Hu||={});var $w;(e=>e.ST=`${pe.ESC}\\`)($w||={});var am=class{constructor(e,t,s,r,o,c){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=o,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${pe.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=r+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=r+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};am=Jt([Re(2,sn),Re(3,rn),Re(4,xa),Re(5,Gs)],am);var Bi=0,Oi=0,zi=0,Qt=0,fS={css:"#00000000",rgba:0},gi;(e=>{function t(o,c,h,f){return f!==void 0?`#${oa(o)}${oa(c)}${oa(h)}${oa(f)}`:`#${oa(o)}${oa(c)}${oa(h)}`}e.toCss=t;function s(o,c,h,f=255){return(o<<24|c<<16|h<<8|f)>>>0}e.toRgba=s;function r(o,c,h,f){return{css:e.toCss(o,c,h,f),rgba:e.toRgba(o,c,h,f)}}e.toColor=r})(gi||={});var jt;(e=>{function t(g,p){if(Qt=(p.rgba&255)/255,Qt===1)return{css:p.css,rgba:p.rgba};let y=p.rgba>>24&255,b=p.rgba>>16&255,w=p.rgba>>8&255,S=g.rgba>>24&255,E=g.rgba>>16&255,T=g.rgba>>8&255;Bi=S+Math.round((y-S)*Qt),Oi=E+Math.round((b-E)*Qt),zi=T+Math.round((w-T)*Qt);let O=gi.toCss(Bi,Oi,zi),L=gi.toRgba(Bi,Oi,zi);return{css:O,rgba:L}}e.blend=t;function s(g){return(g.rgba&255)===255}e.isOpaque=s;function r(g,p,y){let b=Pu.ensureContrastRatio(g.rgba,p.rgba,y);if(b)return gi.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=r;function o(g){let p=(g.rgba|255)>>>0;return[Bi,Oi,zi]=Pu.toChannels(p),{css:gi.toCss(Bi,Oi,zi),rgba:p}}e.opaque=o;function c(g,p){return Qt=Math.round(p*255),[Bi,Oi,zi]=Pu.toChannels(g.rgba),{css:gi.toCss(Bi,Oi,zi,Qt),rgba:gi.toRgba(Bi,Oi,zi,Qt)}}e.opacity=c;function h(g,p){return Qt=g.rgba&255,c(g,Qt*p/255)}e.multiplyOpacity=h;function f(g){return[g.rgba>>24&255,g.rgba>>16&255,g.rgba>>8&255]}e.toColorRGB=f})(jt||={});var Ft;(e=>{let t,s;try{let o=document.createElement("canvas");o.width=1,o.height=1;let c=o.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function r(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Bi=parseInt(o.slice(1,2).repeat(2),16),Oi=parseInt(o.slice(2,3).repeat(2),16),zi=parseInt(o.slice(3,4).repeat(2),16),gi.toColor(Bi,Oi,zi);case 5:return Bi=parseInt(o.slice(1,2).repeat(2),16),Oi=parseInt(o.slice(2,3).repeat(2),16),zi=parseInt(o.slice(3,4).repeat(2),16),Qt=parseInt(o.slice(4,5).repeat(2),16),gi.toColor(Bi,Oi,zi,Qt);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 Bi=parseInt(c[1]),Oi=parseInt(c[2]),zi=parseInt(c[3]),Qt=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),gi.toColor(Bi,Oi,zi,Qt);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Bi,Oi,zi,Qt]=t.getImageData(0,0,1,1).data,Qt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:gi.toRgba(Bi,Oi,zi,Qt),css:o}}e.toColor=r})(Ft||={});var nn;(e=>{function t(r){return s(r>>16&255,r>>8&255,r&255)}e.relativeLuminance=t;function s(r,o,c){let h=r/255,f=o/255,g=c/255,p=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),y=f<=.03928?f/12.92:Math.pow((f+.055)/1.055,2.4),b=g<=.03928?g/12.92:Math.pow((g+.055)/1.055,2.4);return p*.2126+y*.7152+b*.0722}e.relativeLuminance2=s})(nn||={});var Pu;(e=>{function t(h,f){if(Qt=(f&255)/255,Qt===1)return f;let g=f>>24&255,p=f>>16&255,y=f>>8&255,b=h>>24&255,w=h>>16&255,S=h>>8&255;return Bi=b+Math.round((g-b)*Qt),Oi=w+Math.round((p-w)*Qt),zi=S+Math.round((y-S)*Qt),gi.toRgba(Bi,Oi,zi)}e.blend=t;function s(h,f,g){let p=nn.relativeLuminance(h>>8),y=nn.relativeLuminance(f>>8);if(Fs(p,y)<g){if(y<p){let S=r(h,f,g),E=Fs(p,nn.relativeLuminance(S>>8));if(E<g){let T=o(h,f,g),O=Fs(p,nn.relativeLuminance(T>>8));return E>O?S:T}return S}let b=o(h,f,g),w=Fs(p,nn.relativeLuminance(b>>8));if(w<g){let S=r(h,f,g),E=Fs(p,nn.relativeLuminance(S>>8));return w>E?b:S}return b}}e.ensureContrastRatio=s;function r(h,f,g){let p=h>>24&255,y=h>>16&255,b=h>>8&255,w=f>>24&255,S=f>>16&255,E=f>>8&255,T=Fs(nn.relativeLuminance2(w,S,E),nn.relativeLuminance2(p,y,b));for(;T<g&&(w>0||S>0||E>0);)w-=Math.max(0,Math.ceil(w*.1)),S-=Math.max(0,Math.ceil(S*.1)),E-=Math.max(0,Math.ceil(E*.1)),T=Fs(nn.relativeLuminance2(w,S,E),nn.relativeLuminance2(p,y,b));return(w<<24|S<<16|E<<8|255)>>>0}e.reduceLuminance=r;function o(h,f,g){let p=h>>24&255,y=h>>16&255,b=h>>8&255,w=f>>24&255,S=f>>16&255,E=f>>8&255,T=Fs(nn.relativeLuminance2(w,S,E),nn.relativeLuminance2(p,y,b));for(;T<g&&(w<255||S<255||E<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),E=Math.min(255,E+Math.ceil((255-E)*.1)),T=Fs(nn.relativeLuminance2(w,S,E),nn.relativeLuminance2(p,y,b));return(w<<24|S<<16|E<<8|255)>>>0}e.increaseLuminance=o;function c(h){return[h>>24&255,h>>16&255,h>>8&255,h&255]}e.toChannels=c})(Pu||={});function oa(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Fs(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var rR=class extends hc{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ih=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Qn}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],r=t.translateToString(!0),o=0,c=0,h=0,f=t.getFg(0),g=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==f||this._workCell.bg!==g){if(p-o>1){let y=this._getJoinedRanges(r,h,c,t,o);for(let b=0;b<y.length;b++)s.push(y[b])}o=p,h=c,f=this._workCell.fg,g=this._workCell.bg}c+=this._workCell.getChars().length||Ar.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(r,h,c,t,o);for(let y=0;y<p.length;y++)s.push(p[y])}return s}_getJoinedRanges(e,t,s,r,o){let c=e.substring(t,s),h=[];try{h=this._characterJoiners[0].handler(c)}catch(f){console.error(f)}for(let f=1;f<this._characterJoiners.length;f++)try{let g=this._characterJoiners[f].handler(c);for(let p=0;p<g.length;p++)ih._mergeRanges(h,g[p])}catch(g){console.error(g)}return this._stringRangesToCellRanges(h,r,o),h}_stringRangesToCellRanges(e,t,s){let r=0,o=!1,c=0,h=e[r];if(h){for(let f=s;f<this._bufferService.cols;f++){let g=t.getWidth(f),p=t.getString(f).length||Ar.length;if(g!==0){if(!o&&h[0]<=c&&(h[0]=f,o=!0),h[1]<=c){if(h[1]=f,h=e[++r],!h)break;h[0]<=c?(h[0]=f,o=!0):o=!1}c+=p}}h&&(h[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let r=0;r<e.length;r++){let o=e[r];if(s){if(t[1]<=o[0])return e[r-1][1]=t[1],e;if(t[1]<=o[1])return e[r-1][1]=Math.max(t[1],o[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=o[0])return e.splice(r,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};ih=Jt([Re(0,sn)],ih);function aR(e){return 57508<=e&&e<=57558}function lR(e){return 9472<=e&&e<=9631}function oR(e){return aR(e)||lR(e)}function cR(){return{css:{canvas:ku(),cell:ku()},device:{canvas:ku(),cell:ku(),char:{width:0,height:0,left:0,top:0}}}}function ku(){return{width:0,height:0}}var lm=class{constructor(e,t,s,r,o,c,h){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=r,this._coreService=o,this._decorationService=c,this._themeService=h,this._workCell=new Qn,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,r,o,c,h,f,g,p,y){let b=[],w=this._characterJoinerService.getJoinedCharacters(t),S=this._themeService.colors,E=e.getNoBgTrimmedLength();s&&E<c+1&&(E=c+1);let T,O=0,L="",N=0,I=0,U=0,Q=0,ie=!1,le=0,ce=!1,ve=0,we=0,ne=[],se=p!==-1&&y!==-1;for(let V=0;V<E;V++){e.loadCell(V,this._workCell);let F=this._workCell.getWidth();if(F===0)continue;let re=!1,B=V>=we,W=V,D=this._workCell;if(w.length>0&&V===w[0][0]&&B){let be=w.shift(),De=this._isCellInSelection(be[0],t);for(N=be[0]+1;N<be[1];N++)B&&=De===this._isCellInSelection(N,t);B&&=!s||c<be[0]||c>=be[1],B?(re=!0,D=new rR(this._workCell,e.translateToString(!0,be[0],be[1]),be[1]-be[0]),W=be[1]-1,F=D.getWidth()):we=be[1]}let G=this._isCellInSelection(V,t),me=s&&V===c,R=se&&V>=p&&V<=y,H=!1;this._decorationService.forEachDecorationAtCell(V,t,void 0,be=>{H=!0});let ee=D.getChars()||Ar;if(ee===" "&&(D.isUnderline()||D.isOverline())&&(ee=" "),ve=F*f-g.get(ee,D.isBold(),D.isItalic()),!T)T=this._document.createElement("span");else if(O&&(G&&ce||!G&&!ce&&D.bg===I)&&(G&&ce&&S.selectionForeground||D.fg===U)&&D.extended.ext===Q&&R===ie&&ve===le&&!me&&!re&&!H&&B){D.isInvisible()?L+=Ar:L+=ee,O++;continue}else O&&(T.textContent=L),T=this._document.createElement("span"),O=0,L="";if(I=D.bg,U=D.fg,Q=D.extended.ext,ie=R,le=ve,ce=G,re&&c>=V&&c<=W&&(c=V),!this._coreService.isCursorHidden&&me&&this._coreService.isCursorInitialized){if(ne.push("xterm-cursor"),this._coreBrowserService.isFocused)h&&ne.push("xterm-cursor-blink"),ne.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ne.push("xterm-cursor-outline");break;case"block":ne.push("xterm-cursor-block");break;case"bar":ne.push("xterm-cursor-bar");break;case"underline":ne.push("xterm-cursor-underline");break}}if(D.isBold()&&ne.push("xterm-bold"),D.isItalic()&&ne.push("xterm-italic"),D.isDim()&&ne.push("xterm-dim"),D.isInvisible()?L=Ar:L=D.getChars()||Ar,D.isUnderline()&&(ne.push(`xterm-underline-${D.extended.underlineStyle}`),L===" "&&(L=" "),!D.isUnderlineColorDefault()))if(D.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${hc.toColorRGB(D.getUnderlineColor()).join(",")})`;else{let be=D.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&D.isBold()&&be<8&&(be+=8),T.style.textDecorationColor=S.ansi[be].css}D.isOverline()&&(ne.push("xterm-overline"),L===" "&&(L=" ")),D.isStrikethrough()&&ne.push("xterm-strikethrough"),R&&(T.style.textDecoration="underline");let de=D.getFgColor(),Ee=D.getFgColorMode(),ke=D.getBgColor(),Me=D.getBgColorMode(),Fe=!!D.isInverse();if(Fe){let be=de;de=ke,ke=be;let De=Ee;Ee=Me,Me=De}let _e,X,he=!1;this._decorationService.forEachDecorationAtCell(V,t,void 0,be=>{be.options.layer!=="top"&&he||(be.backgroundColorRGB&&(Me=50331648,ke=be.backgroundColorRGB.rgba>>8&16777215,_e=be.backgroundColorRGB),be.foregroundColorRGB&&(Ee=50331648,de=be.foregroundColorRGB.rgba>>8&16777215,X=be.foregroundColorRGB),he=be.options.layer==="top")}),!he&&G&&(_e=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,ke=_e.rgba>>8&16777215,Me=50331648,he=!0,S.selectionForeground&&(Ee=50331648,de=S.selectionForeground.rgba>>8&16777215,X=S.selectionForeground)),he&&ne.push("xterm-decoration-top");let Ce;switch(Me){case 16777216:case 33554432:Ce=S.ansi[ke],ne.push(`xterm-bg-${ke}`);break;case 50331648:Ce=gi.toColor(ke>>16,ke>>8&255,ke&255),this._addStyle(T,`background-color:#${pS((ke>>>0).toString(16),"0",6)}`);break;default:Fe?(Ce=S.foreground,ne.push("xterm-bg-257")):Ce=S.background}switch(_e||D.isDim()&&(_e=jt.multiplyOpacity(Ce,.5)),Ee){case 16777216:case 33554432:D.isBold()&&de<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(de+=8),this._applyMinimumContrast(T,Ce,S.ansi[de],D,_e,void 0)||ne.push(`xterm-fg-${de}`);break;case 50331648:let be=gi.toColor(de>>16&255,de>>8&255,de&255);this._applyMinimumContrast(T,Ce,be,D,_e,X)||this._addStyle(T,`color:#${pS(de.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,Ce,S.foreground,D,_e,X)||Fe&&ne.push("xterm-fg-257")}ne.length&&(T.className=ne.join(" "),ne.length=0),!me&&!re&&!H&&B?O++:T.textContent=L,ve!==this.defaultSpacing&&(T.style.letterSpacing=`${ve}px`),b.push(T),V=W}return T&&O&&(T.textContent=L),b}_applyMinimumContrast(e,t,s,r,o,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||oR(r.getCode()))return!1;let h=this._getContrastCache(r),f;if(!o&&!c&&(f=h.getColor(t.rgba,s.rgba)),f===void 0){let g=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);f=jt.ensureContrastRatio(o||t,c||s,g),h.setColor((o||t).rgba,(c||s).rgba,f??null)}return f?(this._addStyle(e,`color:${f.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e<r[0]&&t<=r[1]:e<s[0]&&t>=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t<r[1]||s[1]===r[1]&&t===s[1]&&e>=s[0]&&e<r[0]||s[1]<r[1]&&t===r[1]&&e<r[0]||s[1]<r[1]&&t===s[1]&&e>=s[0]}};lm=Jt([Re(1,Dw),Re(2,rn),Re(3,Xs),Re(4,xa),Re(5,dc),Re(6,Rl)],lm);function pS(e,t,s){for(;e.length<s;)e=t+e;return e}var uR=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[s,r,o,c],this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(o),this._container.appendChild(c),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,r){e===this._font&&t===this._fontSize&&s===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,s){let r=0;if(!t&&!s&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let h=this._measure(e,0);return h>0&&(this._flat[r]=h),h}let o=e;t&&(o+="B"),s&&(o+="I");let c=this._holey.get(o);if(c===void 0){let h=0;t&&(h|=1),s&&(h|=2),c=this._measure(e,h),c>0&&this._holey.set(o,c)}return c}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},hR=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let o=e.buffers.active.ydisp,c=t[1]-o,h=s[1]-o,f=Math.max(c,0),g=Math.min(h,e.rows-1);if(f>=e.rows||g<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=c,this.viewportEndRow=h,this.viewportCappedStartRow=f,this.viewportCappedEndRow=g,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function dR(){return new hR}var Qf="xterm-dom-renderer-owner-",Vn="xterm-rows",Tu="xterm-fg-",mS="xterm-bg-",xo="xterm-focus",Du="xterm-selection",fR=1,om=class extends tt{constructor(e,t,s,r,o,c,h,f,g,p,y,b,w,S){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=o,this._helperContainer=c,this._linkifier2=h,this._charSizeService=g,this._optionsService=p,this._bufferService=y,this._coreService=b,this._coreBrowserService=w,this._themeService=S,this._terminalClass=fR++,this._rowElements=[],this._selectionRenderModel=dR(),this.onRequestRedraw=this._register(new Te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Vn),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(Du),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=cR(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(E=>this._injectCss(E))),this._injectCss(this._themeService.colors),this._rowFactory=f.createInstance(lm,document),this._element.classList.add(Qf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(E=>this._handleLinkHover(E))),this._register(this._linkifier2.onHideLinkUnderline(E=>this._handleLinkLeave(E))),this._register(Ut(()=>{this._element.classList.remove(Qf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new uR(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Vn} 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} .${Vn} { 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} .${Vn} .xterm-dim { color: ${jt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Vn}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Vn}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Vn}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Vn} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Du} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Du} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Du} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,h]of e.ansi.entries())t+=`${this._terminalSelector} .${Tu}${c} { color: ${h.css}; }${this._terminalSelector} .${Tu}${c}.xterm-dim { color: ${jt.multiplyOpacity(h,.5).css}; }${this._terminalSelector} .${mS}${c} { background-color: ${h.css}; }`;t+=`${this._terminalSelector} .${Tu}257 { color: ${jt.opaque(e.background).css}; }${this._terminalSelector} .${Tu}257.xterm-dim { color: ${jt.multiplyOpacity(jt.opaque(e.background),.5).css}; }${this._terminalSelector} .${mS}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(xo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(xo),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,h=this._selectionRenderModel.viewportCappedEndRow,f=this._document.createDocumentFragment();if(s){let g=e[0]>t[0];f.appendChild(this._createSelectionElement(c,g?t[0]:e[0],g?e[0]:t[0],h-c+1))}else{let g=r===c?e[0]:0,p=c===o?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(c,g,p));let y=h-c-1;if(f.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,y)),c!==h){let b=o===h?t[0]:this._bufferService.cols;f.appendChild(this._createSelectionElement(h,0,b))}}this._selectionContainer.appendChild(f)}_createSelectionElement(e,t,s,r=1){let o=this._document.createElement("div"),c=t*this.dimensions.css.cell.width,h=this.dimensions.css.cell.width*(s-t);return c+h>this.dimensions.css.canvas.width&&(h=this.dimensions.css.canvas.width-c),o.style.height=`${r*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${c}px`,o.style.width=`${h}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,r=s.ybase+s.y,o=Math.min(s.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,h=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=e;g<=t;g++){let p=g+s.ydisp,y=this._rowElements[g],b=s.lines.get(p);if(!y||!b)break;y.replaceChildren(...this._rowFactory.createRow(b,p,p===r,h,f,o,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Qf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,r,o,c){s<0&&(e=0),r<0&&(t=0);let h=this._bufferService.rows-1;s=Math.max(Math.min(s,h),0),r=Math.max(Math.min(r,h),0),o=Math.min(o,this._bufferService.cols);let f=this._bufferService.buffer,g=f.ybase+f.y,p=Math.min(f.x,o-1),y=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,w=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=s;S<=r;++S){let E=S+f.ydisp,T=this._rowElements[S],O=f.lines.get(E);if(!T||!O)break;T.replaceChildren(...this._rowFactory.createRow(O,E,E===g,b,w,p,y,this.dimensions.css.cell.width,this._widthCache,c?S===s?e:0:-1,c?(S===r?t:o)-1:-1))}}};om=Jt([Re(7,_g),Re(8,Eh),Re(9,rn),Re(10,sn),Re(11,xa),Re(12,Xs),Re(13,Rl)],om);var cm=class extends tt{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new mR(this._optionsService))}catch{this._measureStrategy=this._register(new pR(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())}};cm=Jt([Re(2,rn)],cm);var Vw=class extends tt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},pR=class extends Vw{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},mR=class extends Vw{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}},gR=class extends tt{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new _R(this._window)),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(qi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ve(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ve(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}},_R=class extends tt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Cl),this._onDprChange=this._register(new Te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Ut(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ve(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)}},vR=class extends tt{constructor(){super(),this.linkProviders=[],this._register(Ut(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Eg(e,t,s){let r=s.getBoundingClientRect(),o=e.getComputedStyle(s),c=parseInt(o.getPropertyValue("padding-left")),h=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-r.left-c,t.clientY-r.top-h]}function bR(e,t,s,r,o,c,h,f,g){if(!c)return;let p=Eg(e,t,s);if(p)return p[0]=Math.ceil((p[0]+(g?h/2:0))/h),p[1]=Math.ceil(p[1]/f),p[0]=Math.min(Math.max(p[0],1),r+(g?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var um=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,o){return bR(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let s=Eg(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};um=Jt([Re(0,Gs),Re(1,Eh)],um);var yR=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Yw={};MT(Yw,{getSafariVersion:()=>wR,isChromeOS:()=>Qw,isFirefox:()=>Xw,isIpad:()=>CR,isIphone:()=>xR,isLegacyEdge:()=>SR,isLinux:()=>kg,isMac:()=>nh,isNode:()=>kh,isSafari:()=>Gw,isWindows:()=>Zw});var kh=typeof process<"u"&&"title"in process,fc=kh?"node":navigator.userAgent,pc=kh?"node":navigator.platform,Xw=fc.includes("Firefox"),SR=fc.includes("Edge"),Gw=/^((?!chrome|android).)*safari/i.test(fc);function wR(){if(!Gw)return 0;let e=fc.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var nh=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(pc),CR=pc==="iPad",xR=pc==="iPhone",Zw=["Windows","Win16","Win32","WinCE"].includes(pc),kg=pc.indexOf("Linux")>=0,Qw=/\bCrOS\b/.test(fc),Jw=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,r=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),o=e.timeRemaining(),s*1.5>o){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=o}this.clear()}},ER=class extends Jw{_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())}}},kR=class extends Jw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},sh=!kh&&"requestIdleCallback"in window?kR:ER,TR=class{constructor(){this._queue=new sh}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},hm=class extends tt{constructor(e,t,s,r,o,c,h,f,g){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=o,this._coreBrowserService=f,this._renderer=this._register(new Cl),this._pausedResizeTask=new TR,this._observerDisposable=this._register(new Cl),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new yR((p,y)=>this._renderRows(p,y),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new DR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Ut(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(h.onResize(()=>this._fullRefresh())),this._register(h.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(h.cols,h.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(h.buffer.y,h.buffer.y,!0))),this._register(g.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=Ut(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,s){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,t,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};hm=Jt([Re(2,rn),Re(3,Eh),Re(4,xa),Re(5,dc),Re(6,sn),Re(7,Xs),Re(8,Rl)],hm);var DR=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function RR(e,t,s,r){let o=s.buffer.x,c=s.buffer.y;if(!s.buffer.hasScrollback)return AR(o,c,e,t,s,r)+Th(c,t,s,r)+LR(o,c,e,t,s,r);let h;if(c===t)return h=o>e?"D":"C",tc(Math.abs(o-e),ec(h,r));h=c>t?"D":"C";let f=Math.abs(c-t),g=NR(c>t?e:o,s)+(f-1)*s.cols+1+MR(c>t?o:e);return tc(g,ec(h,r))}function MR(e,t){return e-1}function NR(e,t){return t.cols-e}function AR(e,t,s,r,o,c){return Th(t,r,o,c).length===0?"":tc(t1(e,t,e,t-wa(t,o),!1,o).length,ec("D",c))}function Th(e,t,s,r){let o=e-wa(e,s),c=t-wa(t,s),h=Math.abs(o-c)-BR(e,t,s);return tc(h,ec(e1(e,t),r))}function LR(e,t,s,r,o,c){let h;Th(t,r,o,c).length>0?h=r-wa(r,o):h=t;let f=r,g=OR(e,t,s,r,o,c);return tc(t1(e,h,s,f,g==="C",o).length,ec(g,c))}function BR(e,t,s){let r=0,o=e-wa(e,s),c=t-wa(t,s);for(let h=0;h<Math.abs(o-c);h++){let f=e1(e,t)==="A"?-1:1;s.buffer.lines.get(o+f*h)?.isWrapped&&r++}return r}function wa(e,t){let s=0,r=t.buffer.lines.get(e),o=r?.isWrapped;for(;o&&e>=0&&e<t.rows;)s++,r=t.buffer.lines.get(--e),o=r?.isWrapped;return s}function OR(e,t,s,r,o,c){let h;return Th(s,r,o,c).length>0?h=r-wa(r,o):h=t,e<s&&h<=r||e>=s&&h<r?"C":"D"}function e1(e,t){return e>t?"A":"B"}function t1(e,t,s,r,o,c){let h=e,f=t,g="";for(;(h!==s||f!==r)&&f>=0&&f<c.buffer.lines.length;)h+=o?1:-1,o&&h>c.cols-1?(g+=c.buffer.translateBufferLineToString(f,!1,e,h),h=0,e=0,f++):!o&&h<0&&(g+=c.buffer.translateBufferLineToString(f,!1,0,e+1),h=c.cols-1,e=h,f--);return g+c.buffer.translateBufferLineToString(f,!1,e,h)}function ec(e,t){let s=t?"O":"[";return pe.ESC+s+e}function tc(e,t){e=Math.floor(e);let s="";for(let r=0;r<e;r++)s+=t;return s}var zR=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 gS(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 Jf=50,jR=15,HR=50,PR=500,UR=" ",IR=new RegExp(UR,"g"),dm=class extends tt{constructor(e,t,s,r,o,c,h,f,g){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=o,this._mouseService=c,this._optionsService=h,this._renderService=f,this._coreBrowserService=g,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Qn,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=p=>this._handleMouseMove(p),this._mouseUpListener=p=>this._handleMouseUp(p),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(p=>this._handleTrim(p)),this._register(this._bufferService.buffers.onBufferActivate(p=>this._handleBufferActivate(p))),this.enable(),this._model=new zR(this._bufferService),this._activeSelectionMode=0,this._register(Ut(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(p=>{p.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],c=e[0]<t[0]?t[0]:e[0];for(let h=e[1];h<=t[1];h++){let f=s.translateBufferLineToString(h,!0,o,c);r.push(f)}}else{let o=e[1]===t[1]?t[0]:void 0;r.push(s.translateBufferLineToString(e[1],!0,e[0],o));for(let c=e[1]+1;c<=t[1]-1;c++){let h=s.lines.get(c),f=s.translateBufferLineToString(c,!0);h?.isWrapped?r[r.length-1]+=f:r.push(f)}if(e[1]!==t[1]){let c=s.lines.get(t[1]),h=s.translateBufferLineToString(t[1],!0,0,t[0]);c&&c.isWrapped?r[r.length-1]+=h:r.push(h)}}return r.map(o=>o.replace(IR," ")).join(Zw?`\r
|
|
26
|
+
`:`
|
|
27
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),kg&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=gS(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Eg(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Jf),Jf),t/=Jf,t/Math.abs(t)+Math.round(t*(jR-1)))}shouldForceSelection(e){return nh?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),HR)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(nh&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let r=s.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<PR&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let r=RR(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let r=0;t>=r;r++){let o=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:o>1&&t!==r&&(s+=o-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,c=o.lines.get(e[1]);if(!c)return;let h=o.translateBufferLineToString(e[1],!1),f=this._convertViewportColToCharacterIndex(c,e[0]),g=f,p=e[0]-f,y=0,b=0,w=0,S=0;if(h.charAt(f)===" "){for(;f>0&&h.charAt(f-1)===" ";)f--;for(;g<h.length&&h.charAt(g+1)===" ";)g++}else{let O=e[0],L=e[0];c.getWidth(O)===0&&(y++,O--),c.getWidth(L)===2&&(b++,L++);let N=c.getString(L).length;for(N>1&&(S+=N-1,g+=N-1);O>0&&f>0&&!this._isCharWordSeparator(c.loadCell(O-1,this._workCell));){c.loadCell(O-1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===0?(y++,O--):I>1&&(w+=I-1,f-=I-1),f--,O--}for(;L<c.length&&g+1<h.length&&!this._isCharWordSeparator(c.loadCell(L+1,this._workCell));){c.loadCell(L+1,this._workCell);let I=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,L++):I>1&&(S+=I-1,g+=I-1),g++,L++}}g++;let E=f+p-y+w,T=Math.min(this._bufferService.cols,g-f+y+b-w-S);if(!(!t&&h.slice(f,g).trim()==="")){if(s&&E===0&&c.getCodePoint(0)!==32){let O=o.lines.get(e[1]-1);if(O&&c.isWrapped&&O.getCodePoint(this._bufferService.cols-1)!==32){let L=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(L){let N=this._bufferService.cols-L.start;E-=N,T+=N}}}if(r&&E+T===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let O=o.lines.get(e[1]+1);if(O?.isWrapped&&O.getCodePoint(0)!==32){let L=this._getWordAt([0,e[1]+1],!1,!1,!0);L&&(T+=L.length)}}return{start:E,length:T}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=gS(s,this._bufferService.cols)}};dm=Jt([Re(3,sn),Re(4,xa),Re(5,vg),Re(6,rn),Re(7,Gs),Re(8,Xs)],dm);var _S=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},vS=class{constructor(){this._color=new _S,this._css=new _S}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Si=Object.freeze((()=>{let e=[Ft.toColor("#2e3436"),Ft.toColor("#cc0000"),Ft.toColor("#4e9a06"),Ft.toColor("#c4a000"),Ft.toColor("#3465a4"),Ft.toColor("#75507b"),Ft.toColor("#06989a"),Ft.toColor("#d3d7cf"),Ft.toColor("#555753"),Ft.toColor("#ef2929"),Ft.toColor("#8ae234"),Ft.toColor("#fce94f"),Ft.toColor("#729fcf"),Ft.toColor("#ad7fa8"),Ft.toColor("#34e2e2"),Ft.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let r=t[s/36%6|0],o=t[s/6%6|0],c=t[s%6];e.push({css:gi.toCss(r,o,c),rgba:gi.toRgba(r,o,c)})}for(let s=0;s<24;s++){let r=8+s*10;e.push({css:gi.toCss(r,r,r),rgba:gi.toRgba(r,r,r)})}return e})()),ua=Ft.toColor("#ffffff"),Oo=Ft.toColor("#000000"),bS=Ft.toColor("#ffffff"),yS=Oo,Eo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},KR=ua,fm=class extends tt{constructor(e){super(),this._optionsService=e,this._contrastCache=new vS,this._halfContrastCache=new vS,this._onChangeColors=this._register(new Te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ua,background:Oo,cursor:bS,cursorAccent:yS,selectionForeground:void 0,selectionBackgroundTransparent:Eo,selectionBackgroundOpaque:jt.blend(Oo,Eo),selectionInactiveBackgroundTransparent:Eo,selectionInactiveBackgroundOpaque:jt.blend(Oo,Eo),scrollbarSliderBackground:jt.opacity(ua,.2),scrollbarSliderHoverBackground:jt.opacity(ua,.4),scrollbarSliderActiveBackground:jt.opacity(ua,.5),overviewRulerBorder:ua,ansi:Si.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=Tt(e.foreground,ua),t.background=Tt(e.background,Oo),t.cursor=jt.blend(t.background,Tt(e.cursor,bS)),t.cursorAccent=jt.blend(t.background,Tt(e.cursorAccent,yS)),t.selectionBackgroundTransparent=Tt(e.selectionBackground,Eo),t.selectionBackgroundOpaque=jt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Tt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=jt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Tt(e.selectionForeground,fS):void 0,t.selectionForeground===fS&&(t.selectionForeground=void 0),jt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=jt.opacity(t.selectionBackgroundTransparent,.3)),jt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=jt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Tt(e.scrollbarSliderBackground,jt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Tt(e.scrollbarSliderHoverBackground,jt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Tt(e.scrollbarSliderActiveBackground,jt.opacity(t.foreground,.5)),t.overviewRulerBorder=Tt(e.overviewRulerBorder,KR),t.ansi=Si.slice(),t.ansi[0]=Tt(e.black,Si[0]),t.ansi[1]=Tt(e.red,Si[1]),t.ansi[2]=Tt(e.green,Si[2]),t.ansi[3]=Tt(e.yellow,Si[3]),t.ansi[4]=Tt(e.blue,Si[4]),t.ansi[5]=Tt(e.magenta,Si[5]),t.ansi[6]=Tt(e.cyan,Si[6]),t.ansi[7]=Tt(e.white,Si[7]),t.ansi[8]=Tt(e.brightBlack,Si[8]),t.ansi[9]=Tt(e.brightRed,Si[9]),t.ansi[10]=Tt(e.brightGreen,Si[10]),t.ansi[11]=Tt(e.brightYellow,Si[11]),t.ansi[12]=Tt(e.brightBlue,Si[12]),t.ansi[13]=Tt(e.brightMagenta,Si[13]),t.ansi[14]=Tt(e.brightCyan,Si[14]),t.ansi[15]=Tt(e.brightWhite,Si[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)t.ansi[r+16]=Tt(e.extendedAnsi[r],Si[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()}}};fm=Jt([Re(0,rn)],fm);function Tt(e,t){if(e!==void 0)try{return Ft.toColor(e)}catch{}return t}var WR=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},FR=class{constructor(){this._services=new WR,this._services.set(_g,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=jT(e).sort((c,h)=>c.index-h.index),r=[];for(let c of s){let h=this._services.get(c.id);if(!h)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${c.id._id}.`);r.push(h)}let o=s.length>0?s[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},qR={trace:0,debug:1,info:2,warn:3,error:4,off:5},$R="xterm.js: ",pm=class extends tt{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=qR[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":$R)+t,...s)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};pm=Jt([Re(0,rn)],pm);var SS=class extends tt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let o=t-1;o>=0;o--)this.set(e+o+s,this.get(e+o));let r=e+t+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+s,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},et=3,mi=Object.freeze(new hc),Ru=0,ep=2,zo=class i1{constructor(t,s,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*et);let o=s||Qn.fromCharData([0,Sw,1,0]);for(let c=0;c<t;++c)this.setCell(c,o);this.length=t}get(t){let s=this._data[t*et+0],r=s&2097151;return[this._data[t*et+1],s&2097152?this._combined[t]:r?Mr(r):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,s){this._data[t*et+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*et+0]=t|2097152|s[2]<<22):this._data[t*et+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*et+0]>>22}hasWidth(t){return this._data[t*et+0]&12582912}getFg(t){return this._data[t*et+1]}getBg(t){return this._data[t*et+2]}hasContent(t){return this._data[t*et+0]&4194303}getCodePoint(t){let s=this._data[t*et+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*et+0]&2097152}getString(t){let s=this._data[t*et+0];return s&2097152?this._combined[t]:s&2097151?Mr(s&2097151):""}isProtected(t){return this._data[t*et+2]&536870912}loadCell(t,s){return Ru=t*et,s.content=this._data[Ru+0],s.fg=this._data[Ru+1],s.bg=this._data[Ru+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*et+0]=s.content,this._data[t*et+1]=s.fg,this._data[t*et+2]=s.bg}setCellFromCodepoint(t,s,r,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*et+0]=s|r<<22,this._data[t*et+1]=o.fg,this._data[t*et+2]=o.bg}addCodepointToCell(t,s,r){let o=this._data[t*et+0];o&2097152?this._combined[t]+=Mr(s):o&2097151?(this._combined[t]=Mr(o&2097151)+Mr(s),o&=-2097152,o|=2097152):o=s|1<<22,r&&(o&=-12582913,o|=r<<22),this._data[t*et+0]=o}insertCells(t,s,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s<this.length-t){let o=new Qn;for(let c=this.length-t-s-1;c>=0;--c)this.setCell(t+s+c,this.loadCell(t+c,o));for(let c=0;c<s;++c)this.setCell(t+c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,s,r){if(t%=this.length,s<this.length-t){let o=new Qn;for(let c=0;c<this.length-t-s;++c)this.setCell(t+c,this.loadCell(t+s+c,o));for(let c=this.length-s;c<this.length;++c)this.setCell(c,r)}else for(let o=t;o<this.length;++o)this.setCell(o,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,s,r,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,r);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,r);t<s&&t<this.length;)this.setCell(t++,r)}resize(t,s){if(t===this.length)return this._data.length*4*ep<this._data.buffer.byteLength;let r=t*et;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let o=new Uint32Array(r);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,s)}else{this._data=this._data.subarray(0,r);let o=Object.keys(this._combined);for(let h=0;h<o.length;h++){let f=parseInt(o[h],10);f>=t&&delete this._combined[f]}let c=Object.keys(this._extendedAttrs);for(let h=0;h<c.length;h++){let f=parseInt(c[h],10);f>=t&&delete this._extendedAttrs[f]}}return this.length=t,r*4*ep<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ep<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new i1(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*et+0]&4194303)return t+(this._data[t*et+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*et+0]&4194303||this._data[t*et+2]&50331648)return t+(this._data[t*et+0]>>22);return 0}copyCellsFrom(t,s,r,o,c){let h=t._data;if(c)for(let g=o-1;g>=0;g--){for(let p=0;p<et;p++)this._data[(r+g)*et+p]=h[(s+g)*et+p];h[(s+g)*et+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[s+g])}else for(let g=0;g<o;g++){for(let p=0;p<et;p++)this._data[(r+g)*et+p]=h[(s+g)*et+p];h[(s+g)*et+2]&268435456&&(this._extendedAttrs[r+g]=t._extendedAttrs[s+g])}let f=Object.keys(t._combined);for(let g=0;g<f.length;g++){let p=parseInt(f[g],10);p>=s&&(this._combined[p-s+r]=t._combined[p])}}translateToString(t,s,r,o){s=s??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),o&&(o.length=0);let c="";for(;s<r;){let h=this._data[s*et+0],f=h&2097151,g=h&2097152?this._combined[s]:f?Mr(f):Ar;if(c+=g,o)for(let p=0;p<g.length;++p)o.push(s);s+=h>>22||1}return o&&o.push(s),c}};function VR(e,t,s,r,o,c){let h=[];for(let f=0;f<e.length-1;f++){let g=f,p=e.get(++g);if(!p.isWrapped)continue;let y=[e.get(f)];for(;g<e.length&&p.isWrapped;)y.push(p),p=e.get(++g);if(!c&&r>=f&&r<g){f+=y.length-1;continue}let b=0,w=ic(y,b,t),S=1,E=0;for(;S<y.length;){let O=ic(y,S,t),L=O-E,N=s-w,I=Math.min(L,N);y[b].copyCellsFrom(y[S],E,w,I,!1),w+=I,w===s&&(b++,w=0),E+=I,E===O&&(S++,E=0),w===0&&b!==0&&y[b-1].getWidth(s-1)===2&&(y[b].copyCellsFrom(y[b-1],s-1,w++,1,!1),y[b-1].setCell(s-1,o))}y[b].replaceCells(w,s,o);let T=0;for(let O=y.length-1;O>0&&(O>b||y[O].getTrimmedLength()===0);O--)T++;T>0&&(h.push(f+y.length-T),h.push(T)),f+=y.length-1}return h}function YR(e,t){let s=[],r=0,o=t[r],c=0;for(let h=0;h<e.length;h++)if(o===h){let f=t[++r];e.onDeleteEmitter.fire({index:h-c,amount:f}),h+=f-1,c+=f,o=t[++r]}else s.push(h);return{layout:s,countRemoved:c}}function XR(e,t){let s=[];for(let r=0;r<t.length;r++)s.push(e.get(t[r]));for(let r=0;r<s.length;r++)e.set(r,s[r]);e.length=t.length}function GR(e,t,s){let r=[],o=e.map((g,p)=>ic(e,p,t)).reduce((g,p)=>g+p),c=0,h=0,f=0;for(;f<o;){if(o-f<s){r.push(o-f);break}c+=s;let g=ic(e,h,t);c>g&&(c-=g,h++);let p=e[h].getWidth(c-1)===2;p&&c--;let y=p?s-1:s;r.push(y),f+=y}return r}function ic(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,o=e[t+1].getWidth(0)===2;return r&&o?s-1:s}var n1=class s1{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=s1._nextId++,this._onDispose=this.register(new Te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Sa(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};n1._nextId=1;var ZR=n1,Ei={},ha=Ei.B;Ei[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ei.A={"#":"£"};Ei.B=void 0;Ei[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ei.C=Ei[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ei.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ei.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ei.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ei.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ei.E=Ei[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ei.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ei.H=Ei[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ei["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var wS=4294967295,CS=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=mi.clone(),this.savedCharset=ha,this.markers=[],this._nullCell=Qn.fromCharData([0,Sw,1,0]),this._whitespaceCell=Qn.fromCharData([0,Ar,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new sh,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new SS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new eh),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new eh),this._whitespaceCell}getBlankLine(e,t){return new zo(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>wS?wS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=mi);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 SS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(mi),r=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let h=0;h<this.lines.length;h++)r+=+this.lines.get(h).resize(e,s);let c=0;if(this._rows<t)for(let h=this._rows;h<t;h++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new zo(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+c+1?(this.ybase--,c++,this.ydisp>0&&this.ydisp--):this.lines.push(new zo(e,s)));else for(let h=this._rows;h>t;h--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let h=this.lines.length-o;h>0&&(this.lines.trimStart(h),this.ybase=Math.max(this.ybase-h,0),this.ydisp=Math.max(this.ydisp-h,0),this.savedY=Math.max(this.savedY-h,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),c&&(this.y+=c),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let c=0;c<this.lines.length;c++)r+=+this.lines.get(c).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,r=VR(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(mi),s);if(r.length>0){let o=YR(this.lines,r);XR(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let r=this.getNullCell(mi),o=s;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new zo(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(mi),o=[],c=0;for(let h=this.lines.length-1;h>=0;h--){let f=this.lines.get(h);if(!f||!f.isWrapped&&f.getTrimmedLength()<=e)continue;let g=[f];for(;f.isWrapped&&h>0;)f=this.lines.get(--h),g.unshift(f);if(!s){let I=this.ybase+this.y;if(I>=h&&I<h+g.length)continue}let p=g[g.length-1].getTrimmedLength(),y=GR(g,this._cols,e),b=y.length-g.length,w;this.ybase===0&&this.y!==this.lines.length-1?w=Math.max(0,this.y-this.lines.maxLength+b):w=Math.max(0,this.lines.length-this.lines.maxLength+b);let S=[];for(let I=0;I<b;I++){let U=this.getBlankLine(mi,!0);S.push(U)}S.length>0&&(o.push({start:h+g.length+c,newLines:S}),c+=S.length),g.push(...S);let E=y.length-1,T=y[E];T===0&&(E--,T=y[E]);let O=g.length-b-1,L=p;for(;O>=0;){let I=Math.min(L,T);if(g[E]===void 0)break;if(g[E].copyCellsFrom(g[O],L-I,T-I,I,!0),T-=I,T===0&&(E--,T=y[E]),L-=I,L===0){O--;let U=Math.max(O,0);L=ic(g,U,this._cols)}}for(let I=0;I<g.length;I++)y[I]<e&&g[I].setCell(y[I],r);let N=b-w;for(;N-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+c)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let h=[],f=[];for(let T=0;T<this.lines.length;T++)f.push(this.lines.get(T));let g=this.lines.length,p=g-1,y=0,b=o[y];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+c);let w=0;for(let T=Math.min(this.lines.maxLength-1,g+c-1);T>=0;T--)if(b&&b.start>p+w){for(let O=b.newLines.length-1;O>=0;O--)this.lines.set(T--,b.newLines[O]);T++,h.push({index:p+1,amount:b.newLines.length}),w+=b.newLines.length,b=o[++y]}else this.lines.set(T,f[p--]);let S=0;for(let T=h.length-1;T>=0;T--)h[T].index+=S,this.lines.onInsertEmitter.fire(h[T]),S+=h[T].amount;let E=Math.max(0,g+c-this.lines.maxLength);E>0&&this.lines.onTrimEmitter.fire(E)}}translateBufferLineToString(e,t,s=0,r){let o=this.lines.get(e);return o?o.translateToString(t,s,r):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new ZR(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},QR=class extends tt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Te),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new CS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new CS(!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)}},r1=2,a1=1,mm=class extends tt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,r1),this.rows=Math.max(e.rawOptions.rows||0,a1),this.buffers=this._register(new QR(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=s.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let o=s.ybase+s.scrollTop,c=s.ybase+s.scrollBottom;if(s.scrollTop===0){let h=s.lines.isFull;c===s.lines.length-1?h?s.lines.recycle().copyFrom(r):s.lines.push(r.clone()):s.lines.splice(c+1,0,r.clone()),h?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let h=c-o+1;s.lines.shiftElements(o+1,h-1,-1),s.lines.set(c,r.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};mm=Jt([Re(0,rn)],mm);var dl={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:nh,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},JR=["normal","bold","100","200","300","400","500","600","700","800","900"],eM=class extends tt{constructor(e){super(),this._onOptionChange=this._register(new Te),this.onOptionChange=this._onOptionChange.event;let t={...dl};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ut(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in dl))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in dl))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=dl[e]),!tM(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=dl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=JR.includes(t)?t:dl[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 tM(e){return e==="block"||e==="underline"||e==="bar"}function jo(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let r in e)s[r]=t<=1?e[r]:e[r]&&jo(e[r],t-1);return s}var xS=Object.freeze({insertMode:!1}),ES=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),gm=class extends tt{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Te),this.onData=this._onData.event,this._onUserInput=this._register(new Te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=jo(xS),this.decPrivateModes=jo(ES)}reset(){this.modes=jo(xS),this.decPrivateModes=jo(ES)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(r=>r.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};gm=Jt([Re(0,sn),Re(1,kw),Re(2,rn)],gm);var kS={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 tp(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var ip=String.fromCharCode,TS={DEFAULT:e=>{let t=[tp(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${ip(t[0])}${ip(t[1])}${ip(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${tp(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${tp(e,!0)};${e.x};${e.y}${t}`}},_m=class extends tt{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Te),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(kS))this.addProtocol(r,kS[r]);for(let r of Object.keys(TS))this.addEncoding(r,TS[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let r=t/s,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=r+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};_m=Jt([Re(0,sn),Re(1,xa),Re(2,rn)],_m);var np=[[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]],iM=[[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]],wi;function nM(e,t){let s=0,r=t.length-1,o;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=s;)if(o=s+r>>1,e>t[o][1])s=o+1;else if(e<t[o][0])r=o-1;else return!0;return!1}var sM=class{constructor(){if(this.version="6",!wi){wi=new Uint8Array(65536),wi.fill(1),wi[0]=0,wi.fill(0,1,32),wi.fill(0,127,160),wi.fill(2,4352,4448),wi[9001]=2,wi[9002]=2,wi.fill(2,11904,42192),wi[12351]=1,wi.fill(2,44032,55204),wi.fill(2,63744,64256),wi.fill(2,65040,65050),wi.fill(2,65072,65136),wi.fill(2,65280,65377),wi.fill(2,65504,65511);for(let e=0;e<np.length;++e)wi.fill(0,np[e][0],np[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?wi[e]:nM(e,iM)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let o=pa.extractWidth(t);o===0?r=!1:o>s&&(s=o)}return pa.createPropertyValue(0,s,r)}},pa=class Uu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Te,this.onChange=this._onChange.event;let t=new sM;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,r=!1){return(t&16777215)<<3|(s&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,r=0,o=t.length;for(let c=0;c<o;++c){let h=t.charCodeAt(c);if(55296<=h&&h<=56319){if(++c>=o)return s+this.wcwidth(h);let p=t.charCodeAt(c);56320<=p&&p<=57343?h=(h-55296)*1024+p-56320+65536:s+=this.wcwidth(p)}let f=this.charProperties(h,r),g=Uu.extractWidth(f);Uu.extractShouldJoin(f)&&(g-=Uu.extractWidth(r)),s+=g,r=f}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},rM=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 DS(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var ko=2147483647,aM=256,l1=class vm{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>aM)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new vm;if(!t.length)return s;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let o=t[r];if(Array.isArray(o))for(let c=0;c<o.length;++c)s.addSubParam(o[c]);else s.addParam(o)}return s}clone(){let t=new vm(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let r=this._subParamsIdx[s]>>8,o=this._subParamsIdx[s]&255;o-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>ko?ko: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>ko?ko:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-s>0?this._subParams.subarray(s,r):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let r=this._subParamsIdx[s]>>8,o=this._subParamsIdx[s]&255;o-r>0&&(t[s]=this._subParams.slice(r,o))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,o=r[s-1];r[s-1]=~o?Math.min(o*10+t,ko):t}},To=[],lM=class{constructor(){this._state=0,this._active=To,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=To}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=To,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||To,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",xh(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=To,this._id=-1,this._state=0}}},Mn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=xh(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Do=[],oM=class{constructor(){this._handlers=Object.create(null),this._active=Do,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Do}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Do,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Do,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",xh(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,o=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Do,this._ident=0}},Ho=new l1;Ho.addParam(0);var RS=class{constructor(e){this._handler=e,this._data="",this._params=Ho,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Ho,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=xh(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=Ho,this._data="",this._hitLimit=!1,s));return this._params=Ho,this._data="",this._hitLimit=!1,t}},cM=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=s<<4|r}},Gn=160,uM=(function(){let e=new cM(4095),t=Array.apply(null,Array(256)).map((f,g)=>g),s=(f,g)=>t.slice(f,g),r=s(32,127),o=s(0,24);o.push(25),o.push.apply(o,s(28,32));let c=s(0,14),h;e.setDefault(1,0),e.addMany(r,0,2,0);for(h in c)e.addMany([24,26,153,154],h,3,0),e.addMany(s(128,144),h,3,0),e.addMany(s(144,152),h,3,0),e.add(156,h,0,0),e.add(27,h,11,1),e.add(157,h,4,8),e.addMany([152,158,159],h,0,7),e.add(155,h,11,3),e.add(144,h,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Gn,0,2,0),e.add(Gn,8,5,8),e.add(Gn,6,0,6),e.add(Gn,11,0,11),e.add(Gn,13,13,13),e})(),hM=class extends tt{constructor(e=uM){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 l1,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Ut(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new lM),this._dcsParser=this._register(new oM),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let c=e.intermediates.charCodeAt(o);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=r,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(t),{dispose:()=>{let o=r.indexOf(t);o!==-1&&r.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,r,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=o}parse(e,t,s){let r=0,o=0,c=0,h;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let f=this._parseStack.handlers,g=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&g>-1){for(;g>=0&&(h=f[g](this._params),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 4:if(s===!1&&g>-1){for(;g>=0&&(h=f[g](),h!==!0);g--)if(h instanceof Promise)return this._parseStack.handlerPos=g,h}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],h=this._dcsParser.unhook(r!==24&&r!==26,s),h)return h;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],h=this._oscParser.end(r!==24&&r!==26,s),h)return h;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let f=c;f<t;++f){switch(r=e[f],o=this._transitions.table[this.currentState<<8|(r<160?r:Gn)],o>>4){case 2:for(let w=f+1;;++w){if(w>=t||(r=e[w])<32||r>126&&r<Gn){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Gn){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Gn){this._printHandler(e,f,w),f=w-1;break}if(++w>=t||(r=e[w])<32||r>126&&r<Gn){this._printHandler(e,f,w),f=w-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:f,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let g=this._csiHandlers[this._collect<<8|r],p=g?g.length-1:-1;for(;p>=0&&(h=g[p](this._params),h!==!0);p--)if(h instanceof Promise)return this._preserveStack(3,g,p,o,f),h;p<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++f<t&&(r=e[f])>47&&r<60);f--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let y=this._escHandlers[this._collect<<8|r],b=y?y.length-1:-1;for(;b>=0&&(h=y[b](),h!==!0);b--)if(h instanceof Promise)return this._preserveStack(4,y,b,o,f),h;b<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let w=f+1;;++w)if(w>=t||(r=e[w])===24||r===26||r===27||r>127&&r<Gn){this._dcsParser.put(e,f,w),f=w-1;break}break;case 14:if(h=this._dcsParser.unhook(r!==24&&r!==26),h)return this._preserveStack(6,[],0,o,f),h;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let w=f+1;;w++)if(w>=t||(r=e[w])<32||r>127&&r<Gn){this._oscParser.put(e,f,w),f=w-1;break}break;case 6:if(h=this._oscParser.end(r!==24&&r!==26),h)return this._preserveStack(5,[],0,o,f),h;r===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},dM=/^([\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})$/,fM=/^[\da-f]+$/;function MS(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=dM.exec(t);if(s){let r=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/r*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/r*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),fM.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,r=[0,0,0];for(let o=0;o<3;++o){let c=parseInt(t.slice(s*o,s*o+s),16);r[o]=s===1?c<<4:s===2?c:s===3?c>>4:c>>8}return r}}function sp(e,t){let s=e.toString(16),r=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function pM(e,t=16){let[s,r,o]=e;return`rgb:${sp(s,t)}/${sp(r,t)}/${sp(o,t)}`}var mM={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Er=131072,NS=10;function AS(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 LS=5e3,BS=0,gM=class extends tt{constructor(e,t,s,r,o,c,h,f,g=new hM){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=r,this._optionsService=o,this._oscLinkService=c,this._coreMouseService=h,this._unicodeService=f,this._parser=g,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new OT,this._utf8Decoder=new zT,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=mi.clone(),this._eraseAttrDataInternal=mi.clone(),this._onRequestBell=this._register(new Te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Te),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new bm(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,y)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:y.toArray()})}),this._parser.setEscHandlerFallback(p=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(p)})}),this._parser.setExecuteHandlerFallback(p=>{this._logService.debug("Unknown EXECUTE code: ",{code:p})}),this._parser.setOscHandlerFallback((p,y,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:y,data:b})}),this._parser.setDcsHandlerFallback((p,y,b)=>{y==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:y,payload:b})}),this._parser.setPrintHandler((p,y,b)=>this.print(p,y,b)),this._parser.registerCsiHandler({final:"@"},p=>this.insertChars(p)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},p=>this.scrollLeft(p)),this._parser.registerCsiHandler({final:"A"},p=>this.cursorUp(p)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},p=>this.scrollRight(p)),this._parser.registerCsiHandler({final:"B"},p=>this.cursorDown(p)),this._parser.registerCsiHandler({final:"C"},p=>this.cursorForward(p)),this._parser.registerCsiHandler({final:"D"},p=>this.cursorBackward(p)),this._parser.registerCsiHandler({final:"E"},p=>this.cursorNextLine(p)),this._parser.registerCsiHandler({final:"F"},p=>this.cursorPrecedingLine(p)),this._parser.registerCsiHandler({final:"G"},p=>this.cursorCharAbsolute(p)),this._parser.registerCsiHandler({final:"H"},p=>this.cursorPosition(p)),this._parser.registerCsiHandler({final:"I"},p=>this.cursorForwardTab(p)),this._parser.registerCsiHandler({final:"J"},p=>this.eraseInDisplay(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},p=>this.eraseInDisplay(p,!0)),this._parser.registerCsiHandler({final:"K"},p=>this.eraseInLine(p,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},p=>this.eraseInLine(p,!0)),this._parser.registerCsiHandler({final:"L"},p=>this.insertLines(p)),this._parser.registerCsiHandler({final:"M"},p=>this.deleteLines(p)),this._parser.registerCsiHandler({final:"P"},p=>this.deleteChars(p)),this._parser.registerCsiHandler({final:"S"},p=>this.scrollUp(p)),this._parser.registerCsiHandler({final:"T"},p=>this.scrollDown(p)),this._parser.registerCsiHandler({final:"X"},p=>this.eraseChars(p)),this._parser.registerCsiHandler({final:"Z"},p=>this.cursorBackwardTab(p)),this._parser.registerCsiHandler({final:"`"},p=>this.charPosAbsolute(p)),this._parser.registerCsiHandler({final:"a"},p=>this.hPositionRelative(p)),this._parser.registerCsiHandler({final:"b"},p=>this.repeatPrecedingCharacter(p)),this._parser.registerCsiHandler({final:"c"},p=>this.sendDeviceAttributesPrimary(p)),this._parser.registerCsiHandler({prefix:">",final:"c"},p=>this.sendDeviceAttributesSecondary(p)),this._parser.registerCsiHandler({final:"d"},p=>this.linePosAbsolute(p)),this._parser.registerCsiHandler({final:"e"},p=>this.vPositionRelative(p)),this._parser.registerCsiHandler({final:"f"},p=>this.hVPosition(p)),this._parser.registerCsiHandler({final:"g"},p=>this.tabClear(p)),this._parser.registerCsiHandler({final:"h"},p=>this.setMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"h"},p=>this.setModePrivate(p)),this._parser.registerCsiHandler({final:"l"},p=>this.resetMode(p)),this._parser.registerCsiHandler({prefix:"?",final:"l"},p=>this.resetModePrivate(p)),this._parser.registerCsiHandler({final:"m"},p=>this.charAttributes(p)),this._parser.registerCsiHandler({final:"n"},p=>this.deviceStatus(p)),this._parser.registerCsiHandler({prefix:"?",final:"n"},p=>this.deviceStatusPrivate(p)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},p=>this.softReset(p)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},p=>this.setCursorStyle(p)),this._parser.registerCsiHandler({final:"r"},p=>this.setScrollRegion(p)),this._parser.registerCsiHandler({final:"s"},p=>this.saveCursor(p)),this._parser.registerCsiHandler({final:"t"},p=>this.windowOptions(p)),this._parser.registerCsiHandler({final:"u"},p=>this.restoreCursor(p)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},p=>this.insertColumns(p)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},p=>this.deleteColumns(p)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},p=>this.selectProtected(p)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},p=>this.requestMode(p,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},p=>this.requestMode(p,!1)),this._parser.setExecuteHandler(pe.BEL,()=>this.bell()),this._parser.setExecuteHandler(pe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(pe.BS,()=>this.backspace()),this._parser.setExecuteHandler(pe.HT,()=>this.tab()),this._parser.setExecuteHandler(pe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(pe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Hu.IND,()=>this.index()),this._parser.setExecuteHandler(Hu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Hu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Mn(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new Mn(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new Mn(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new Mn(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new Mn(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new Mn(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new Mn(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new Mn(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new Mn(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new Mn(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new Mn(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new Mn(p=>this.restoreCursorColor(p))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let p in Ei)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 RS((p,y)=>this.requestStatusString(p,y)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),LS))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${LS} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,r=this._activeBuffer.x,o=this._activeBuffer.y,c=0,h=this._parseStack.paused;if(h){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;r=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Er&&(c=this._parseStack.position+Er)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,p=>String.fromCharCode(p)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(p=>p.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Er&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Er))),h||this._dirtyRowTracker.clearRange(),e.length>Er)for(let p=c;p<e.length;p+=Er){let y=p+Er<e.length?p+Er:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(p,y),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,y),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,b))return this._preserveStack(r,o,b,p),this._logSlowResolvingAsync(s),s}else if(!h){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,p))return this._preserveStack(r,o,p,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==r||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let f=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),g=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);g<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(g,this._bufferService.rows-1),end:Math.min(f,this._bufferService.rows-1)})}print(e,t,s){let r,o,c=this._charsetService.charset,h=this._optionsService.rawOptions.screenReaderMode,f=this._bufferService.cols,g=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,y=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,y);let w=this._parser.precedingJoinState;for(let S=t;S<s;++S){if(r=e[S],r<127&&c){let L=c[String.fromCharCode(r)];L&&(r=L.charCodeAt(0))}let E=this._unicodeService.charProperties(r,w);o=pa.extractWidth(E);let T=pa.extractShouldJoin(E),O=T?pa.extractWidth(w):0;if(w=E,h&&this._onA11yChar.fire(Mr(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-O>f){if(g){let L=b,N=this._activeBuffer.x-O;for(this._activeBuffer.x=O,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),O>0&&b instanceof zo&&b.copyCellsFrom(L,N,0,O,!1);N<f;)L.setCellFromCodepoint(N++,0,1,y)}else if(this._activeBuffer.x=f-1,o===2)continue}if(T&&this._activeBuffer.x){let L=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-L,r,o);for(let N=o-O;--N>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y);continue}if(p&&(b.insertCells(this._activeBuffer.x,o-O,this._activeBuffer.getNullCell(y)),b.getWidth(f-1)===2&&b.setCellFromCodepoint(f-1,0,1,y)),b.setCellFromCodepoint(this._activeBuffer.x++,r,o,y),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,y)}this._parser.precedingJoinState=w,this._activeBuffer.x<f&&s-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,y),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>AS(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new RS(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Mn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,r=!1,o=!1){let c=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);c.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),o),r&&(c.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(mi));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,r=pa.extractWidth(t),o=this._activeBuffer.x-r,c=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),h=new Uint32Array(c.length*s),f=0;for(let p=0;p<c.length;){let y=c.codePointAt(p)||0;h[f++]=y,p+=y>65535?2:1}let g=f;for(let p=1;p<s;++p)h.copyWithin(g,0,f),g+=f;return this.print(h,0,g),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(pe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(pe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(pe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(pe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(pe.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ha),this._charsetService.setgCharset(1,ha),this._charsetService.setgCharset(2,ha),this._charsetService.setgCharset(3,ha);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let s;(T=>(T[T.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",T[T.SET=1]="SET",T[T.RESET=2]="RESET",T[T.PERMANENTLY_SET=3]="PERMANENTLY_SET",T[T.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(s||={});let r=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:c}=this._coreMouseService,h=this._coreService,{buffers:f,cols:g}=this._bufferService,{active:p,alt:y}=f,b=this._optionsService.rawOptions,w=(T,O)=>(h.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${T};${O}$y`),!0),S=T=>T?1:2,E=e.params[0];return t?E===2?w(E,4):E===4?w(E,S(h.modes.insertMode)):E===12?w(E,3):E===20?w(E,S(b.convertEol)):w(E,0):E===1?w(E,S(r.applicationCursorKeys)):E===3?w(E,b.windowOptions.setWinLines?g===80?2:g===132?1:0:0):E===6?w(E,S(r.origin)):E===7?w(E,S(r.wraparound)):E===8?w(E,3):E===9?w(E,S(o==="X10")):E===12?w(E,S(b.cursorBlink)):E===25?w(E,S(!h.isCursorHidden)):E===45?w(E,S(r.reverseWraparound)):E===66?w(E,S(r.applicationKeypad)):E===67?w(E,4):E===1e3?w(E,S(o==="VT200")):E===1002?w(E,S(o==="DRAG")):E===1003?w(E,S(o==="ANY")):E===1004?w(E,S(r.sendFocus)):E===1005?w(E,4):E===1006?w(E,S(c==="SGR")):E===1015?w(E,4):E===1016?w(E,S(c==="SGR_PIXELS")):E===1048?w(E,1):E===47||E===1047||E===1049?w(E,S(p===y)):E===2004?w(E,S(r.bracketedPasteMode)):E===2026?w(E,S(r.synchronizedOutput)):w(E,0)}_updateAttrColor(e,t,s,r,o){return t===2?(e|=50331648,e&=-16777216,e|=hc.fromColorRGB([s,r,o])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let r=[0,0,-1,0,0,0],o=0,c=0;do{if(r[c+o]=e.params[t+c],e.hasSubParams(t+c)){let h=e.getSubParams(t+c),f=0;do r[1]===5&&(o=1),r[c+f+1+o]=h[f];while(++f<h.length&&f+c+1+o<r.length);break}if(r[1]===5&&c+o>=2||r[1]===2&&c+o>=5)break;r[1]&&(o=1)}while(++c+t<e.length&&c+o<r.length);for(let h=2;h<r.length;++h)r[h]===-1&&(r[h]=0);switch(r[0]){case 38:s.fg=this._updateAttrColor(s.fg,r[1],r[3],r[4],r[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,r[1],r[3],r[4],r[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,r[1],r[3],r[4],r[5])}return c}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=mi.fg,e.bg=mi.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,r=this._curAttrData;for(let o=0;o<t;o++)s=e.params[o],s>=30&&s<=37?(r.fg&=-50331904,r.fg|=16777216|s-30):s>=40&&s<=47?(r.bg&=-50331904,r.bg|=16777216|s-40):s>=90&&s<=97?(r.fg&=-50331904,r.fg|=16777216|s-90|8):s>=100&&s<=107?(r.bg&=-50331904,r.bg|=16777216|s-100|8):s===0?this._processSGR0(r):s===1?r.fg|=134217728:s===3?r.bg|=67108864:s===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,r)):s===5?r.fg|=536870912:s===7?r.fg|=67108864:s===8?r.fg|=1073741824:s===9?r.fg|=2147483648:s===2?r.bg|=134217728:s===21?this._processUnderline(2,r):s===22?(r.fg&=-134217729,r.bg&=-134217729):s===23?r.bg&=-67108865:s===24?(r.fg&=-268435457,this._processUnderline(0,r)):s===25?r.fg&=-536870913:s===27?r.fg&=-67108865:s===28?r.fg&=-1073741825:s===29?r.fg&=2147483647:s===39?(r.fg&=-67108864,r.fg|=mi.fg&16777215):s===49?(r.bg&=-67108864,r.bg|=mi.bg&16777215):s===38||s===48||s===58?o+=this._extractColor(e,o,r):s===53?r.bg|=1073741824:s===55?r.bg&=-1073741825:s===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):s===100?(r.fg&=-67108864,r.fg|=mi.fg&16777215,r.bg&=-67108864,r.bg|=mi.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${pe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[?${t};${s}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=mi.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!AS(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${pe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>NS&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>NS&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let r=s.shift(),o=s.shift();if(/^\d+$/.exec(r)){let c=parseInt(r);if(OS(c))if(o==="?")t.push({type:0,index:c});else{let h=MS(o);h&&t.push({type:1,index:c,color:h})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(s,r):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),r,o=s.findIndex(c=>c.startsWith("id="));return o!==-1&&(r=s[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let r=0;r<s.length&&!(t>=this._specialColors.length);++r,++t)if(s[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=MS(s[r]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let r=0;r<s.length;++r)if(/^\d+$/.exec(s[r])){let o=parseInt(s[r]);OS(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,ha),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(mM[e[0]],Ei[e[1]]||ha),!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=mi.clone(),this._eraseAttrDataInternal=mi.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 Qn;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(s);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=h=>(this._coreService.triggerDataEvent(`${pe.ESC}${h}${pe.ESC}\\`),!0),r=this._bufferService.buffer,o=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},bm=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&&(BS=e,e=t,t=BS),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};bm=Jt([Re(0,sn)],bm);function OS(e){return 0<=e&&e<256}var _M=5e7,zS=12,vM=50,bM=class extends tt{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>_M)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],o=this._action(r,t);if(o){let h=f=>performance.now()-s>=zS?setTimeout(()=>this._innerWrite(0,f)):this._innerWrite(s,f);o.catch(f=>(queueMicrotask(()=>{throw f}),Promise.resolve(!1))).then(h);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=zS)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>vM&&(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()}},ym=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let f=t.addMarker(t.ybase+t.y),g={data:e,id:this._nextId++,lines:[f]};return f.onDispose(()=>this._removeMarkerFromLink(g,f)),this._dataByLinkId.set(g.id,g),g.id}let s=e,r=this._getEntryIdKey(s),o=this._entriesWithId.get(r);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let c=t.addMarker(t.ybase+t.y),h={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(h,c)),this._entriesWithId.set(h.key,h),this._dataByLinkId.set(h.id,h),h.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};ym=Jt([Re(0,sn)],ym);var jS=!1,yM=class extends tt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Cl),this._onBinary=this._register(new Te),this.onBinary=this._onBinary.event,this._onData=this._register(new Te),this.onData=this._onData.event,this._onLineFeed=this._register(new Te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Te),this._instantiationService=new FR,this.optionsService=this._register(new eM(e)),this._instantiationService.setService(rn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(mm)),this._instantiationService.setService(sn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(pm)),this._instantiationService.setService(kw,this._logService),this.coreService=this._register(this._instantiationService.createInstance(gm)),this._instantiationService.setService(xa,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(_m)),this._instantiationService.setService(Ew,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(pa)),this._instantiationService.setService(UT,this.unicodeService),this._charsetService=this._instantiationService.createInstance(rM),this._instantiationService.setService(PT,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ym),this._instantiationService.setService(Tw,this._oscLinkService),this._inputHandler=this._register(new gM(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(qi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(qi.forward(this._bufferService.onResize,this._onResize)),this._register(qi.forward(this.coreService.onData,this._onData)),this._register(qi.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new bM((t,s)=>this._inputHandler.parse(t,s))),this._register(qi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Te),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!jS&&(this._logService.warn("writeSync is unreliable and will be removed soon."),jS=!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,r1),t=Math.max(t,a1),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(DS.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(DS(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ut(()=>{for(let t of e)t.dispose()})}}},SM={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 wM(e,t,s,r){let o={type:0,cancel:!1,key:void 0},c=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=pe.ESC+"OB":o.key=pe.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":pe.DEL,e.altKey&&(o.key=pe.ESC+o.key);break;case 9:if(e.shiftKey){o.key=pe.ESC+"[Z";break}o.key=pe.HT,o.cancel=!0;break;case 13:o.key=e.altKey?pe.ESC+pe.CR:pe.CR,o.cancel=!0;break;case 27:o.key=pe.ESC,e.altKey&&(o.key=pe.ESC+pe.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"D":t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D";break;case 39:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"C":t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C";break;case 38:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"A":t?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A";break;case 40:if(e.metaKey)break;c?o.key=pe.ESC+"[1;"+(c+1)+"B":t?o.key=pe.ESC+"OB":o.key=pe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=pe.ESC+"[2~");break;case 46:c?o.key=pe.ESC+"[3;"+(c+1)+"~":o.key=pe.ESC+"[3~";break;case 36:c?o.key=pe.ESC+"[1;"+(c+1)+"H":t?o.key=pe.ESC+"OH":o.key=pe.ESC+"[H";break;case 35:c?o.key=pe.ESC+"[1;"+(c+1)+"F":t?o.key=pe.ESC+"OF":o.key=pe.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=pe.ESC+"[5;"+(c+1)+"~":o.key=pe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=pe.ESC+"[6;"+(c+1)+"~":o.key=pe.ESC+"[6~";break;case 112:c?o.key=pe.ESC+"[1;"+(c+1)+"P":o.key=pe.ESC+"OP";break;case 113:c?o.key=pe.ESC+"[1;"+(c+1)+"Q":o.key=pe.ESC+"OQ";break;case 114:c?o.key=pe.ESC+"[1;"+(c+1)+"R":o.key=pe.ESC+"OR";break;case 115:c?o.key=pe.ESC+"[1;"+(c+1)+"S":o.key=pe.ESC+"OS";break;case 116:c?o.key=pe.ESC+"[15;"+(c+1)+"~":o.key=pe.ESC+"[15~";break;case 117:c?o.key=pe.ESC+"[17;"+(c+1)+"~":o.key=pe.ESC+"[17~";break;case 118:c?o.key=pe.ESC+"[18;"+(c+1)+"~":o.key=pe.ESC+"[18~";break;case 119:c?o.key=pe.ESC+"[19;"+(c+1)+"~":o.key=pe.ESC+"[19~";break;case 120:c?o.key=pe.ESC+"[20;"+(c+1)+"~":o.key=pe.ESC+"[20~";break;case 121:c?o.key=pe.ESC+"[21;"+(c+1)+"~":o.key=pe.ESC+"[21~";break;case 122:c?o.key=pe.ESC+"[23;"+(c+1)+"~":o.key=pe.ESC+"[23~";break;case 123:c?o.key=pe.ESC+"[24;"+(c+1)+"~":o.key=pe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=pe.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=pe.DEL:e.keyCode===219?o.key=pe.ESC:e.keyCode===220?o.key=pe.FS:e.keyCode===221&&(o.key=pe.GS);else if((!s||r)&&e.altKey&&!e.metaKey){let h=SM[e.keyCode]?.[e.shiftKey?1:0];if(h)o.key=pe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let f=e.ctrlKey?e.keyCode-64:e.keyCode+32,g=String.fromCharCode(f);e.shiftKey&&(g=g.toUpperCase()),o.key=pe.ESC+g}else if(e.keyCode===32)o.key=pe.ESC+(e.ctrlKey?pe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let f=e.code.slice(3,4);e.shiftKey||(f=f.toLowerCase()),o.key=pe.ESC+f,o.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=pe.US),e.key==="@"&&(o.key=pe.NUL));break}return o}var ai=0,CM=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new sh,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new sh,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,c)=>this._getKey(o)-this._getKey(c)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<r.length;o++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[o]=e[t],t++):r[o]=this._array[s++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ai=this._search(t),ai===-1)||this._getKey(this._array[ai])!==t)return!1;do if(this._array[ai]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ai),!0;while(++ai<this._array.length&&this._getKey(this._array[ai])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,c)=>o-c),t=0,s=new Array(this._array.length-e.length),r=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:s[r++]=this._array[o];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ai=this._search(e),!(ai<0||ai>=this._array.length)&&this._getKey(this._array[ai])===e))do yield this._array[ai];while(++ai<this._array.length&&this._getKey(this._array[ai])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ai=this._search(e),!(ai<0||ai>=this._array.length)&&this._getKey(this._array[ai])===e))do t(this._array[ai]);while(++ai<this._array.length&&this._getKey(this._array[ai])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let r=t+s>>1,o=this._getKey(this._array[r]);if(o>e)s=r-1;else if(o<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},rp=0,HS=0,xM=class extends tt{constructor(){super(),this._decorations=new CM(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ut(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new EM(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let r=0,o=0;for(let c of this._decorations.getKeyIterator(t))r=c.options.x??0,o=r+(c.options.width??1),e>=r&&e<o&&(!s||(c.options.layer??"bottom")===s)&&(yield c)}forEachDecorationAtCell(e,t,s,r){this._decorations.forEachByKey(t,o=>{rp=o.options.x??0,HS=rp+(o.options.width??1),e>=rp&&e<HS&&(!s||(o.options.layer??"bottom")===s)&&r(o)})}},EM=class extends Br{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Te),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Ft.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ft.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},kM=1e3,TM=class{constructor(e,t=kM){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=r-this._lastRefreshMs,c=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},PS=20,rh=class extends tt{constructor(e,t,s,r){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let c=0;c<this._terminal.rows;c++)this._rowElements[c]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[c]);if(this._topBoundaryFocusListener=c=>this._handleBoundaryFocus(c,0),this._bottomBoundaryFocusListener=c=>this._handleBoundaryFocus(c,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new TM(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(c=>this._handleResize(c.rows))),this._register(this._terminal.onRender(c=>this._refreshRows(c.start,c.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(c=>this._handleChar(c))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
28
|
+
`))),this._register(this._terminal.onA11yTab(c=>this._handleTab(c))),this._register(this._terminal.onKey(c=>this._handleKey(c.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ve(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ut(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<PS+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
29
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===PS+1&&(this._liveRegion.textContent+=Up.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,r=s.lines.length.toString();for(let o=e;o<=t;o++){let c=s.lines.get(s.ydisp+o),h=[],f=c?.translateToString(!0,void 0,void 0,h)||"",g=(s.ydisp+o+1).toString(),p=this._rowElements[o];p&&(f.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=f,this._rowColumns.set(p,h)),p.setAttribute("aria-posinset",g),p.setAttribute("aria-setsize",r),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],o=s.getAttribute("aria-posinset"),c=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===c||e.relatedTarget!==r)return;let h,f;if(t===0?(h=s,f=this._rowElements.pop(),this._rowContainer.removeChild(f)):(h=this._rowElements.shift(),f=s,this._rowContainer.removeChild(h)),h.removeEventListener("focus",this._topBoundaryFocusListener),f.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let g=this._createAccessibilityTreeNode();this._rowElements.unshift(g),this._rowContainer.insertAdjacentElement("afterbegin",g)}else{let g=this._createAccessibilityTreeNode();this._rowElements.push(g),this._rowContainer.appendChild(g)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let o=({node:f,offset:g})=>{let p=f instanceof Text?f.parentNode:f,y=parseInt(p?.getAttribute("aria-posinset"),10)-1;if(isNaN(y))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(p);if(!b)return console.warn("columns is null. Race condition?"),null;let w=g<b.length?b[g]:b.slice(-1)[0]+1;return w>=this._terminal.cols&&(++y,w=0),{row:y,column:w}},c=o(t),h=o(s);if(!(!c||!h)){if(c.row>h.row||c.row===h.row&&c.column>=h.column)throw new Error("invalid range");this._terminal.select(c.column,c.row,(h.row-c.row)*this._terminal.cols-c.column+h.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let r=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};rh=Jt([Re(1,_g),Re(2,Xs),Re(3,Gs)],rh);var Sm=class extends tt{constructor(e,t,s,r,o){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=r,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ut(()=>{Sa(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(Ve(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ve(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ve(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ve(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let r=0;r<s.length;r++){let o=s[r];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[r,o]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(s=this._checkLinkProviderResult(r,e,s)):o.provideLinks(e.y,c=>{if(this._isMouseOut)return;let h=c?.map(f=>({link:f}));this._activeProviderReplies?.set(r,h),s=this._checkLinkProviderResult(r,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let r=0;r<t.size;r++){let o=t.get(r);if(o)for(let c=0;c<o.length;c++){let h=o[c],f=h.link.range.start.y<e?0:h.link.range.start.x,g=h.link.range.end.y>e?this._bufferService.cols:h.link.range.end.x;for(let p=f;p<=g;p++){if(s.has(p)){o.splice(c--,1);break}s.add(p)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),o=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(o=!0);if(!o&&r){let c=r.find(h=>this._linkAtPosition(h.link,t));c&&(s=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let c=0;c<this._activeProviderReplies.size;c++){let h=this._activeProviderReplies.get(c)?.find(f=>this._linkAtPosition(f.link,t));if(h){s=!0,this._handleNewLink(h);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&DM(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,Sa(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let r=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(r,o),this._lastMouseEvent)){let c=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);c&&this._askForLink(c,!1)}})))}_linkHover(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,r=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return s<=o&&o<=r}_positionFromMouseEvent(e,t,s){let r=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,r,o){return{x1:e,y1:t,x2:s,y2:r,cols:this._bufferService.cols,fg:o}}};Sm=Jt([Re(1,vg),Re(2,Gs),Re(3,sn),Re(4,Rw)],Sm);function DM(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 RM=class extends yM{constructor(e={}){super(e),this._linkifier=this._register(new Cl),this.browser=Yw,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Cl),this._onCursorMove=this._register(new Te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Te),this.onKey=this._onKey.event,this._onRender=this._register(new Te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Te),this.onBell=this._onBell.event,this._onFocus=this._register(new Te),this._onBlur=this._register(new Te),this._onA11yCharEmitter=this._register(new Te),this._onA11yTabEmitter=this._register(new Te),this._onWillOpen=this._register(new Te),this._setup(),this._decorationService=this._instantiationService.createInstance(xM),this._instantiationService.setService(dc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(vR),this._instantiationService.setService(Rw,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Kp)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(qi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(qi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(qi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(qi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ut(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let o=jt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${pe.ESC}]${r};${pM(o)}${$w.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(c=>c.ansi[t.index]=gi.toColor(...t.color));else{let c=s;this._themeService.modifyColors(h=>h[c]=gi.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(rh,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,o=t.getWidth(s),c=this._renderService.dimensions.css.cell.width*o,h=this.buffer.y*this._renderService.dimensions.css.cell.height,f=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=f+"px",this.textarea.style.top=h+"px",this.textarea.style.width=c+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ve(this.element,"copy",t=>{this.hasSelection()&<(t,this._selectionService)}));let e=t=>BT(t,this.textarea,this.coreService,this.optionsService);this._register(Ve(this.textarea,"paste",e)),this._register(Ve(this.element,"paste",e)),Xw?this._register(Ve(this.element,"mousedown",t=>{t.button===2&&Xy(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ve(this.element,"contextmenu",t=>{Xy(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),kg&&this._register(Ve(this.element,"auxclick",t=>{t.button===1&&yw(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ve(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ve(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ve(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ve(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ve(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ve(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ve(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(Ve(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Pp.get()),Qw||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(gR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Xs,this._coreBrowserService),this._register(Ve(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Ve(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(cm,this._document,this._helperContainer),this._instantiationService.setService(Eh,this._charSizeService),this._themeService=this._instantiationService.createInstance(fm),this._instantiationService.setService(Rl,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ih),this._instantiationService.setService(Dw,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(hm,this.rows,this.screenElement)),this._instantiationService.setService(Gs,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(am,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(um),this._instantiationService.setService(vg,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Sm,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(sm,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(dm,this.element,this.screenElement,r)),this._instantiationService.setService(KT,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(qi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(rm,this.screenElement)),this._register(Ve(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(rh,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(th,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(th,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(om,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(c){let h=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!h)return!1;let f,g;switch(c.overrideType||c.type){case"mousemove":g=32,c.buttons===void 0?(f=3,c.button!==void 0&&(f=c.button<3?c.button:3)):f=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":g=0,f=c.button<3?c.button:3;break;case"mousedown":g=1,f=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let p=c.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;g=p<0?0:1,f=4;break;default:return!1}return g===void 0||f===void 0||f>4?!1:e.coreMouseService.triggerMouseEvent({col:h.col,row:h.row,x:h.x,y:h.y,button:f,action:g,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:c=>(s(c),c.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(c)),wheel:c=>(s(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&s(c)},mousemove:c=>{c.buttons||s(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?r.mousemove||(t.addEventListener("mousemove",o.mousemove),r.mousemove=o.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),c&16?r.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),r.wheel=o.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),c&2?r.mouseup||(r.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),c&4?r.mousedrag||(r.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ve(t,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return s(c),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(c)})),this._register(Ve(t,"wheel",c=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(c,!0);let h=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(h,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){bw(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=wM(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===pe.ETX||s.key===pe.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(MM(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(mi));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(pe.ESC+"[I"):this.coreService.triggerDataEvent(pe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[4;${s};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[6;${o};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function MM(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var NM=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},AM=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 Qn)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},US=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 AM(t)}getNullCell(){return new Qn}},LM=class extends tt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Te),this.onBufferChange=this._onBufferChange.event,this._normal=new US(this._core.buffers.normal,"normal"),this._alternate=new US(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)}},BM=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,r)=>t(s,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},OM=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}},zM=["cols","rows"],ys=0,jM=class extends tt{constructor(e){super(),this._core=this._register(new RM(e)),this._addonManager=this._register(new NM),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],s=(r,o)=>{this._checkReadonlyOptions(r),this._core.options[r]=o};for(let r in this._core.options){let o={get:t.bind(this,r),set:s.bind(this,r)};Object.defineProperty(this._publicOptions,r,o)}}_checkReadonlyOptions(e){if(zM.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 BM(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new OM(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 LM(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
30
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Pp.get()},set promptLabel(e){Pp.set(e)},get tooMuchOutput(){return Up.get()},set tooMuchOutput(e){Up.set(e)}}}_verifyIntegers(...e){for(ys of e)if(ys===1/0||isNaN(ys)||ys%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ys of e)if(ys&&(ys===1/0||isNaN(ys)||ys%1!==0||ys<0))throw new Error("This API only accepts positive integers")}};class HM{pending=null;accept(t){let s="";for(const r of t)s+=this.acceptChar(r);return s}acceptChar(t){return t===""?this.acceptBackspace():h1.has(t)?this.acceptConsonant(t):d1.has(t)?this.acceptVowel(t):KM(t)&&this.canReplacePendingWith(t)?(this.pending=KS(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(f1.has(t))return this.pending.final=t,"";const o=this.flushPending();return this.pending={initial:t},o}const s=IM.get(`${this.pending.final}${t}`);if(s)return this.pending.final=s,"";const r=this.flushPending();return this.pending={initial:t},r}acceptVowel(t){if(!this.pending)return t;if(!this.pending.vowel)return this.pending.vowel=t,"";if(!this.pending.final){const c=UM.get(`${this.pending.vowel}${t}`);return c?(this.pending.vowel=c,""):this.flushPending()+t}const s=IS.get(this.pending.final);if(s){this.pending.final=s[0];const c=this.flushPending();return this.pending={initial:s[1],vowel:t},c}const r=this.pending.final,o=WS({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=IS.get(this.pending.final);return t?this.pending.final=t[0]:delete this.pending.final,""}return this.pending.vowel?(delete this.pending.vowel,""):(this.pending=null,"")}canReplacePendingWith(t){if(!this.pending?.initial)return!1;const s=KS(t);return s.initial===this.pending.initial&&(!this.pending.vowel||s.vowel===this.pending.vowel)&&(!this.pending.final||s.final===this.pending.final)}flushPending(){if(!this.pending)return"";const t=WS(this.pending);return this.pending=null,t}}const ah=44032,lh=21,ml=28,PM=19*lh*ml,o1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],c1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],u1=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],h1=Tg(o1),d1=Tg(c1),f1=Tg(u1),UM=new Map([["ㅗㅏ","ㅘ"],["ㅗㅐ","ㅙ"],["ㅗㅣ","ㅚ"],["ㅜㅓ","ㅝ"],["ㅜㅔ","ㅞ"],["ㅜㅣ","ㅟ"],["ㅡㅣ","ㅢ"]]),p1=[["ㄱㅅ","ㄳ"],["ㄴㅈ","ㄵ"],["ㄴㅎ","ㄶ"],["ㄹㄱ","ㄺ"],["ㄹㅁ","ㄻ"],["ㄹㅂ","ㄼ"],["ㄹㅅ","ㄽ"],["ㄹㅌ","ㄾ"],["ㄹㅍ","ㄿ"],["ㄹㅎ","ㅀ"],["ㅂㅅ","ㅄ"]],IM=new Map(p1),IS=new Map(p1.map(([e,t])=>[t,[e[0],e[1]]]));function Tg(e){return new Map(e.map((t,s)=>[t,s]))}function KM(e){const t=e.codePointAt(0);return t!==void 0&&t>=ah&&t<ah+PM}function KS(e){const t=e.codePointAt(0)-ah,s=Math.floor(t/(lh*ml)),r=Math.floor(t%(lh*ml)/ml),o=t%ml,c={initial:o1[s],vowel:c1[r]};return o===0?c:{...c,final:u1[o]}}function WS(e){if(!e.vowel)return e.initial;const t=h1.get(e.initial),s=d1.get(e.vowel),r=e.final?f1.get(e.final):0;return t===void 0||s===void 0||r===void 0?`${e.initial}${e.vowel}${e.final??""}`:String.fromCodePoint(ah+(t*lh+s)*ml+r)}const WM=[{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 FM({ctrlActive:e,onCtrl:t,onStandaloneKey:s,onPreserveFocus:r,onHide:o}){function c(h){h.stopPropagation(),r()}return m.jsxs("div",{className:"mobile-terminal-key-bar",role:"toolbar","aria-label":"Mobile terminal keys",onMouseDown:c,onPointerDown:c,children:[m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-ctrl","aria-label":"Arm Control modifier","aria-pressed":e,"data-active":e,onClick:t,children:"Ctrl"}),WM.map(h=>m.jsx("button",{type:"button",className:"mobile-terminal-key","aria-label":h.ariaLabel,onClick:()=>s(h.key),children:h.label},h.key)),m.jsx("button",{type:"button",className:"mobile-terminal-key mobile-terminal-key-hide","aria-label":"Hide terminal control keys",title:"Hide",onClick:o,children:"×"})]})}const qM={escape:"\x1B",tab:" ",arrowUp:"\x1B[A",arrowDown:"\x1B[B",arrowRight:"\x1B[C",arrowLeft:"\x1B[D"};function $M(e){return qM[e]}function VM(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}const m1="--nterminal-viewport-height",g1="--nterminal-keyboard-inset-bottom",_1="data-nterminal-keyboard-visible",Dh="data-nterminal-compose-open",oh="nterminal:viewport-refresh",YM=120;function XM(e=window){const t=e.document.documentElement,s=e.visualViewport;function r(){Dg(e)}return r(),s?.addEventListener("resize",r),s?.addEventListener("scroll",r),e.addEventListener("resize",r),e.addEventListener(oh,r),e.addEventListener("orientationchange",r),e.addEventListener("pageshow",r),e.document.addEventListener("visibilitychange",r),()=>{s?.removeEventListener("resize",r),s?.removeEventListener("scroll",r),e.removeEventListener("resize",r),e.removeEventListener(oh,r),e.removeEventListener("orientationchange",r),e.removeEventListener("pageshow",r),e.document.removeEventListener("visibilitychange",r),t.style.removeProperty(m1),t.style.removeProperty(g1),t.removeAttribute(_1)}}function Dg(e=window){const t=e.document.documentElement,s=GM(e),r=QM(e),o=r>YM;return s!==null&&FS(t,m1,`${s}px`),FS(t,g1,`${r}px`),ZM(t,_1,String(o)),{viewportHeight:s,keyboardInsetBottom:r,keyboardVisible:o}}function GM(e){if(e.document.documentElement.hasAttribute(Dh)&&_a(e.innerHeight))return e.innerHeight;const t=e.visualViewport?.height;return _a(t)?t:_a(e.innerHeight)?e.innerHeight:null}function _a(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function FS(e,t,s){e.style.getPropertyValue(t)!==s&&e.style.setProperty(t,s)}function ZM(e,t,s){e.getAttribute(t)!==s&&e.setAttribute(t,s)}function QM(e){return Math.max(JM(e),eN(e))}function JM(e){const t=e.visualViewport?.height;if(!_a(t)||!_a(e.innerHeight))return 0;const s=typeof e.visualViewport?.offsetTop=="number"?e.visualViewport.offsetTop:0;return Math.max(0,Math.round(e.innerHeight-t-s))}function eN(e){if(!_a(e.innerHeight))return 0;const s=e.navigator.virtualKeyboard?.boundingRect?.height;return!_a(s)||s>=e.innerHeight*.8?0:Math.round(s)}const mc=new Map,nc=new Map,tN=Object.freeze({open:!1,text:""});function iN(e){let t=nc.get(e);return t||(t=new Set,nc.set(e,t)),t}function v1(e){const t=nc.get(e);if(t)for(const s of Array.from(t))s()}function Rg(e){return mc.get(e)??tN}function nN(e,t){const s=iN(e);return s.add(t),()=>{s.delete(t)}}function sN(e,t){const s=Rg(e);s.open!==t&&(mc.set(e,{...s,open:t}),v1(e))}function rN(e,t){const s=Rg(e);s.text!==t&&(mc.set(e,{...s,text:t}),v1(e))}function Mu(e){mc.delete(e),nc.delete(e)}function qS(){mc.clear(),nc.clear()}const b1=120,aN="\x1B[200~",lN="\x1B[201~";function $S(e,t){const s=t.stripTrailingLineBreaks===!1?e:Mg(e),r=cN(s);return r?t.bracketedPasteMode?`${aN}${r}${lN}`:r:""}function oN(e){return e==="queue"?" ":"\r"}function Mg(e){return e.replace(/(?:\r\n|\r|\n)+$/,"")}function cN(e){return e.replace(/\r\n/g,`
|
|
31
|
+
`).replace(/\r/g,`
|
|
32
|
+
`).replace(/\n/g,"\r")}const uN=420,hN=3e3,VS=650,dN=80,fN=3,Iu=new Set;let bl=null;function pN({terminalId:e,onSubmit:t,queueAvailable:s=!1,disabled:r=!1}){const o=v.useMemo(()=>N=>nN(e,N),[e]),c=v.useMemo(()=>()=>Rg(e),[e]),h=v.useSyncExternalStore(o,c,c),{open:f,text:g}=h,p=v.useRef(null),y=v.useRef(null),b=v.useRef(null),w=v.useRef(null);v.useEffect(()=>()=>{w.current?.(),w.current=null},[]),v.useLayoutEffect(()=>{if(!(!f||!Ku()))return gN(e),()=>_N(e)},[f,e]),v.useLayoutEffect(()=>{const N=p.current?.closest(".terminal-pane");if(!N)return;function I(){N?.removeAttribute("data-compose-open"),N?.style.removeProperty("--compose-drawer-panel-height")}if(!f){I();return}const U=y.current;N.setAttribute("data-compose-open","true");function Q(){const ve=U?.getBoundingClientRect().height??0;ve>0&&N?.style.setProperty("--compose-drawer-panel-height",`${Math.ceil(ve)}px`)}Q();const ie=[window.setTimeout(Q,0),window.setTimeout(Q,180),window.setTimeout(Q,260)],le=window.requestAnimationFrame?.(Q)??null,ce=typeof ResizeObserver=="function"&&U?new ResizeObserver(Q):null;return ce&&U&&ce.observe(U),()=>{for(const ve of ie)window.clearTimeout(ve);le!==null&&window.cancelAnimationFrame?.(le),ce?.disconnect(),I()}},[f]),v.useEffect(()=>{if(!f){w.current?.(),w.current=null;return}YS(b.current),L()},[f]);function S(N){sN(e,N)}function E(N){rN(e,N)}function T(){mN(p.current),S(!1),XS()}function O(N="send"){if(!(r||!g)){if(t(g,N),E(""),Ku()){b.current?.blur(),XS();return}window.setTimeout(()=>b.current?.focus(),b1+20)}}function L(){Ku()&&(w.current?.(),w.current=vN())}return m.jsxs("div",{ref:p,className:"compose-drawer","data-open":f?"true":"false",children:[m.jsxs("button",{type:"button",className:"compose-drawer-handle","aria-label":"Open compose drawer","aria-hidden":f?"true":void 0,tabIndex:f?-1:0,title:"Compose long input — type without per-keystroke latency, send with Cmd/Ctrl+Enter",onClick:()=>S(!0),children:[m.jsx("span",{"aria-hidden":"true",children:"▴"}),m.jsx("span",{children:"compose"}),g?m.jsx("span",{className:"compose-drawer-handle-dot","aria-label":"draft saved"}):null]}),m.jsxs("div",{ref:y,className:"compose-drawer-panel","aria-hidden":f?void 0:"true",children:[m.jsxs("button",{type:"button",className:"compose-drawer-header","aria-label":"Collapse compose drawer",tabIndex:f?0:-1,title:"Click to collapse — Esc also closes when focus is in the textarea",onClick:T,children:[m.jsx("span",{"aria-hidden":"true",children:"▾"}),m.jsx("span",{className:"compose-drawer-title",children:"compose"}),m.jsx("span",{className:"compose-drawer-hint","aria-hidden":"true",children:s?"Cmd/Ctrl+Enter to send · Cmd/Ctrl+Shift+Enter to queue · Esc to close":"Cmd/Ctrl+Enter to send · Enter for newline · Esc to close"}),m.jsx("span",{className:"compose-drawer-close","aria-hidden":"true",children:"×"})]}),m.jsx("textarea",{ref:b,className:"compose-drawer-input","aria-label":"Compose input",tabIndex:f?0:-1,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",value:g,onChange:N=>E(N.target.value),onFocus:L,onKeyDown:N=>{if(N.key==="Enter"&&(N.metaKey||N.ctrlKey)){if(N.preventDefault(),N.shiftKey){s&&O("queue");return}O("send");return}N.key==="Escape"&&(N.preventDefault(),T())},placeholder:s?"Type a longer command here, then send or queue it.":"Type a longer command here, then Cmd/Ctrl+Enter to send."}),m.jsxs("div",{className:"compose-drawer-actions",children:[m.jsx("button",{type:"button",className:"compose-drawer-clear",tabIndex:f?0:-1,onClick:()=>{E(""),YS(b.current),L()},disabled:!g,children:"Clear"}),s?m.jsx("button",{type:"button",className:"compose-drawer-queue",tabIndex:f?0:-1,title:"Queue in Codex with Cmd/Ctrl+Shift+Enter",onClick:()=>O("queue"),disabled:r||!g,children:"Queue"}):null,m.jsx("button",{type:"button",className:"compose-drawer-send",tabIndex:f?0:-1,onClick:()=>O("send"),disabled:r||!g,children:"Send"})]})]})]})}function mN(e){const t=document.activeElement;t instanceof HTMLElement&&(!e||e.contains(t))&&t.blur()}function YS(e){if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}}function Ku(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function XS(){if(!Ku())return;const e=gl;e(),window.requestAnimationFrame?.(e),window.setTimeout(e,120),window.setTimeout(e,320)}function gN(e){bl!==null&&(window.clearTimeout(bl),bl=null),Iu.add(e),document.documentElement.setAttribute(Dh,"true"),gl()}function _N(e){if(Iu.delete(e),Iu.size>0||bl!==null){gl();return}bl=window.setTimeout(()=>{if(bl=null,Iu.size>0){gl();return}document.documentElement.removeAttribute(Dh),gl()},uN),gl()}function vN(){let e=!1,t=null,s=null,r=null,o=0;const c=Date.now(),h=window.visualViewport,f=bN();function g(){t!==null&&(window.clearTimeout(t),t=null),s!==null&&(window.cancelAnimationFrame?.(s),s=null)}function p(){e||(e=!0,g(),h?.removeEventListener("resize",b),h?.removeEventListener("scroll",b),f?.removeEventListener("geometrychange",b))}function y(w){if(!e){if(w<VS&&typeof window.requestAnimationFrame=="function"){s=window.requestAnimationFrame(b);return}t=window.setTimeout(b,dN)}}function b(){if(e)return;g();const w=Dg(),S=Date.now()-c;if(w.keyboardInsetBottom>0&&w.keyboardInsetBottom===r?o+=1:(o=w.keyboardInsetBottom>0?1:0,r=w.keyboardInsetBottom),S>=hN||S>=VS&&o>=fN){p();return}y(S)}return h?.addEventListener("resize",b),h?.addEventListener("scroll",b),f?.addEventListener("geometrychange",b),b(),p}function gl(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0,Dg()}function bN(){const e=navigator.virtualKeyboard;return!e||typeof e.addEventListener!="function"?null:e}function yN(e,t){e.attachCustomKeyEventHandler(c=>{if(SN(c)){const h=GS(e);return h?(c.preventDefault(),c.stopPropagation(),ZS(h),!1):!0}return wN(c)?(c.preventDefault(),c.stopPropagation(),CN(e,t),!1):!0});const s=e.element;if(!s)return{dispose(){e.attachCustomKeyEventHandler(()=>!0)}};const r=c=>{const h=GS(e);if(h){if(c.clipboardData){c.clipboardData.setData("text/plain",h),c.preventDefault();return}c.preventDefault(),ZS(h)}},o=c=>{const h=c.clipboardData?.getData("text/plain");if(!h)return;const f=Mg(h);c.preventDefault(),c.stopImmediatePropagation(),y1(e,f,t)};return s.addEventListener("copy",r,!0),s.addEventListener("paste",o,!0),{dispose(){s.removeEventListener("copy",r,!0),s.removeEventListener("paste",o,!0),e.attachCustomKeyEventHandler(()=>!0)}}}function SN(e){return e.type!=="keydown"||e.altKey||e.key.toLowerCase()!=="c"?!1:e.metaKey&&!e.ctrlKey&&!e.shiftKey||e.ctrlKey&&e.shiftKey&&!e.metaKey?!0:e.ctrlKey&&!e.shiftKey&&!e.metaKey}function wN(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 CN(e,t){if(navigator.clipboard?.readText)try{const s=await navigator.clipboard.readText();if(!s)return;y1(e,Mg(s),t)}catch{}}function y1(e,t,s){if(t){if(s){s(t);return}e.paste(t)}}function GS(e){return e.hasSelection()?e.getSelection():""}async function ZS(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}xN(e)}function xN(e){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,s=document.createElement("textarea");s.value=e,s.setAttribute("readonly","true"),s.style.position="fixed",s.style.left="-9999px",s.style.top="0",s.style.opacity="0",document.body.appendChild(s),s.focus({preventScroll:!0}),s.select();try{typeof document.execCommand=="function"&&document.execCommand("copy")}finally{s.remove(),t?.focus({preventScroll:!0})}}const EN=[4,10,11,12];function kN(e,t){const s=[e.parser.registerCsiHandler({final:"c"},r=>QS(r)),e.parser.registerCsiHandler({prefix:">",final:"c"},r=>QS(r)),e.parser.registerCsiHandler({final:"n"},r=>TN(r)),e.parser.registerCsiHandler({prefix:"?",final:"n"},r=>DN(r)),e.parser.registerCsiHandler({final:"t"},r=>RN(r)),e.parser.registerDcsHandler({intermediates:"$",final:"q"},()=>!0),...EN.map(r=>e.parser.registerOscHandler(r,o=>MN(o)))];return{dispose(){for(const r of s)r.dispose()}}}function QS(e){return Rh(e)===0}function TN(e){const t=Rh(e);return t===5||t===6}function DN(e){return Rh(e)===6}function RN(e){const t=Rh(e);return t===14||t===16||t===18}function MN(e){return e.split(";").some(t=>t==="?")}function Rh(e){const t=e[0];return typeof t=="number"?t:0}const Ca=new Map,NN=2*1024*1024,AN=1500,LN=25e3;function BN(e,t){let s=Ca.get(e);s||(s=jN(e),Ca.set(e,s),Mh(s)),s.listeners.add(t);const r=c=>WN(s,c),o=()=>{s.listeners.delete(t)};return{status:s.status,snapshot:s.snapshot,output:s.output.slice(),history:s.history,send:r,detach:o}}function Po(e){const t=Ca.get(e);t&&(FN(t),Ca.delete(e))}function ON(e,t={}){const s=Ca.get(e);if(!s)return!1;s.exited=!1,s.reconnectEnabled=!0,t.preserveCachedOutputOnNextSnapshot&&(s.preserveCachedOutputOnNextSnapshot=!0),s.reconnectTimer!==null&&(window.clearTimeout(s.reconnectTimer),s.reconnectTimer=null),gc(s);const r=s.socket;return s.socket=null,da(s,"reconnecting"),r&&(r.readyState===WebSocket.OPEN||r.readyState===WebSocket.CONNECTING)&&r.close(),Mh(s),!0}function zN(){for(const e of Ca.values()){if(e.status!=="unauthorized"||e.exited)continue;e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),gc(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(),Mh(e)}}function ap(){for(const e of Array.from(Ca.keys()))Po(e)}function jN(e){return{url:e,socket:null,status:"connecting",snapshot:null,output:[],history:null,outputBytes:0,pendingOut:[],listeners:new Set,reconnectTimer:null,reconnectEnabled:!0,heartbeat:null,isAlive:!1,exited:!1,preserveCachedOutputOnNextSnapshot:!1}}function Mh(e){if(!e.reconnectEnabled)return;da(e,e.socket===null&&e.status!=="reconnecting"?"connecting":"reconnecting");const t=new WebSocket(e.url);e.socket=t,e.isAlive=!1,t.addEventListener("open",()=>{if(e.socket===t){da(e,"connected");for(const s of e.pendingOut)t.send(JSON.stringify(s));e.pendingOut.length=0,e.isAlive=!0,HN(e)}}),t.addEventListener("message",s=>{if(e.socket!==t)return;const r=typeof s.data=="string"?s.data:"";if(!r)return;let o=null;try{o=JSON.parse(r)}catch{return}if(!o||typeof o.type!="string")return;if(o.type==="pong"){e.isAlive=!0;return}const c=UN(e,o);S1(e,{type:"message",message:c})}),t.addEventListener("close",s=>{if(e.socket===t){if(e.socket=null,gc(e),s.code===1008){e.reconnectEnabled=!1,da(e,PN(s.reason)?"unauthorized":"closed");return}if(e.exited||!e.reconnectEnabled){da(e,"closed");return}da(e,"reconnecting"),e.reconnectTimer=window.setTimeout(()=>{e.reconnectTimer=null,Mh(e)},AN)}}),t.addEventListener("error",()=>{})}function HN(e){gc(e),e.heartbeat=window.setInterval(()=>{const t=e.socket;if(!(!t||t.readyState!==WebSocket.OPEN)){if(!e.isAlive){t.close();return}e.isAlive=!1,t.send(JSON.stringify({type:"ping",nonce:Date.now().toString(36)}))}},LN)}function gc(e){e.heartbeat!==null&&(window.clearInterval(e.heartbeat),e.heartbeat=null)}function PN(e){return e.trim().toLowerCase()==="unauthorized"}function UN(e,t){return t.type==="snapshot"?(e.snapshot=t.terminal,e.history=t.history??null,e.exited=t.terminal.status==="exited",e.preserveCachedOutputOnNextSnapshot?(e.preserveCachedOutputOnNextSnapshot=!1,IN(e,t.output),lp(e),{...t,output:e.output.slice(),history:e.history}):(e.output=t.output.slice(),e.outputBytes=e.output.reduce((s,r)=>s+r.length,0),lp(e),t)):t.type==="output"?(e.output.push(t.data),e.outputBytes+=t.data.length,lp(e),t):t.type==="terminal_updated"?(e.snapshot=t.terminal,t.terminal.status==="exited"&&(e.exited=!0),t):(t.type==="exit"&&(e.exited=!0,e.snapshot&&e.snapshot.id===t.terminalId&&(e.snapshot={...e.snapshot,status:"exited",exitCode:t.exitCode})),t)}function IN(e,t){const s=KN(e.output,t);if(s===0)return;const r=t.slice(s);for(const o of r)e.output.push(o),e.outputBytes+=o.length}function KN(e,t){const s=Math.min(e.length,t.length);for(let r=s;r>0;r-=1){let o=!0;for(let c=0;c<r;c+=1)if(e[e.length-r+c]!==t[c]){o=!1;break}if(o)return r}return 0}function lp(e){for(;e.outputBytes>NN&&e.output.length>1;){const t=e.output.shift();e.outputBytes-=t.length}}function da(e,t){e.status!==t&&(e.status=t,S1(e,{type:"status",status:t}))}function S1(e,t){for(const s of Array.from(e.listeners))s(t)}function WN(e,t){const s=e.socket;return s&&s.readyState===WebSocket.OPEN?(s.send(JSON.stringify(t)),!0):(t.type==="input"&&e.pendingOut.push(t),!1)}function FN(e){e.reconnectEnabled=!1,e.reconnectTimer!==null&&(window.clearTimeout(e.reconnectTimer),e.reconnectTimer=null),gc(e);const t=e.socket;e.socket=null,t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),e.listeners.clear()}const qN=[0,50,150,350],$N=120,VN=2,YN=[300,1200,2500],XN=1e3,GN=1e5,wm="\x1B[?1049l\x1B[?1047l\x1B[?47l",ZN=new Set(["47","1047","1049"]),QN=400,JN=3,e3=3,t3=32,i3=1.42,n3=2,s3=24,r3=240,a3=60,l3=420,o3=6,c3=2,JS=[500,1500,3e3,5e3,8e3],e0=15e3,u3=xi.lazy(()=>gg(()=>import("./TranscriptMarkdownBody-B5UquJIY.js"),__vite__mapDeps([2,1])));function t0({terminal:e,serverApi:t,active:s,visible:r=!0,canClose:o,refreshCwdOnEnter:c=!1,tabId:h,onSelect:f,onClose:g,onExit:p,onSnapshot:y,onAuthClose:b}){const w=v.useSyncExternalStore(aw,Ap,()=>ma),S=v.useSyncExternalStore(lw,Lp,()=>Sl),E=v.useSyncExternalStore(ow,Op,()=>!0),T=v.useSyncExternalStore(qm,Or,()=>yl),O=v.useSyncExternalStore(ug,()=>hg("history.toggle"),()=>"Alt+H"),L=v.useRef(null),N=v.useRef(null),I=v.useRef(null),U=v.useRef(null),Q=v.useRef({onExit:p,onSnapshot:y}),ie=v.useRef(t.createWebSocketUrl),le=v.useRef(b),ce=v.useRef(null),ve=v.useRef(null),we=v.useRef(null),ne=v.useRef(!1),se=v.useRef(new Map),V=v.useRef([]),F=v.useRef([]),re=v.useRef([]),B=v.useRef(0),W=v.useRef(!1),D=v.useRef(null),G=v.useRef(0),me=v.useRef(null),R=v.useRef(null),H=v.useRef(!1),ee=v.useRef(!1),de=v.useRef(!1),Ee=v.useRef(!1),ke=v.useRef(null),Me=v.useRef(null),Fe=v.useRef(!1),_e=v.useRef(!1),X=v.useRef(!1),he=v.useRef(!1),Ce=v.useRef(!1),be=v.useRef(!1),De=v.useRef(!1),Oe=v.useRef(s),Ie=v.useRef(r),oe=v.useRef(c),xe=v.useRef(w),Ae=v.useRef(S),ze=v.useRef(!1),He=v.useRef(null),gt=v.useRef(null),Xe=v.useRef(!1),st=v.useRef(null),[,ei]=v.useState("connecting"),[an,ki]=v.useState(!1),[ti,Ti]=v.useState(null),[Jn,K]=v.useState(!1),[$e,ot]=v.useState(null),[wt,li]=v.useState(!1),[Dt,ln]=v.useState(!1),[es,ts]=v.useState(!1),[Rt,Pi]=v.useState(null),[_t,vt]=v.useState(!1),Ct=!!Rt||Wu(e.currentCommand),[Di,oi]=v.useState(!1);v.useLayoutEffect(()=>{Oe.current=s},[s]),v.useLayoutEffect(()=>{Ie.current=r},[r]),v.useLayoutEffect(()=>{oe.current=c},[c]),v.useLayoutEffect(()=>{xe.current=w},[w]),v.useLayoutEffect(()=>{Ae.current=S},[S]),v.useLayoutEffect(()=>{ze.current=_t},[_t]),v.useLayoutEffect(()=>{He.current=Rt},[Rt]),v.useLayoutEffect(()=>{Xe.current=Ct},[Ct]),v.useEffect(()=>{r&&s&&e.status==="running"&&(Lt(),en())},[s,r,e.status]),v.useEffect(()=>{Q.current={onExit:p,onSnapshot:y}},[p,y]),v.useEffect(()=>{ie.current=t.createWebSocketUrl,le.current=b},[t,b]),v.useEffect(()=>{let M=!1,J=null,Be=0;const Ke=E3(e.currentCommand),qe=Wu(e.currentCommand);function Je(){J!==null&&(window.clearTimeout(J),J=null)}function Bt(dt){if(M)return;let bt;if(dt){if(!qe)return;bt=e0}else if(Be<JS.length){if(!Ke)return;bt=JS[Be++]}else{if(!qe)return;bt=e0}J=window.setTimeout(()=>{J=null,Vt()},bt)}async function Vt(){try{const dt=await t.getTerminalTranscriptSource(e.id);if(M)return;Pi(bt=>bt&&dt.source&&bt.provider===dt.source.provider&&bt.sessionId===dt.source.sessionId?bt:dt.source),Bt(!!dt.source)}catch(dt){if(M)return;op(dt)&&Pi(null),Bt(!1)}}return Pi(null),e.status!=="running"?()=>{M=!0,Je()}:(Vt(),()=>{M=!0,Je()})},[t,e.currentCommand,e.id,e.status]),v.useEffect(()=>{const M=Rt?`${e.id}:${Rt.provider}:${Rt.sessionId}`:null,J=gt.current;J!==null&&M!==null&&J!==M&&ze.current&&vt(!1),gt.current=M},[e.id,Rt?.provider,Rt?.sessionId]),v.useEffect(()=>{function M(J){!Oe.current||!Ie.current||!He.current||J.isComposing||J.key==="Process"||f3(J.target)||cw(J)?.id!=="history.toggle"||(J.preventDefault(),J.stopPropagation(),vt(Ke=>!Ke))}return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[]),v.useEffect(()=>{const M=N.current;M&&(M.options.disableStdin=e.status==="exited"),e.status==="exited"&&ei("closed")},[e.status]),v.useEffect(()=>{const M=N.current;M&&(M.options.fontSize=w,Wf(w,Ae.current).then(()=>{xe.current===w&&Lt()}))},[w]),v.useEffect(()=>{const M=N.current;M&&(M.options.fontFamily=Np(S),Wf(xe.current,S).then(()=>{Ae.current===S&&Lt()}))},[S]),v.useEffect(()=>{const M=N.current;M&&(M.options.theme=i0(T))},[T]),v.useEffect(()=>{const M=L.current;if(!M)return;let J=!1,Be=null,Ke=null,qe=null,Je=null,Bt=null,Vt=null,dt=null;ce.current=null,Ce.current=!1,be.current=!1,Ee.current=!1,bn(),ci();const bt=xe.current,Vi=Ae.current,Yt=new jM({cursorBlink:!0,convertEol:!1,disableStdin:e.status==="exited",fontFamily:Np(Vi),fontSize:bt,fontWeight:400,fontWeightBold:700,macOptionClickForcesSelection:!0,scrollback:GN,theme:{...i0(Or())}}),x=new DT;return Yt.loadAddon(x),Je=kN(Yt),N.current=Yt,I.current=x,Wf(bt,Vi).then(()=>{if(J)return;Yt.open(M),Ce.current=!0,Be=yN(Yt,Bl),Ie.current&&Oe.current&&e.status==="running"&&en(),Lt(),Bt=B3(M,Yt,()=>xe.current*1.2,ds,j=>{vi(j)},ns,ks),Vt=N3(M,Yt,ds,j=>{vi(j)},ns,ks);const k=new HM;Ke=Yt.onData(j=>{if(De.current){const ye=VM(j);if(ye){ps(!1),Ji(ye);return}}const te=k.accept(j);te&&Ji(te)}),qe=Yt.onScroll(j=>{if(_e.current||he.current||X.current){ui();return}Da(),os(Yt)&&on({scrollToBottom:!0}),ds(),j<=3&&vi()}),dt=new ResizeObserver(()=>{It()}),dt.observe(M),be.current&&(Ri(),be.current=!1,Lt()),On()}),()=>{J=!0,Ce.current=!1,be.current=!1,bn(),ve.current=null,we.current=null,ne.current=!1,Kt(),is(),X.current=!1,Bt?.(),Vt?.(),dt?.disconnect(),Be?.dispose(),Ke?.dispose(),qe?.dispose(),Je?.dispose(),Yt.dispose(),N.current=null,I.current=null}},[e.id]),v.useEffect(()=>{const M=ie.current(e.id),J=BN(M,qt);return U.current=J.send,ei(J.status),J.status==="connected"&&Lt(),J.snapshot&&(Q.current.onSnapshot(J.snapshot,{notifyCompletion:!1}),N.current&&(Lt(),_i(J.output,J.history),Lt())),()=>{J.detach(),U.current=null}},[e.id,e.status]);function qt(M){if(M.type==="status"){ei(M.status),M.status==="unauthorized"&&le.current?.({source:"terminal-ws-1008",terminalId:e.id}),M.status==="connected"&&Lt();return}vn(M.message)}function ci(M=[],J=null){F.current=[],re.current=Nu(M),B.current=0,W.current=!1,D.current=null,X.current=!1,G.current+=1,me.current=J,R.current=null,H.current=!1,ee.current=!1,de.current=!1,be.current=!1,st.current=null,ke.current=null,Fe.current=!1,ki(!1),Ti(null),K(!1),ot(null),li(!1),ln(!1)}function _i(M=[],J=null){ci(M,J),Ht()}function Ht(){if(!N.current||!Ce.current){be.current=!0;return}be.current=!1,Ri()}async function Ri(){const M=N.current;if(!M)return;const J=Au(M,Fe.current),Be=J?re.current.length:B.current;await ii(M,{liveOutputLimit:Be,scrollToBottom:J}),N.current===M&&ui()}function ii(M,J={}){return new Promise(Be=>{X.current=!0,W.current=!1;const Ke=G.current+1;G.current=Ke;const qe=Math.max(0,Math.min(J.liveOutputLimit??re.current.length,re.current.length)),Je=J.historyPages??F.current,Bt=()=>{if(N.current!==M||G.current!==Ke){Be(!1);return}try{B.current=qe,J.scrollToBottom&&ss(M)}finally{X.current=!1;const dt=Ma();dt?on(dt):J.applyDeferredSnapshot!==!1&&rt(),Be(!0)}},Vt=()=>{if(N.current!==M||G.current!==Ke){Be(!1);return}M.clear();const dt=Nu([...Je,...re.current.slice(0,qe)]);if(dt.length===0){Bt();return}for(let bt=0;bt<dt.length;bt+=1){const Vi=dt[bt];bt===dt.length-1?M.write(Vi,Bt):M.write(Vi)}};if(M.buffer.active.type==="alternate"){M.write(wm,Vt);return}Vt()})}async function vi(M=0){const J=N.current;if(de.current||!J)return;if(jn(J)){ui();return}const Be=me.current;de.current=!0,ki(!0);const Ke=J.buffer.active.viewportY;try{let qe=!!(Be&&!Be.hasMore);if(!qe)try{const Je=await t.getTerminalHistory(e.id,{beforeLine:Be?.startLine??0,limit:XN}),Bt={startLine:Je.startLine,endLine:Je.endLine,hasMore:Je.hasMore};if(Je.output.length>0){await Gi(J,Je.output,Ke,M)&&(me.current=Bt);return}me.current=Bt,qe=!Je.hasMore}catch(Je){qe=op(Je)}if(qe){if(jn(J)){ui();return}await _n(J,Ke,M)}}catch{}finally{de.current=!1,ki(!1)}}async function _n(M,J,Be){if(!(H.current||ee.current))try{const Ke=R.current,qe=await t.getTerminalTranscriptHistory(e.id,{...Ke?{cursor:Ke}:{},limit:QN}),Je=qe.output.map(x1);if(!qe.source)return;if(Je.length===0){Pi(qe.source),R.current=qe.cursor,ee.current=!qe.hasMore||!qe.cursor;return}await Gi(M,Je,J,Be)&&(Pi(qe.source),R.current=qe.cursor,ee.current=!qe.hasMore||!qe.cursor)}catch(Ke){op(Ke)&&(H.current=!0)}}async function Gi(M,J,Be,Ke){if(jn(M))return ui(),!1;const qe=[...J,...F.current],Je=R3(J);return!await ii(M,{liveOutputLimit:B.current,scrollToBottom:!1,historyPages:qe,applyDeferredSnapshot:!1})||N.current!==M?!1:(F.current=qe,Na(M,Math.max(0,Be+Je+Math.min(0,Ke))),Fe.current=!os(M),ds(),!0)}v.useEffect(()=>{const M=window.visualViewport;function J(){document.visibilityState==="visible"&&Lt()}function Be(){Lt()}function Ke(){It()}function qe(){Ln()}return document.addEventListener("visibilitychange",J),window.addEventListener("pageshow",Be),window.addEventListener("resize",Ke),window.addEventListener(oh,qe),M?.addEventListener("resize",Ke),M?.addEventListener("scroll",Ke),()=>{document.removeEventListener("visibilitychange",J),window.removeEventListener("pageshow",Be),window.removeEventListener("resize",Ke),window.removeEventListener(oh,qe),M?.removeEventListener("resize",Ke),M?.removeEventListener("scroll",Ke)}},[e.id]);function Zi(){const M=ie.current(e.id);Ee.current=!0,st.current=null,ei("reconnecting"),Lt(),ON(M,{preserveCachedOutputOnNextSnapshot:!0})}function vn(M){if(M.type==="snapshot"&&M.terminal.id===e.id){Q.current.onSnapshot(M.terminal,{notifyCompletion:!1});const Be=N.current;if(!Be)return;Lt();const Ke=Ee.current;if(Ee.current=!1,Ke){me.current=M.history??me.current,ui(),Lt();return}if(yn(Be,M.terminal)){Kr(M.output,M.history??null),ui(),Lt();return}_i(M.output,M.history??null),Lt();return}if(M.type==="terminal_updated"&&M.terminal.id===e.id){Q.current.onSnapshot(M.terminal,{notifyCompletion:!0});return}if(M.type==="output"&&M.terminalId===e.id){const Be=T1(M.data);if(!Be)return;re.current.push(Be),N.current&&Ce.current?on({scrollToBottom:!0}):be.current=!0;return}const J=N.current;if(J){if(M.type==="exit"&&M.terminalId===e.id){Q.current.onExit(M.exitCode),ei("closed");return}M.type==="error"&&J.writeln(`\r
|
|
33
|
+
[nterminal] ${M.message}`)}}function $i(M=25){if(document.visibilityState==="hidden"||!Ie.current||se.current.has(M))return;const J=window.setTimeout(()=>{se.current.delete(M),!bi()&&Aa()},M);se.current.set(M,J)}function It(){bi()||On()}function bi(){const M=Zs();return M&&Ur(M)?(ne.current=!0,we.current=M,!0):M&&Ll(M)?(ne.current=!1,we.current=null,!0):((!M||!M.composeOpen&&!M.keyboardVisible)&&(ne.current=!1,we.current=null),!1)}function Ln(){if(!ne.current)return;const M=Zs();M&&(M.composeOpen||M.keyboardVisible)||(ne.current=!1,we.current=null)}function Ur(M){if(!M.mobileLike||!M.composeOpen&&!M.keyboardVisible)return!1;const J=ve.current;return J?Qi(M.windowWidth,J.windowWidth)&&Qi(M.visualViewportWidth,J.visualViewportWidth)&&Qi(M.containerWidth,J.containerWidth):!1}function Ll(M){if(!M.mobileLike||M.composeOpen||M.keyboardVisible)return!1;const J=we.current;return!J||!J.composeOpen&&!J.keyboardVisible?!1:Qi(M.windowWidth,J.windowWidth)&&Qi(M.visualViewportWidth,J.visualViewportWidth)&&Qi(M.containerWidth,J.containerWidth)}function Zs(){const M=L.current;if(!M||M.isConnected===!1)return null;const J=M.getBoundingClientRect(),Be=Bn(window.innerWidth)??0,Ke=Bn(window.visualViewport?.width)??Be,qe=Bn(J.width)??Bn(M.clientWidth)??Be;if(Be<=0||Ke<=0||qe<=0)return null;const Je=Ta()>$N,Bt=document.documentElement.hasAttribute(Dh),Vt=Es()||Je;return{windowWidth:Be,visualViewportWidth:Ke,containerWidth:qe,composeOpen:Bt,keyboardVisible:Je,mobileLike:Vt}}function Ta(){const M=Bn(window.visualViewport?.height),J=Bn(window.innerHeight);if(M===null||J===null)return 0;const Be=typeof window.visualViewport?.offsetTop=="number"?window.visualViewport.offsetTop:0;return Math.max(0,Math.round(J-M-Be))}function Es(){return navigator.maxTouchPoints>0?!0:typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function Bn(M){return typeof M=="number"&&Number.isFinite(M)&&M>0?M:null}function Qi(M,J){return Math.abs(M-J)<=VN}function On(){for(const M of qN)$i(M)}function Lt(){ce.current=null,On()}function bn(){for(const M of se.current.values())window.clearTimeout(M);se.current.clear()}function Kt(){for(const M of V.current)window.clearTimeout(M);V.current=[]}function ds(){if(ui(),!ke.current){K(!1);return}K(!0),is(),Me.current=window.setTimeout(()=>{Me.current=null,K(!1)},1200)}function ui(){const M=N.current,J=M?M3(M):null;if(ke.current=J,Ti(J),ln(!!(M&&J)),li(!!(M&&J&&!os(M))),J||!M||!zn()){ot(null);return}ot({alternate:M.buffer.active.type==="alternate"})}function zn(){const M=me.current;return F.current.length>0||!!M?.hasMore}function is(){Me.current!==null&&(window.clearTimeout(Me.current),Me.current=null)}function Da(){const M=N.current;M&&(Fe.current=!os(M),ui())}function Ir(M){D.current=cp(D.current,M)}function Ra(M){const J=D.current;return D.current=null,cp(J,M)}function Ma(){const M=D.current;return D.current=null,M}function on(M={}){const J=N.current;if(!J||!Ce.current){be.current=!0;return}if(X.current){Ir(M);return}if(W.current){Ir(M);return}const Be=Ra(M);if(!Be.force&&!Au(J,Fe.current)){ui();return}W.current=!0;const Ke=G.current,qe=()=>{if(N.current!==J||G.current!==Ke){W.current=!1;return}if(!Be.force&&!Au(J,Fe.current)){W.current=!1,ui();return}const Je=B.current,Bt=re.current[Je];if(Bt===void 0){W.current=!1,Be.scrollToBottom&&ss(J),ui();const Vt=Ma();Vt?on(cp(Be,Vt)):rt();return}J.write(Bt,()=>{if(N.current!==J||G.current!==Ke){W.current=!1;return}B.current=Je+1,qe()})};qe()}function jn(M){return!os(M)&&($t()||W.current||X.current)}function yn(M,J){return(Xe.current||Wu(J?.currentCommand))&&!os(M)}function $t(){return B.current<re.current.length}function Kr(M,J){st.current={output:M,history:J,appendFromLiveOutputIndex:B.current}}function rt(){const M=N.current,J=st.current;if(!M||!J||!os(M)||$t()||W.current||X.current)return;const Be=Nu(J.output),Ke=Nu(re.current.slice(J.appendFromLiveOutputIndex));st.current=null,_i(D3(Be,Ke),J.history),Lt()}function ns(){he.current=!0}function ks(){Da(),he.current=!1;const M=N.current;M&&os(M)&&on({scrollToBottom:!0})}function ss(M){Ui(()=>l0(M))&&(Fe.current=!1)}function Na(M,J){Ui(()=>(M.scrollToLine(J),!0))}function Ui(M){_e.current=!0;try{return M()}finally{_e.current=!1}}function Wr(){const M=N.current;if(!M)return;const J=()=>{l0(M),Fe.current=!1,ui(),on({force:!0,scrollToBottom:!0}),en()};if(M.buffer.active.type==="alternate"){M.write(wm,J);return}J()}function Qs(M){const J=N.current,Be=L.current;if(!J||!Be)return;const Ke=Be.getBoundingClientRect();if(Ke.height<=0)return;const qe=Math.max(0,Math.min(1,(M-Ke.top)/Ke.height)),Je=Math.round(J.buffer.active.baseY*qe);ns();try{J.scrollToLine(Je)}finally{ks()}Fe.current=!os(J),ui(),ds(),Je<=3&&vi()}function Fr(M){M.preventDefault(),M.stopPropagation(),M.currentTarget.setPointerCapture?.(M.pointerId),Qs(M.clientY)}function fs(M){(M.buttons&1)!==0&&(M.preventDefault(),M.stopPropagation(),Qs(M.clientY))}function Aa(){const M=N.current,J=I.current;if(!(!M||!J)&&!(document.visibilityState==="hidden"||!Ie.current||L.current?.isConnected===!1))try{const Be=Au(M,Fe.current),Ke=Zs();J.fit(),Ke&&(ve.current=Ke),Be&&ss(M),M.refresh(0,Math.max(0,M.rows-1)),ui();const qe={cols:M.cols,rows:M.rows},Je=ce.current;if(Je&&Je.cols===qe.cols&&Je.rows===qe.rows)return;Js({type:"resize",terminalId:e.id,cols:qe.cols,rows:qe.rows})&&(ce.current=qe)}catch{}}function Js(M){const J=U.current;return J?J(M):!1}function Ji(M){on({force:!0,scrollToBottom:!0}),Js({type:"input",terminalId:e.id,data:M})&&C3(M)&&Ts()}function Bl(M){const J=$S(M,{bracketedPasteMode:N.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!0});J&&Ji(J)}function La(M,J){const Be=$S(M,{bracketedPasteMode:N.current?.modes.bracketedPasteMode===!0,stripTrailingLineBreaks:!1});Be&&Ji(Be),window.setTimeout(()=>Ji(oN(J)),b1)}function Ts(){!oe.current||!Oe.current||(Kt(),V.current=YN.map(M=>{const J=window.setTimeout(()=>{V.current=V.current.filter(Be=>Be!==J),oe.current&&Oe.current&&Js({type:"refresh_cwd",terminalId:e.id})},M);return J}))}function en(){ze.current||N.current?.focus()}const Hn=v.useCallback(()=>{vt(!1)},[]);function er(){ts(M=>{const J=!M;return De.current=J,J}),en()}function ps(M){De.current=M,ts(M)}function Sn(M){De.current&&ps(!1),Ji($M(M)),en()}return m.jsxs("section",{className:"terminal-pane","data-active":s,onMouseDown:()=>{s||f()},children:[m.jsx(p3,{terminal:e,canClose:o,tabId:h,transcriptSource:Rt,transcriptShortcutLabel:O,onOpenTranscript:()=>vt(!0),onReload:Zi,onClose:g}),m.jsx("div",{className:"xterm-container",ref:L}),an?m.jsx("div",{className:"terminal-history-loader",role:"status","aria-label":"Loading older terminal output",children:m.jsx("span",{"aria-hidden":"true"})}):null,E&&ti?m.jsxs("div",{className:"terminal-scroll-progress","data-active":Jn,"aria-hidden":"true",children:[ti.current,"/",ti.total]}):E&&$e?m.jsxs("div",{className:"terminal-scroll-progress","data-active":!1,"data-pending":"true","data-buffer":$e.alternate?"alternate":"normal","aria-hidden":"true",children:[$e.alternate?"alt ":"","0/?"]}):null,wt?m.jsx("button",{type:"button",className:"terminal-scroll-bottom-button","aria-label":"Scroll terminal to bottom",title:"Scroll to bottom",onPointerDown:M=>M.stopPropagation(),onMouseDown:M=>M.stopPropagation(),onClick:M=>{M.stopPropagation(),Wr()},children:"↓"}):null,Dt?m.jsx("button",{type:"button",className:"terminal-scroll-handle","aria-label":"Drag terminal scroll handle",title:"Drag to scroll",onPointerDown:Fr,onPointerMove:fs,children:m.jsx("span",{"aria-hidden":"true"})}):null,s&&e.status==="running"?Di?m.jsx(FM,{ctrlActive:es,onCtrl:er,onStandaloneKey:Sn,onPreserveFocus:en,onHide:()=>oi(!1)}):m.jsx("button",{type:"button",className:"mobile-terminal-key-toggle","aria-label":"Show terminal control keys",title:"Show Ctrl / Esc / Tab / arrows",onMouseDown:M=>{M.stopPropagation(),en()},onPointerDown:M=>{M.stopPropagation(),en()},onClick:()=>oi(!0),children:"⌨"}):null,m.jsx(pN,{terminalId:e.id,onSubmit:La,queueAvailable:Rt?.provider==="codex"||C1(e.currentCommand),disabled:e.status!=="running"}),_t&&Rt?m.jsx(m3,{terminalId:e.id,serverApi:t,source:Rt,fontSize:w,onClose:Hn}):null]})}function i0(e){return mE(e)}function h3(e,t,s){const r=d3(e,t),o=n0(r*Math.max(1,s),a3,l3);return{limit:n0(Math.ceil(o/n3),s3,r3),maxLines:o}}function d3(e,t){const s=e?.clientHeight??0;if(s<=0)return t3;const r=Math.max(10,t*i3);return Math.max(1,Math.floor(s/r))}function n0(e,t,s){return Math.max(t,Math.min(s,Math.floor(e)))}function f3(e){return e instanceof HTMLElement?!!e.closest(".security-panel:not(.transcript-dialog)"):!1}function p3({terminal:e,canClose:t,tabId:s,transcriptSource:r,transcriptShortcutLabel:o,onOpenTranscript:c,onReload:h,onClose:f}){const g=F0({id:`pane-${e.id}`,disabled:!s,...s?{data:{kind:"pane",sourceTabId:s,terminalId:e.id}}:{}}),p={cursor:s?"grab":"default",opacity:g.isDragging?.5:void 0};return m.jsxs("header",{ref:g.setNodeRef,className:"terminal-pane-header",style:p,"data-dragging":g.isDragging,...g.attributes,...g.listeners,children:[m.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),m.jsx("span",{className:"terminal-pane-cwd",title:e.cwd,children:e.cwd}),m.jsx("span",{className:"terminal-pane-spacer"}),r?m.jsxs("button",{type:"button",className:"terminal-pane-transcript","data-provider":r.provider,title:`View ${ch(r.provider)} transcript history`,"aria-label":`View ${ch(r.provider)} transcript history`,onPointerDown:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),onClick:y=>{y.stopPropagation(),c()},children:[m.jsx("span",{children:"View history"}),m.jsx("kbd",{children:o})]}):null,m.jsx("span",{className:`terminal-pane-state terminal-pane-state-${e.status}`,children:e.status}),e.status==="running"?m.jsx("button",{type:"button",className:"terminal-pane-reload","aria-label":`Reload pane ${e.title}`,title:"Reload pane output",onPointerDown:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),onClick:y=>{y.stopPropagation(),h()},children:"↻"}):null,t?m.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close pane ${e.title}`,title:"Close pane",onPointerDown:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),onClick:y=>{y.stopPropagation(),f()},children:"x"}):null]})}const m3=xi.memo(function({terminalId:t,serverApi:s,source:r,fontSize:o,onClose:c}){const h=v.useRef(null),f=v.useRef(0),g=v.useRef(!1),p=v.useRef(!1),y=v.useRef(null),b=v.useRef(""),[w,S]=v.useState([]),[E,T]=v.useState(!1),[O,L]=v.useState(""),[N,I]=v.useState(-1),[U,Q]=v.useState(null),[ie,le]=v.useState(!1),[ce,ve]=v.useState(!0),[we,ne]=v.useState(!1),[se,V]=v.useState(null);v.useEffect(()=>{function _e(X){X.key==="Escape"&&(X.preventDefault(),X.stopPropagation(),c())}return document.addEventListener("keydown",_e,!0),()=>document.removeEventListener("keydown",_e,!0)},[c]),v.useEffect(()=>{f.current+=1;const _e=f.current;return g.current=!1,p.current=!0,y.current=null,S([]),Q(null),le(!1),V(null),de(null,"initial",_e),()=>{f.current===_e&&(f.current+=1)}},[s,E,r.provider,r.sessionId,t]),v.useLayoutEffect(()=>{const _e=h.current;if(!_e)return;if(p.current){if(ce||w.length===0)return;p.current=!1;const he=()=>{_e.scrollTop=_e.scrollHeight};he(),window.requestAnimationFrame?.(he);return}const X=y.current;X!==null&&(y.current=null,_e.scrollTop+=_e.scrollHeight-X)},[w,ce,E]);const F=ch(r.provider),re=a0(w,E),B=v3(re),W=S3(B,O),D=W.length,G=D>0?N>=0&&N<D?N:0:-1,me=G>=0?W[G]?.entryIndex??null:null,R=G>=0?W[G]??null:null,H=re?re.split(`
|
|
34
|
+
`).length-1:0,ee=O.trim()?D>0?`${G+1}/${D} ${D===1?"match":"matches"} · ${H} ${H===1?"line":"lines"}`:`0 matches · ${H} ${H===1?"line":"lines"}`:H>0?`${H} lines`:"0 lines";v.useEffect(()=>{const _e=O.trim().toLowerCase();I(X=>!_e||D===0?-1:b.current!==_e?0:X>=0&&X<D?X:0),b.current=_e},[O,D]);async function de(_e,X,he=f.current){if(!g.current){g.current=!0,X==="initial"?ve(!0):(ne(!0),y.current=h.current?.scrollHeight??null),V(null);try{await Ee(_e,X,he)}catch(Ce){if(f.current!==he)return;V(Ce instanceof Error?Ce.message:"Failed to load transcript history.")}finally{f.current===he&&(g.current=!1,ve(!1),ne(!1))}}}async function Ee(_e,X,he){let Ce=_e,be=0,De=[];const Oe=X==="initial"&&r.provider!=="claude"?c3:o3;for(;f.current===he;){const Ie=await s.getTerminalTranscriptHistory(t,{...Ce?{cursor:Ce}:{},...h3(h.current,o,X==="initial"?JN:e3),includeTools:E});if(f.current!==he)return;const oe=r0(Ie.output,r.provider,{includeTools:E}),xe=ke(Ie,X,De,oe);if(oe&&(De=[oe,...De],xe))return;if(!Ie.hasMore||!Ie.cursor||be>=Oe){De.length>0&&S(Ae=>X==="older"?[...De,...Ae]:De);return}Ce=Ie.cursor,be+=1}}function ke(_e,X,he,Ce=r0(_e.output,r.provider,{includeTools:E})){if(Q(_e.cursor),le(!!(_e.hasMore&&_e.cursor)),!Ce)return!1;const be=[Ce,...he];return a0(be,E)?(S(De=>X==="older"?[...be,...De]:be),!0):!1}function Me(){const _e=h.current;!_e||_e.scrollTop>72||!ie||!U||g.current||de(U,"older")}function Fe(_e){D!==0&&I(X=>{const he=G>=0?G:_e>0?-1:0;return((X>=0&&X<D?X:he)+_e+D)%D})}return m.jsx("div",{className:"security-overlay transcript-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"transcript-dialog-title",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>{_e.stopPropagation(),c()},children:m.jsxs("div",{className:"security-panel transcript-dialog",onPointerDown:_e=>_e.stopPropagation(),onMouseDown:_e=>_e.stopPropagation(),onClick:_e=>_e.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsxs("div",{className:"transcript-dialog-title",children:[m.jsxs("h2",{id:"transcript-dialog-title",children:[F," JSONL"]}),m.jsx("span",{title:r.sessionId,children:r.sessionId})]}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:c,children:"×"})]}),m.jsxs("div",{className:"transcript-dialog-controls",children:[m.jsxs("label",{className:"auth-checkbox transcript-tool-toggle",children:[m.jsx("input",{type:"checkbox",checked:E,onChange:_e=>T(_e.currentTarget.checked)}),"Show tool output"]}),m.jsxs("label",{className:"transcript-search",children:[m.jsx("span",{children:"Search"}),m.jsx("input",{type:"search",value:O,"aria-label":"Search JSONL transcript",placeholder:"Find in history",onChange:_e=>L(_e.currentTarget.value),onKeyDown:_e=>{_e.key==="Enter"&&(_e.preventDefault(),Fe(_e.shiftKey?-1:1))}})]}),m.jsxs("div",{className:"transcript-search-actions","aria-label":"Search result navigation",children:[m.jsx("button",{type:"button",onClick:()=>Fe(-1),disabled:D===0,children:"Prev"}),m.jsx("button",{type:"button",onClick:()=>Fe(1),disabled:D===0,children:"Next"})]}),m.jsx("span",{className:"transcript-result-count",children:ee})]}),m.jsxs("div",{ref:h,className:"transcript-dialog-scroll","aria-label":"JSONL transcript output",onScroll:Me,children:[we?m.jsx("div",{className:"transcript-dialog-status",children:"Loading older entries..."}):null,!ce&&ie?m.jsx("div",{className:"transcript-dialog-hint",children:"Scroll up for older entries"}):null,re?m.jsx(g3,{entries:B,searchQuery:O,activeEntryIndex:me,activeSearchMatch:R,fontSize:o}):null,ce?m.jsx("div",{className:"transcript-dialog-status",children:"Loading transcript..."}):null,!ce&&!re&&!se?ie&&U?m.jsxs("div",{className:"transcript-dialog-status",children:[E?"The latest entries are hidden record types.":"The latest entries contain only hidden tool output."," ",m.jsx("button",{type:"button",onClick:()=>{de(U,"older")},disabled:we,children:"Search earlier entries"})]}):m.jsx("div",{className:"transcript-dialog-status",children:"No transcript entries found."}):null,se?m.jsx("div",{className:"transcript-dialog-error",children:se}):null]})]})})});function g3({entries:e,searchQuery:t,activeEntryIndex:s,activeSearchMatch:r,fontSize:o}){const c=v.useRef(new Map);return v.useEffect(()=>{if(s===null)return;const h=c.current.get(s);if(!h||typeof h.scrollIntoView!="function")return;const f=h.querySelectorAll(".transcript-search-hit");((r?.entryIndex===s?f[r.matchIndexInEntry]:null)??h).scrollIntoView({block:"center",inline:"nearest"})},[s,r,t]),m.jsx("div",{className:"transcript-output transcript-formatted-output",style:{fontSize:o},children:e.map((h,f)=>m.jsxs("section",{ref:g=>{g?c.current.set(f,g):c.current.delete(f)},className:`transcript-entry transcript-entry-${h.kind}${s===f?" transcript-entry-search-active":""}`,children:[h.header?m.jsx("div",{className:"transcript-entry-header",children:w1(h.header,t)}):null,h.body?m.jsx("div",{className:"transcript-entry-body",children:h.kind==="tool"?m.jsx(s0,{text:h.body,searchQuery:t}):m.jsx(xi.Suspense,{fallback:m.jsx(s0,{text:h.body,searchQuery:t}),children:m.jsx(u3,{text:h.body,searchQuery:t})})}):null]},`${h.header??"plain"}-${f}`))})}function s0({text:e,searchQuery:t}){const s=e.endsWith(`
|
|
35
|
+
`)?e.slice(0,-1).split(`
|
|
36
|
+
`):e.split(`
|
|
37
|
+
`);return m.jsx("pre",{className:"transcript-entry-pre",children:s.map((r,o)=>m.jsx("span",{className:`transcript-line transcript-line-${w3(r,o===0||s[o-1]?.trim()==="")}`,children:w1(r,t)},o))})}function w1(e,t){const s=t.trim();if(!s)return e||" ";const r=e.toLowerCase(),o=s.toLowerCase(),c=[];let h=0,f=r.indexOf(o);for(;f!==-1;){f>h&&c.push(e.slice(h,f));const g=f+s.length;c.push(m.jsx("mark",{className:"transcript-search-hit",children:e.slice(f,g)},`${f}-${g}`)),h=g,f=r.indexOf(o,h)}return h<e.length&&c.push(e.slice(h)),c.length>0?c:e||" "}function _3(e,t){const s=t.trim().toLowerCase();if(!s)return 0;const r=e.toLowerCase();let o=0,c=r.indexOf(s);for(;c!==-1;)o+=1,c=r.indexOf(s,c+s.length);return o}function v3(e){const t=e.endsWith(`
|
|
38
|
+
`)?e.slice(0,-1):e;if(!t)return[];const s=[];let r=null,o="plain",c=[];function h(){const f=b3(c).join(`
|
|
39
|
+
`);(r||f)&&s.push({header:r,body:f,kind:o}),r=null,o="plain",c=[]}for(const f of t.split(`
|
|
40
|
+
`)){const g=y3(f);g?(h(),r=f,o=g):c.push(f)}return h(),s}function b3(e){let t=e.length;for(;t>0&&(e[t-1]??"").trim()==="";)t-=1;return e.slice(0,t)}function y3(e){const t=/^\[[^\]]+\]\s+(.+)$/.exec(e.trimEnd());if(!t)return null;const s=t[1]??"";return s==="User"?"user":s==="Codex"||s==="Claude"?"assistant":s==="System"?"system":/^Tool (?:call(?::|$)|output$)/.test(s)?"tool":null}function S3(e,t){const s=[];for(let r=0;r<e.length;r+=1){const o=e[r];if(!o)continue;const c=o.header?`${o.header}
|
|
41
|
+
${o.body}`:o.body,h=_3(c,t);for(let f=0;f<h;f+=1)s.push({entryIndex:r,matchIndexInEntry:f})}return s}function w3(e,t){const s=e.trim();if(!s)return"blank";const r=s.replace(/^\[[^\]]+\]\s+/,""),o=/^\[[^\]]+\]\s+/.test(s);return(o||t)&&/^User$/.test(r)?"user":(o||t)&&/^(?:Codex|Claude)$/.test(r)?"assistant":(o||t)&&/^System$/.test(r)?"system":(o||t)&&(/^Tool (?:call(?::|$)|output$)/.test(r)||k1(s))?"tool":/^(?:\$|>|❯|➜)\s+/.test(s)?"command":/^(?:✓|✔|PASS|passed\b|success\b)/i.test(s)?"success":/^(?:✗|✘|FAIL|failed\b|error\b|traceback\b)/i.test(s)?"error":/^\[[^\]]+\]/.test(s)||/^(?:info|debug|warn)\b/i.test(s)?"dim":"plain"}function C3(e){return e.includes("\r")||e.includes(`
|
|
42
|
+
`)}function op(e){return e instanceof cs&&e.status===404}function Wu(e){return C1(e)||x3(e)}function C1(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="codex"||t==="codex.js"||t.startsWith("codex-")}function x3(e){if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="claude"||t==="claude.js"||t.startsWith("claude-")}function E3(e){if(Wu(e))return!0;if(!e)return!1;const t=e.replace(/^.*[\\/]/,"").toLowerCase();return t==="node"||t==="nodejs"}function ch(e){return e==="codex"?"Codex":"Claude"}function r0(e,t,s={}){const r=`[nterminal] ${ch(t)} transcript archive ends here. Live terminal screen continues below.`,o=e.join("").replace(/\r\n/g,`
|
|
43
|
+
`).replace(/\r/g,`
|
|
44
|
+
`).replace(r,"").replace(/\n{3,}/g,`
|
|
45
|
+
|
|
46
|
+
`).trimEnd(),c=x1(o),h=s.includeTools?c:E1(c);return h?`${h}
|
|
47
|
+
`:""}function x1(e){return e.replace(/^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z)\]/gm,(t,s)=>{const r=k3(s);return r?`[${r}]`:t})}function k3(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))return null;const s=t.getFullYear(),r=Ro(t.getMonth()+1),o=Ro(t.getDate()),c=Ro(t.getHours()),h=Ro(t.getMinutes()),f=Ro(t.getSeconds());return`${s}-${r}-${o} ${c}:${h}:${f}`}function Ro(e){return e.toString().padStart(2,"0")}function a0(e,t){return e.map(s=>t?s:E1(s)).filter(Boolean).map(s=>s.endsWith(`
|
|
48
|
+
`)?s:`${s}
|
|
49
|
+
`).join("")}function E1(e){if(!e)return"";const t=e.split(`
|
|
50
|
+
`),s=[];let r=!1,o=!1,c=!0;for(const h of t){const f=h.trim()==="",g=c?T3(h):null;if(g&&(r=g==="tool",o=!1),k1(h)){o=!0,c=!1;continue}if(o){f?(o=!1,r||s.push(h),c=!0):c=!1;continue}r||s.push(h),c=f}return s.join(`
|
|
51
|
+
`).replace(/\n{3,}/g,`
|
|
52
|
+
|
|
53
|
+
`).trimEnd()}function T3(e){const t=e.replace(/^\[[^\]]+\]\s+/,"");return/^Tool (?:call(?::|$)|output$)/.test(t)?"tool":/^(?:User|Codex|Claude|System)$/.test(t)?"message":null}function k1(e){return/^\[tool (?:call(?::|])|output\])/.test(e.trim())}function D3(e,t){if(t.length===0)return e;let s=0;const r=Math.min(e.length,t.length);for(let o=r;o>0;o-=1){let c=!0;for(let h=0;h<o;h+=1)if(e[e.length-o+h]!==t[h]){c=!1;break}if(c){s=o;break}}return[...e,...t.slice(s)]}function R3(e){let t=0;for(const s of e){if(!s)continue;const r=s.match(/\r\n|\r|\n/g);t+=r?.length??1}return Math.max(1,t)}function Nu(e){const t=[];for(const s of e){const r=T1(s);r&&t.push(r)}return t}function T1(e){return e.replace(/\x1b\[\?([0-9;:]*)([hl])/g,(t,s,r)=>{const o=s.split(";").filter(Boolean).filter(c=>!ZN.has(c.split(":")[0]??""));return o.length>0?`\x1B[?${o.join(";")}${r}`:""})}function cp(e,t={}){const s={};return(e?.force||t.force)&&(s.force=!0),(e?.scrollToBottom||t.scrollToBottom)&&(s.scrollToBottom=!0),s}function M3(e){const t=e.buffer.active,s=t.baseY+e.rows;return s<=e.rows?null:{current:Math.max(1,Math.min(s,t.viewportY+1)),total:s}}function os(e){return e.buffer.active.viewportY>=Math.max(0,e.buffer.active.baseY-1)}function Au(e,t){return!t||os(e)}function l0(e){return os(e)?!1:(e.scrollToLine(Math.max(0,e.buffer.active.baseY)),!0)}function N3(e,t,s,r,o,c){const h=f=>{const g=L3(f);g!==0&&(f.cancelable&&f.preventDefault(),f.stopPropagation(),A3(t,g,s,r,o,c))};return e.addEventListener("wheel",h,{capture:!0,passive:!1}),()=>{e.removeEventListener("wheel",h,{capture:!0})}}function A3(e,t,s,r,o,c){const h=()=>{o();try{e.scrollLines(t)}finally{c()}s(),t<0&&e.buffer.active.viewportY<=3&&r(t)};if(e.buffer.active.type==="alternate"){e.write(wm,h);return}h()}function L3(e){const s=e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?e.deltaY/24:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*24:e.deltaY;if(s===0)return 0;const r=s<0?Math.floor(s):Math.ceil(s);return Math.max(-30,Math.min(30,r))}function B3(e,t,s,r,o,c,h){let f=null,g=0;const p={passive:!1};function y(S){f=up(S),g=0}function b(S){const E=up(S);if(E===null){f=null,g=0;return}if(f===null){f=E;return}const T=E.clientY-f.clientY;if(f=E,S.cancelable&&S.preventDefault(),T===0)return;if(O3(t)&&z3(t,E,-T)){g=0;return}g-=T/s();const O=g<0?Math.ceil(g):Math.floor(g);if(O!==0){g-=O,c();try{t.scrollLines(O)}finally{h()}r(),O<0&&t.buffer.active.viewportY<=3&&o(O)}}function w(S){if(S.touches.length>0){f=up(S);return}f=null,g=0}return e.addEventListener("touchstart",y,p),e.addEventListener("touchmove",b,p),e.addEventListener("touchend",w),e.addEventListener("touchcancel",w),()=>{e.removeEventListener("touchstart",y,p),e.removeEventListener("touchmove",b,p),e.removeEventListener("touchend",w),e.removeEventListener("touchcancel",w)}}function up(e){if(e.touches.length!==1)return null;const t=e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null}function O3(e){return e.buffer.active.type==="alternate"||e.modes.mouseTrackingMode!=="none"}function z3(e,t,s){const r=e.element;return r?(r.dispatchEvent(j3(t,s)),!0):!1}function j3(e,t){const s=typeof WheelEvent=="function"?WheelEvent.DOM_DELTA_PIXEL:0,r={bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:t,deltaMode:s};if(typeof WheelEvent=="function")return new WheelEvent("wheel",r);const o=new Event("wheel",r);return Object.defineProperties(o,{clientX:{value:e.clientX},clientY:{value:e.clientY},deltaX:{value:0},deltaY:{value:t},deltaMode:{value:0}}),o}function Cm({node:e,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c=!0,refreshCwdOnEnter:h=!1,tabId:f,dropZoneActive:g=!1,draggingTerminalId:p=null,mobileFocusLeafKey:y=null,path:b=[],totalPanes:w,onSelect:S,onClose:E,onResize:T,onExit:O,onSnapshot:L,onCloseEditor:N,onAuthClose:I}){const U=w??xm(e);if(b.length===0&&y){const ce=Em(e),ve=ce.some(we=>we.key===y)?y:ce[0]?.key;if(ce.length>1&&ve)return m.jsx("div",{className:"mobile-focused-split",children:ce.map(we=>{const ne=we.key===ve;if(we.type==="editor"){const V=s[we.editorId];return m.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:V?m.jsx($y,{api:r,editor:V,canClose:U>1,onClose:()=>N(we.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})},we.key)}const se=t[we.terminalId];return se?m.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:m.jsx(t0,{terminal:se,serverApi:r,active:ne,visible:c&&ne,canClose:U>1,refreshCwdOnEnter:h&&ne,tabId:f,onSelect:()=>S(we.terminalId),onClose:()=>E(we.terminalId),onExit:V=>O(we.terminalId,V),onSnapshot:L,...I?{onAuthClose:I}:{}})},we.key):m.jsx("div",{className:"mobile-focused-pane","data-active":ne,"aria-hidden":!ne,children:m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"})},we.key)})})}if(e.type==="pane"){const ce=t[e.terminalId];if(!ce)return m.jsx("div",{className:"missing-pane",children:"Terminal unavailable"});const ve=m.jsx(t0,{terminal:ce,serverApi:r,active:e.terminalId===o,visible:c,canClose:U>1,refreshCwdOnEnter:h&&e.terminalId===o,tabId:f,onSelect:()=>S(e.terminalId),onClose:()=>E(e.terminalId),onExit:ne=>O(e.terminalId,ne),onSnapshot:L,...I?{onAuthClose:I}:{}});return g&&p!==e.terminalId?m.jsxs("div",{className:"pane-drop-host",children:[ve,m.jsx(Lu,{terminalId:e.terminalId,side:"top"}),m.jsx(Lu,{terminalId:e.terminalId,side:"right"}),m.jsx(Lu,{terminalId:e.terminalId,side:"bottom"}),m.jsx(Lu,{terminalId:e.terminalId,side:"left"})]}):ve}if(e.type==="editor"){const ce=s[e.editorId];return ce?m.jsx($y,{api:r,editor:ce,canClose:U>1,onClose:()=>N(e.editorId)}):m.jsx("div",{className:"missing-pane",children:"Editor unavailable"})}const Q=Math.max(.1,Math.min(.9,e.ratio)),ie=1-Q,le=e.direction==="vertical"?{gridTemplateColumns:`minmax(0, ${Q}fr) 1px minmax(0, ${ie}fr)`}:{gridTemplateRows:`minmax(0, ${Q}fr) 1px minmax(0, ${ie}fr)`};return m.jsxs("div",{className:"split-pane","data-direction":e.direction,style:le,children:[m.jsx("div",{className:"split-cell",children:m.jsx(Cm,{node:e.first,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:f,dropZoneActive:g,draggingTerminalId:p,mobileFocusLeafKey:y,path:[...b,0],totalPanes:U,onSelect:S,onClose:E,onResize:T,onExit:O,onSnapshot:L,onCloseEditor:N,...I?{onAuthClose:I}:{}})}),m.jsx(H3,{direction:e.direction,path:b,onResize:T}),m.jsx("div",{className:"split-cell",children:m.jsx(Cm,{node:e.second,terminals:t,editors:s,api:r,activeTerminalId:o,visible:c,refreshCwdOnEnter:h,tabId:f,dropZoneActive:g,draggingTerminalId:p,mobileFocusLeafKey:y,path:[...b,1],totalPanes:U,onSelect:S,onClose:E,onResize:T,onExit:O,onSnapshot:L,onCloseEditor:N,...I?{onAuthClose:I}:{}})})]})}function Lu({terminalId:e,side:t}){const{setNodeRef:s,isOver:r}=Qm({id:`pane-${e}-${t}`,data:{kind:"pane-zone",terminalId:e,side:t}});return m.jsx("div",{ref:s,className:`pane-drop-zone pane-drop-zone--${t}`,"data-over":r,"aria-hidden":"true"})}function H3({direction:e,path:t,onResize:s}){function r(o){o.preventDefault(),o.stopPropagation();const c=o.currentTarget;c.setPointerCapture?.(o.pointerId),c.classList.add("is-dragging"),document.body.style.cursor=e==="vertical"?"col-resize":"row-resize";const h=c.parentElement;if(!h)return;const f=h.getBoundingClientRect();function g(y){const b=e==="vertical"?(y.clientX-f.left)/f.width:(y.clientY-f.top)/f.height;s(t,Math.min(.9,Math.max(.1,b)))}function p(){window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p),c.classList.remove("is-dragging"),document.body.style.cursor=""}window.addEventListener("pointermove",g),window.addEventListener("pointerup",p)}return m.jsx("div",{"aria-label":"Resize panes","aria-orientation":e==="vertical"?"vertical":"horizontal",className:"split-divider","data-direction":e,onPointerDown:r,role:"separator",children:m.jsx("span",{className:"split-divider-handle","aria-hidden":"true"})})}function xm(e){return e.type==="pane"||e.type==="editor"?1:xm(e.first)+xm(e.second)}function Em(e){return e.type==="pane"?[{key:P3(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:U3(e.editorId),type:"editor",editorId:e.editorId}]:[...Em(e.first),...Em(e.second)]}function P3(e){return`terminal:${e}`}function U3(e){return`editor:${e}`}const Nh="workspace-default",I3="NTerminal";function K3(){return{workspaces:[],activeWorkspaceId:null,terminals:{}}}function W3(e,t){switch(t.type){case"workspace.hydrated":return km(t.terminals,t.savedTabs,t.savedWorkspaces,t.savedActiveWorkspaceId);case"workspace.created":return F3(e,{id:t.workspaceId,title:t.title,defaultCwd:t.defaultCwd??null});case"workspace.closed":return Y3(e,t.workspaceId);case"workspace.selected":return D1(e,t.workspaceId);case"workspace.renamed":return q3(e,t.workspaceId,t.title);case"workspace.defaultCwdChanged":return $3(e,t.workspaceId,t.defaultCwd);case"workspace.reordered":return V3(e,t.sourceWorkspaceId,t.targetWorkspaceId,t.placement);case"terminal.created":return R1(e,t.terminal);case"terminal.split":return X3(e,t.terminal,t.direction);case"terminal.updated":return aA(e,t.terminal);case"terminal.exited":return lA(e,t.terminalId,t.exitCode);case"terminal.closed":return A1(e,t.terminalId);case"terminal.detached":return oA(e,t.terminalId,t.workspaceId);case"editor.split":return G3(e,t.editorId,t.title,t.direction);case"editor.closed":return cA(e,t.editorId);case"pane.selected":return sA(e,t.terminalId);case"pane.resized":return rA(e,t.path,t.ratio);case"tab.selected":return Q3(e,t.tabId);case"tab.renamed":return nA(e,t.tabId,t.title);case"tab.reordered":return Ng(e,t.sourceTabId,t.targetIndex);case"tab.dropped_into_pane":return J3(e,t.sourceTabId,t.sourceTerminalId,t.targetTerminalId,t.side);case"terminal.extracted_to_tab":return M1(e,t.sourceTabId,t.sourceTerminalId,t.targetIndex);case"tab.moved_to_workspace":return N1(e,t.sourceTabId,t.targetWorkspaceId,t.targetIndex);case"terminal.extracted_to_workspace":return eA(e,t.sourceTabId,t.sourceTerminalId,t.targetWorkspaceId,t.targetIndex);case"activePane.closed":return Z3(e);default:return e}}function F3(e,t){if(e.workspaces.some(r=>r.id===t.id))return D1(e,t.id);const s={id:t.id,title:t.title,defaultCwd:hs(t.defaultCwd),detachedTerminalIds:[],tabs:[],activeTabId:null};return{...e,workspaces:[...e.workspaces,s],activeWorkspaceId:s.id}}function D1(e,t){return e.workspaces.some(s=>s.id===t)?{...e,activeWorkspaceId:t}:e}function q3(e,t,s){const r=s.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.title===r?h:(o=!0,{...h,title:r}));return o?{...e,workspaces:c}:e}function $3(e,t,s){const r=hs(s);let o=!1;const c=e.workspaces.map(h=>h.id!==t||h.defaultCwd===r?h:(o=!0,{...h,defaultCwd:r}));return o?{...e,workspaces:c}:e}function V3(e,t,s,r){if(t===s)return e;const o=e.workspaces.findIndex(b=>b.id===t),c=e.workspaces.findIndex(b=>b.id===s);if(o<0||c<0)return e;const h=e.workspaces.slice(),[f]=h.splice(o,1);if(!f)return e;const g=h.findIndex(b=>b.id===s);if(g<0)return e;const p=r==="before"?g:g+1,y=h.slice();return y.splice(p,0,f),iA(e.workspaces,y)?e:{...e,workspaces:y}}function Y3(e,t){if(e.workspaces.length<=1||!e.workspaces.some(f=>f.id===t))return e;const s=e.workspaces.find(f=>f.id===t),r=new Set(s?uh(s):[]),o={...e.terminals};for(const f of r)delete o[f];const c=e.workspaces.filter(f=>f.id!==t),h=e.activeWorkspaceId===t?c[0]?.id??null:e.activeWorkspaceId;return{workspaces:c,activeWorkspaceId:h,terminals:o}}function R1(e,t){const s=B1(e),r=Ea(s)??Lh(),o=P1(t);return{...s,activeWorkspaceId:r.id,terminals:{...s.terminals,[t.id]:t},workspaces:s.workspaces.map(c=>c.id===r.id?{...c,defaultCwd:c.defaultCwd??hs(t.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>h!==t.id),tabs:[...c.tabs,o],activeTabId:o.id}:H1(c,t.id))}}function X3(e,t,s){const r=Ea(e),o=r?Ah(r):void 0;if(!r||!o)return R1(e,t);const c=o.activeTerminalId,h=rc(o.root,c,{type:"split",direction:s,ratio:.5,first:{type:"pane",terminalId:c},second:{type:"pane",terminalId:t.id}});return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(f=>f.id===r.id?{...f,defaultCwd:f.defaultCwd??hs(t.cwd),detachedTerminalIds:f.detachedTerminalIds.filter(g=>g!==t.id),tabs:f.tabs.map(g=>g.id===o.id?{...g,root:h,activeTerminalId:t.id}:g)}:H1(f,t.id))}}function G3(e,t,s,r){const o=Ea(e),c=o?Ah(o):void 0;if(!o||!c)return e;const h=c.activeTerminalId,f=rc(c.root,h,{type:"split",direction:r,ratio:.5,first:{type:"pane",terminalId:h},second:{type:"editor",editorId:t,title:s}});return{...e,workspaces:e.workspaces.map(g=>g.id===o.id?{...g,tabs:g.tabs.map(p=>p.id===c.id?{...p,root:f,activeTerminalId:h}:p)}:g)}}function Z3(e){const t=Ea(e),s=t?Ah(t):void 0;return s?A1(e,s.activeTerminalId):e}function Q3(e,t){const s=Ea(e);return!s||!s.tabs.some(r=>r.id===t)?e:{...e,workspaces:e.workspaces.map(r=>r.id===s.id?{...r,activeTabId:t}:r)}}function Ng(e,t,s){const r=e.workspaces.map(o=>{const c=o.tabs.findIndex(y=>y.id===t);if(c<0)return o;const h=o.tabs.slice(),[f]=h.splice(c,1);if(!f)return o;const g=Math.max(0,Math.min(h.length,s)),p=h.slice();return p.splice(g,0,f),tA(o.tabs,p)?o:{...o,tabs:p}});return r.every((o,c)=>o===e.workspaces[c])?e:{...e,workspaces:r}}function J3(e,t,s,r,o){if(s===r||!e.terminals[s]||!e.terminals[r])return e;let c=e.workspaces.map(g=>{const p=g.tabs.findIndex(E=>E.id===t);if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b=xl(y.root,s);if(!b){const E=g.tabs.filter((T,O)=>O!==p);return{...g,tabs:E}}const w={...y,root:b,activeTerminalId:ji(b)[0]??y.activeTerminalId},S=g.tabs.slice();return S[p]=w,{...g,tabs:S}});const h=o==="left"||o==="right"?"vertical":"horizontal",f=o==="left"||o==="top";return c=c.map(g=>{const p=g.tabs.findIndex(T=>ji(T.root).includes(r));if(p<0)return g;const y=g.tabs[p];if(!y)return g;const b={type:"pane",terminalId:s},w={type:"split",direction:h,ratio:.5,first:f?b:{type:"pane",terminalId:r},second:f?{type:"pane",terminalId:r}:b},S=rc(y.root,r,w),E=g.tabs.slice();return E[p]={...y,root:S,activeTerminalId:s},{...g,tabs:E,activeTabId:y.id}}),B1({...e,workspaces:c})}function M1(e,t,s,r){let o=-1,c=-1;for(let O=0;O<e.workspaces.length;O+=1){const L=e.workspaces[O].tabs.findIndex(N=>N.id===t);if(L>=0){o=O,c=L;break}}if(o<0)return e;const h=e.workspaces[o],f=h.tabs[c],g=ji(f.root);if(!g.includes(s))return e;if(g.length===1)return Ng(e,t,r);const p=xl(f.root,s);if(!p)return e;const y={...f,root:p,activeTerminalId:ji(p)[0]??f.activeTerminalId},b=e.terminals[s],w={id:`tab-${Date.now().toString(36)}-${s.slice(0,8)}`,title:b?.title??"",activeTerminalId:s,root:{type:"pane",terminalId:s}},S=h.tabs.slice();S[c]=y;const E=Math.max(0,Math.min(S.length,r));S.splice(E,0,w);const T=e.workspaces.slice();return T[o]={...h,tabs:S,activeTabId:w.id},{...e,workspaces:T}}function N1(e,t,s,r=Number.MAX_SAFE_INTEGER){const o=O1(e.workspaces,t),c=e.workspaces.find(p=>p.id===s);if(!o||!c)return e;if(o.workspace.id===s)return r===Number.MAX_SAFE_INTEGER?e:Ng(e,t,r);const h=ji(o.tab.root),f=h.map(p=>e.terminals[p]).find(Boolean),g=e.workspaces.map(p=>{if(p.id===o.workspace.id)return ka({...p,tabs:p.tabs.filter(y=>y.id!==t)});if(p.id===s){const y=p.tabs.slice(),b=Math.max(0,Math.min(y.length,r));return y.splice(b,0,o.tab),{...p,defaultCwd:p.defaultCwd??hs(f?.cwd),detachedTerminalIds:p.detachedTerminalIds.filter(w=>!h.includes(w)),tabs:y,activeTabId:o.tab.id}}return p});return{...e,workspaces:g,activeWorkspaceId:s}}function eA(e,t,s,r,o=Number.MAX_SAFE_INTEGER){const c=e.workspaces.find(S=>S.id===r),h=O1(e.workspaces,t);if(!c||!h||!e.terminals[s]||!ji(h.tab.root).includes(s))return e;if(h.workspace.id===r)return M1(e,t,s,o);if(ji(h.tab.root).length===1)return N1(e,t,r,o);const g=xl(h.tab.root,s);if(!g)return e;const p={...h.tab,root:g,activeTerminalId:ji(g)[0]??h.tab.activeTerminalId},y=e.terminals[s],b={id:`tab-${Date.now().toString(36)}-${s.slice(0,8)}`,title:y.title??s,activeTerminalId:s,root:{type:"pane",terminalId:s}},w=e.workspaces.map(S=>{if(S.id===h.workspace.id)return ka({...S,tabs:S.tabs.map(E=>E.id===t?p:E)});if(S.id===r){const E=S.tabs.slice(),T=Math.max(0,Math.min(E.length,o));return E.splice(T,0,b),{...S,defaultCwd:S.defaultCwd??hs(y.cwd),detachedTerminalIds:S.detachedTerminalIds.filter(O=>O!==s),tabs:E,activeTabId:b.id}}return S});return{...e,workspaces:w,activeWorkspaceId:r}}function tA(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1)if(e[s]?.id!==t[s]?.id)return!1;return!0}function iA(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1)if(e[s]?.id!==t[s]?.id)return!1;return!0}function nA(e,t,s){const r=s.trim();if(!r)return e;let o=!1;const c=e.workspaces.map(h=>{let f=!1;const g=h.tabs.map(p=>p.id!==t||p.title===r?p:(o=!0,f=!0,{...p,title:r}));return f?{...h,tabs:g}:h});return o?{...e,workspaces:c}:e}function sA(e,t){const s=e.workspaces.find(o=>o.tabs.some(c=>El(c.root,t))),r=s?.tabs.find(o=>El(o.root,t));return!s||!r?e:{...e,activeWorkspaceId:s.id,workspaces:e.workspaces.map(o=>o.id===s.id?{...o,activeTabId:r.id,tabs:o.tabs.map(c=>c.id===r.id?{...c,activeTerminalId:t}:c)}:o)}}function rA(e,t,s){const r=Ea(e),o=r?Ah(r):void 0;if(!r||!o)return e;const c=Am(o.root,t,K1(s));return c===o.root?e:{...e,workspaces:e.workspaces.map(h=>h.id===r.id?{...h,tabs:h.tabs.map(f=>f.id===o.id?{...f,root:c}:f)}:h)}}function km(e,t,s,r){const o=Object.fromEntries(e.map(b=>[b.id,b])),c=new Set(e.map(b=>b.id)),h=new Set,f=!!(s&&s.some(b=>U1(b))||t&&t.some(b=>I1(b)));let g=uA(t,s,c,h);g.length===0&&(g=[Lh()]);const p=typeof r=="string"&&g.some(b=>b.id===r)?r:g[0]?.id??null,y=p??g[0]?.id??Nh;for(const b of e)if(!h.has(b.id)){if(f)g=fA(g,y,b.id,b);else{const w=P1(b);g=mA(g,y,w,b)}h.add(b.id)}return{workspaces:g.map(b=>ka(pA(b,o))),activeWorkspaceId:p,terminals:o}}function sc(e){return ji(e.root)}function Tm(e){return Lm(e.root)}function uh(e){return Ag([...e.tabs.flatMap(t=>ji(t.root)),...e.detachedTerminalIds])}function hp(e){const t=e.workspaces.map(s=>{const r=s.tabs.flatMap(o=>{const c=Mm(o.root);return c?[{...o,root:c}]:[]});return ka({...s,tabs:r})});return{activeWorkspaceId:t.some(s=>s.id===e.activeWorkspaceId)?e.activeWorkspaceId:t[0]?.id??null,workspaces:t}}function aA(e,t){return{...e,terminals:{...e.terminals,[t.id]:t},workspaces:e.workspaces.map(s=>({...s,tabs:s.tabs.map(r=>El(r.root,t.id)?{...r,title:r.title||t.title}:r)}))}}function lA(e,t,s){const r=e.terminals[t];return r?{...e,terminals:{...e.terminals,[t]:{...r,status:"exited",exitCode:s}}}:e}function A1(e,t){const s={...e.terminals};return delete s[t],L1(e,t,s)}function oA(e,t,s){if(!e.terminals[t])return e;const r=(s&&e.workspaces.some(c=>c.id===s)?s:null)??hA(e,t)?.id??dA(e,t)?.id??e.activeWorkspaceId??e.workspaces[0]?.id??Nh,o=e.workspaces.find(c=>c.id===r);return!o||!j1(o,t)?e:L1(e,t,{...e.terminals},{detachToWorkspaceId:r})}function L1(e,t,s,r={}){let o=e.workspaces.map(h=>{const f=[];for(const g of h.tabs){const p=xl(g.root,t);if(!p)continue;const y=ji(p),b=y.includes(g.activeTerminalId)?g.activeTerminalId:y[0];b&&f.push({...g,root:p,activeTerminalId:b})}return ka({...h,detachedTerminalIds:h.detachedTerminalIds.filter(g=>g!==t),tabs:f})});r.detachToWorkspaceId&&s[t]&&(o=o.map(h=>h.id===r.detachToWorkspaceId?z1(h,t,s[t]):h));const c=o.some(h=>h.id===e.activeWorkspaceId);return{workspaces:o,activeWorkspaceId:c?e.activeWorkspaceId:o[0]?.id??null,terminals:s}}function cA(e,t){const s=e.workspaces.map(o=>{const c=[];for(const h of o.tabs){const f=Dm(h.root,t);if(!f)continue;const g=ji(f),p=g.includes(h.activeTerminalId)?h.activeTerminalId:g[0];p&&c.push({...h,root:f,activeTerminalId:p})}return ka({...o,tabs:c})}),r=s.some(o=>o.id===e.activeWorkspaceId);return{...e,workspaces:s,activeWorkspaceId:r?e.activeWorkspaceId:s[0]?.id??null}}function uA(e,t,s,r){if(t&&t.length>0){const o=[];for(const c of t)U1(c)&&o.push(o0(c,s,r));if(o.length>0)return o}return[o0({...Lh(),tabs:e??[]},s,r)]}function o0(e,t,s){const r=[];for(const c of e.tabs){if(!I1(c))continue;const h=Rm(c.root,t);if(!h)continue;const f=ji(h);for(const p of f)s.add(p);const g=f.includes(c.activeTerminalId)?c.activeTerminalId:f[0];g&&r.push({...c,root:h,activeTerminalId:g})}const o=[];for(const c of e.detachedTerminalIds??[])!t.has(c)||s.has(c)||(s.add(c),o.push(c));return ka({...e,defaultCwd:hs(e.defaultCwd),detachedTerminalIds:o,tabs:r})}function B1(e){return Ea(e)?e:{...e,workspaces:[Lh()],activeWorkspaceId:Nh}}function Ea(e){return e.workspaces.find(t=>t.id===e.activeWorkspaceId)??e.workspaces[0]}function Ah(e){return e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]}function O1(e,t){for(const s of e){const r=s.tabs.findIndex(o=>o.id===t);if(r>=0)return{workspace:s,tab:s.tabs[r],tabIndex:r}}return null}function hA(e,t){return e.workspaces.find(s=>s.tabs.some(r=>El(r.root,t)))}function dA(e,t){return e.workspaces.find(s=>s.detachedTerminalIds.includes(t))}function fA(e,t,s,r){return e.map(o=>o.id===t?z1(o,s,r):o)}function z1(e,t,s){return j1(e,t)?{...e,defaultCwd:e.defaultCwd??hs(s?.cwd),detachedTerminalIds:Ag([...e.detachedTerminalIds.filter(r=>r!==t),t])}:e}function j1(e,t){return e.detachedTerminalIds.includes(t)||e.detachedTerminalIds.length<Dl}function H1(e,t){return e.detachedTerminalIds.includes(t)?{...e,detachedTerminalIds:e.detachedTerminalIds.filter(s=>s!==t)}:e}function pA(e,t){if(e.defaultCwd)return e;const s=uh(e).find(o=>!!t[o]),r=s?hs(t[s]?.cwd):null;return r?{...e,defaultCwd:r}:e}function Lh(){return{id:Nh,title:I3,defaultCwd:null,detachedTerminalIds:[],tabs:[],activeTabId:null}}function ka(e){const t=e.tabs.some(s=>s.id===e.activeTabId);return{...e,defaultCwd:hs(e.defaultCwd),detachedTerminalIds:Ag(e.detachedTerminalIds??[]),activeTabId:t?e.activeTabId:e.tabs[0]?.id??null}}function mA(e,t,s,r){const o=ji(s.root);return e.map(c=>c.id===t?{...c,defaultCwd:c.defaultCwd??hs(r?.cwd),detachedTerminalIds:c.detachedTerminalIds.filter(h=>!o.includes(h)),tabs:[...c.tabs,s],activeTabId:c.activeTabId??s.id}:c)}function P1(e){return{id:`tab-${e.id}`,title:e.title||e.id,root:{type:"pane",terminalId:e.id},activeTerminalId:e.id}}function rc(e,t,s){return e.type==="pane"?e.terminalId===t?s:e:e.type==="editor"?e:{...e,first:rc(e.first,t,s),second:rc(e.second,t,s)}}function xl(e,t){if(e.type==="pane")return e.terminalId===t?null:e;if(e.type==="editor")return e;const s=xl(e.first,t),r=xl(e.second,t);return s&&r?{...e,first:s,second:r}:s??r}function Dm(e,t){if(e.type==="editor")return e.editorId===t?null:e;if(e.type==="pane")return e;const s=Dm(e.first,t),r=Dm(e.second,t);return s&&r?{...e,first:s,second:r}:s??r}function Rm(e,t){if(e.type==="pane")return t.has(e.terminalId)?e:null;if(e.type==="editor")return null;const s=Rm(e.first,t),r=Rm(e.second,t);return s&&r?{...e,ratio:K1(e.ratio),first:s,second:r}:s??r}function Mm(e){if(e.type==="editor")return null;if(e.type==="pane")return e;const t=Mm(e.first),s=Mm(e.second);return t&&s?{...e,first:t,second:s}:t??s}function U1(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 I1(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.title=="string"&&typeof t.activeTerminalId=="string"&&Nm(t.root)}function Nm(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="pane"?typeof t.terminalId=="string":t.type==="editor"?typeof t.editorId=="string"&&typeof t.title=="string":t.type==="split"?(t.direction==="horizontal"||t.direction==="vertical")&&Nm(t.first)&&Nm(t.second):!1}function Am(e,t,s){if(e.type==="pane"||e.type==="editor")return e;if(t.length===0)return e.ratio===s?e:{...e,ratio:s};const[r,...o]=t;if(r===0){const c=Am(e.first,o,s);return c===e.first?e:{...e,first:c}}if(r===1){const c=Am(e.second,o,s);return c===e.second?e:{...e,second:c}}return e}function K1(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}function hs(e){if(typeof e!="string")return null;const t=e.trim();return t||null}function Ag(e){const t=new Set,s=[];for(const r of e)!r||t.has(r)||(t.add(r),s.push(r));return s}function El(e,t){return e.type==="pane"?e.terminalId===t:e.type==="editor"?!1:El(e.first,t)||El(e.second,t)}function ji(e){return e.type==="pane"?[e.terminalId]:e.type==="editor"?[]:[...ji(e.first),...ji(e.second)]}function Lm(e){return e.type==="pane"||e.type==="editor"?1:Lm(e.first)+Lm(e.second)}const Pr=new Map,ac=new Map,lc=new Map;function Nl(e){return e??"__local__"}function gA(e){return{agentId:e,state:K3(),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 Nt(e){const t=Nl(e);let s=Pr.get(t);return s||(s=gA(e),Pr.set(t,s)),s}function W1(e,t){const s=Nl(e);let r=ac.get(s);return r||(r=new Set,ac.set(s,r)),r.add(t),()=>{r.delete(t)}}function _A(e){const t=Nl(e),s=ac.get(t);if(s)for(const r of Array.from(s))r()}function Al(e,t){Pr.set(Nl(e),t),_A(e)}const Bm=new Set;function vA(e){return Bm.add(e),()=>{Bm.delete(e)}}function Mo(e,t){const s=Nt(e),r=Nl(e);t.type==="workspace.hydrated"&&lc.delete(r);const o=W3(s.state,t);let c=s.unreadCompletions,h=null;if(t.type==="terminal.updated"){const p=s.state.terminals[t.terminal.id],y=p?.activity==="busy",b=t.terminal.activity==="busy",w=t.terminal.activity==="idle",S=kA(r);if(t.notifyCompletion===!0&&b&&S.add(t.terminal.id),t.notifyCompletion===!0&&y&&w&&S.has(t.terminal.id)){const E=bA(o,t.terminal.id);E&&(h={terminalId:t.terminal.id,tabId:E.tab.id,commandName:p?.currentCommand??null},(E.workspace.activeTabId!==E.tab.id||E.workspace.id!==o.activeWorkspaceId)&&(c.has(t.terminal.id)||(c=new Set(c),c.add(t.terminal.id))))}(w||t.terminal.status==="exited")&&S.delete(t.terminal.id)}if(t.type==="tab.selected"||t.type==="workspace.selected"){let p=null;if(t.type==="tab.selected")p=yA(o,t.tabId)?.tab??null;else{const b=o.workspaces.find(w=>w.id===t.workspaceId);p=b?.tabs.find(w=>w.id===b.activeTabId)??null}const y=p?ji(p.root):[];if(y.some(b=>c.has(b))){const b=new Set(c);for(const w of y)b.delete(w);c=b}}const f=o!==s.state,g=c!==s.unreadCompletions;if((f||g)&&Al(e,{...s,state:o,unreadCompletions:c}),g&&Lg(),h)for(const p of Array.from(Bm))p({agentId:e,...h})}function bA(e,t){for(const s of e.workspaces)for(const r of s.tabs)if(ji(r.root).includes(t))return{workspace:s,tab:r};return null}function yA(e,t){for(const s of e.workspaces){const r=s.tabs.find(o=>o.id===t);if(r)return{workspace:s,tab:r}}return null}const Om=new Set;function SA(e){return Om.add(e),()=>{Om.delete(e)}}function wA(){let e=0;for(const t of Pr.values())e+=t.unreadCompletions.size;return e}function Lg(){for(const e of Array.from(Om))e()}function CA(e,t){const s=Nt(e);if(!s.unreadCompletions.has(t))return;const r=new Set(s.unreadCompletions);r.delete(t),Al(e,{...s,unreadCompletions:r}),Lg()}function c0(e,t){const s=Nt(e);t!==s.state&&Al(e,{...s,state:t})}function dp(e,t){const s=Nt(e),r=t(s.editors);r!==s.editors&&Al(e,{...s,editors:r})}function kr(e,t,s){const r=Nt(e);r.loaded===t&&r.error===s||Al(e,{...r,loaded:t,error:s})}function No(e,t,s){const r=Nt(e);r.layoutRevision===t&&r.lastPersistedLayoutJson===s||Al(e,{...r,layoutRevision:t,lastPersistedLayoutJson:s})}function xA(e){const t=Nt(e);return t.mutable.editorIdCounter+=1,t.mutable.editorIdCounter}function EA(e){const t=Nl(e),s=Pr.get(t);s&&s.mutable.saveCoord.saveTimer!==null&&window.clearTimeout(s.mutable.saveCoord.saveTimer);const r=s?s.unreadCompletions.size>0:!1;Pr.delete(t),ac.delete(t),lc.delete(t),r&&Lg()}function fp(){for(const e of Pr.values()){const t=e.mutable.saveCoord.saveTimer;t!==null&&window.clearTimeout(t),e.unreadCompletions.size>0}Pr.clear(),ac.clear(),lc.clear()}function kA(e){let t=lc.get(e);return t||(t=new Set,lc.set(e,t)),t}function zm(e,t){let s=!1,r=!1,o=null,c=!1;for(const h of sc(e)){const f=t[h];if(f){if(f.status==="exited"){c=!0,s=!0;continue}f.activity==="busy"?(r=!0,s=!0,!o&&f.currentCommand&&(o=f.currentCommand)):f.activity==="idle"&&(s=!0)}}return s?c?{state:"exited",commandName:null}:r?{state:"busy",commandName:o}:{state:"idle",commandName:null}:null}function Bg(e){return e?e.state==="busy"?e.commandName?`running: ${e.commandName}`:"running":e.state==="exited"?"exited":"idle":""}function jm(e,t){const s=t[e.activeTerminalId];return e.title||s?.title||e.activeTerminalId}function TA(e,t,s,r){return r?.state==="busy"?r.commandName?`running: ${r.commandName}`:"running":r?.state==="exited"?"exited":t[e.activeTerminalId]?.cwd||`${s} pane${s===1?"":"s"}`}function DA({tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,onSelectTab:c,onCreateTab:h,onToggleWorkspaces:f,onCloseTerminals:g,onReattachTerminal:p,onDeleteTerminal:y,onSplitVertical:b,onSplitHorizontal:w,onRenameTab:S,activePaneAvailable:E}){const[T,O]=v.useState(null),[L,N]=v.useState(!1),[I,U]=v.useState(null),Q=v.useRef(null),ie=e.findIndex(F=>F.id===t),le=ie>=0?e[ie]:e[0]??null,ce=le?zm(le,s):null,ve=le?Tm(le):0,we=le?jm(le,s):"No tab";v.useEffect(()=>{Q.current?.focus(),Q.current?.select()},[T?.tabId]),v.useEffect(()=>{if(!L)return;const F=re=>{re.key==="Escape"&&N(!1)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[L]),v.useEffect(()=>{L&&e.length===0&&N(!1)},[L,e.length]);function ne(F,re){O({tabId:F,title:re})}function se(){if(!T)return;const F=T.title.trim();F&&S(T.tabId,F),O(null)}function V(){return m.jsxs("div",{className:"terminal-pane-actions","aria-label":"Pane actions",children:[m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split right",title:`Split right - ${K2()}`,onClick:b,disabled:!E,children:m.jsx("span",{className:"split-icon split-icon-right","aria-hidden":"true"})}),m.jsx("button",{type:"button",className:"pane-action-button","aria-label":"Split down",title:`Split down - ${W2()}`,onClick:w,disabled:!E,children:m.jsx("span",{className:"split-icon split-icon-down","aria-hidden":"true"})})]})}return m.jsxs(m.Fragment,{children:[m.jsxs("nav",{className:"terminal-tabs","aria-label":"Terminal tabs",children:[m.jsx("button",{type:"button",className:"mobile-menu-button","aria-label":"Toggle workspaces",title:"Workspaces",onClick:f,children:m.jsxs("span",{className:"hamburger-lines","aria-hidden":"true",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]})}),m.jsxs("button",{type:"button",className:"mobile-tab-current-button","aria-label":"Open tab switcher",title:we,onClick:()=>N(!0),disabled:e.length===0,children:[ce?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ce.state,"aria-hidden":"true",title:Bg(ce)}):null,m.jsx("span",{children:we}),m.jsxs("small",{children:[ie>=0?ie+1:0,"/",e.length||0,ve>1?` / ${ve}`:""]})]}),m.jsxs("div",{className:"terminal-tab-list",children:[e.map((F,re)=>{const B=sc(F),W=Tm(F),D=jm(F,s),G=F.id===t,me=T?.tabId===F.id,R=zm(F,s),H=r?.has(F.id)??!1;return m.jsxs(xi.Fragment,{children:[m.jsx(u0,{index:re}),m.jsx(RA,{tab:F,active:G,editing:me,title:D,paneCount:W,terminalIds:B,canClose:e.length>1,editValue:me?T.title:null,editInputRef:me?Q:null,activity:R,unread:H,onSelect:()=>c(F.id),onBeginRename:()=>ne(F.id,D),onCloseAll:()=>g(B),onCommitRename:se,onCancelRename:()=>O(null),onRenameChange:ee=>O({tabId:F.id,title:ee})})]},F.id)}),m.jsx(u0,{index:e.length}),m.jsx("button",{type:"button",className:"tab-add-button","aria-label":"New tab",title:"New tab",onClick:h,children:"+"}),(o?.length??0)>0?m.jsx("div",{className:"terminal-detached-pills","aria-label":"Detached terminals",children:(o??[]).map(F=>m.jsx(NA,{terminal:F,onReattach:()=>p?.(F.id),onDelete:()=>U(F)},F.id))}):null]}),m.jsx("button",{type:"button",className:"mobile-tab-add-button","aria-label":"Create new tab",title:"New tab",onClick:h,children:"+"}),E?V():null]}),L?m.jsx(MA,{tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:T,editInputRef:Q,onClose:()=>N(!1),onSelectTab:F=>{c(F),N(!1)},onCreateTab:()=>{h(),N(!1)},onBeginRename:ne,onCloseTerminals:F=>{g(F),N(!1)},onCommitRename:se,onCancelRename:()=>O(null),onRenameChange:(F,re)=>O({tabId:F,title:re}),onReattachTerminal:F=>{p?.(F),N(!1)},onDeleteTerminal:F=>{U(F),N(!1)}}):null,I?m.jsx(AA,{terminal:I,onCancel:()=>U(null),onConfirm:()=>{y?.(I.id),U(null)}}):null]})}function RA({tab:e,active:t,editing:s,title:r,paneCount:o,canClose:c,editValue:h,editInputRef:f,activity:g,unread:p,onSelect:y,onBeginRename:b,onCloseAll:w,onCommitRename:S,onCancelRename:E,onRenameChange:T}){const{attributes:O,listeners:L,setNodeRef:N,transform:I,isDragging:U}=F0({id:`tab-${e.id}`,data:{kind:"tab",tabId:e.id,terminalId:e.activeTerminalId},disabled:s}),Q={transform:vp.Translate.toString(I),opacity:U?.4:void 0,zIndex:U?2:void 0};return m.jsxs("div",{ref:N,className:"terminal-tab","data-active":t,"data-dragging":U,"data-unread":p?"true":void 0,style:Q,...O,...L,children:[g?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":g.state,"aria-hidden":"true",title:Bg(g)}):null,s&&f&&h!==null?m.jsxs("form",{className:"terminal-tab-editor",onSubmit:ie=>{ie.preventDefault(),S()},children:[m.jsx("input",{ref:f,"aria-label":`Rename ${r}`,value:h,onBlur:S,onChange:ie=>T(ie.target.value),onKeyDown:ie=>{if(ie.key==="Enter"){ie.preventDefault(),S();return}ie.key==="Escape"&&(ie.preventDefault(),E())}}),m.jsx("small",{children:o})]}):m.jsxs("button",{type:"button",className:"terminal-tab-select","aria-label":`Select ${r}`,title:r,onClick:y,onDoubleClick:ie=>{ie.preventDefault(),b()},children:[m.jsx("span",{children:r}),m.jsxs("small",{children:[o," pane",o===1?"":"s"]})]}),c&&!s?m.jsx("button",{type:"button",className:"icon-button","aria-label":`Close ${r}`,title:`Close ${r}`,onPointerDown:ie=>ie.stopPropagation(),onClick:ie=>{ie.stopPropagation(),w()},children:"x"}):null]})}function MA({tabs:e,activeTabId:t,terminals:s,unreadCompletionTabIds:r,detachedTerminals:o,editingTab:c,editInputRef:h,onClose:f,onSelectTab:g,onCreateTab:p,onBeginRename:y,onCloseTerminals:b,onCommitRename:w,onCancelRename:S,onRenameChange:E,onReattachTerminal:T,onDeleteTerminal:O}){const L=v.useRef(null);return v.useEffect(()=>{L.current?.scrollIntoView?.({block:"nearest"})},[t]),m.jsx("div",{className:"mobile-tab-sheet-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"mobile-tab-sheet-title",onClick:f,children:m.jsxs("section",{className:"mobile-tab-sheet",onClick:N=>N.stopPropagation(),children:[m.jsxs("header",{children:[m.jsxs("div",{children:[m.jsx("strong",{id:"mobile-tab-sheet-title",children:"Switch Tabs"}),m.jsxs("small",{children:[e.length," open"]})]}),m.jsxs("div",{className:"mobile-tab-sheet-header-actions",children:[m.jsx("button",{type:"button","aria-label":"New tab",title:"New tab",onClick:p,children:"+"}),m.jsx("button",{type:"button","aria-label":"Close tab switcher",title:"Close",onClick:f,children:"×"})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-list",children:[e.map((N,I)=>{const U=sc(N),Q=Tm(N),ie=jm(N,s),le=N.id===t,ce=c?.tabId===N.id,ve=zm(N,s),we=r?.has(N.id)??!1;return m.jsxs("div",{ref:le?L:null,className:"mobile-tab-sheet-row","data-active":le,"data-unread":we?"true":void 0,children:[ce&&c?m.jsx("form",{className:"mobile-tab-sheet-editor",onSubmit:ne=>{ne.preventDefault(),w()},children:m.jsx("input",{ref:h,"aria-label":`Rename ${ie}`,value:c.title,onBlur:w,onChange:ne=>E(N.id,ne.target.value),onKeyDown:ne=>{if(ne.key==="Enter"){ne.preventDefault(),w();return}ne.key==="Escape"&&(ne.preventDefault(),S())}})}):m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Switch to ${ie}`,onClick:()=>g(N.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:I+1}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:ie}),m.jsx("small",{children:TA(N,s,Q,ve)})]}),m.jsxs("span",{className:"mobile-tab-sheet-meta",children:[ve?m.jsx("span",{className:"terminal-tab-status-dot","data-activity":ve.state,"aria-hidden":"true",title:Bg(ve)}):null,m.jsx("span",{children:Q})]})]}),m.jsxs("div",{className:"mobile-tab-sheet-actions",children:[ce?m.jsx("button",{type:"button","aria-label":`Done renaming ${ie}`,onClick:w,children:"Done"}):m.jsx("button",{type:"button","aria-label":`Rename ${ie}`,onClick:()=>y(N.id,ie),children:"Rename"}),e.length>1?m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Close ${ie}`,onClick:()=>b(U),children:"×"}):null]})]},N.id)}),(o?.length??0)>0?m.jsxs("div",{className:"mobile-tab-sheet-detached","aria-label":"Detached terminals",children:[m.jsx("span",{children:"Detached"}),(o??[]).map(N=>{const I=N.title||N.cwd||N.id.slice(0,8);return m.jsxs("div",{className:"mobile-tab-sheet-row mobile-tab-sheet-row-detached",children:[m.jsxs("button",{type:"button",className:"mobile-tab-sheet-select","aria-label":`Re-open ${I}`,onClick:()=>T(N.id),children:[m.jsx("span",{className:"mobile-tab-sheet-index",children:"+"}),m.jsxs("span",{className:"mobile-tab-sheet-copy",children:[m.jsx("strong",{children:I}),m.jsx("small",{children:N.cwd})]}),m.jsx("span",{className:"mobile-tab-sheet-type",children:"detached"})]}),m.jsx("div",{className:"mobile-tab-sheet-actions",children:m.jsx("button",{type:"button",className:"mobile-tab-sheet-close","aria-label":`Delete ${I}`,onClick:()=>O(N),children:"×"})})]},N.id)})]}):null]})]})})}function u0({index:e}){const{setNodeRef:t,isOver:s}=Qm({id:`tab-position-${e}`,data:{kind:"tab-position",index:e}});return m.jsx("div",{ref:t,className:"terminal-tab-drop-slot","data-over":s,"aria-hidden":"true"})}function NA({terminal:e,onReattach:t,onDelete:s}){const r=e.title||e.cwd||e.id.slice(0,8),o=`${e.title||"Terminal"}
|
|
54
|
+
${e.cwd}
|
|
55
|
+
(detached — click to re-open, × to delete)`;return m.jsxs("span",{className:"terminal-detached-pill",title:o,children:[m.jsx("button",{type:"button",className:"terminal-detached-pill-open","aria-label":`Re-open ${r}`,onClick:t,children:r}),m.jsx("button",{type:"button",className:"terminal-detached-pill-delete","aria-label":`Delete ${r}`,title:`Delete ${r} — this destroys the underlying shell session.`,onClick:c=>{c.stopPropagation(),s()},children:"×"})]})}function AA({terminal:e,onCancel:t,onConfirm:s}){const r=e.title||e.cwd||e.id.slice(0,8);return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"delete-terminal-title",onClick:t,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:o=>o.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"delete-terminal-title",children:"Delete Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:t,children:"×"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:"Delete this terminal?"}),m.jsx("span",{children:r}),m.jsx("small",{children:"The shell session and scrollback will be destroyed."})]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:t,children:"Cancel"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:s,children:"Delete"})]})]})})}function LA({uploads:e,onDismiss:t,onDismissAll:s,onRetry:r,onCancel:o}){if(e.length===0)return null;const h=e.some(g=>g.status==="failed"||g.status==="partial")?"alert":"status",f=e.filter(g=>g.status==="queued"||g.status==="uploading").length;return m.jsxs("aside",{className:`upload-toast upload-toast-${HA(e)}`,role:h,"aria-live":h==="alert"?"assertive":"polite",children:[m.jsxs("header",{className:"upload-toast-header",children:[m.jsx("strong",{children:e.length===1?Fu(e[0]):`Uploads ${f>0?`(${f} active)`:`(${e.length})`}`}),m.jsx("button",{type:"button","aria-label":"Dismiss upload status",onClick:s,children:"x"})]}),m.jsx("div",{className:"upload-toast-body upload-queue-body",children:e.map(g=>m.jsx(BA,{upload:g,compact:e.length>1,onDismiss:()=>t(g.id),onRetry:()=>r(g.id),onCancel:()=>o(g.id)},g.id))})]})}function BA({upload:e,compact:t,onDismiss:s,onRetry:r,onCancel:o}){const c="response"in e?e.response:void 0,h=e.status==="failed"||e.status==="partial",f=e.status==="queued"||e.status==="uploading";return m.jsxs("section",{className:"upload-queue-item","data-status":e.status,"aria-label":Fu(e),children:[m.jsxs("div",{className:"upload-queue-item-header",children:[m.jsx("strong",{children:Fu(e)}),m.jsxs("div",{className:"upload-queue-actions",children:[f?m.jsx("button",{type:"button",onClick:o,children:"Cancel"}):null,h?m.jsx("button",{type:"button",onClick:r,children:"Retry"}):null,m.jsx("button",{type:"button","aria-label":`Dismiss ${Fu(e)}`,onClick:s,children:"x"})]})]}),e.status==="queued"?m.jsx("p",{children:e.message??"Queued"}):null,e.status==="uploading"?m.jsx(OA,{toast:e}):null,c&&"message"in e&&e.message?m.jsx("p",{className:"upload-toast-muted",children:e.message}):null,c?m.jsx(zA,{response:c,compact:t}):null,e.status==="failed"&&!c&&e.message?m.jsx("p",{children:e.message}):null]})}function OA({toast:e}){const t=e.percent===null?PA(e.loaded):`${e.percent}%`;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"upload-progress-row",children:[m.jsxs("span",{children:[e.fileCount," file",e.fileCount===1?"":"s"]}),m.jsx("span",{children:t})]}),m.jsx("div",{className:"upload-progress-track","aria-hidden":"true",children:m.jsx("span",{style:{width:e.percent===null?"100%":`${e.percent}%`}})})]})}function zA({response:e,compact:t}){const s=e.results.filter(h=>h.status==="failed"),r=e.results.filter(h=>h.status==="uploaded"),o=t?3:6,c=[...s,...r].slice(0,o);return m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"upload-toast-destination",children:e.destinationCwd}),c.length>0?m.jsx("ul",{className:"upload-result-list",children:c.map((h,f)=>m.jsx(jA,{result:h},`${h.relativePath}-${f}`))}):null,e.results.length>c.length?m.jsxs("p",{className:"upload-toast-muted",children:["+",e.results.length-c.length," more"]}):null]})}function jA({result:e}){const t=e.savedRelativePath??e.relativePath,s=e.status==="uploaded"&&e.savedRelativePath!==void 0&&e.savedRelativePath!==e.relativePath;return m.jsxs("li",{"data-status":e.status,children:[m.jsx("span",{className:"upload-result-path",children:t}),s?m.jsx("span",{className:"upload-result-renamed",children:"renamed"}):null,e.status==="failed"&&e.error?m.jsx("span",{className:"upload-result-error",children:e.error}):null]})}function Fu(e){if(e.status==="queued")return"Preparing upload";if(e.status==="uploading")return`Uploading ${e.fileCount} file${e.fileCount===1?"":"s"}`;if(e.status==="success"){const t=e.response?.uploaded??e.fileCount;return`Uploaded ${t} file${t===1?"":"s"}`}if(e.status==="partial"){const t=e.response?.uploaded??0,s=(e.response?.uploaded??0)+(e.response?.failed??0)||e.fileCount;return`Uploaded ${t} of ${s} files`}return"Upload failed"}function HA(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 PA(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${Math.round(e/(1024*1024))} MB`}function UA({toast:e,onActivate:t,onDismiss:s}){if(!e)return null;const r=e,o=r.commandName?`${r.commandName} finished`:"Command finished";function c(f){f.stopPropagation(),s()}function h(f){f.target===f.currentTarget&&(f.key!=="Enter"&&f.key!==" "||(f.preventDefault(),t(r)))}return m.jsxs("aside",{className:"completion-toast",role:"status","aria-live":"polite",tabIndex:0,onClick:()=>t(r),onKeyDown:h,children:[m.jsxs("header",{className:"completion-toast-header",children:[m.jsxs("div",{className:"completion-toast-copy",children:[m.jsx("strong",{children:r.tabTitle}),m.jsx("span",{children:o})]}),m.jsx("button",{type:"button","aria-label":"Dismiss completion alert",onClick:c,onPointerDown:f=>f.stopPropagation(),children:"x"})]}),m.jsx("video",{className:"completion-toast-character",src:r.assetSrc,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"})]})}const IA=Io(0,0,1,1),$s=1e-6;function KA(e){return F1(e).map(t=>t.terminalId)}function F1(e){return Uo(e,IA).sort($A).map((t,s)=>({...t,index:s+1}))}function WA(e,t,s){const r=F1(e),o=r.find(h=>h.terminalId===t);return o?r.filter(h=>h.terminalId!==t).map(h=>qA(o,h,s)).filter(h=>h!==null).sort(VA)[0]?.entry.terminalId??null:null}function FA(e,t){return!Number.isInteger(t)||t<1?null:KA(e)[t-1]??null}function Uo(e,t){if(e.type==="pane")return[{terminalId:e.terminalId,bounds:t}];if(e.type==="editor")return[];const s=YA(e.ratio);if(e.direction==="vertical"){const o=t.left+(t.right-t.left)*s;return[...Uo(e.first,Io(t.left,t.top,o,t.bottom)),...Uo(e.second,Io(o,t.top,t.right,t.bottom))]}const r=t.top+(t.bottom-t.top)*s;return[...Uo(e.first,Io(t.left,t.top,t.right,r)),...Uo(e.second,Io(t.left,r,t.right,t.bottom))]}function qA(e,t,s){const r=e.bounds,o=t.bounds,c=h0(r.left,r.right,o.left,o.right),h=h0(r.top,r.bottom,o.top,o.bottom);switch(s){case"left":return o.centerX>=r.centerX-$s||h<=$s?null:{entry:t,primaryDistance:Math.max(0,r.left-o.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:h};case"right":return o.centerX<=r.centerX+$s||h<=$s?null:{entry:t,primaryDistance:Math.max(0,o.left-r.right),perpendicularDistance:Math.abs(r.centerY-o.centerY),overlap:h};case"up":return o.centerY>=r.centerY-$s||c<=$s?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+$s||c<=$s?null:{entry:t,primaryDistance:Math.max(0,o.top-r.bottom),perpendicularDistance:Math.abs(r.centerX-o.centerX),overlap:c};default:return null}}function $A(e,t){return _l(e.bounds.top,t.bounds.top)||_l(e.bounds.left,t.bounds.left)}function VA(e,t){return _l(e.primaryDistance,t.primaryDistance)||_l(e.perpendicularDistance,t.perpendicularDistance)||_l(t.overlap,e.overlap)||_l(e.entry.index,t.entry.index)}function _l(e,t){const s=e-t;return Math.abs(s)<=$s?0:s}function h0(e,t,s,r){return Math.max(0,Math.min(t,r)-Math.max(e,s))}function Io(e,t,s,r){return{left:e,top:t,right:s,bottom:r,centerX:e+(s-e)/2,centerY:t+(r-t)/2}}function YA(e){return Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}class XA extends Error{constructor(t){super(t),this.name="UploadDropError"}}function d0(e){return e?Array.from(e.types??[]).includes("Files")||Y1(e.items).some(s=>s.kind==="file")?!0:X1(e.files).length>0:!1}async function GA(e){const t=Y1(e.items).filter(s=>s.kind==="file");return t.length>0?ZA(t):QA(e.files)}async function ZA(e){const t=[];for(const s of e){const r=i5(s);if(r){await q1(r,"",t);continue}const o=s.getAsFile();if(o){t.push({relativePath:$1(o),file:o});continue}throw new XA("Folder upload is not supported by this browser.")}return t}function QA(e){return X1(e).map(t=>({relativePath:$1(t),file:t}))}async function q1(e,t,s){const r=s5(t,e.name);if(e.isFile){const h=await JA(e);s.push({relativePath:r,file:h});return}if(!e.isDirectory)return;const o=e.createReader(),c=await e5(o);for(const h of c)await q1(h,r,s)}function JA(e){return new Promise((t,s)=>{e.file(t,r=>s(r))})}async function e5(e){const t=[];for(;;){const s=await t5(e);if(s.length===0)return t;t.push(...s)}}function t5(e){return new Promise((t,s)=>{e.readEntries(t,r=>s(r))})}function $1(e){const t=e.webkitRelativePath;return V1(typeof t=="string"&&t?t:e.name)}function i5(e){const t=e.webkitGetAsEntry?.();return n5(t)?t:null}function n5(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 s5(e,t){return V1(e?`${e}/${t}`:t)}function V1(e){return e.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(Boolean).join("/")}function Y1(e){return e?Array.from(e):[]}function X1(e){return e?Array.from(e):[]}const f0="nterminal.terminalWorkspaces.v2",G1="nterminal.sidebarCollapsed.v1",r5=75,p0=V0.map(e=>e.url),a5=V0[0].url,l5=6;function o5({api:e,serverApi:t,activeAgentId:s=null,onSelectServer:r,sessionExpiresAt:o=null,onLogout:c=async()=>{},onSessionInvalid:h}){const f=v.useMemo(()=>e??ph(),[e]),g=v.useMemo(()=>t??Go(null),[t]),p=v.useMemo(()=>k5(s),[s]),y=v.useMemo(()=>x=>W1(s,x),[s]),b=v.useMemo(()=>()=>Nt(s),[s]),w=v.useSyncExternalStore(y,b,b),S=w.state,E=w.editors,T=!w.loaded,O=w.error,[L,N]=v.useState(!1),[I,U]=v.useState(()=>L5()),[Q,ie]=v.useState("servers"),[le,ce]=v.useState(!1),ve=v.useSyncExternalStore(J2,Iy,Iy);v.useSyncExternalStore(ug,Uy,Uy);const[we,ne]=v.useState(0),[se,V]=v.useState(null),[F,re]=v.useState(()=>[null]),[B,W]=v.useState(0),[D,G]=v.useState(()=>[s]),[me,R]=v.useState(()=>new Set),[H,ee]=v.useState({}),[de,Ee]=v.useState(null),ke=v.useRef(0),Me=v.useRef(0),[Fe,_e]=v.useState(null),[X,he]=v.useState(null),Ce=v.useRef(null),be=v.useRef(0),De=v.useRef(null),Oe=v.useRef(null),Ie=v.useRef(null),[oe,xe]=v.useState(null),Ae=AE(wy(P0,{activationConstraint:{distance:8}}),wy(U0,{activationConstraint:{delay:250,tolerance:5}}));v.useEffect(()=>eT(f),[f]);function ze(x){const k=x.active.data.current;if(k){if(k.kind==="tab"&&typeof k.tabId=="string"&&typeof k.terminalId=="string"){xe({tabId:k.tabId,terminalId:k.terminalId});return}k.kind==="pane"&&typeof k.sourceTabId=="string"&&typeof k.terminalId=="string"&&xe({tabId:k.sourceTabId,terminalId:k.terminalId})}}function He(x){xe(null);const k=x.active.data.current,j=x.over?.data.current;if(!(!k||!j||typeof k.terminalId!="string")){if(k.kind==="tab"&&typeof k.tabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){rt({type:"tab.reordered",sourceTabId:k.tabId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){rt({type:"tab.moved_to_workspace",sourceTabId:k.tabId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&rt({type:"tab.dropped_into_pane",sourceTabId:k.tabId,sourceTerminalId:k.terminalId,targetTerminalId:j.terminalId,side:j.side});return}if(k.kind==="pane"&&typeof k.sourceTabId=="string"){if(j.kind==="tab-position"&&typeof j.index=="number"){rt({type:"terminal.extracted_to_tab",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetIndex:j.index});return}if(j.kind==="workspace"&&typeof j.workspaceId=="string"){rt({type:"terminal.extracted_to_workspace",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetWorkspaceId:j.workspaceId});return}j.kind==="pane-zone"&&typeof j.terminalId=="string"&&(j.side==="top"||j.side==="right"||j.side==="bottom"||j.side==="left")&&rt({type:"tab.dropped_into_pane",sourceTabId:k.sourceTabId,sourceTerminalId:k.terminalId,targetTerminalId:j.terminalId,side:j.side})}}}function gt(){xe(null)}const Xe=S.workspaces.find(x=>x.id===S.activeWorkspaceId)??S.workspaces[0],st=Xe?.tabs.find(x=>x.id===Xe.activeTabId)??Xe?.tabs[0],ei=st?.activeTerminalId??null,an=ei?S.terminals[ei]:void 0,ki=C5("(max-width: 760px)"),ti=v.useMemo(()=>st?hh(st.root):[],[st]),Ti=Xe&&st?Ko(s,Xe.id,st.id):null,Jn=st?Z1(ti,st.activeTerminalId,Ti?H[Ti]:void 0):null,K=ki&&ti.length>1,$e=v.useMemo(()=>(Xe?.detachedTerminalIds??[]).flatMap(x=>{const k=S.terminals[x];return k?[k]:[]}),[Xe?.detachedTerminalIds,S.terminals]),ot=v.useMemo(()=>{const x=new Set;for(const k of Xe?.tabs??[])sc(k).some(j=>w.unreadCompletions.has(j))&&x.add(k.id);return x},[Xe?.tabs,w.unreadCompletions]),[wt,li]=v.useState([]),Dt=v.useRef([]),ln=v.useRef(null),[es,ts]=v.useState(null),[Rt,Pi]=v.useState(null),[_t,vt]=v.useState([]),[Ct,Di]=v.useState(()=>ba()),oi=v.useRef(0),qt=v.useRef(s),ci=v.useRef(p0),_i=v.useRef(Ct),Ht=v.useRef(()=>{});Ht.current=Wr;const Ri=v.useCallback(async()=>{try{const x=await f.listNotificationAssets();vt(x.assets.filter(k=>k.enabled).map(k=>k.url))}catch{vt([])}},[f]);v.useEffect(()=>{G(x=>x.some(k=>mn(k,s))?x:[...x,s])},[s]);const ii=v.useCallback(x=>{const k=Nt(x),j=Go(x);for(const te of Object.keys(k.state.terminals))Po(j.createWebSocketUrl(te)),Mu(te);EA(x),G(te=>te.filter(ye=>!mn(ye,x))),R(te=>{const ye=`${$u(x)}:`;let ge=!1;const Se=new Set;for(const Pe of te){if(Pe.startsWith(ye)){ge=!0;continue}Se.add(Pe)}return ge?Se:te}),ee(te=>{const ye=`${$u(x)}:`;let ge=!1;const Se={};for(const[Pe,it]of Object.entries(te)){if(Pe.startsWith(ye)){ge=!0;continue}Se[Pe]=it}return ge?Se:te})},[]);v.useEffect(()=>{let x=!1;return f.listAgents().then(k=>{if(!x){const j=k.agents.map(ye=>ye.id),te=[null,...j];s!==null&&!j.includes(s)&&(ii(s),r?.(null)),re(te)}}).catch(()=>{}),()=>{x=!0}},[s,f,ii,r,B]);const vi=v.useCallback(x=>{ii(x),W(k=>k+1),mn(x,qt.current)&&r?.(null)},[ii,r]);v.useEffect(()=>{re(x=>x.some(k=>mn(k,s))?x:[...x,s])},[s]),v.useEffect(()=>{qt.current=s},[s]),v.useEffect(()=>{V(null)},[s]),v.useEffect(()=>{const x=De.current;if(!x)return;if(!mn(x.agentId,s)){De.current=null;return}if(!w.loaded||S.workspaces.length===0)return;De.current=null;const k=x.edge==="first"?S.workspaces[0]:S.workspaces[S.workspaces.length-1];k&&k.id!==S.activeWorkspaceId&&rt({type:"workspace.selected",workspaceId:k.id})},[s,w.loaded,S.activeWorkspaceId,S.workspaces]),v.useEffect(()=>{const x=Oe.current;if(x){if(!mn(x.agentId,s)){Oe.current=null;return}w.loaded&&(Oe.current=null,S.workspaces.some(k=>k.id===x.workspaceId)&&rt({type:"workspace.selected",workspaceId:x.workspaceId}))}},[s,w.loaded,S.workspaces]),v.useEffect(()=>{const x=Ie.current;if(x){if(!mn(x.agentId,s)){Ie.current=null;return}w.loaded&&(Ie.current=null,w.error||vn())}},[s,w.error,w.loaded]),v.useEffect(()=>{Ri()},[Ri]),v.useEffect(()=>tw(()=>Di(ba())),[]),v.useEffect(()=>{const x=k=>{Ht.current(k)};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[]),v.useEffect(()=>{ci.current=_t.length>0?_t:p0},[_t]),v.useEffect(()=>{_i.current=Ct},[Ct]),v.useEffect(()=>{if(!w.loaded||!Xe||!st)return;const x=Ko(s,Xe.id,st.id);R(k=>{if(k.has(x))return k;const j=new Set(k);return j.add(x),j})},[s,w.loaded,Xe?.id,st?.id]),v.useEffect(()=>()=>{Je()},[]),v.useEffect(()=>vA(x=>{const k=Nt(x.agentId).state,j=k.workspaces.flatMap(Se=>Se.tabs).find(Se=>Se.id===x.tabId),te=k.terminals[x.terminalId],ye=j?.title?.trim()||te?.title||x.commandName||"terminal",ge=document.visibilityState==="visible"&&mn(x.agentId,qt.current)&&x.tabId===E5(k);if(ge||L2({tabTitle:ye,commandName:x.commandName,terminalId:x.terminalId}),!ge&&document.visibilityState==="visible"&&_i.current.enabled){const Se=oi.current+1;oi.current=Se;const Pe=ci.current;ts({id:Se,agentId:x.agentId,terminalId:x.terminalId,tabId:x.tabId,tabTitle:ye,commandName:x.commandName,assetSrc:Pe[Math.floor(Math.random()*Pe.length)]??a5})}}),[]),v.useEffect(()=>{if(!es||Ct.persistUntilDismissed)return;const x=window.setTimeout(()=>{ts(k=>k?.id===es.id?null:k)},Ct.durationSeconds*1e3);return()=>window.clearTimeout(x)},[es,Ct]),v.useEffect(()=>{B5(I),I&&Gi()},[I]),v.useEffect(()=>{let x=!1;async function k(){if(!Nt(s).loaded){kr(s,!1,null);try{let te=null,ye=null;try{te=T5(p)}catch(it){if(!(it instanceof fh))throw it;ye=it}const[ge,Se]=await Promise.all([g.listTerminals(),g.getTerminalLayout()]),Pe=ge.terminals.length>0?ge.terminals:[(await g.createTerminal({cols:80,rows:24})).terminal];if(!x){const it=Se.layout?J1(Se.layout):null;if(!it&&ye)throw ye;const Xt=it??te??{},ni=km(Pe,void 0,Xt.savedWorkspaces,Xt.savedActiveWorkspaceId),Ba=hp(ni);c0(s,ni),No(s,Se.revision,JSON.stringify(Ba)),kr(s,!0,null),!it&&te&&Bt(Ba,{baseRevision:Se.revision})}}catch(te){!x&&!Kr(te)&&kr(s,!0,Tr(te))}}}return k(),()=>{x=!0}},[s,g,we]);function _n(){kr(s,!1,null),ne(x=>x+1)}function Gi(){ke.current+=1,Me.current+=1,Ee(null)}function Zi(x){ke.current+=1,Me.current+=1,Ee(k=>k&&{...k,cwd:x,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null})}function vn(){ke.current+=1,Me.current+=1;const x=S.workspaces.length+1,k=bi();Ee({mode:"create",workspaceId:null,title:`Workspace ${x}`,cwd:k,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),k&&Ln(k)}function $i(x){if(mn(x,s)){vn();return}Ie.current={agentId:x},r?.(x)}function It(x){if(I&&!L)return;const k=S.workspaces.find(te=>te.id===x);if(!k)return;ke.current+=1,Me.current+=1;const j=k.defaultCwd??an?.cwd??"";Ee({mode:"edit",workspaceId:x,title:k.title,cwd:j,browseRoot:null,browseEntries:[],browseStatus:"idle",submitStatus:"idle",error:null}),j&&Ln(j)}function bi(){return Xe?.defaultCwd??an?.cwd??""}async function Ln(x){const k=ke.current+1;ke.current=k;const j=x.trim();if(Ee(te=>te&&{...te,cwd:x,browseStatus:j?"loading":"idle",browseRoot:null,browseEntries:[],error:j?null:"Choose a default working directory."}),!!j)try{const te=await g.createFileRoot({path:j}),ye=await g.listFiles({rootToken:te.rootToken,path:""});if(ke.current!==k)return;Ee(ge=>ge&&{...ge,cwd:te.rootPath,browseRoot:{rootToken:te.rootToken,rootPath:te.rootPath},browseEntries:ye.entries.filter(Se=>Se.kind==="directory"),browseStatus:"idle",error:null})}catch(te){if(ke.current!==k)return;Ee(ye=>ye&&{...ye,browseStatus:"idle",error:Tr(te)})}}async function Ur(){const x=de;if(!x)return;const k=x.title.trim(),j=x.cwd.trim();if(!k||!j){Ee({...x,submitStatus:"idle",error:k?"Choose a default working directory.":"Workspace name is required."});return}const te=Me.current+1;Me.current=te,Ee({...x,submitStatus:"submitting",error:null});try{const ye=await g.createFileRoot({path:j});if(Me.current!==te)return;if(x.mode==="create"){const ge=S.workspaces.length+1;rt({type:"workspace.created",workspaceId:`workspace-${Date.now().toString(36)}-${ge}`,title:k,defaultCwd:ye.rootPath})}else x.workspaceId&&(rt({type:"workspace.renamed",workspaceId:x.workspaceId,title:k}),rt({type:"workspace.defaultCwdChanged",workspaceId:x.workspaceId,defaultCwd:ye.rootPath}));Ee(null)}catch(ye){if(Me.current!==te)return;Ee(ge=>ge&&{...ge,submitStatus:"idle",error:Tr(ye)})}}function Ll(x){Me.current+=1,Ee(x)}function Zs(x,k,j){if(x===k)return;const te=S.workspaces.some(ge=>ge.id===x),ye=S.workspaces.some(ge=>ge.id===k);!te||!ye||rt({type:"workspace.reordered",sourceWorkspaceId:x,targetWorkspaceId:k,placement:j})}function Ta(x,k){const j=S.workspaces.findIndex(ye=>ye.id===x),te=S.workspaces[j+k];j<0||!te||Zs(x,te.id,k<0?"before":"after")}function Es(x,k){k.pointerType==="mouse"&&k.button!==0||(k.preventDefault(),k.stopPropagation(),Ce.current={sourceId:x,pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,active:!1,targetId:null,placement:"after"},k.currentTarget.setPointerCapture?.(k.pointerId))}function Bn(x){const k=Ce.current;if(!k||k.pointerId!==x.pointerId)return;const j=Math.hypot(x.clientX-k.startX,x.clientY-k.startY);if(!k.active){if(j<l5)return;k.active=!0,_e(k.sourceId)}const ye=document.elementFromPoint(x.clientX,x.clientY)?.closest("[data-workspace-id]"),ge=ye?.dataset.workspaceId??null;if(!ye||!ge||ge===k.sourceId||!S.workspaces.some(it=>it.id===ge)){k.targetId=null,he(null);return}const Se=ye.getBoundingClientRect(),Pe=x.clientY<Se.top+Se.height/2?"before":"after";k.targetId=ge,k.placement=Pe,he({workspaceId:ge,placement:Pe})}function Qi(x){const k=Ce.current;!k||k.pointerId!==x.pointerId||(x.preventDefault(),x.stopPropagation(),x.currentTarget.releasePointerCapture?.(x.pointerId),Ce.current=null,_e(null),he(null),k.active&&k.targetId&&Zs(k.sourceId,k.targetId,k.placement))}function On(x){const k=Ce.current;k&&k.pointerId===x.pointerId&&x.currentTarget.releasePointerCapture?.(x.pointerId),Ce.current=null,_e(null),he(null)}async function Lt(){await $t(async()=>{const x=Xe?.defaultCwd?{cols:80,rows:24,cwd:Xe.defaultCwd}:{cols:80,rows:24},k=await g.createTerminal(x);rt({type:"terminal.created",terminal:k.terminal})})}async function bn(x){await $t(async()=>{const k=ei?{parentTerminalId:ei,cols:80,rows:24}:Xe?.defaultCwd?{cols:80,rows:24,cwd:Xe.defaultCwd}:{cols:80,rows:24},j=await g.createTerminal(k);rt({type:"terminal.split",terminal:j.terminal,direction:x})})}async function Kt(x){let k=ei,j=Ti;const te=Xe?.defaultCwd?.trim();if(!k&&!te)throw new Error("No active pane is available.");const ye=await g.readFile(x);if(!k&&te){const Pe=await g.createTerminal({cols:80,rows:24,cwd:te});k=Pe.terminal.id,rt({type:"terminal.created",terminal:Pe.terminal})}if(k){rt({type:"pane.selected",terminalId:k});const Pe=Nt(s).state,it=Pe.workspaces.find(ni=>ni.id===Pe.activeWorkspaceId)??Pe.workspaces[0],Xt=it?.tabs.find(ni=>ni.id===it.activeTabId)??it?.tabs[0];j=it&&Xt?Ko(s,it.id,Xt.id):null}const ge=`editor-${Date.now().toString(36)}-${xA(s)}`,Se=A5(ye.path);dp(s,Pe=>({...Pe,[ge]:{id:ge,title:Se,rootToken:x.rootToken,path:ye.path,read:ye}})),j&&ee(Pe=>({...Pe,[j]:Q1(ge)})),rt({type:"editor.split",editorId:ge,title:Se,direction:"vertical"})}function ds(x){dp(s,k=>{const j={...k};return delete j[x],j}),rt({type:"editor.closed",editorId:x})}function ui(x){zn([x])}function zn(x){const k=[...new Set(x)].filter(te=>S.terminals[te]);if(k.length===0)return;const j=k.length===1?S.terminals[k[0]]?.title||S.terminals[k[0]]?.cwd||k[0]:`${k.length} panes`;V(null),Pi({terminalIds:k,label:j,workspaceId:Xe?.id??S.activeWorkspaceId??null})}function is(x,k){const j=Aa(x,k);if(!j)return!1;const te=x.filter(ye=>!j.detachedTerminalIds.includes(ye));if(j.detachedTerminalIds.length+te.length>Dl)return V(R5(j.detachedTerminalIds.length)),!1;V(null);for(const ye of x)rt(j.id?{type:"terminal.detached",terminalId:ye,workspaceId:j.id}:{type:"terminal.detached",terminalId:ye});return!0}async function Da(x){await $t(async()=>{for(const k of x)await jn(k),Po(g.createWebSocketUrl(k)),Mu(k),rt({type:"terminal.closed",terminalId:k})})}async function Ir(x){const k=S.workspaces.find(j=>j.id===x);!k||S.workspaces.length<=1||window.confirm(`Delete workspace "${k.title}" and close all terminal sessions inside it? This cannot be undone.`)&&await $t(async()=>{const j=uh(k),te=[];let ye=null;for(const Se of j)try{await jn(Se)}catch(Pe){te.push(Tr(Pe)),Pe instanceof cs&&Pe.status===401&&!g.isAgent&&(ye=Pe)}finally{Po(g.createWebSocketUrl(Se)),Mu(Se)}const ge=k.tabs.flatMap(Se=>Hm(Se.root));if(ge.length>0){const Se=new Set(ge);dp(s,Pe=>{const it={...Pe};for(const Xt of Se)delete it[Xt];return it})}if(rt({type:"workspace.closed",workspaceId:x}),ye)throw ye;if(te.length>0)throw new Error(`Workspace was removed, but ${te.length} terminal session${te.length===1?"":"s"} may still be running. ${te[0]}`)})}async function Ra(x){await $t(async()=>{await jn(x),Po(g.createWebSocketUrl(x)),Mu(x),rt({type:"terminal.closed",terminalId:x})})}async function Ma(x,k){const j=k.trim();if(!j)return;let te=null;for(const ye of S.workspaces){const ge=ye.tabs.find(Se=>Se.id===x);if(ge){te=ge.activeTerminalId;break}}if(rt({type:"tab.renamed",tabId:x,title:j}),!!te)try{const ye=await g.renameTerminal(te,j);ns({type:"terminal.updated",terminal:ye.terminal})}catch(ye){kr(s,!0,Tr(ye))}}function on(x){const k=S.terminals[x];k&&rt({type:"terminal.created",terminal:k})}async function jn(x){try{await g.closeTerminal(x)}catch(k){if(k instanceof cs&&k.status===404)return;throw k}}async function yn(){await $t(async()=>{await c()})}async function $t(x){kr(s,!0,null);try{await x()}catch(k){if(Kr(k))return;kr(s,!0,Tr(k))}}function Kr(x){return x instanceof cs&&x.status===401&&!g.isAgent&&h?(h({source:"workspace-api-401",status:401,activeAgentId:s}),!0):!1}function rt(x){Mo(s,x);const k=Nt(s),j=k.state;if(!k.loaded||j.workspaces.length===0)return;const te=hp(j);JSON.stringify(te)!==k.lastPersistedLayoutJson&&qe(te)}function ns(x){Mo(s,x)}function ks(x,k,j,te){const ye=Ko(x,k,j);ee(ge=>({...ge,[ye]:te}))}function ss(x){Ti&&ee(k=>({...k,[Ti]:x}))}function Na(x,k){const j=dh(x);k?ks(s,k.workspaceId,k.tabId,j):ss(j),rt({type:"pane.selected",terminalId:x})}function Ui(x){ss(x.key),x.type==="terminal"&&rt({type:"pane.selected",terminalId:x.terminalId})}function Wr(x){if(le||Rt||x.isComposing||x.key==="Process"||p5(x.target))return;const k=u5(x);if(!k)return;if(x.preventDefault(),x.stopPropagation(),k.type==="server.previous"||k.type==="server.next"){Fr(k.type==="server.next"?1:-1);return}const j=Nt(s).state,te=j.workspaces.find(Se=>Se.id===j.activeWorkspaceId)??j.workspaces[0],ye=te?.tabs.find(Se=>Se.id===te.activeTabId)??te?.tabs[0];if(k.type==="split"){if(!ye)return;bn(k.direction);return}if(!te||!ye)return;if(k.type==="tab.previous"||k.type==="tab.next"){const Se=f5(te.tabs,ye.id,k.type==="tab.next"?1:-1);Se&&rt({type:"tab.selected",tabId:Se.id});return}if(k.type==="tab.index"){const Se=te.tabs[k.index-1];Se&&rt({type:"tab.selected",tabId:Se.id});return}const ge=h5(ye.root,ye.activeTerminalId,k);ge&&Na(ge,{workspaceId:te.id,tabId:ye.id})}function Qs(x,k){if(!r||F.length===0)return;const j=F.findIndex(Se=>mn(Se,s)),ye=((j===-1?0:j)+x+F.length)%F.length,ge=F[ye]??null;mn(ge,s)||(k&&(De.current={agentId:ge,edge:k}),r(ge))}function Fr(x){const k=Nt(s).state,j=k.workspaces;if(j.length===0){Qs(x,x===1?"first":"last");return}const te=j.findIndex(Se=>Se.id===k.activeWorkspaceId),ge=(te===-1?0:te)+x;if(ge>=0&&ge<j.length){rt({type:"workspace.selected",workspaceId:j[ge].id});return}Qs(x,x===1?"first":"last")}function fs(x,k){if(mn(x,s)){rt({type:"workspace.selected",workspaceId:k});return}Oe.current={agentId:x,workspaceId:k},r?.(x)}function Aa(x,k){if(k)return S.workspaces.find(j=>j.id===k)??null;for(const j of x){const te=S.workspaces.find(ge=>ge.tabs.some(Se=>sc(Se).includes(j)));if(te)return te;const ye=S.workspaces.find(ge=>ge.detachedTerminalIds.includes(j));if(ye)return ye}return S.workspaces.find(j=>j.id===S.activeWorkspaceId)??S.workspaces[0]??null}function Js(x){d0(x.dataTransfer)&&(x.preventDefault(),x.dataTransfer.dropEffect="copy")}function Ji(x){if(!d0(x.dataTransfer))return;x.preventDefault();const k=M5(Nt(s).state),j=be.current+1;if(be.current=j,!k){en({id:j,status:"failed",fileCount:0,message:"No active running terminal is available for upload."});return}en({id:j,status:"queued",fileCount:0,terminalId:k.id,message:"Preparing upload..."}),Bl(j,k.id,x.dataTransfer)}async function Bl(x,k,j){try{const te=await GA(j);if(te.length===0)throw new Error("No files were found in the drop.");Hn(x,{id:x,status:"queued",fileCount:te.length,message:"Queued"},{terminalId:k,files:te})}catch(te){Hn(x,{id:x,status:"failed",fileCount:0,message:Tr(te)},{terminalId:k})}finally{Ts()}}async function La(x){const k=Dt.current.find(ge=>ge.id===x);if(!k?.terminalId||!k.files||k.files.length===0)return;const j=k.terminalId,te=k.files,ye=new AbortController;ln.current=x,Hn(x,{id:x,status:"uploading",fileCount:te.length,loaded:0,total:null,percent:null},{terminalId:j,files:te,abortController:ye});try{const ge=await pT({terminalId:j,files:te,signal:ye.signal,onProgress:Xt=>{Hn(x,{id:x,status:"uploading",fileCount:te.length,loaded:Xt.loaded,total:Xt.total,percent:Xt.percent},{terminalId:j,files:te,abortController:ye})}}),Se=ge.failed>0?ge.uploaded>0?"partial":"failed":"success",Pe=ge.failed>0?N5(ge):void 0,it={id:x,status:Se,fileCount:te.length,response:ge};Pe&&(it.message=Pe),Hn(x,it,{terminalId:j,files:te})}catch(ge){Hn(x,{id:x,status:"failed",fileCount:te.length,message:ye.signal.aborted?"Upload canceled.":Tr(ge)},{terminalId:j,files:te})}finally{ln.current===x&&(ln.current=null),Ts()}}function Ts(){if(ln.current!==null)return;const x=Dt.current.find(k=>k.status==="queued");x?.terminalId&&x.files&&x.files.length>0&&La(x.id)}function en(x){er(k=>[...k,x])}function Hn(x,k,j={}){er(te=>te.map(ye=>{if(ye.id!==x)return ye;const ge={...k},Se=j.terminalId??ye.terminalId,Pe=j.files??ye.files;return Se!==void 0&&(ge.terminalId=Se),Pe!==void 0&&(ge.files=Pe),j.abortController!==void 0&&(ge.abortController=j.abortController),ge}))}function er(x){const k=x(Dt.current);Dt.current=k,li(k)}function ps(x){Dt.current.find(j=>j.id===x)?.abortController?.abort(),ln.current===x&&(ln.current=null),er(j=>j.filter(te=>te.id!==x)),Ts()}function Sn(){for(const x of Dt.current)x.abortController?.abort();ln.current=null,er(()=>[])}function M(x){const k=Dt.current.find(j=>j.id===x);if(k){if(k.status==="queued"){ps(x);return}k.abortController?.abort()}}function J(x){const k=Dt.current.find(te=>te.id===x);if(!k?.terminalId||!k.files||k.files.length===0)return;const j=Be(k);if(j.length===0){Hn(x,{id:x,status:"failed",fileCount:k.fileCount,message:"No failed files are available to retry."},{terminalId:k.terminalId,files:k.files});return}Hn(x,{id:x,status:"queued",fileCount:j.length,message:"Queued"},{terminalId:k.terminalId,files:j}),Ts()}function Be(x){const k=x.files??[],j="response"in x?x.response:void 0;if(!j)return k;const te=j.results.filter(Se=>Se.status==="failed").map(Se=>Se.relativePath);if(te.length===0)return[];const ye=new Map;for(const Se of k){const Pe=ye.get(Se.relativePath)??[];Pe.push(Se),ye.set(Se.relativePath,Pe)}const ge=[];for(const Se of te){const it=ye.get(Se)?.shift();it&&ge.push(it)}return ge}function Ke(x){const j=Nt(x.agentId).state.workspaces.find(te=>te.tabs.some(ye=>ye.id===x.tabId));j&&ks(x.agentId,j.id,x.tabId,dh(x.terminalId)),Mo(x.agentId,{type:"pane.selected",terminalId:x.terminalId}),CA(x.agentId,x.terminalId),mn(x.agentId,s)||r?.(x.agentId),ts(null)}function qe(x){const k=Nt(s).mutable.saveCoord;k.pendingLayoutSave=x,Ao(x,p),k.saveTimer!==null&&window.clearTimeout(k.saveTimer),k.saveTimer=window.setTimeout(()=>{k.saveTimer=null;const j=k.pendingLayoutSave;k.pendingLayoutSave=null,j&&Bt(j)},r5)}function Je(){const x=Nt(s).mutable.saveCoord;x.saveTimer!==null&&(window.clearTimeout(x.saveTimer),x.saveTimer=null);const k=x.pendingLayoutSave;x.pendingLayoutSave=null,k&&(Ao(k,p),Bt(k))}function Bt(x,k={}){const j=Nt(s).mutable.saveCoord;j.nextPersistLayout=x,k.baseRevision!==void 0&&(j.queuedBaseRevision=k.baseRevision),!j.nextPersistQueued&&(j.nextPersistQueued=!0,j.persistChain=j.persistChain.then(async()=>{j.nextPersistQueued=!1;const te=j.nextPersistLayout,ye=j.queuedBaseRevision;j.nextPersistLayout=null,j.queuedBaseRevision=void 0,te&&await Vt(te,ye!==void 0?{baseRevision:ye}:{})}))}async function Vt(x,k={}){const j=Nt(s),te=k.baseRevision??j.layoutRevision,ye={layout:x,...typeof te=="number"?{baseRevision:te}:{}};try{const ge=await g.saveTerminalLayout(ye),Se=ge.layout??x;No(s,ge.revision,JSON.stringify(Se)),Ao(Se,p);return}catch(ge){if(ge instanceof cs&&ge.status===400&&ge.message===Pk){D5(s,p),kr(s,!0,eC());return}if(ge instanceof cs&&ge.status===409)try{const Se=await g.getTerminalLayout(),Pe=Nt(s).mutable.saveCoord;if(Pe.nextPersistLayout||Pe.pendingLayoutSave){const it=Se.layout?JSON.stringify(Se.layout):Nt(s).lastPersistedLayoutJson;No(s,Se.revision,it);return}if(Se.layout){const it=Nt(s).state,Xt=km(Object.values(it.terminals),void 0,Se.layout.workspaces,Se.layout.activeWorkspaceId),ni=hp(Xt);c0(s,Xt),No(s,Se.revision,JSON.stringify(ni)),Ao(ni,p)}else No(s,Se.revision,j.lastPersistedLayoutJson);return}catch{}Ao(x,p)}}const dt=O5(o),bt=!I||L,Vi=bt?Q:"servers";function Yt(x){const k=x.active?w:Nt(x.agentId),j=x.active?S:k.state,te=x.active?w.loaded:k.loaded,ye=x.active?O:k.error;return m.jsxs("div",{className:`workspace-list-panel${x.active?" workspace-list-panel--active-server":""}`,"aria-label":`${x.label} workspaces`,children:[m.jsxs("div",{className:"workspace-list-header",children:[m.jsx("span",{children:"Workspaces"}),m.jsx("button",{type:"button","aria-label":`New workspace on ${x.label}`,title:"New workspace",onClick:()=>$i(x.agentId),children:"+"})]}),te?ye?m.jsx("button",{type:"button",className:"workspace-list-placeholder workspace-list-placeholder--error",onClick:()=>r?.(x.agentId),children:ye}):m.jsx("div",{className:"workspace-list-items",children:j.workspaces.map(ge=>{const Se=x.active&&ge.id===Xe?.id,Pe=uh(ge).length,it=x.active&&j.workspaces.length>1,Xt=X?.workspaceId===ge.id&&Fe!==ge.id?X.placement:null;return m.jsxs(b5,{workspaceId:ge.id,active:Se,disabled:!x.active,reorderable:it,dragging:Fe===ge.id,dropPlacement:Xt,children:[it?m.jsx("button",{type:"button",className:"workspace-list-drag-handle","data-workspace-drag-handle":ge.id,title:"Drag to reorder","aria-label":`Reorder ${ge.title}`,"aria-grabbed":Fe===ge.id,onPointerDown:ni=>Es(ge.id,ni),onPointerMove:Bn,onPointerUp:Qi,onPointerCancel:On,onKeyDown:ni=>{(ni.key==="ArrowUp"||ni.key==="ArrowDown")&&(ni.preventDefault(),ni.stopPropagation(),Ta(ge.id,ni.key==="ArrowUp"?-1:1))},onClick:ni=>ni.stopPropagation(),children:"::"}):null,m.jsxs("button",{type:"button",className:"workspace-list-select","aria-current":Se?"page":void 0,title:ge.defaultCwd??void 0,onClick:()=>fs(x.agentId,ge.id),onDoubleClick:()=>{x.active&&It(ge.id)},children:[m.jsx("span",{className:"workspace-list-name",children:ge.title}),m.jsxs("small",{children:[ge.defaultCwd??"No folder"," · ",Pe," ",Pe===1?"session":"sessions"]})]}),x.active?m.jsxs("div",{className:"workspace-list-actions",children:[m.jsx("button",{type:"button",className:"workspace-list-edit","aria-label":`Edit ${ge.title}`,title:"Edit workspace",onClick:()=>It(ge.id),children:"..."}),m.jsx("button",{type:"button",className:"workspace-list-delete","aria-label":`Delete ${ge.title}`,title:"Delete workspace",disabled:j.workspaces.length<=1,onClick:()=>{Ir(ge.id)},children:"x"})]}):null]},ge.id)})}):m.jsx("button",{type:"button",className:"workspace-list-placeholder",onClick:()=>r?.(x.agentId),children:"Open server to load workspaces"})]})}return m.jsx(Ak,{sensors:Ae,onDragStart:ze,onDragEnd:He,onDragCancel:gt,children:m.jsxs("main",{className:"terminal-shell","data-collapsed":I,"data-sidebar-open":L,onDragOver:Js,onDrop:Ji,children:[m.jsx("button",{type:"button",className:"workspace-backdrop","aria-label":"Close workspaces",onClick:()=>N(!1)}),m.jsxs("aside",{className:"workspace-sidebar",children:[m.jsxs("header",{className:"workspace-brand",children:[bt?m.jsx(x0,{height:20}):m.jsx(C0,{size:24}),m.jsx("button",{type:"button",className:"sidebar-collapse-button","aria-label":I?"Expand sidebar":"Collapse sidebar",title:I?"Expand sidebar":"Collapse sidebar",onClick:()=>U(x=>!x),children:I?">":"<"}),m.jsx("button",{type:"button",className:"sidebar-drawer-close-button","aria-label":"Close workspaces",title:"Close workspaces",onClick:()=>N(!1),children:"x"})]}),m.jsxs("div",{className:`workspace-sidebar-content workspace-sidebar-content--${Vi==="files"?"files":"servers"}`,children:[bt?m.jsxs("div",{className:"workspace-sidebar-tabs",role:"tablist","aria-label":"Sidebar mode",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":Q==="servers",onClick:()=>{ie("servers")},children:"Workspaces"}),m.jsx("button",{type:"button",role:"tab","aria-selected":Q==="files",onClick:()=>{ie("files")},children:"Files"})]}):null,Vi==="servers"&&bt?m.jsx("nav",{className:"workspace-nav","aria-label":"Workspaces",children:m.jsx(zy,{api:f,activeAgentId:s,onSelectServer:r??(()=>{}),onSessionInvalid:h,refreshToken:B,renderServerChildren:Yt})}):null,bt?null:m.jsx("nav",{className:"workspace-nav workspace-nav--collapsed","aria-label":"Servers",children:m.jsx(zy,{api:f,activeAgentId:s,onSelectServer:r??(()=>{}),onSessionInvalid:h,refreshToken:B,compact:!0})}),Vi==="files"?m.jsx(bT,{api:g,activeTerminalId:ei,activeTerminalCwd:an?.cwd??null,workspaceRootPath:Xe?.defaultCwd??an?.cwd??null,onOpenFile:Kt}):null]}),m.jsxs("div",{className:"workspace-sidebar-footer",children:[bt?m.jsx("span",{children:dt}):null,m.jsxs("div",{className:"workspace-sidebar-footer-actions",children:[m.jsxs("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"settings",title:"Settings",onClick:()=>ce(!0),children:[m.jsx(g0,{name:"settings"}),ve.hasUpdates?m.jsx("span",{className:"update-pulse-dot","aria-hidden":"true"}):null]}),bt?m.jsx("button",{type:"button",className:"workspace-footer-icon-button","aria-label":"logout",title:"Logout",onClick:()=>{yn()},children:m.jsx(g0,{name:"logout"})}):null]})]})]}),le?m.jsx(cT,{api:f,onClose:()=>ce(!1),updateAvailable:ve.hasUpdates,onNotificationAssetsChanged:()=>{Ri()},onAgentRemoved:vi}):null,de?m.jsx(m5,{dialog:de,activePaneCwd:an?.cwd??null,activeWorkspaceCwd:Xe?.defaultCwd??null,onChange:Ll,onManualCwdChange:Zi,onBrowse:Ln,onCancel:Gi,onSubmit:()=>{Ur()}}):null,m.jsxs("section",{className:"terminal-main","aria-label":"Terminal workspace","data-mobile-pane-switcher":K?"true":void 0,children:[m.jsx(DA,{tabs:Xe?.tabs??[],activeTabId:Xe?.activeTabId??null,terminals:S.terminals,unreadCompletionTabIds:ot,detachedTerminals:$e,onSelectTab:x=>rt({type:"tab.selected",tabId:x}),onCreateTab:()=>{Lt()},onToggleWorkspaces:()=>N(x=>!x),onCloseTerminals:x=>zn(x),onReattachTerminal:x=>on(x),onDeleteTerminal:x=>{Ra(x)},onSplitVertical:()=>{bn("vertical")},onSplitHorizontal:()=>{bn("horizontal")},onRenameTab:(x,k)=>{Ma(x,k)},activePaneAvailable:!!ei}),K?m.jsx(S5,{targets:ti,activeLeafKey:Jn,terminals:S.terminals,editors:E,onSelect:Ui}):null,O?m.jsxs("div",{className:"workspace-error",role:"alert",children:[m.jsx("span",{children:O}),m.jsxs("div",{className:"workspace-error-actions",children:[m.jsx("button",{type:"button",onClick:_n,children:"Retry"}),s!==null&&r?m.jsx("button",{type:"button",onClick:()=>r(null),children:"Main server"}):null]})]}):null,m.jsxs("section",{className:"workspace-body","aria-busy":T,children:[T?m.jsx("div",{className:"workspace-placeholder",children:"Opening shell..."}):null,!T&&!st?m.jsx(v5,{onCreate:()=>{Lt()}}):null,D.map(x=>{const k=mn(x,s);return m.jsx(c5,{agentId:x,active:k,activeServerApi:k?g:void 0,visitedTabKeys:me,refreshCwdOnEnter:k&&Vi==="files",draggingTab:k?oe:null,mobileSplitFocus:ki,mobileFocusedLeafByTabKey:H,onSelect:j=>{k&&Na(j)},onClose:j=>{k&&ui(j)},onCloseEditor:j=>{k&&ds(j)},onResize:(j,te)=>{k&&rt({type:"pane.resized",path:j,ratio:te})},onExit:(j,te)=>{k?ns({type:"terminal.exited",terminalId:j,exitCode:te}):Mo(x,{type:"terminal.exited",terminalId:j,exitCode:te})},onSnapshot:(j,te)=>{const ye={type:"terminal.updated",terminal:j,notifyCompletion:te?.notifyCompletion===!0};k?ns(ye):Mo(x,ye)},...x===null&&h?{onAuthClose:j=>h({...j,source:j?.source??"terminal-ws-1008",activeAgentId:x})}:{}},$u(x))})]}),Rt?m.jsx(y5,{label:Rt.label,count:Rt.terminalIds.length,warning:se,onCancel:()=>{V(null),Pi(null)},onHide:()=>{is(Rt.terminalIds,Rt.workspaceId)&&Pi(null)},onDelete:()=>{const x=Rt.terminalIds;V(null),Pi(null),Da(x)}}):null,m.jsx(UA,{toast:es,onActivate:Ke,onDismiss:()=>ts(null)}),m.jsx(LA,{uploads:wt,onDismiss:ps,onDismissAll:Sn,onRetry:J,onCancel:M})]})]})})}function c5({agentId:e,active:t,activeServerApi:s,visitedTabKeys:r,refreshCwdOnEnter:o,draggingTab:c,mobileSplitFocus:h,mobileFocusedLeafByTabKey:f,onSelect:g,onClose:p,onCloseEditor:y,onResize:b,onExit:w,onSnapshot:S,onAuthClose:E}){const T=v.useMemo(()=>ve=>W1(e,ve),[e]),O=v.useMemo(()=>()=>Nt(e),[e]),L=v.useSyncExternalStore(T,O,O),N=v.useMemo(()=>Go(e),[e]),I=s??N,U=L.state,Q=U.workspaces.find(ve=>ve.id===U.activeWorkspaceId)??U.workspaces[0],ie=Q?.id??null,ce=(Q?.tabs.find(ve=>ve.id===Q.activeTabId)??Q?.tabs[0])?.id??null;return!L.loaded||U.workspaces.length===0?null:m.jsx("div",{className:"workspace-server-surface","data-active":t,"aria-hidden":!t,children:U.workspaces.flatMap(ve=>ve.tabs.map(we=>{const ne=t&&ve.id===ie&&we.id===ce,se=Ko(e,ve.id,we.id),V=hh(we.root),F=h&&V.length>1?Z1(V,we.activeTerminalId,f[se]):null;return!ne&&!r.has(se)?null:m.jsx("div",{className:"workspace-tab-surface","data-active":ne,"aria-hidden":!ne,children:m.jsx(Cm,{node:we.root,terminals:U.terminals,editors:L.editors,api:I,activeTerminalId:we.activeTerminalId,visible:ne,refreshCwdOnEnter:ne&&o,tabId:we.id,dropZoneActive:ne&&c!==null,draggingTerminalId:ne?c?.terminalId??null:null,mobileFocusLeafKey:F,onSelect:g,onClose:p,onCloseEditor:y,onResize:b,onExit:w,onSnapshot:S,...E?{onAuthClose:E}:{}})},`${ve.id}:${we.id}`)}))})}function u5(e){const t=cw(e);if(t)switch(t.id){case"server.previous":case"server.next":case"tab.previous":case"tab.next":return{type:t.id};case"tab.index":case"pane.index":return t.index===null?null:{type:t.id,index:t.index};case"split.right":return{type:"split",direction:"vertical"};case"split.down":return{type:"split",direction:"horizontal"};default:return null}if(e.ctrlKey&&e.altKey&&!e.metaKey&&!e.shiftKey){const s=d5(e.key);return s?{type:"pane.direction",direction:s}:null}return null}function h5(e,t,s){switch(s.type){case"pane.direction":return WA(e,t,s.direction);case"pane.index":return FA(e,s.index);default:return null}}function d5(e){switch(e){case"ArrowLeft":return"left";case"ArrowRight":return"right";case"ArrowUp":return"up";case"ArrowDown":return"down";default:return null}}function f5(e,t,s){if(e.length===0)return null;const r=e.findIndex(c=>c.id===t);return e[((r===-1?0:r)+s+e.length)%e.length]??null}function hh(e){return e.type==="pane"?[{key:dh(e.terminalId),type:"terminal",terminalId:e.terminalId}]:e.type==="editor"?[{key:Q1(e.editorId),type:"editor",editorId:e.editorId,title:e.title}]:[...hh(e.first),...hh(e.second)]}function Hm(e){return e.type==="pane"?[]:e.type==="editor"?[e.editorId]:[...Hm(e.first),...Hm(e.second)]}function Z1(e,t,s){if(s&&e.some(o=>o.key===s))return s;const r=t?dh(t):null;return r&&e.some(o=>o.key===r)?r:e[0]?.key??null}function dh(e){return`terminal:${e}`}function Q1(e){return`editor:${e}`}function p5(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 m5({dialog:e,activePaneCwd:t,activeWorkspaceCwd:s,onChange:r,onManualCwdChange:o,onBrowse:c,onCancel:h,onSubmit:f}){const g=e.browseRoot?.rootPath??e.cwd,p=e.browseEntries.filter(S=>S.kind==="directory"),y=e.submitStatus==="submitting";function b(S){r(E=>E&&{...E,...S})}function w(S){S&&(b({cwd:S,error:null}),c(S))}return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"workspace-dialog-title",onClick:h,children:m.jsxs("form",{className:"security-panel workspace-dialog",onClick:S=>S.stopPropagation(),onSubmit:S=>{S.preventDefault(),y||f()},children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"workspace-dialog-title",children:e.mode==="create"?"New Workspace":"Edit Workspace"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:h,children:"x"})]}),m.jsxs("section",{className:"workspace-dialog-body",children:[m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Name"}),m.jsx("input",{value:e.title,autoFocus:!0,disabled:y,onChange:S=>b({title:S.currentTarget.value,error:null}),placeholder:"Workspace name"})]}),m.jsxs("label",{className:"workspace-dialog-field",children:[m.jsx("span",{children:"Default cwd"}),m.jsxs("div",{className:"workspace-dialog-path-row",children:[m.jsx("input",{value:e.cwd,disabled:y,onChange:S=>o(S.currentTarget.value),placeholder:"/home/user/project"}),m.jsx("button",{type:"button",onClick:()=>{c(e.cwd)},disabled:y||!e.cwd.trim()||e.browseStatus==="loading",children:"Browse"})]})]}),m.jsxs("div",{className:"workspace-dialog-quick-actions",children:[m.jsx("button",{type:"button",onClick:()=>w(t),disabled:y||!t,children:"Use active pane"}),m.jsx("button",{type:"button",onClick:()=>w(s),disabled:y||!s,children:"Use current workspace"})]}),m.jsxs("div",{className:"workspace-dialog-browser","aria-label":"Workspace folder browser","aria-busy":e.browseStatus==="loading",children:[m.jsxs("div",{className:"workspace-dialog-browser-header",children:[m.jsx("span",{title:g,children:g||"No folder selected"}),m.jsx("button",{type:"button",onClick:()=>{c(_5(g))},disabled:y||!g||g==="/"||e.browseStatus==="loading",children:"Up"})]}),e.browseStatus==="loading"?m.jsx("div",{className:"workspace-dialog-empty",children:"Loading..."}):null,e.browseStatus!=="loading"&&p.length===0?m.jsx("div",{className:"workspace-dialog-empty",children:"No folders"}):null,e.browseStatus!=="loading"&&p.length>0?m.jsx("div",{className:"workspace-dialog-folder-list",children:p.map(S=>m.jsxs("button",{type:"button","aria-label":`Choose folder ${S.name}`,disabled:y,onClick:()=>{c(g5(g,S.path))},children:[m.jsx("span",{children:S.name}),m.jsx("small",{children:S.path})]},S.path))}):null]}),e.error?m.jsx("div",{className:"workspace-dialog-error",role:"alert",children:e.error}):null]}),m.jsxs("div",{className:"workspace-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:h,children:"Cancel"}),m.jsx("button",{type:"submit",className:"primary-button",disabled:y||e.browseStatus==="loading",children:y?"Saving...":e.mode==="create"?"Create":"Save"})]})]})})}function g5(e,t){return t?t.startsWith("/")?qu(t):qu(`${e||"/"}/${t}`):qu(e)}function _5(e){const t=qu(e);if(!t||t==="/")return"/";const s=t.lastIndexOf("/");return s<=0?"/":t.slice(0,s)}function qu(e){const t=e.trim();if(!t)return"";const s=t.replace(/\/+/g,"/");return s==="/"?"/":s.endsWith("/")?s.slice(0,-1):s}function v5({onCreate:e}){return m.jsxs("div",{className:"empty-workspace",children:[m.jsx("span",{children:"No terminal is open."}),m.jsx("button",{type:"button",onClick:e,children:"New tab"})]})}function b5({workspaceId:e,active:t,disabled:s=!1,reorderable:r=!1,dragging:o=!1,dropPlacement:c=null,children:h}){const{setNodeRef:f,isOver:g}=Qm({id:`workspace-drop:${e}`,data:{kind:"workspace",workspaceId:e},disabled:s}),p=["workspace-list-item",t?"workspace-list-item--active":"",r?"workspace-list-item--reorderable":"",o?"workspace-list-item--dragging":"",c?"workspace-list-item--drop-target":"",c?`workspace-list-item--drop-${c}`:""].filter(Boolean).join(" ");return m.jsx("div",{ref:f,className:p,"data-workspace-id":e,"data-drop-over":g?"true":void 0,children:h})}function y5({label:e,count:t,warning:s,onCancel:r,onHide:o,onDelete:c}){return m.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"close-terminal-title",onClick:r,children:m.jsxs("div",{className:"security-panel terminal-delete-dialog",onClick:h=>h.stopPropagation(),children:[m.jsxs("header",{className:"security-panel-header",children:[m.jsx("h2",{id:"close-terminal-title",children:"Close Terminal"}),m.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:r,children:"x"})]}),m.jsxs("section",{className:"terminal-delete-dialog-body",children:[m.jsx("p",{children:t===1?"What should happen to this terminal?":`What should happen to these ${t} panes?`}),m.jsx("span",{children:e}),m.jsx("small",{children:"Hide keeps the shell running in this workspace. Delete destroys the underlying session."}),s?m.jsx("div",{className:"terminal-delete-warning",role:"alert",children:s}):null]}),m.jsxs("div",{className:"terminal-delete-dialog-actions",children:[m.jsx("button",{type:"button",className:"secondary-button",onClick:r,children:"Cancel"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:o,children:"Hide"}),m.jsx("button",{type:"button",className:"terminal-delete-confirm",onClick:c,children:"Delete"})]})]})})}function S5({targets:e,activeLeafKey:t,terminals:s,editors:r,onSelect:o}){const[c,h]=v.useState(!1);if(e.length<=1)return null;const f=t?e.findIndex(w=>w.key===t):-1,g=f>=0?f:0,p=e[g]??e[0],y=m0(p,s,r);function b(w){const S=(g+w+e.length)%e.length,E=e[S];E&&o(E)}return m.jsxs("div",{className:"mobile-pane-switcher",role:"group","aria-label":"Pane switcher",children:[m.jsx("button",{type:"button","aria-label":"Previous pane",onClick:()=>b(-1),children:"<"}),m.jsxs("button",{type:"button",className:"mobile-pane-current","aria-label":"Open pane switcher","aria-haspopup":"dialog","aria-expanded":c,title:y,onClick:()=>h(!0),children:["Pane ",g+1,"/",e.length," | ",y]}),m.jsx("button",{type:"button","aria-label":"Next pane",onClick:()=>b(1),children:">"}),c?m.jsx("div",{className:"mobile-pane-sheet-backdrop",onClick:()=>h(!1),children:m.jsxs("section",{className:"mobile-pane-sheet",role:"dialog","aria-modal":"true","aria-label":"Pane switcher",onClick:w=>w.stopPropagation(),children:[m.jsxs("header",{children:[m.jsx("strong",{children:"Panes"}),m.jsx("button",{type:"button","aria-label":"Close pane switcher",onClick:()=>h(!1),children:"x"})]}),m.jsx("div",{className:"mobile-pane-sheet-list",children:e.map((w,S)=>{const E=m0(w,s,r),T=w5(w,s,r),O=w.key===p.key;return m.jsxs("button",{type:"button","data-active":O,onClick:()=>{o(w),h(!1)},children:[m.jsx("span",{className:"mobile-pane-sheet-index",children:S+1}),m.jsxs("span",{className:"mobile-pane-sheet-copy",children:[m.jsx("strong",{children:E}),m.jsx("small",{children:T})]}),m.jsx("span",{className:"mobile-pane-sheet-type",children:w.type})]},w.key)})})]})}):null]})}function m0(e,t,s){if(e.type==="editor")return s[e.editorId]?.title||e.title||e.editorId;const r=t[e.terminalId];return r?.title||r?.cwd||e.terminalId}function w5(e,t,s){if(e.type==="editor"){const c=s[e.editorId];return c?.path?`editor | ${c.path}`:"editor"}const r=t[e.terminalId];return r?`${r.activity==="busy"?`busy${r.currentCommand?`: ${r.currentCommand}`:""}`:r.activity==="idle"?"idle":r.status} | ${r.cwd}`:"terminal"}function C5(e){const[t,s]=v.useState(()=>x5(e));return v.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function"){s(!1);return}const r=window.matchMedia(e),o=()=>s(r.matches);return o(),typeof r.addEventListener=="function"?(r.addEventListener("change",o),()=>r.removeEventListener("change",o)):(r.addListener(o),()=>r.removeListener(o))},[e]),t}function x5(e){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(e).matches}function mn(e,t){return e===t}function E5(e){const t=e.workspaces.find(r=>r.id===e.activeWorkspaceId)??e.workspaces[0];return(t?.tabs.find(r=>r.id===t.activeTabId)??t?.tabs[0])?.id??null}function $u(e){return e??"__local__"}function Ko(e,t,s){return`${$u(e)}:${t}:${s}`}class fh extends Error{constructor(){super(eC())}}function k5(e){return e?{workspaceKey:`${f0}:${e}`}:{workspaceKey:f0}}function T5(e){const t=localStorage.getItem(e.workspaceKey);if(!t)return null;try{const s=JSON.parse(t);if($0(s))throw new fh;const r=q0(s);return r?J1(r):null}catch(s){if(s instanceof fh)throw s;return null}}function J1(e){if($0(e))throw new fh;const t=q0(e);return t?{savedWorkspaces:t.workspaces,savedActiveWorkspaceId:t.activeWorkspaceId}:null}function Ao(e,t){if(e.workspaces.length>0){localStorage.setItem(t.workspaceKey,JSON.stringify(e));return}localStorage.removeItem(t.workspaceKey)}function D5(e,t){const s=Nt(e).lastPersistedLayoutJson;if(s){localStorage.setItem(t.workspaceKey,s);return}localStorage.removeItem(t.workspaceKey)}function R5(e){return`This workspace already has ${e} hidden terminal session${e===1?"":"s"}; the limit is ${Dl}. Re-open or delete hidden sessions before hiding more.`}function eC(){return`A saved terminal layout has more than ${Dl} hidden terminal sessions in one workspace. Re-open or delete hidden sessions, then save the layout again.`}function M5(e){const t=e.workspaces.find(o=>o.id===e.activeWorkspaceId)??e.workspaces[0],s=t?.tabs.find(o=>o.id===t.activeTabId)??t?.tabs[0],r=s?e.terminals[s.activeTerminalId]:void 0;return r?.status==="running"?r:null}function N5(e){return e.results.find(t=>t.status==="failed"&&t.error)?.error}function A5(e){return e.split("/").filter(Boolean).pop()??e}function L5(){try{return localStorage.getItem(G1)==="true"}catch{return!1}}function B5(e){try{localStorage.setItem(G1,e?"true":"false")}catch{}}function O5(e){if(!e)return"session · local";const t=Date.parse(e);if(!Number.isFinite(t))return"session · local";const s=t-Date.now();if(s<=0)return"session · expired";const r=Math.max(1,Math.floor(s/6e4));return r<60?`session · ${r}m left`:`session · ${Math.floor(r/60)}h left`}function g0({name:e}){return m.jsxs("svg",{className:"workspace-footer-icon",viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[e==="settings"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M4 7h9"}),m.jsx("path",{d:"M17 7h3"}),m.jsx("circle",{cx:"15",cy:"7",r:"2"}),m.jsx("path",{d:"M4 12h3"}),m.jsx("path",{d:"M11 12h9"}),m.jsx("circle",{cx:"9",cy:"12",r:"2"}),m.jsx("path",{d:"M4 17h9"}),m.jsx("path",{d:"M17 17h3"}),m.jsx("circle",{cx:"15",cy:"17",r:"2"})]}):null,e==="logout"?m.jsxs(m.Fragment,{children:[m.jsx("path",{d:"M10 6H6v12h4"}),m.jsx("path",{d:"M13 8l4 4-4 4"}),m.jsx("path",{d:"M8 12h9"})]}):null]})}function Tr(e){return e instanceof Error?e.message:"Request failed"}function z5({api:e,onDone:t}){const[s,r]=v.useState(null),[o,c]=v.useState(null),[h,f]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(null),[w,S]=v.useState(null);v.useEffect(()=>{let T=!1;return e.setupTotp().then(O=>{T||(r(O.qrDataUrl),c(O.secret))}).catch(O=>{T||S(O instanceof Error?O.message:"Failed to generate QR code")}),()=>{T=!0}},[e]);async function E(T){if(T.preventDefault(),!!o){p(!0),b(null);try{await e.activateTotp({secret:o,otp:h}),t()}catch(O){b(O instanceof Error?O.message:"Verification failed")}finally{p(!1)}}}return w?m.jsx("p",{className:"form-error",children:w}):!s||!o?m.jsx("p",{className:"muted",children:"Generating authenticator setup..."}):m.jsxs("div",{className:"totp-setup",children:[m.jsx("p",{className:"totp-setup-instructions",children:"Scan this QR code with an authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code to confirm."}),m.jsx("div",{className:"totp-qr-container",children:m.jsx("img",{src:s,alt:"TOTP QR code",width:192,height:192})}),m.jsxs("details",{className:"totp-secret-details",children:[m.jsx("summary",{children:"Can't scan? Enter manually"}),m.jsx("p",{className:"totp-secret-text",children:o})]}),m.jsxs("form",{className:"auth-form",onSubmit:E,children:[m.jsxs("label",{children:["Verification code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:T=>f(T.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),y?m.jsx("p",{className:"form-error",children:y}):null,m.jsx("button",{type:"submit",disabled:g||h.length!==6,children:"Activate 2FA"})]})]})}function j5(e){return{source:pp(e?.source)||"unknown",...typeof e?.status=="number"?{status:e.status}:{},...e?.activeAgentId!==void 0?{activeAgentId:e.activeAgentId}:{},...e?.terminalId?{terminalId:pp(e.terminalId)}:{},...e?.detail?{detail:pp(e.detail)}:{}}}function H5(e){return{invalidationSource:e.source}}function P5(e){Nn("auth.session_invalid.request",tC(e)),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid requested",e),yh("session-invalid-request").catch(()=>{}))}function U5(e,t){Nn("auth.session_invalid.result",{...tC(e),authenticated:t}),!(typeof console>"u"||typeof console.warn!="function")&&(console.warn("[nterminal] session invalid check result",{...e,authenticated:t}),yh("session-invalid-result").catch(()=>{}))}function tC(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 pp(e){return e?e.replace(/[^a-zA-Z0-9_.:-]/g,"_").slice(0,96):""}function I5({api:e,serverApi:t,activeAgentId:s=null,onSelectServer:r}){const o=v.useMemo(()=>e??ph(),[e]),c=v.useMemo(()=>t??Go(null),[t]),[h,f]=v.useState(null),[g,p]=v.useState(null),y=v.useRef(null),b=v.useRef("loading");v.useEffect(()=>{let L=!1;return o.getSession().then(N=>{L||(f(N),p(null))}).catch(N=>{L||(p(va(N)),f(null))}),()=>{L=!0}},[o]);const w=q5(h);v.useEffect(()=>{const L=b.current;Nn("auth.view",{view:w,previousView:L,authenticated:h?.authenticated??null,passwordSet:h?.passwordSet??null,totpEnabled:h?.totpEnabled??null,deviceTrusted:h?.deviceTrusted??null,currentIpWhitelisted:h?.currentIpWhitelisted??null}),L==="workspace"&&w!=="workspace"&&yh(`auth-left-workspace-${w}`).catch(()=>{}),b.current=w},[h,w]);async function S(){const L=await o.getSession();f(L),p(null)}async function E(){ap(),fp(),qS(),p(null),f(null);try{await S()}catch(L){p(va(L))}}function T(L){const N=j5(L);if(P5(N),y.current)return y.current;const I=(async()=>{p(null);try{const U=await o.getSession(H5(N));if(U5(N,U.authenticated),f(U),U.authenticated){zN();return}ap(),fp(),qS()}catch(U){p(va(U))}finally{y.current=null}})();return y.current=I,I}if(w==="workspace")return m.jsx(o5,{api:o,serverApi:c,activeAgentId:s,onSelectServer:r,sessionExpiresAt:h?.expiresAt??null,onSessionInvalid:L=>{T(L)},onLogout:async()=>{ap(),fp();const L=await o.logout();f(L)}});const O={loading:"Terminal",setup_password:"Set password",setup_totp:"Set up 2FA",login:"Unlock terminal",reauth:"Verify it’s you",workspace:"Terminal"};return m.jsxs("main",{className:"auth-screen",children:[m.jsxs("div",{className:"auth-background","aria-hidden":"true",children:[m.jsx("div",{className:"auth-grid"}),m.jsx("div",{className:"auth-glow"})]}),m.jsxs("section",{className:"auth-panel","aria-busy":w==="loading",children:[m.jsxs("header",{className:"auth-header",children:[m.jsxs("div",{className:"auth-brand",children:[m.jsx(C0,{size:26}),m.jsxs("div",{children:[m.jsx(x0,{height:17}),m.jsx("p",{className:"auth-host",children:"local terminal"})]})]}),m.jsx("h1",{children:O[w]})]}),g?m.jsx("p",{className:"form-error",children:g}):null,w==="loading"?m.jsx("p",{className:"muted",children:"Checking session..."}):null,w==="loading"&&g?m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{E()},children:"Retry"}):null,w==="setup_password"?m.jsx(K5,{api:o,onSession:L=>{f(L)}}):null,w==="setup_totp"?m.jsx(z5,{api:o,onDone:()=>{S()}}):null,w==="login"?m.jsx(W5,{api:o,session:h,onSession:f,onRefresh:S}):null,w==="reauth"?m.jsx(F5,{api:o,session:h,onSession:f,onFullLogin:()=>f(L=>L&&{...L,deviceTrusted:!1})}):null]})]})}function K5({api:e,onSession:t}){const[s,r]=v.useState(""),[o,c]=v.useState(""),[h,f]=v.useState(!1),[g,p]=v.useState(null);async function y(b){b.preventDefault(),f(!0),p(null);try{if(s!==o){p("Passwords do not match");return}t(await e.setupPassword({password:s}))}catch(w){p(va(w))}finally{f(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:y,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,value:s,onChange:b=>r(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),m.jsxs("label",{children:["Confirm password",m.jsx("input",{value:o,onChange:b=>c(b.currentTarget.value),type:"password",minLength:8,required:!0})]}),g?m.jsx("p",{className:"form-error",children:g}):null,m.jsx("button",{type:"submit",disabled:h||s.length<8||o.length<8,children:"Set password"})]})}function W5({api:e,session:t,onSession:s,onRefresh:r}){const[o,c]=v.useState(""),[h,f]=v.useState(""),[g,p]=v.useState(!1),[y,b]=v.useState(!1),[w,S]=v.useState(null),E=t?.totpEnabled??!1,T=t?.currentIpWhitelisted??!1;async function O(L){L.preventDefault(),b(!0),S(null);try{s(await e.login({password:o,...E?{otp:h}:{},rememberNetwork:g}))}catch(N){S(va(N))}finally{b(!1)}}return m.jsxs("form",{className:"auth-form",onSubmit:O,children:[m.jsxs("label",{children:["Password",m.jsx("input",{autoFocus:!0,type:"password",value:o,onChange:L=>c(L.currentTarget.value),required:!0})]}),E?m.jsxs("label",{children:["Authenticator code",m.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:h,onChange:L=>f(L.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}):null,T?null:m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:g,onChange:L=>p(L.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),w?m.jsx("p",{className:"form-error",children:w}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:y||o.length===0||E&&h.length!==6,children:"Unlock"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{r()},disabled:y,children:"Refresh"})]})]})}function F5({api:e,session:t,onSession:s,onFullLogin:r}){const o=t?.currentIpWhitelisted??!1,[c,h]=v.useState(""),[f,g]=v.useState(!1),[p,y]=v.useState(!1),[b,w]=v.useState(!1),[S,E]=v.useState(!1),[T,O]=v.useState(null),L=xi.useCallback(async(I,U)=>{y(!0),O(null);try{s(await e.reauth({...I?{otp:I}:{},rememberNetwork:U}))}catch(Q){O(va(Q))}finally{y(!1)}},[e,s]);v.useEffect(()=>{if(o){let I=!1;w(!0),E(!1),O(null);const U=window.setTimeout(()=>{I||E(!0)},6e3);return e.reauth({rememberNetwork:!1}).then(Q=>{I||s(Q)}).catch(Q=>{I||(O(va(Q)),E(!0))}).finally(()=>{window.clearTimeout(U),I||w(!1)}),()=>{I=!0,window.clearTimeout(U)}}},[e,o,s]);async function N(I){I.preventDefault(),await L(c,f)}return o&&b&&!S&&!T?m.jsx("p",{className:"muted",children:"Reconnecting from a trusted network…"}):m.jsxs("form",{className:"auth-form",onSubmit:N,children:[o&&S&&!T?m.jsx("p",{className:"muted",children:"Automatic verification is taking longer than expected. You can enter a code or use password login."}):null,m.jsx("p",{className:"muted",children:"This device is remembered. Enter your authenticator code to continue."}),m.jsxs("label",{children:["Authenticator code",m.jsx("input",{autoFocus:!0,type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:c,onChange:I=>h(I.currentTarget.value.replace(/\D/g,"")),placeholder:"000000",required:!0})]}),m.jsxs("label",{className:"auth-checkbox",children:[m.jsx("input",{type:"checkbox",checked:f,onChange:I=>g(I.currentTarget.checked)}),"Remember this network (skip 2FA here next time)"]}),T?m.jsx("p",{className:"form-error",children:T}):null,m.jsxs("div",{className:"button-row",children:[m.jsx("button",{type:"submit",disabled:p||c.length!==6,children:"Continue"}),m.jsx("button",{type:"button",className:"secondary-button",onClick:r,disabled:p,children:"Use password instead"})]})]})}function q5(e){return e?e.passwordSet?e.authenticated&&!e.totpEnabled?"setup_totp":e.authenticated?"workspace":e.deviceTrusted&&e.totpEnabled?"reauth":"login":"setup_password":"loading"}function va(e){return e instanceof Error?e.message:"Request failed"}const _0="NTerminal",Pm="nterminal.activeAgentId";function $5(){const[e,t]=v.useState(()=>V5()),s=v.useMemo(()=>ph(),[]),r=v.useMemo(()=>Go(e),[e]);v.useEffect(()=>{const c=()=>{const h=wA();document.title=h>0?`(${h}) ${_0}`:_0};return c(),SA(c)},[]);function o(c){Y5(c),t(c)}return m.jsx(I5,{api:s,activeAgentId:e,serverApi:r,onSelectServer:o})}function V5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Pm);return e&&e.trim()?e:null}catch{return null}}function Y5(e){if(!(typeof window>"u"))try{if(e){window.localStorage.setItem(Pm,e);return}window.localStorage.removeItem(Pm)}catch{}}const v0=["gesturestart","gesturechange","gestureend"],X5=[".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 G5(e=window){if(!Q5(e))return()=>{};const t={passive:!1},s=e.document;function r(c){c.cancelable&&c.preventDefault()}function o(c){if(c.defaultPrevented)return;const h=c.touches;!h||h.length===0||(h.length>1||!Z5(c.target))&&r(c)}for(const c of v0)s.addEventListener(c,r,t);return s.addEventListener("touchmove",o,t),s.addEventListener("dblclick",r,t),()=>{for(const c of v0)s.removeEventListener(c,r,t);s.removeEventListener("touchmove",o,t),s.removeEventListener("dblclick",r,t)}}function Z5(e){return e instanceof Element&&e.closest(X5)!==null}function Q5(e){return e.navigator.maxTouchPoints>0?!0:typeof e.matchMedia=="function"&&e.matchMedia("(pointer: coarse)").matches}u2();XM();G5();Fm();dE.createRoot(document.getElementById("root")).render(m.jsx(xi.StrictMode,{children:m.jsx($5,{})}));export{xi as R,nE as g,m as j};
|