@mmmbuto/nexuscrew 0.8.21 → 0.8.22

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.
@@ -0,0 +1,91 @@
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function i(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=i(o);fetch(o.href,a)}})();function Fh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qc={exports:{}},$s={},Jc={exports:{}},Ze={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Zp;function xw(){if(Zp)return Ze;Zp=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),S=Symbol.iterator;function y(L){return L===null||typeof L!="object"?null:(L=S&&L[S]||L["@@iterator"],typeof L=="function"?L:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,x={};function b(L,W,oe){this.props=L,this.context=W,this.refs=x,this.updater=oe||k}b.prototype.isReactComponent={},b.prototype.setState=function(L,W){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,W,"setState")},b.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function C(){}C.prototype=b.prototype;function D(L,W,oe){this.props=L,this.context=W,this.refs=x,this.updater=oe||k}var j=D.prototype=new C;j.constructor=D,w(j,b.prototype),j.isPureReactComponent=!0;var M=Array.isArray,Z=Object.prototype.hasOwnProperty,F={current:null},T={key:!0,ref:!0,__self:!0,__source:!0};function X(L,W,oe){var me,V={},Q=null,de=null;if(W!=null)for(me in W.ref!==void 0&&(de=W.ref),W.key!==void 0&&(Q=""+W.key),W)Z.call(W,me)&&!T.hasOwnProperty(me)&&(V[me]=W[me]);var ae=arguments.length-2;if(ae===1)V.children=oe;else if(1<ae){for(var ke=Array(ae),je=0;je<ae;je++)ke[je]=arguments[je+2];V.children=ke}if(L&&L.defaultProps)for(me in ae=L.defaultProps,ae)V[me]===void 0&&(V[me]=ae[me]);return{$$typeof:e,type:L,key:Q,ref:de,props:V,_owner:F.current}}function K(L,W){return{$$typeof:e,type:L.type,key:W,ref:L.ref,props:L.props,_owner:L._owner}}function G(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function ee(L){var W={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(oe){return W[oe]})}var A=/\/+/g;function N(L,W){return typeof L=="object"&&L!==null&&L.key!=null?ee(""+L.key):W.toString(36)}function R(L,W,oe,me,V){var Q=typeof L;(Q==="undefined"||Q==="boolean")&&(L=null);var de=!1;if(L===null)de=!0;else switch(Q){case"string":case"number":de=!0;break;case"object":switch(L.$$typeof){case e:case t:de=!0}}if(de)return de=L,V=V(de),L=me===""?"."+N(de,0):me,M(V)?(oe="",L!=null&&(oe=L.replace(A,"$&/")+"/"),R(V,W,oe,"",function(je){return je})):V!=null&&(G(V)&&(V=K(V,oe+(!V.key||de&&de.key===V.key?"":(""+V.key).replace(A,"$&/")+"/")+L)),W.push(V)),1;if(de=0,me=me===""?".":me+":",M(L))for(var ae=0;ae<L.length;ae++){Q=L[ae];var ke=me+N(Q,ae);de+=R(Q,W,oe,ke,V)}else if(ke=y(L),typeof ke=="function")for(L=ke.call(L),ae=0;!(Q=L.next()).done;)Q=Q.value,ke=me+N(Q,ae++),de+=R(Q,W,oe,ke,V);else if(Q==="object")throw W=String(L),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return de}function I(L,W,oe){if(L==null)return L;var me=[],V=0;return R(L,me,"","",function(Q){return W.call(oe,Q,V++)}),me}function z(L){if(L._status===-1){var W=L._result;W=W(),W.then(function(oe){(L._status===0||L._status===-1)&&(L._status=1,L._result=oe)},function(oe){(L._status===0||L._status===-1)&&(L._status=2,L._result=oe)}),L._status===-1&&(L._status=0,L._result=W)}if(L._status===1)return L._result.default;throw L._result}var $={current:null},H={transition:null},re={ReactCurrentDispatcher:$,ReactCurrentBatchConfig:H,ReactCurrentOwner:F};function q(){throw Error("act(...) is not supported in production builds of React.")}return Ze.Children={map:I,forEach:function(L,W,oe){I(L,function(){W.apply(this,arguments)},oe)},count:function(L){var W=0;return I(L,function(){W++}),W},toArray:function(L){return I(L,function(W){return W})||[]},only:function(L){if(!G(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},Ze.Component=b,Ze.Fragment=i,Ze.Profiler=o,Ze.PureComponent=D,Ze.StrictMode=s,Ze.Suspense=m,Ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=re,Ze.act=q,Ze.cloneElement=function(L,W,oe){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var me=w({},L.props),V=L.key,Q=L.ref,de=L._owner;if(W!=null){if(W.ref!==void 0&&(Q=W.ref,de=F.current),W.key!==void 0&&(V=""+W.key),L.type&&L.type.defaultProps)var ae=L.type.defaultProps;for(ke in W)Z.call(W,ke)&&!T.hasOwnProperty(ke)&&(me[ke]=W[ke]===void 0&&ae!==void 0?ae[ke]:W[ke])}var ke=arguments.length-2;if(ke===1)me.children=oe;else if(1<ke){ae=Array(ke);for(var je=0;je<ke;je++)ae[je]=arguments[je+2];me.children=ae}return{$$typeof:e,type:L.type,key:V,ref:Q,props:me,_owner:de}},Ze.createContext=function(L){return L={$$typeof:c,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:a,_context:L},L.Consumer=L},Ze.createElement=X,Ze.createFactory=function(L){var W=X.bind(null,L);return W.type=L,W},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(L){return{$$typeof:d,render:L}},Ze.isValidElement=G,Ze.lazy=function(L){return{$$typeof:_,_payload:{_status:-1,_result:L},_init:z}},Ze.memo=function(L,W){return{$$typeof:p,type:L,compare:W===void 0?null:W}},Ze.startTransition=function(L){var W=H.transition;H.transition={};try{L()}finally{H.transition=W}},Ze.unstable_act=q,Ze.useCallback=function(L,W){return $.current.useCallback(L,W)},Ze.useContext=function(L){return $.current.useContext(L)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(L){return $.current.useDeferredValue(L)},Ze.useEffect=function(L,W){return $.current.useEffect(L,W)},Ze.useId=function(){return $.current.useId()},Ze.useImperativeHandle=function(L,W,oe){return $.current.useImperativeHandle(L,W,oe)},Ze.useInsertionEffect=function(L,W){return $.current.useInsertionEffect(L,W)},Ze.useLayoutEffect=function(L,W){return $.current.useLayoutEffect(L,W)},Ze.useMemo=function(L,W){return $.current.useMemo(L,W)},Ze.useReducer=function(L,W,oe){return $.current.useReducer(L,W,oe)},Ze.useRef=function(L){return $.current.useRef(L)},Ze.useState=function(L){return $.current.useState(L)},Ze.useSyncExternalStore=function(L,W,oe){return $.current.useSyncExternalStore(L,W,oe)},Ze.useTransition=function(){return $.current.useTransition()},Ze.version="18.3.1",Ze}var em;function Hh(){return em||(em=1,Jc.exports=xw()),Jc.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var tm;function Ew(){if(tm)return $s;tm=1;var e=Hh(),t=Symbol.for("react.element"),i=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(d,m,p){var _,S={},y=null,k=null;p!==void 0&&(y=""+p),m.key!==void 0&&(y=""+m.key),m.ref!==void 0&&(k=m.ref);for(_ in m)s.call(m,_)&&!a.hasOwnProperty(_)&&(S[_]=m[_]);if(d&&d.defaultProps)for(_ in m=d.defaultProps,m)S[_]===void 0&&(S[_]=m[_]);return{$$typeof:t,type:d,key:y,ref:k,props:S,_owner:o.current}}return $s.Fragment=i,$s.jsx=c,$s.jsxs=c,$s}var im;function Nw(){return im||(im=1,Qc.exports=Ew()),Qc.exports}var u=Nw(),P=Hh();const Rw=Fh(P);var xa={},Zc={exports:{}},li={},eu={exports:{}},tu={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var nm;function Pw(){return nm||(nm=1,(function(e){function t(H,re){var q=H.length;H.push(re);e:for(;0<q;){var L=q-1>>>1,W=H[L];if(0<o(W,re))H[L]=re,H[q]=W,q=L;else break e}}function i(H){return H.length===0?null:H[0]}function s(H){if(H.length===0)return null;var re=H[0],q=H.pop();if(q!==re){H[0]=q;e:for(var L=0,W=H.length,oe=W>>>1;L<oe;){var me=2*(L+1)-1,V=H[me],Q=me+1,de=H[Q];if(0>o(V,q))Q<W&&0>o(de,V)?(H[L]=de,H[Q]=q,L=Q):(H[L]=V,H[me]=q,L=me);else if(Q<W&&0>o(de,q))H[L]=de,H[Q]=q,L=Q;else break e}}return re}function o(H,re){var q=H.sortIndex-re.sortIndex;return q!==0?q:H.id-re.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],p=[],_=1,S=null,y=3,k=!1,w=!1,x=!1,b=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(H){for(var re=i(p);re!==null;){if(re.callback===null)s(p);else if(re.startTime<=H)s(p),re.sortIndex=re.expirationTime,t(m,re);else break;re=i(p)}}function M(H){if(x=!1,j(H),!w)if(i(m)!==null)w=!0,z(Z);else{var re=i(p);re!==null&&$(M,re.startTime-H)}}function Z(H,re){w=!1,x&&(x=!1,C(X),X=-1),k=!0;var q=y;try{for(j(re),S=i(m);S!==null&&(!(S.expirationTime>re)||H&&!ee());){var L=S.callback;if(typeof L=="function"){S.callback=null,y=S.priorityLevel;var W=L(S.expirationTime<=re);re=e.unstable_now(),typeof W=="function"?S.callback=W:S===i(m)&&s(m),j(re)}else s(m);S=i(m)}if(S!==null)var oe=!0;else{var me=i(p);me!==null&&$(M,me.startTime-re),oe=!1}return oe}finally{S=null,y=q,k=!1}}var F=!1,T=null,X=-1,K=5,G=-1;function ee(){return!(e.unstable_now()-G<K)}function A(){if(T!==null){var H=e.unstable_now();G=H;var re=!0;try{re=T(!0,H)}finally{re?N():(F=!1,T=null)}}else F=!1}var N;if(typeof D=="function")N=function(){D(A)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,I=R.port2;R.port1.onmessage=A,N=function(){I.postMessage(null)}}else N=function(){b(A,0)};function z(H){T=H,F||(F=!0,N())}function $(H,re){X=b(function(){H(e.unstable_now())},re)}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(H){H.callback=null},e.unstable_continueExecution=function(){w||k||(w=!0,z(Z))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return i(m)},e.unstable_next=function(H){switch(y){case 1:case 2:case 3:var re=3;break;default:re=y}var q=y;y=re;try{return H()}finally{y=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,re){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var q=y;y=H;try{return re()}finally{y=q}},e.unstable_scheduleCallback=function(H,re,q){var L=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?L+q:L):q=L,H){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=q+W,H={id:_++,callback:re,priorityLevel:H,startTime:q,expirationTime:W,sortIndex:-1},q>L?(H.sortIndex=q,t(p,H),i(m)===null&&H===i(p)&&(x?(C(X),X=-1):x=!0,$(M,q-L))):(H.sortIndex=W,t(m,H),w||k||(w=!0,z(Z))),H},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(H){var re=y;return function(){var q=y;y=re;try{return H.apply(this,arguments)}finally{y=q}}}})(tu)),tu}var rm;function Dw(){return rm||(rm=1,eu.exports=Pw()),eu.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var sm;function Mw(){if(sm)return li;sm=1;var e=Hh(),t=Dw();function i(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function a(n,r){c(n,r),c(n+"Capture",r)}function c(n,r){for(o[n]=r,n=0;n<r.length;n++)s.add(r[n])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),m=Object.prototype.hasOwnProperty,p=/^[: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]*$/,_={},S={};function y(n){return m.call(S,n)?!0:m.call(_,n)?!1:p.test(n)?S[n]=!0:(_[n]=!0,!1)}function k(n,r,l,h){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function w(n,r,l,h){if(r===null||typeof r>"u"||k(n,r,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function x(n,r,l,h,f,g,E){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=h,this.attributeNamespace=f,this.mustUseProperty=l,this.propertyName=n,this.type=r,this.sanitizeURL=g,this.removeEmptyString=E}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){b[n]=new x(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];b[r]=new x(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){b[n]=new x(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){b[n]=new x(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){b[n]=new x(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){b[n]=new x(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){b[n]=new x(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){b[n]=new x(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){b[n]=new x(n,5,!1,n.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function D(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var r=n.replace(C,D);b[r]=new x(r,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var r=n.replace(C,D);b[r]=new x(r,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var r=n.replace(C,D);b[r]=new x(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){b[n]=new x(n,1,!1,n.toLowerCase(),null,!1,!1)}),b.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){b[n]=new x(n,1,!1,n.toLowerCase(),null,!0,!0)});function j(n,r,l,h){var f=b.hasOwnProperty(r)?b[r]:null;(f!==null?f.type!==0:h||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(w(r,l,f,h)&&(l=null),h||f===null?y(r)&&(l===null?n.removeAttribute(r):n.setAttribute(r,""+l)):f.mustUseProperty?n[f.propertyName]=l===null?f.type===3?!1:"":l:(r=f.attributeName,h=f.attributeNamespace,l===null?n.removeAttribute(r):(f=f.type,l=f===3||f===4&&l===!0?"":""+l,h?n.setAttributeNS(h,r,l):n.setAttribute(r,l))))}var M=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Z=Symbol.for("react.element"),F=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),X=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),G=Symbol.for("react.provider"),ee=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),$=Symbol.for("react.offscreen"),H=Symbol.iterator;function re(n){return n===null||typeof n!="object"?null:(n=H&&n[H]||n["@@iterator"],typeof n=="function"?n:null)}var q=Object.assign,L;function W(n){if(L===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);L=r&&r[1]||""}return`
34
+ `+L+n}var oe=!1;function me(n,r){if(!n||oe)return"";oe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(se){var h=se}Reflect.construct(n,[],r)}else{try{r.call()}catch(se){h=se}n.call(r.prototype)}else{try{throw Error()}catch(se){h=se}n()}}catch(se){if(se&&h&&typeof se.stack=="string"){for(var f=se.stack.split(`
35
+ `),g=h.stack.split(`
36
+ `),E=f.length-1,O=g.length-1;1<=E&&0<=O&&f[E]!==g[O];)O--;for(;1<=E&&0<=O;E--,O--)if(f[E]!==g[O]){if(E!==1||O!==1)do if(E--,O--,0>O||f[E]!==g[O]){var U=`
37
+ `+f[E].replace(" at new "," at ");return n.displayName&&U.includes("<anonymous>")&&(U=U.replace("<anonymous>",n.displayName)),U}while(1<=E&&0<=O);break}}}finally{oe=!1,Error.prepareStackTrace=l}return(n=n?n.displayName||n.name:"")?W(n):""}function V(n){switch(n.tag){case 5:return W(n.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return n=me(n.type,!1),n;case 11:return n=me(n.type.render,!1),n;case 1:return n=me(n.type,!0),n;default:return""}}function Q(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case T:return"Fragment";case F:return"Portal";case K:return"Profiler";case X:return"StrictMode";case N:return"Suspense";case R:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case ee:return(n.displayName||"Context")+".Consumer";case G:return(n._context.displayName||"Context")+".Provider";case A:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case I:return r=n.displayName||null,r!==null?r:Q(n.type)||"Memo";case z:r=n._payload,n=n._init;try{return Q(n(r))}catch{}}return null}function de(n){var r=n.type;switch(n.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Q(r);case 8:return r===X?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r}return null}function ae(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ke(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function je(n){var r=ke(n)?"checked":"value",l=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),h=""+n[r];if(!n.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var f=l.get,g=l.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return f.call(this)},set:function(E){h=""+E,g.call(this,E)}}),Object.defineProperty(n,r,{enumerable:l.enumerable}),{getValue:function(){return h},setValue:function(E){h=""+E},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function Ye(n){n._valueTracker||(n._valueTracker=je(n))}function qe(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),h="";return n&&(h=ke(n)?n.checked?"true":"false":n.value),n=h,n!==l?(r.setValue(n),!0):!1}function Ce(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function rt(n,r){var l=r.checked;return q({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function St(n,r){var l=r.defaultValue==null?"":r.defaultValue,h=r.checked!=null?r.checked:r.defaultChecked;l=ae(r.value!=null?r.value:l),n._wrapperState={initialChecked:h,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function ne(n,r){r=r.checked,r!=null&&j(n,"checked",r,!1)}function le(n,r){ne(n,r);var l=ae(r.value),h=r.type;if(l!=null)h==="number"?(l===0&&n.value===""||n.value!=l)&&(n.value=""+l):n.value!==""+l&&(n.value=""+l);else if(h==="submit"||h==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?J(n,r.type,l):r.hasOwnProperty("defaultValue")&&J(n,r.type,ae(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function Be(n,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var h=r.type;if(!(h!=="submit"&&h!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+n._wrapperState.initialValue,l||r===n.value||(n.value=r),n.defaultValue=r}l=n.name,l!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,l!==""&&(n.name=l)}function J(n,r,l){(r!=="number"||Ce(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var B=Array.isArray;function fe(n,r,l,h){if(n=n.options,r){r={};for(var f=0;f<l.length;f++)r["$"+l[f]]=!0;for(l=0;l<n.length;l++)f=r.hasOwnProperty("$"+n[l].value),n[l].selected!==f&&(n[l].selected=f),f&&h&&(n[l].defaultSelected=!0)}else{for(l=""+ae(l),r=null,f=0;f<n.length;f++){if(n[f].value===l){n[f].selected=!0,h&&(n[f].defaultSelected=!0);return}r!==null||n[f].disabled||(r=n[f])}r!==null&&(r.selected=!0)}}function be(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(i(91));return q({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function Se(n,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(i(92));if(B(l)){if(1<l.length)throw Error(i(93));l=l[0]}r=l}r==null&&(r=""),l=r}n._wrapperState={initialValue:ae(l)}}function Ae(n,r){var l=ae(r.value),h=ae(r.defaultValue);l!=null&&(l=""+l,l!==n.value&&(n.value=l),r.defaultValue==null&&n.defaultValue!==l&&(n.defaultValue=l)),h!=null&&(n.defaultValue=""+h)}function ce(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function Me(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Pe(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?Me(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var He,Oe=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,h,f){MSApp.execUnsafeLocalFunction(function(){return n(r,l,h,f)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(He=He||document.createElement("div"),He.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=He.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function $e(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var he={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ee=["Webkit","ms","Moz","O"];Object.keys(he).forEach(function(n){Ee.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),he[r]=he[n]})});function Xe(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||he.hasOwnProperty(n)&&he[n]?(""+r).trim():r+"px"}function st(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var h=l.indexOf("--")===0,f=Xe(l,r[l],h);l==="float"&&(l="cssFloat"),h?n.setProperty(l,f):n[l]=f}}var ue=q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ne(n,r){if(r){if(ue[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(i(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(i(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(i(61))}if(r.style!=null&&typeof r.style!="object")throw Error(i(62))}}function Ve(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){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 qt=null;function di(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var fl=null,yr=null,Sr=null;function md(n){if(n=Ns(n)){if(typeof fl!="function")throw Error(i(280));var r=n.stateNode;r&&(r=Fo(r),fl(n.stateNode,n.type,r))}}function gd(n){yr?Sr?Sr.push(n):Sr=[n]:yr=n}function vd(){if(yr){var n=yr,r=Sr;if(Sr=yr=null,md(n),r)for(n=0;n<r.length;n++)md(r[n])}}function _d(n,r){return n(r)}function yd(){}var pl=!1;function Sd(n,r,l){if(pl)return n(r,l);pl=!0;try{return _d(n,r,l)}finally{pl=!1,(yr!==null||Sr!==null)&&(yd(),vd())}}function os(n,r){var l=n.stateNode;if(l===null)return null;var h=Fo(l);if(h===null)return null;l=h[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(h=!h.disabled)||(n=n.type,h=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!h;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(i(231,r,typeof l));return l}var ml=!1;if(d)try{var as={};Object.defineProperty(as,"passive",{get:function(){ml=!0}}),window.addEventListener("test",as,as),window.removeEventListener("test",as,as)}catch{ml=!1}function My(n,r,l,h,f,g,E,O,U){var se=Array.prototype.slice.call(arguments,3);try{r.apply(l,se)}catch(ve){this.onError(ve)}}var ls=!1,_o=null,yo=!1,gl=null,Ly={onError:function(n){ls=!0,_o=n}};function jy(n,r,l,h,f,g,E,O,U){ls=!1,_o=null,My.apply(Ly,arguments)}function Ty(n,r,l,h,f,g,E,O,U){if(jy.apply(this,arguments),ls){if(ls){var se=_o;ls=!1,_o=null}else throw Error(i(198));yo||(yo=!0,gl=se)}}function Un(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function wd(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function bd(n){if(Un(n)!==n)throw Error(i(188))}function Ay(n){var r=n.alternate;if(!r){if(r=Un(n),r===null)throw Error(i(188));return r!==n?null:n}for(var l=n,h=r;;){var f=l.return;if(f===null)break;var g=f.alternate;if(g===null){if(h=f.return,h!==null){l=h;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return bd(f),n;if(g===h)return bd(f),r;g=g.sibling}throw Error(i(188))}if(l.return!==h.return)l=f,h=g;else{for(var E=!1,O=f.child;O;){if(O===l){E=!0,l=f,h=g;break}if(O===h){E=!0,h=f,l=g;break}O=O.sibling}if(!E){for(O=g.child;O;){if(O===l){E=!0,l=g,h=f;break}if(O===h){E=!0,h=g,l=f;break}O=O.sibling}if(!E)throw Error(i(189))}}if(l.alternate!==h)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?n:r}function kd(n){return n=Ay(n),n!==null?Cd(n):null}function Cd(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=Cd(n);if(r!==null)return r;n=n.sibling}return null}var xd=t.unstable_scheduleCallback,Ed=t.unstable_cancelCallback,Iy=t.unstable_shouldYield,By=t.unstable_requestPaint,wt=t.unstable_now,Oy=t.unstable_getCurrentPriorityLevel,vl=t.unstable_ImmediatePriority,Nd=t.unstable_UserBlockingPriority,So=t.unstable_NormalPriority,zy=t.unstable_LowPriority,Rd=t.unstable_IdlePriority,wo=null,Hi=null;function Fy(n){if(Hi&&typeof Hi.onCommitFiberRoot=="function")try{Hi.onCommitFiberRoot(wo,n,void 0,(n.current.flags&128)===128)}catch{}}var ji=Math.clz32?Math.clz32:Wy,Hy=Math.log,$y=Math.LN2;function Wy(n){return n>>>=0,n===0?32:31-(Hy(n)/$y|0)|0}var bo=64,ko=4194304;function cs(n){switch(n&-n){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: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&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Co(n,r){var l=n.pendingLanes;if(l===0)return 0;var h=0,f=n.suspendedLanes,g=n.pingedLanes,E=l&268435455;if(E!==0){var O=E&~f;O!==0?h=cs(O):(g&=E,g!==0&&(h=cs(g)))}else E=l&~f,E!==0?h=cs(E):g!==0&&(h=cs(g));if(h===0)return 0;if(r!==0&&r!==h&&(r&f)===0&&(f=h&-h,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((h&4)!==0&&(h|=l&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=h;0<r;)l=31-ji(r),f=1<<l,h|=n[l],r&=~f;return h}function Uy(n,r){switch(n){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64: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 r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ky(n,r){for(var l=n.suspendedLanes,h=n.pingedLanes,f=n.expirationTimes,g=n.pendingLanes;0<g;){var E=31-ji(g),O=1<<E,U=f[E];U===-1?((O&l)===0||(O&h)!==0)&&(f[E]=Uy(O,r)):U<=r&&(n.expiredLanes|=O),g&=~O}}function _l(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Pd(){var n=bo;return bo<<=1,(bo&4194240)===0&&(bo=64),n}function yl(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function us(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-ji(r),n[r]=l}function qy(n,r){var l=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var h=n.eventTimes;for(n=n.expirationTimes;0<l;){var f=31-ji(l),g=1<<f;r[f]=0,h[f]=-1,n[f]=-1,l&=~g}}function Sl(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var h=31-ji(l),f=1<<h;f&r|n[h]&r&&(n[h]|=r),l&=~f}}var nt=0;function Dd(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var Md,wl,Ld,jd,Td,bl=!1,xo=[],mn=null,gn=null,vn=null,hs=new Map,ds=new Map,_n=[],Vy="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 submit".split(" ");function Ad(n,r){switch(n){case"focusin":case"focusout":mn=null;break;case"dragenter":case"dragleave":gn=null;break;case"mouseover":case"mouseout":vn=null;break;case"pointerover":case"pointerout":hs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ds.delete(r.pointerId)}}function fs(n,r,l,h,f,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:h,nativeEvent:g,targetContainers:[f]},r!==null&&(r=Ns(r),r!==null&&wl(r)),n):(n.eventSystemFlags|=h,r=n.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),n)}function Yy(n,r,l,h,f){switch(r){case"focusin":return mn=fs(mn,n,r,l,h,f),!0;case"dragenter":return gn=fs(gn,n,r,l,h,f),!0;case"mouseover":return vn=fs(vn,n,r,l,h,f),!0;case"pointerover":var g=f.pointerId;return hs.set(g,fs(hs.get(g)||null,n,r,l,h,f)),!0;case"gotpointercapture":return g=f.pointerId,ds.set(g,fs(ds.get(g)||null,n,r,l,h,f)),!0}return!1}function Id(n){var r=Kn(n.target);if(r!==null){var l=Un(r);if(l!==null){if(r=l.tag,r===13){if(r=wd(l),r!==null){n.blockedOn=r,Td(n.priority,function(){Ld(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function Eo(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=Cl(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var h=new l.constructor(l.type,l);qt=h,l.target.dispatchEvent(h),qt=null}else return r=Ns(l),r!==null&&wl(r),n.blockedOn=l,!1;r.shift()}return!0}function Bd(n,r,l){Eo(n)&&l.delete(r)}function Xy(){bl=!1,mn!==null&&Eo(mn)&&(mn=null),gn!==null&&Eo(gn)&&(gn=null),vn!==null&&Eo(vn)&&(vn=null),hs.forEach(Bd),ds.forEach(Bd)}function ps(n,r){n.blockedOn===r&&(n.blockedOn=null,bl||(bl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Xy)))}function ms(n){function r(f){return ps(f,n)}if(0<xo.length){ps(xo[0],n);for(var l=1;l<xo.length;l++){var h=xo[l];h.blockedOn===n&&(h.blockedOn=null)}}for(mn!==null&&ps(mn,n),gn!==null&&ps(gn,n),vn!==null&&ps(vn,n),hs.forEach(r),ds.forEach(r),l=0;l<_n.length;l++)h=_n[l],h.blockedOn===n&&(h.blockedOn=null);for(;0<_n.length&&(l=_n[0],l.blockedOn===null);)Id(l),l.blockedOn===null&&_n.shift()}var wr=M.ReactCurrentBatchConfig,No=!0;function Gy(n,r,l,h){var f=nt,g=wr.transition;wr.transition=null;try{nt=1,kl(n,r,l,h)}finally{nt=f,wr.transition=g}}function Qy(n,r,l,h){var f=nt,g=wr.transition;wr.transition=null;try{nt=4,kl(n,r,l,h)}finally{nt=f,wr.transition=g}}function kl(n,r,l,h){if(No){var f=Cl(n,r,l,h);if(f===null)Hl(n,r,h,Ro,l),Ad(n,h);else if(Yy(f,n,r,l,h))h.stopPropagation();else if(Ad(n,h),r&4&&-1<Vy.indexOf(n)){for(;f!==null;){var g=Ns(f);if(g!==null&&Md(g),g=Cl(n,r,l,h),g===null&&Hl(n,r,h,Ro,l),g===f)break;f=g}f!==null&&h.stopPropagation()}else Hl(n,r,h,null,l)}}var Ro=null;function Cl(n,r,l,h){if(Ro=null,n=di(h),n=Kn(n),n!==null)if(r=Un(n),r===null)n=null;else if(l=r.tag,l===13){if(n=wd(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return Ro=n,null}function Od(n){switch(n){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"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 1;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"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Oy()){case vl:return 1;case Nd:return 4;case So:case zy:return 16;case Rd:return 536870912;default:return 16}default:return 16}}var yn=null,xl=null,Po=null;function zd(){if(Po)return Po;var n,r=xl,l=r.length,h,f="value"in yn?yn.value:yn.textContent,g=f.length;for(n=0;n<l&&r[n]===f[n];n++);var E=l-n;for(h=1;h<=E&&r[l-h]===f[g-h];h++);return Po=f.slice(n,1<h?1-h:void 0)}function Do(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function Mo(){return!0}function Fd(){return!1}function fi(n){function r(l,h,f,g,E){this._reactName=l,this._targetInst=f,this.type=h,this.nativeEvent=g,this.target=E,this.currentTarget=null;for(var O in n)n.hasOwnProperty(O)&&(l=n[O],this[O]=l?l(g):g[O]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Mo:Fd,this.isPropagationStopped=Fd,this}return q(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Mo)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Mo)},persist:function(){},isPersistent:Mo}),r}var br={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},El=fi(br),gs=q({},br,{view:0,detail:0}),Jy=fi(gs),Nl,Rl,vs,Lo=q({},gs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Dl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==vs&&(vs&&n.type==="mousemove"?(Nl=n.screenX-vs.screenX,Rl=n.screenY-vs.screenY):Rl=Nl=0,vs=n),Nl)},movementY:function(n){return"movementY"in n?n.movementY:Rl}}),Hd=fi(Lo),Zy=q({},Lo,{dataTransfer:0}),eS=fi(Zy),tS=q({},gs,{relatedTarget:0}),Pl=fi(tS),iS=q({},br,{animationName:0,elapsedTime:0,pseudoElement:0}),nS=fi(iS),rS=q({},br,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),sS=fi(rS),oS=q({},br,{data:0}),$d=fi(oS),aS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lS={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"},cS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function uS(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=cS[n])?!!r[n]:!1}function Dl(){return uS}var hS=q({},gs,{key:function(n){if(n.key){var r=aS[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Do(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?lS[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Dl,charCode:function(n){return n.type==="keypress"?Do(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Do(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),dS=fi(hS),fS=q({},Lo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wd=fi(fS),pS=q({},gs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Dl}),mS=fi(pS),gS=q({},br,{propertyName:0,elapsedTime:0,pseudoElement:0}),vS=fi(gS),_S=q({},Lo,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),yS=fi(_S),SS=[9,13,27,32],Ml=d&&"CompositionEvent"in window,_s=null;d&&"documentMode"in document&&(_s=document.documentMode);var wS=d&&"TextEvent"in window&&!_s,Ud=d&&(!Ml||_s&&8<_s&&11>=_s),Kd=" ",qd=!1;function Vd(n,r){switch(n){case"keyup":return SS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yd(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var kr=!1;function bS(n,r){switch(n){case"compositionend":return Yd(r);case"keypress":return r.which!==32?null:(qd=!0,Kd);case"textInput":return n=r.data,n===Kd&&qd?null:n;default:return null}}function kS(n,r){if(kr)return n==="compositionend"||!Ml&&Vd(n,r)?(n=zd(),Po=xl=yn=null,kr=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Ud&&r.locale!=="ko"?null:r.data;default:return null}}var CS={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 Xd(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!CS[n.type]:r==="textarea"}function Gd(n,r,l,h){gd(h),r=Bo(r,"onChange"),0<r.length&&(l=new El("onChange","change",null,l,h),n.push({event:l,listeners:r}))}var ys=null,Ss=null;function xS(n){mf(n,0)}function jo(n){var r=Rr(n);if(qe(r))return n}function ES(n,r){if(n==="change")return r}var Qd=!1;if(d){var Ll;if(d){var jl="oninput"in document;if(!jl){var Jd=document.createElement("div");Jd.setAttribute("oninput","return;"),jl=typeof Jd.oninput=="function"}Ll=jl}else Ll=!1;Qd=Ll&&(!document.documentMode||9<document.documentMode)}function Zd(){ys&&(ys.detachEvent("onpropertychange",ef),Ss=ys=null)}function ef(n){if(n.propertyName==="value"&&jo(Ss)){var r=[];Gd(r,Ss,n,di(n)),Sd(xS,r)}}function NS(n,r,l){n==="focusin"?(Zd(),ys=r,Ss=l,ys.attachEvent("onpropertychange",ef)):n==="focusout"&&Zd()}function RS(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return jo(Ss)}function PS(n,r){if(n==="click")return jo(r)}function DS(n,r){if(n==="input"||n==="change")return jo(r)}function MS(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Ti=typeof Object.is=="function"?Object.is:MS;function ws(n,r){if(Ti(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),h=Object.keys(r);if(l.length!==h.length)return!1;for(h=0;h<l.length;h++){var f=l[h];if(!m.call(r,f)||!Ti(n[f],r[f]))return!1}return!0}function tf(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function nf(n,r){var l=tf(n);n=0;for(var h;l;){if(l.nodeType===3){if(h=n+l.textContent.length,n<=r&&h>=r)return{node:l,offset:r-n};n=h}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=tf(l)}}function rf(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?rf(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function sf(){for(var n=window,r=Ce();r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=Ce(n.document)}return r}function Tl(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function LS(n){var r=sf(),l=n.focusedElem,h=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&rf(l.ownerDocument.documentElement,l)){if(h!==null&&Tl(l)){if(r=h.start,n=h.end,n===void 0&&(n=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(n,l.value.length);else if(n=(r=l.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var f=l.textContent.length,g=Math.min(h.start,f);h=h.end===void 0?g:Math.min(h.end,f),!n.extend&&g>h&&(f=h,h=g,g=f),f=nf(l,g);var E=nf(l,h);f&&E&&(n.rangeCount!==1||n.anchorNode!==f.node||n.anchorOffset!==f.offset||n.focusNode!==E.node||n.focusOffset!==E.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),n.removeAllRanges(),g>h?(n.addRange(r),n.extend(E.node,E.offset)):(r.setEnd(E.node,E.offset),n.addRange(r)))}}for(r=[],n=l;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)n=r[l],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var jS=d&&"documentMode"in document&&11>=document.documentMode,Cr=null,Al=null,bs=null,Il=!1;function of(n,r,l){var h=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Il||Cr==null||Cr!==Ce(h)||(h=Cr,"selectionStart"in h&&Tl(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),bs&&ws(bs,h)||(bs=h,h=Bo(Al,"onSelect"),0<h.length&&(r=new El("onSelect","select",null,r,l),n.push({event:r,listeners:h}),r.target=Cr)))}function To(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var xr={animationend:To("Animation","AnimationEnd"),animationiteration:To("Animation","AnimationIteration"),animationstart:To("Animation","AnimationStart"),transitionend:To("Transition","TransitionEnd")},Bl={},af={};d&&(af=document.createElement("div").style,"AnimationEvent"in window||(delete xr.animationend.animation,delete xr.animationiteration.animation,delete xr.animationstart.animation),"TransitionEvent"in window||delete xr.transitionend.transition);function Ao(n){if(Bl[n])return Bl[n];if(!xr[n])return n;var r=xr[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in af)return Bl[n]=r[l];return n}var lf=Ao("animationend"),cf=Ao("animationiteration"),uf=Ao("animationstart"),hf=Ao("transitionend"),df=new Map,ff="abort auxClick 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(" ");function Sn(n,r){df.set(n,r),a(r,[n])}for(var Ol=0;Ol<ff.length;Ol++){var zl=ff[Ol],TS=zl.toLowerCase(),AS=zl[0].toUpperCase()+zl.slice(1);Sn(TS,"on"+AS)}Sn(lf,"onAnimationEnd"),Sn(cf,"onAnimationIteration"),Sn(uf,"onAnimationStart"),Sn("dblclick","onDoubleClick"),Sn("focusin","onFocus"),Sn("focusout","onBlur"),Sn(hf,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ks="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(" "),IS=new Set("cancel close invalid load scroll toggle".split(" ").concat(ks));function pf(n,r,l){var h=n.type||"unknown-event";n.currentTarget=l,Ty(h,r,void 0,n),n.currentTarget=null}function mf(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var h=n[l],f=h.event;h=h.listeners;e:{var g=void 0;if(r)for(var E=h.length-1;0<=E;E--){var O=h[E],U=O.instance,se=O.currentTarget;if(O=O.listener,U!==g&&f.isPropagationStopped())break e;pf(f,O,se),g=U}else for(E=0;E<h.length;E++){if(O=h[E],U=O.instance,se=O.currentTarget,O=O.listener,U!==g&&f.isPropagationStopped())break e;pf(f,O,se),g=U}}}if(yo)throw n=gl,yo=!1,gl=null,n}function lt(n,r){var l=r[Vl];l===void 0&&(l=r[Vl]=new Set);var h=n+"__bubble";l.has(h)||(gf(r,n,2,!1),l.add(h))}function Fl(n,r,l){var h=0;r&&(h|=4),gf(l,n,h,r)}var Io="_reactListening"+Math.random().toString(36).slice(2);function Cs(n){if(!n[Io]){n[Io]=!0,s.forEach(function(l){l!=="selectionchange"&&(IS.has(l)||Fl(l,!1,n),Fl(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Io]||(r[Io]=!0,Fl("selectionchange",!1,r))}}function gf(n,r,l,h){switch(Od(r)){case 1:var f=Gy;break;case 4:f=Qy;break;default:f=kl}l=f.bind(null,r,l,n),f=void 0,!ml||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),h?f!==void 0?n.addEventListener(r,l,{capture:!0,passive:f}):n.addEventListener(r,l,!0):f!==void 0?n.addEventListener(r,l,{passive:f}):n.addEventListener(r,l,!1)}function Hl(n,r,l,h,f){var g=h;if((r&1)===0&&(r&2)===0&&h!==null)e:for(;;){if(h===null)return;var E=h.tag;if(E===3||E===4){var O=h.stateNode.containerInfo;if(O===f||O.nodeType===8&&O.parentNode===f)break;if(E===4)for(E=h.return;E!==null;){var U=E.tag;if((U===3||U===4)&&(U=E.stateNode.containerInfo,U===f||U.nodeType===8&&U.parentNode===f))return;E=E.return}for(;O!==null;){if(E=Kn(O),E===null)return;if(U=E.tag,U===5||U===6){h=g=E;continue e}O=O.parentNode}}h=h.return}Sd(function(){var se=g,ve=di(l),_e=[];e:{var ge=df.get(n);if(ge!==void 0){var Re=El,Le=n;switch(n){case"keypress":if(Do(l)===0)break e;case"keydown":case"keyup":Re=dS;break;case"focusin":Le="focus",Re=Pl;break;case"focusout":Le="blur",Re=Pl;break;case"beforeblur":case"afterblur":Re=Pl;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Re=Hd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Re=eS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Re=mS;break;case lf:case cf:case uf:Re=nS;break;case hf:Re=vS;break;case"scroll":Re=Jy;break;case"wheel":Re=yS;break;case"copy":case"cut":case"paste":Re=sS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Re=Wd}var Te=(r&4)!==0,bt=!Te&&n==="scroll",te=Te?ge!==null?ge+"Capture":null:ge;Te=[];for(var Y=se,ie;Y!==null;){ie=Y;var ye=ie.stateNode;if(ie.tag===5&&ye!==null&&(ie=ye,te!==null&&(ye=os(Y,te),ye!=null&&Te.push(xs(Y,ye,ie)))),bt)break;Y=Y.return}0<Te.length&&(ge=new Re(ge,Le,null,l,ve),_e.push({event:ge,listeners:Te}))}}if((r&7)===0){e:{if(ge=n==="mouseover"||n==="pointerover",Re=n==="mouseout"||n==="pointerout",ge&&l!==qt&&(Le=l.relatedTarget||l.fromElement)&&(Kn(Le)||Le[tn]))break e;if((Re||ge)&&(ge=ve.window===ve?ve:(ge=ve.ownerDocument)?ge.defaultView||ge.parentWindow:window,Re?(Le=l.relatedTarget||l.toElement,Re=se,Le=Le?Kn(Le):null,Le!==null&&(bt=Un(Le),Le!==bt||Le.tag!==5&&Le.tag!==6)&&(Le=null)):(Re=null,Le=se),Re!==Le)){if(Te=Hd,ye="onMouseLeave",te="onMouseEnter",Y="mouse",(n==="pointerout"||n==="pointerover")&&(Te=Wd,ye="onPointerLeave",te="onPointerEnter",Y="pointer"),bt=Re==null?ge:Rr(Re),ie=Le==null?ge:Rr(Le),ge=new Te(ye,Y+"leave",Re,l,ve),ge.target=bt,ge.relatedTarget=ie,ye=null,Kn(ve)===se&&(Te=new Te(te,Y+"enter",Le,l,ve),Te.target=ie,Te.relatedTarget=bt,ye=Te),bt=ye,Re&&Le)t:{for(Te=Re,te=Le,Y=0,ie=Te;ie;ie=Er(ie))Y++;for(ie=0,ye=te;ye;ye=Er(ye))ie++;for(;0<Y-ie;)Te=Er(Te),Y--;for(;0<ie-Y;)te=Er(te),ie--;for(;Y--;){if(Te===te||te!==null&&Te===te.alternate)break t;Te=Er(Te),te=Er(te)}Te=null}else Te=null;Re!==null&&vf(_e,ge,Re,Te,!1),Le!==null&&bt!==null&&vf(_e,bt,Le,Te,!0)}}e:{if(ge=se?Rr(se):window,Re=ge.nodeName&&ge.nodeName.toLowerCase(),Re==="select"||Re==="input"&&ge.type==="file")var Ie=ES;else if(Xd(ge))if(Qd)Ie=DS;else{Ie=RS;var ze=NS}else(Re=ge.nodeName)&&Re.toLowerCase()==="input"&&(ge.type==="checkbox"||ge.type==="radio")&&(Ie=PS);if(Ie&&(Ie=Ie(n,se))){Gd(_e,Ie,l,ve);break e}ze&&ze(n,ge,se),n==="focusout"&&(ze=ge._wrapperState)&&ze.controlled&&ge.type==="number"&&J(ge,"number",ge.value)}switch(ze=se?Rr(se):window,n){case"focusin":(Xd(ze)||ze.contentEditable==="true")&&(Cr=ze,Al=se,bs=null);break;case"focusout":bs=Al=Cr=null;break;case"mousedown":Il=!0;break;case"contextmenu":case"mouseup":case"dragend":Il=!1,of(_e,l,ve);break;case"selectionchange":if(jS)break;case"keydown":case"keyup":of(_e,l,ve)}var Fe;if(Ml)e:{switch(n){case"compositionstart":var We="onCompositionStart";break e;case"compositionend":We="onCompositionEnd";break e;case"compositionupdate":We="onCompositionUpdate";break e}We=void 0}else kr?Vd(n,l)&&(We="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(We="onCompositionStart");We&&(Ud&&l.locale!=="ko"&&(kr||We!=="onCompositionStart"?We==="onCompositionEnd"&&kr&&(Fe=zd()):(yn=ve,xl="value"in yn?yn.value:yn.textContent,kr=!0)),ze=Bo(se,We),0<ze.length&&(We=new $d(We,n,null,l,ve),_e.push({event:We,listeners:ze}),Fe?We.data=Fe:(Fe=Yd(l),Fe!==null&&(We.data=Fe)))),(Fe=wS?bS(n,l):kS(n,l))&&(se=Bo(se,"onBeforeInput"),0<se.length&&(ve=new $d("onBeforeInput","beforeinput",null,l,ve),_e.push({event:ve,listeners:se}),ve.data=Fe))}mf(_e,r)})}function xs(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Bo(n,r){for(var l=r+"Capture",h=[];n!==null;){var f=n,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=os(n,l),g!=null&&h.unshift(xs(n,g,f)),g=os(n,r),g!=null&&h.push(xs(n,g,f))),n=n.return}return h}function Er(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function vf(n,r,l,h,f){for(var g=r._reactName,E=[];l!==null&&l!==h;){var O=l,U=O.alternate,se=O.stateNode;if(U!==null&&U===h)break;O.tag===5&&se!==null&&(O=se,f?(U=os(l,g),U!=null&&E.unshift(xs(l,U,O))):f||(U=os(l,g),U!=null&&E.push(xs(l,U,O)))),l=l.return}E.length!==0&&n.push({event:r,listeners:E})}var BS=/\r\n?/g,OS=/\u0000|\uFFFD/g;function _f(n){return(typeof n=="string"?n:""+n).replace(BS,`
38
+ `).replace(OS,"")}function Oo(n,r,l){if(r=_f(r),_f(n)!==r&&l)throw Error(i(425))}function zo(){}var $l=null,Wl=null;function Ul(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Kl=typeof setTimeout=="function"?setTimeout:void 0,zS=typeof clearTimeout=="function"?clearTimeout:void 0,yf=typeof Promise=="function"?Promise:void 0,FS=typeof queueMicrotask=="function"?queueMicrotask:typeof yf<"u"?function(n){return yf.resolve(null).then(n).catch(HS)}:Kl;function HS(n){setTimeout(function(){throw n})}function ql(n,r){var l=r,h=0;do{var f=l.nextSibling;if(n.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"){if(h===0){n.removeChild(f),ms(r);return}h--}else l!=="$"&&l!=="$?"&&l!=="$!"||h++;l=f}while(l);ms(r)}function wn(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function Sf(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return n;r--}else l==="/$"&&r++}n=n.previousSibling}return null}var Nr=Math.random().toString(36).slice(2),$i="__reactFiber$"+Nr,Es="__reactProps$"+Nr,tn="__reactContainer$"+Nr,Vl="__reactEvents$"+Nr,$S="__reactListeners$"+Nr,WS="__reactHandles$"+Nr;function Kn(n){var r=n[$i];if(r)return r;for(var l=n.parentNode;l;){if(r=l[tn]||l[$i]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=Sf(n);n!==null;){if(l=n[$i])return l;n=Sf(n)}return r}n=l,l=n.parentNode}return null}function Ns(n){return n=n[$i]||n[tn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function Rr(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(i(33))}function Fo(n){return n[Es]||null}var Yl=[],Pr=-1;function bn(n){return{current:n}}function ct(n){0>Pr||(n.current=Yl[Pr],Yl[Pr]=null,Pr--)}function at(n,r){Pr++,Yl[Pr]=n.current,n.current=r}var kn={},Vt=bn(kn),ni=bn(!1),qn=kn;function Dr(n,r){var l=n.type.contextTypes;if(!l)return kn;var h=n.stateNode;if(h&&h.__reactInternalMemoizedUnmaskedChildContext===r)return h.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in l)f[g]=r[g];return h&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=f),f}function ri(n){return n=n.childContextTypes,n!=null}function Ho(){ct(ni),ct(Vt)}function wf(n,r,l){if(Vt.current!==kn)throw Error(i(168));at(Vt,r),at(ni,l)}function bf(n,r,l){var h=n.stateNode;if(r=r.childContextTypes,typeof h.getChildContext!="function")return l;h=h.getChildContext();for(var f in h)if(!(f in r))throw Error(i(108,de(n)||"Unknown",f));return q({},l,h)}function $o(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||kn,qn=Vt.current,at(Vt,n),at(ni,ni.current),!0}function kf(n,r,l){var h=n.stateNode;if(!h)throw Error(i(169));l?(n=bf(n,r,qn),h.__reactInternalMemoizedMergedChildContext=n,ct(ni),ct(Vt),at(Vt,n)):ct(ni),at(ni,l)}var nn=null,Wo=!1,Xl=!1;function Cf(n){nn===null?nn=[n]:nn.push(n)}function US(n){Wo=!0,Cf(n)}function Cn(){if(!Xl&&nn!==null){Xl=!0;var n=0,r=nt;try{var l=nn;for(nt=1;n<l.length;n++){var h=l[n];do h=h(!0);while(h!==null)}nn=null,Wo=!1}catch(f){throw nn!==null&&(nn=nn.slice(n+1)),xd(vl,Cn),f}finally{nt=r,Xl=!1}}return null}var Mr=[],Lr=0,Uo=null,Ko=0,bi=[],ki=0,Vn=null,rn=1,sn="";function Yn(n,r){Mr[Lr++]=Ko,Mr[Lr++]=Uo,Uo=n,Ko=r}function xf(n,r,l){bi[ki++]=rn,bi[ki++]=sn,bi[ki++]=Vn,Vn=n;var h=rn;n=sn;var f=32-ji(h)-1;h&=~(1<<f),l+=1;var g=32-ji(r)+f;if(30<g){var E=f-f%5;g=(h&(1<<E)-1).toString(32),h>>=E,f-=E,rn=1<<32-ji(r)+f|l<<f|h,sn=g+n}else rn=1<<g|l<<f|h,sn=n}function Gl(n){n.return!==null&&(Yn(n,1),xf(n,1,0))}function Ql(n){for(;n===Uo;)Uo=Mr[--Lr],Mr[Lr]=null,Ko=Mr[--Lr],Mr[Lr]=null;for(;n===Vn;)Vn=bi[--ki],bi[ki]=null,sn=bi[--ki],bi[ki]=null,rn=bi[--ki],bi[ki]=null}var pi=null,mi=null,ht=!1,Ai=null;function Ef(n,r){var l=Ni(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=n,r=n.deletions,r===null?(n.deletions=[l],n.flags|=16):r.push(l)}function Nf(n,r){switch(n.tag){case 5:var l=n.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,pi=n,mi=wn(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,pi=n,mi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=Vn!==null?{id:rn,overflow:sn}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Ni(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,pi=n,mi=null,!0):!1;default:return!1}}function Jl(n){return(n.mode&1)!==0&&(n.flags&128)===0}function Zl(n){if(ht){var r=mi;if(r){var l=r;if(!Nf(n,r)){if(Jl(n))throw Error(i(418));r=wn(l.nextSibling);var h=pi;r&&Nf(n,r)?Ef(h,l):(n.flags=n.flags&-4097|2,ht=!1,pi=n)}}else{if(Jl(n))throw Error(i(418));n.flags=n.flags&-4097|2,ht=!1,pi=n}}}function Rf(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;pi=n}function qo(n){if(n!==pi)return!1;if(!ht)return Rf(n),ht=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!Ul(n.type,n.memoizedProps)),r&&(r=mi)){if(Jl(n))throw Pf(),Error(i(418));for(;r;)Ef(n,r),r=wn(r.nextSibling)}if(Rf(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"){if(r===0){mi=wn(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}mi=null}}else mi=pi?wn(n.stateNode.nextSibling):null;return!0}function Pf(){for(var n=mi;n;)n=wn(n.nextSibling)}function jr(){mi=pi=null,ht=!1}function ec(n){Ai===null?Ai=[n]:Ai.push(n)}var KS=M.ReactCurrentBatchConfig;function Rs(n,r,l){if(n=l.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(i(309));var h=l.stateNode}if(!h)throw Error(i(147,n));var f=h,g=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(E){var O=f.refs;E===null?delete O[g]:O[g]=E},r._stringRef=g,r)}if(typeof n!="string")throw Error(i(284));if(!l._owner)throw Error(i(290,n))}return n}function Vo(n,r){throw n=Object.prototype.toString.call(r),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function Df(n){var r=n._init;return r(n._payload)}function Mf(n){function r(te,Y){if(n){var ie=te.deletions;ie===null?(te.deletions=[Y],te.flags|=16):ie.push(Y)}}function l(te,Y){if(!n)return null;for(;Y!==null;)r(te,Y),Y=Y.sibling;return null}function h(te,Y){for(te=new Map;Y!==null;)Y.key!==null?te.set(Y.key,Y):te.set(Y.index,Y),Y=Y.sibling;return te}function f(te,Y){return te=Ln(te,Y),te.index=0,te.sibling=null,te}function g(te,Y,ie){return te.index=ie,n?(ie=te.alternate,ie!==null?(ie=ie.index,ie<Y?(te.flags|=2,Y):ie):(te.flags|=2,Y)):(te.flags|=1048576,Y)}function E(te){return n&&te.alternate===null&&(te.flags|=2),te}function O(te,Y,ie,ye){return Y===null||Y.tag!==6?(Y=Kc(ie,te.mode,ye),Y.return=te,Y):(Y=f(Y,ie),Y.return=te,Y)}function U(te,Y,ie,ye){var Ie=ie.type;return Ie===T?ve(te,Y,ie.props.children,ye,ie.key):Y!==null&&(Y.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===z&&Df(Ie)===Y.type)?(ye=f(Y,ie.props),ye.ref=Rs(te,Y,ie),ye.return=te,ye):(ye=va(ie.type,ie.key,ie.props,null,te.mode,ye),ye.ref=Rs(te,Y,ie),ye.return=te,ye)}function se(te,Y,ie,ye){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==ie.containerInfo||Y.stateNode.implementation!==ie.implementation?(Y=qc(ie,te.mode,ye),Y.return=te,Y):(Y=f(Y,ie.children||[]),Y.return=te,Y)}function ve(te,Y,ie,ye,Ie){return Y===null||Y.tag!==7?(Y=ir(ie,te.mode,ye,Ie),Y.return=te,Y):(Y=f(Y,ie),Y.return=te,Y)}function _e(te,Y,ie){if(typeof Y=="string"&&Y!==""||typeof Y=="number")return Y=Kc(""+Y,te.mode,ie),Y.return=te,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case Z:return ie=va(Y.type,Y.key,Y.props,null,te.mode,ie),ie.ref=Rs(te,null,Y),ie.return=te,ie;case F:return Y=qc(Y,te.mode,ie),Y.return=te,Y;case z:var ye=Y._init;return _e(te,ye(Y._payload),ie)}if(B(Y)||re(Y))return Y=ir(Y,te.mode,ie,null),Y.return=te,Y;Vo(te,Y)}return null}function ge(te,Y,ie,ye){var Ie=Y!==null?Y.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return Ie!==null?null:O(te,Y,""+ie,ye);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case Z:return ie.key===Ie?U(te,Y,ie,ye):null;case F:return ie.key===Ie?se(te,Y,ie,ye):null;case z:return Ie=ie._init,ge(te,Y,Ie(ie._payload),ye)}if(B(ie)||re(ie))return Ie!==null?null:ve(te,Y,ie,ye,null);Vo(te,ie)}return null}function Re(te,Y,ie,ye,Ie){if(typeof ye=="string"&&ye!==""||typeof ye=="number")return te=te.get(ie)||null,O(Y,te,""+ye,Ie);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case Z:return te=te.get(ye.key===null?ie:ye.key)||null,U(Y,te,ye,Ie);case F:return te=te.get(ye.key===null?ie:ye.key)||null,se(Y,te,ye,Ie);case z:var ze=ye._init;return Re(te,Y,ie,ze(ye._payload),Ie)}if(B(ye)||re(ye))return te=te.get(ie)||null,ve(Y,te,ye,Ie,null);Vo(Y,ye)}return null}function Le(te,Y,ie,ye){for(var Ie=null,ze=null,Fe=Y,We=Y=0,Tt=null;Fe!==null&&We<ie.length;We++){Fe.index>We?(Tt=Fe,Fe=null):Tt=Fe.sibling;var it=ge(te,Fe,ie[We],ye);if(it===null){Fe===null&&(Fe=Tt);break}n&&Fe&&it.alternate===null&&r(te,Fe),Y=g(it,Y,We),ze===null?Ie=it:ze.sibling=it,ze=it,Fe=Tt}if(We===ie.length)return l(te,Fe),ht&&Yn(te,We),Ie;if(Fe===null){for(;We<ie.length;We++)Fe=_e(te,ie[We],ye),Fe!==null&&(Y=g(Fe,Y,We),ze===null?Ie=Fe:ze.sibling=Fe,ze=Fe);return ht&&Yn(te,We),Ie}for(Fe=h(te,Fe);We<ie.length;We++)Tt=Re(Fe,te,We,ie[We],ye),Tt!==null&&(n&&Tt.alternate!==null&&Fe.delete(Tt.key===null?We:Tt.key),Y=g(Tt,Y,We),ze===null?Ie=Tt:ze.sibling=Tt,ze=Tt);return n&&Fe.forEach(function(jn){return r(te,jn)}),ht&&Yn(te,We),Ie}function Te(te,Y,ie,ye){var Ie=re(ie);if(typeof Ie!="function")throw Error(i(150));if(ie=Ie.call(ie),ie==null)throw Error(i(151));for(var ze=Ie=null,Fe=Y,We=Y=0,Tt=null,it=ie.next();Fe!==null&&!it.done;We++,it=ie.next()){Fe.index>We?(Tt=Fe,Fe=null):Tt=Fe.sibling;var jn=ge(te,Fe,it.value,ye);if(jn===null){Fe===null&&(Fe=Tt);break}n&&Fe&&jn.alternate===null&&r(te,Fe),Y=g(jn,Y,We),ze===null?Ie=jn:ze.sibling=jn,ze=jn,Fe=Tt}if(it.done)return l(te,Fe),ht&&Yn(te,We),Ie;if(Fe===null){for(;!it.done;We++,it=ie.next())it=_e(te,it.value,ye),it!==null&&(Y=g(it,Y,We),ze===null?Ie=it:ze.sibling=it,ze=it);return ht&&Yn(te,We),Ie}for(Fe=h(te,Fe);!it.done;We++,it=ie.next())it=Re(Fe,te,We,it.value,ye),it!==null&&(n&&it.alternate!==null&&Fe.delete(it.key===null?We:it.key),Y=g(it,Y,We),ze===null?Ie=it:ze.sibling=it,ze=it);return n&&Fe.forEach(function(Cw){return r(te,Cw)}),ht&&Yn(te,We),Ie}function bt(te,Y,ie,ye){if(typeof ie=="object"&&ie!==null&&ie.type===T&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case Z:e:{for(var Ie=ie.key,ze=Y;ze!==null;){if(ze.key===Ie){if(Ie=ie.type,Ie===T){if(ze.tag===7){l(te,ze.sibling),Y=f(ze,ie.props.children),Y.return=te,te=Y;break e}}else if(ze.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===z&&Df(Ie)===ze.type){l(te,ze.sibling),Y=f(ze,ie.props),Y.ref=Rs(te,ze,ie),Y.return=te,te=Y;break e}l(te,ze);break}else r(te,ze);ze=ze.sibling}ie.type===T?(Y=ir(ie.props.children,te.mode,ye,ie.key),Y.return=te,te=Y):(ye=va(ie.type,ie.key,ie.props,null,te.mode,ye),ye.ref=Rs(te,Y,ie),ye.return=te,te=ye)}return E(te);case F:e:{for(ze=ie.key;Y!==null;){if(Y.key===ze)if(Y.tag===4&&Y.stateNode.containerInfo===ie.containerInfo&&Y.stateNode.implementation===ie.implementation){l(te,Y.sibling),Y=f(Y,ie.children||[]),Y.return=te,te=Y;break e}else{l(te,Y);break}else r(te,Y);Y=Y.sibling}Y=qc(ie,te.mode,ye),Y.return=te,te=Y}return E(te);case z:return ze=ie._init,bt(te,Y,ze(ie._payload),ye)}if(B(ie))return Le(te,Y,ie,ye);if(re(ie))return Te(te,Y,ie,ye);Vo(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,Y!==null&&Y.tag===6?(l(te,Y.sibling),Y=f(Y,ie),Y.return=te,te=Y):(l(te,Y),Y=Kc(ie,te.mode,ye),Y.return=te,te=Y),E(te)):l(te,Y)}return bt}var Tr=Mf(!0),Lf=Mf(!1),Yo=bn(null),Xo=null,Ar=null,tc=null;function ic(){tc=Ar=Xo=null}function nc(n){var r=Yo.current;ct(Yo),n._currentValue=r}function rc(n,r,l){for(;n!==null;){var h=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,h!==null&&(h.childLanes|=r)):h!==null&&(h.childLanes&r)!==r&&(h.childLanes|=r),n===l)break;n=n.return}}function Ir(n,r){Xo=n,tc=Ar=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(si=!0),n.firstContext=null)}function Ci(n){var r=n._currentValue;if(tc!==n)if(n={context:n,memoizedValue:r,next:null},Ar===null){if(Xo===null)throw Error(i(308));Ar=n,Xo.dependencies={lanes:0,firstContext:n}}else Ar=Ar.next=n;return r}var Xn=null;function sc(n){Xn===null?Xn=[n]:Xn.push(n)}function jf(n,r,l,h){var f=r.interleaved;return f===null?(l.next=l,sc(r)):(l.next=f.next,f.next=l),r.interleaved=l,on(n,h)}function on(n,r){n.lanes|=r;var l=n.alternate;for(l!==null&&(l.lanes|=r),l=n,n=n.return;n!==null;)n.childLanes|=r,l=n.alternate,l!==null&&(l.childLanes|=r),l=n,n=n.return;return l.tag===3?l.stateNode:null}var xn=!1;function oc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Tf(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function an(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function En(n,r,l){var h=n.updateQueue;if(h===null)return null;if(h=h.shared,(et&2)!==0){var f=h.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),h.pending=r,on(n,l)}return f=h.interleaved,f===null?(r.next=r,sc(h)):(r.next=f.next,f.next=r),h.interleaved=r,on(n,l)}function Go(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var h=r.lanes;h&=n.pendingLanes,l|=h,r.lanes=l,Sl(n,l)}}function Af(n,r){var l=n.updateQueue,h=n.alternate;if(h!==null&&(h=h.updateQueue,l===h)){var f=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var E={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};g===null?f=g=E:g=g.next=E,l=l.next}while(l!==null);g===null?f=g=r:g=g.next=r}else f=g=r;l={baseState:h.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:h.shared,effects:h.effects},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}function Qo(n,r,l,h){var f=n.updateQueue;xn=!1;var g=f.firstBaseUpdate,E=f.lastBaseUpdate,O=f.shared.pending;if(O!==null){f.shared.pending=null;var U=O,se=U.next;U.next=null,E===null?g=se:E.next=se,E=U;var ve=n.alternate;ve!==null&&(ve=ve.updateQueue,O=ve.lastBaseUpdate,O!==E&&(O===null?ve.firstBaseUpdate=se:O.next=se,ve.lastBaseUpdate=U))}if(g!==null){var _e=f.baseState;E=0,ve=se=U=null,O=g;do{var ge=O.lane,Re=O.eventTime;if((h&ge)===ge){ve!==null&&(ve=ve.next={eventTime:Re,lane:0,tag:O.tag,payload:O.payload,callback:O.callback,next:null});e:{var Le=n,Te=O;switch(ge=r,Re=l,Te.tag){case 1:if(Le=Te.payload,typeof Le=="function"){_e=Le.call(Re,_e,ge);break e}_e=Le;break e;case 3:Le.flags=Le.flags&-65537|128;case 0:if(Le=Te.payload,ge=typeof Le=="function"?Le.call(Re,_e,ge):Le,ge==null)break e;_e=q({},_e,ge);break e;case 2:xn=!0}}O.callback!==null&&O.lane!==0&&(n.flags|=64,ge=f.effects,ge===null?f.effects=[O]:ge.push(O))}else Re={eventTime:Re,lane:ge,tag:O.tag,payload:O.payload,callback:O.callback,next:null},ve===null?(se=ve=Re,U=_e):ve=ve.next=Re,E|=ge;if(O=O.next,O===null){if(O=f.shared.pending,O===null)break;ge=O,O=ge.next,ge.next=null,f.lastBaseUpdate=ge,f.shared.pending=null}}while(!0);if(ve===null&&(U=_e),f.baseState=U,f.firstBaseUpdate=se,f.lastBaseUpdate=ve,r=f.shared.interleaved,r!==null){f=r;do E|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);Jn|=E,n.lanes=E,n.memoizedState=_e}}function If(n,r,l){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var h=n[r],f=h.callback;if(f!==null){if(h.callback=null,h=l,typeof f!="function")throw Error(i(191,f));f.call(h)}}}var Ps={},Wi=bn(Ps),Ds=bn(Ps),Ms=bn(Ps);function Gn(n){if(n===Ps)throw Error(i(174));return n}function ac(n,r){switch(at(Ms,r),at(Ds,n),at(Wi,Ps),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Pe(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=Pe(r,n)}ct(Wi),at(Wi,r)}function Br(){ct(Wi),ct(Ds),ct(Ms)}function Bf(n){Gn(Ms.current);var r=Gn(Wi.current),l=Pe(r,n.type);r!==l&&(at(Ds,n),at(Wi,l))}function lc(n){Ds.current===n&&(ct(Wi),ct(Ds))}var ft=bn(0);function Jo(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var cc=[];function uc(){for(var n=0;n<cc.length;n++)cc[n]._workInProgressVersionPrimary=null;cc.length=0}var Zo=M.ReactCurrentDispatcher,hc=M.ReactCurrentBatchConfig,Qn=0,pt=null,Nt=null,Lt=null,ea=!1,Ls=!1,js=0,qS=0;function Yt(){throw Error(i(321))}function dc(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Ti(n[l],r[l]))return!1;return!0}function fc(n,r,l,h,f,g){if(Qn=g,pt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Zo.current=n===null||n.memoizedState===null?GS:QS,n=l(h,f),Ls){g=0;do{if(Ls=!1,js=0,25<=g)throw Error(i(301));g+=1,Lt=Nt=null,r.updateQueue=null,Zo.current=JS,n=l(h,f)}while(Ls)}if(Zo.current=na,r=Nt!==null&&Nt.next!==null,Qn=0,Lt=Nt=pt=null,ea=!1,r)throw Error(i(300));return n}function pc(){var n=js!==0;return js=0,n}function Ui(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Lt===null?pt.memoizedState=Lt=n:Lt=Lt.next=n,Lt}function xi(){if(Nt===null){var n=pt.alternate;n=n!==null?n.memoizedState:null}else n=Nt.next;var r=Lt===null?pt.memoizedState:Lt.next;if(r!==null)Lt=r,Nt=n;else{if(n===null)throw Error(i(310));Nt=n,n={memoizedState:Nt.memoizedState,baseState:Nt.baseState,baseQueue:Nt.baseQueue,queue:Nt.queue,next:null},Lt===null?pt.memoizedState=Lt=n:Lt=Lt.next=n}return Lt}function Ts(n,r){return typeof r=="function"?r(n):r}function mc(n){var r=xi(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var h=Nt,f=h.baseQueue,g=l.pending;if(g!==null){if(f!==null){var E=f.next;f.next=g.next,g.next=E}h.baseQueue=f=g,l.pending=null}if(f!==null){g=f.next,h=h.baseState;var O=E=null,U=null,se=g;do{var ve=se.lane;if((Qn&ve)===ve)U!==null&&(U=U.next={lane:0,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),h=se.hasEagerState?se.eagerState:n(h,se.action);else{var _e={lane:ve,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null};U===null?(O=U=_e,E=h):U=U.next=_e,pt.lanes|=ve,Jn|=ve}se=se.next}while(se!==null&&se!==g);U===null?E=h:U.next=O,Ti(h,r.memoizedState)||(si=!0),r.memoizedState=h,r.baseState=E,r.baseQueue=U,l.lastRenderedState=h}if(n=l.interleaved,n!==null){f=n;do g=f.lane,pt.lanes|=g,Jn|=g,f=f.next;while(f!==n)}else f===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function gc(n){var r=xi(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var h=l.dispatch,f=l.pending,g=r.memoizedState;if(f!==null){l.pending=null;var E=f=f.next;do g=n(g,E.action),E=E.next;while(E!==f);Ti(g,r.memoizedState)||(si=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,h]}function Of(){}function zf(n,r){var l=pt,h=xi(),f=r(),g=!Ti(h.memoizedState,f);if(g&&(h.memoizedState=f,si=!0),h=h.queue,vc($f.bind(null,l,h,n),[n]),h.getSnapshot!==r||g||Lt!==null&&Lt.memoizedState.tag&1){if(l.flags|=2048,As(9,Hf.bind(null,l,h,f,r),void 0,null),jt===null)throw Error(i(349));(Qn&30)!==0||Ff(l,r,f)}return f}function Ff(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=pt.updateQueue,r===null?(r={lastEffect:null,stores:null},pt.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function Hf(n,r,l,h){r.value=l,r.getSnapshot=h,Wf(r)&&Uf(n)}function $f(n,r,l){return l(function(){Wf(r)&&Uf(n)})}function Wf(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Ti(n,l)}catch{return!0}}function Uf(n){var r=on(n,1);r!==null&&zi(r,n,1,-1)}function Kf(n){var r=Ui();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ts,lastRenderedState:n},r.queue=n,n=n.dispatch=XS.bind(null,pt,n),[r.memoizedState,n]}function As(n,r,l,h){return n={tag:n,create:r,destroy:l,deps:h,next:null},r=pt.updateQueue,r===null?(r={lastEffect:null,stores:null},pt.updateQueue=r,r.lastEffect=n.next=n):(l=r.lastEffect,l===null?r.lastEffect=n.next=n:(h=l.next,l.next=n,n.next=h,r.lastEffect=n)),n}function qf(){return xi().memoizedState}function ta(n,r,l,h){var f=Ui();pt.flags|=n,f.memoizedState=As(1|r,l,void 0,h===void 0?null:h)}function ia(n,r,l,h){var f=xi();h=h===void 0?null:h;var g=void 0;if(Nt!==null){var E=Nt.memoizedState;if(g=E.destroy,h!==null&&dc(h,E.deps)){f.memoizedState=As(r,l,g,h);return}}pt.flags|=n,f.memoizedState=As(1|r,l,g,h)}function Vf(n,r){return ta(8390656,8,n,r)}function vc(n,r){return ia(2048,8,n,r)}function Yf(n,r){return ia(4,2,n,r)}function Xf(n,r){return ia(4,4,n,r)}function Gf(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Qf(n,r,l){return l=l!=null?l.concat([n]):null,ia(4,4,Gf.bind(null,r,n),l)}function _c(){}function Jf(n,r){var l=xi();r=r===void 0?null:r;var h=l.memoizedState;return h!==null&&r!==null&&dc(r,h[1])?h[0]:(l.memoizedState=[n,r],n)}function Zf(n,r){var l=xi();r=r===void 0?null:r;var h=l.memoizedState;return h!==null&&r!==null&&dc(r,h[1])?h[0]:(n=n(),l.memoizedState=[n,r],n)}function ep(n,r,l){return(Qn&21)===0?(n.baseState&&(n.baseState=!1,si=!0),n.memoizedState=l):(Ti(l,r)||(l=Pd(),pt.lanes|=l,Jn|=l,n.baseState=!0),r)}function VS(n,r){var l=nt;nt=l!==0&&4>l?l:4,n(!0);var h=hc.transition;hc.transition={};try{n(!1),r()}finally{nt=l,hc.transition=h}}function tp(){return xi().memoizedState}function YS(n,r,l){var h=Dn(n);if(l={lane:h,action:l,hasEagerState:!1,eagerState:null,next:null},ip(n))np(r,l);else if(l=jf(n,r,l,h),l!==null){var f=Zt();zi(l,n,h,f),rp(l,r,h)}}function XS(n,r,l){var h=Dn(n),f={lane:h,action:l,hasEagerState:!1,eagerState:null,next:null};if(ip(n))np(r,f);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var E=r.lastRenderedState,O=g(E,l);if(f.hasEagerState=!0,f.eagerState=O,Ti(O,E)){var U=r.interleaved;U===null?(f.next=f,sc(r)):(f.next=U.next,U.next=f),r.interleaved=f;return}}catch{}finally{}l=jf(n,r,f,h),l!==null&&(f=Zt(),zi(l,n,h,f),rp(l,r,h))}}function ip(n){var r=n.alternate;return n===pt||r!==null&&r===pt}function np(n,r){Ls=ea=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function rp(n,r,l){if((l&4194240)!==0){var h=r.lanes;h&=n.pendingLanes,l|=h,r.lanes=l,Sl(n,l)}}var na={readContext:Ci,useCallback:Yt,useContext:Yt,useEffect:Yt,useImperativeHandle:Yt,useInsertionEffect:Yt,useLayoutEffect:Yt,useMemo:Yt,useReducer:Yt,useRef:Yt,useState:Yt,useDebugValue:Yt,useDeferredValue:Yt,useTransition:Yt,useMutableSource:Yt,useSyncExternalStore:Yt,useId:Yt,unstable_isNewReconciler:!1},GS={readContext:Ci,useCallback:function(n,r){return Ui().memoizedState=[n,r===void 0?null:r],n},useContext:Ci,useEffect:Vf,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,ta(4194308,4,Gf.bind(null,r,n),l)},useLayoutEffect:function(n,r){return ta(4194308,4,n,r)},useInsertionEffect:function(n,r){return ta(4,2,n,r)},useMemo:function(n,r){var l=Ui();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var h=Ui();return r=l!==void 0?l(r):r,h.memoizedState=h.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},h.queue=n,n=n.dispatch=YS.bind(null,pt,n),[h.memoizedState,n]},useRef:function(n){var r=Ui();return n={current:n},r.memoizedState=n},useState:Kf,useDebugValue:_c,useDeferredValue:function(n){return Ui().memoizedState=n},useTransition:function(){var n=Kf(!1),r=n[0];return n=VS.bind(null,n[1]),Ui().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var h=pt,f=Ui();if(ht){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),jt===null)throw Error(i(349));(Qn&30)!==0||Ff(h,r,l)}f.memoizedState=l;var g={value:l,getSnapshot:r};return f.queue=g,Vf($f.bind(null,h,g,n),[n]),h.flags|=2048,As(9,Hf.bind(null,h,g,l,r),void 0,null),l},useId:function(){var n=Ui(),r=jt.identifierPrefix;if(ht){var l=sn,h=rn;l=(h&~(1<<32-ji(h)-1)).toString(32)+l,r=":"+r+"R"+l,l=js++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=qS++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},QS={readContext:Ci,useCallback:Jf,useContext:Ci,useEffect:vc,useImperativeHandle:Qf,useInsertionEffect:Yf,useLayoutEffect:Xf,useMemo:Zf,useReducer:mc,useRef:qf,useState:function(){return mc(Ts)},useDebugValue:_c,useDeferredValue:function(n){var r=xi();return ep(r,Nt.memoizedState,n)},useTransition:function(){var n=mc(Ts)[0],r=xi().memoizedState;return[n,r]},useMutableSource:Of,useSyncExternalStore:zf,useId:tp,unstable_isNewReconciler:!1},JS={readContext:Ci,useCallback:Jf,useContext:Ci,useEffect:vc,useImperativeHandle:Qf,useInsertionEffect:Yf,useLayoutEffect:Xf,useMemo:Zf,useReducer:gc,useRef:qf,useState:function(){return gc(Ts)},useDebugValue:_c,useDeferredValue:function(n){var r=xi();return Nt===null?r.memoizedState=n:ep(r,Nt.memoizedState,n)},useTransition:function(){var n=gc(Ts)[0],r=xi().memoizedState;return[n,r]},useMutableSource:Of,useSyncExternalStore:zf,useId:tp,unstable_isNewReconciler:!1};function Ii(n,r){if(n&&n.defaultProps){r=q({},r),n=n.defaultProps;for(var l in n)r[l]===void 0&&(r[l]=n[l]);return r}return r}function yc(n,r,l,h){r=n.memoizedState,l=l(h,r),l=l==null?r:q({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var ra={isMounted:function(n){return(n=n._reactInternals)?Un(n)===n:!1},enqueueSetState:function(n,r,l){n=n._reactInternals;var h=Zt(),f=Dn(n),g=an(h,f);g.payload=r,l!=null&&(g.callback=l),r=En(n,g,f),r!==null&&(zi(r,n,f,h),Go(r,n,f))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var h=Zt(),f=Dn(n),g=an(h,f);g.tag=1,g.payload=r,l!=null&&(g.callback=l),r=En(n,g,f),r!==null&&(zi(r,n,f,h),Go(r,n,f))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=Zt(),h=Dn(n),f=an(l,h);f.tag=2,r!=null&&(f.callback=r),r=En(n,f,h),r!==null&&(zi(r,n,h,l),Go(r,n,h))}};function sp(n,r,l,h,f,g,E){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(h,g,E):r.prototype&&r.prototype.isPureReactComponent?!ws(l,h)||!ws(f,g):!0}function op(n,r,l){var h=!1,f=kn,g=r.contextType;return typeof g=="object"&&g!==null?g=Ci(g):(f=ri(r)?qn:Vt.current,h=r.contextTypes,g=(h=h!=null)?Dr(n,f):kn),r=new r(l,g),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=ra,n.stateNode=r,r._reactInternals=n,h&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=f,n.__reactInternalMemoizedMaskedChildContext=g),r}function ap(n,r,l,h){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,h),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,h),r.state!==n&&ra.enqueueReplaceState(r,r.state,null)}function Sc(n,r,l,h){var f=n.stateNode;f.props=l,f.state=n.memoizedState,f.refs={},oc(n);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Ci(g):(g=ri(r)?qn:Vt.current,f.context=Dr(n,g)),f.state=n.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(yc(n,r,g,l),f.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof f.getSnapshotBeforeUpdate=="function"||typeof f.UNSAFE_componentWillMount!="function"&&typeof f.componentWillMount!="function"||(r=f.state,typeof f.componentWillMount=="function"&&f.componentWillMount(),typeof f.UNSAFE_componentWillMount=="function"&&f.UNSAFE_componentWillMount(),r!==f.state&&ra.enqueueReplaceState(f,f.state,null),Qo(n,l,f,h),f.state=n.memoizedState),typeof f.componentDidMount=="function"&&(n.flags|=4194308)}function Or(n,r){try{var l="",h=r;do l+=V(h),h=h.return;while(h);var f=l}catch(g){f=`
39
+ Error generating stack: `+g.message+`
40
+ `+g.stack}return{value:n,source:r,stack:f,digest:null}}function wc(n,r,l){return{value:n,source:null,stack:l??null,digest:r??null}}function bc(n,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var ZS=typeof WeakMap=="function"?WeakMap:Map;function lp(n,r,l){l=an(-1,l),l.tag=3,l.payload={element:null};var h=r.value;return l.callback=function(){ha||(ha=!0,Bc=h),bc(n,r)},l}function cp(n,r,l){l=an(-1,l),l.tag=3;var h=n.type.getDerivedStateFromError;if(typeof h=="function"){var f=r.value;l.payload=function(){return h(f)},l.callback=function(){bc(n,r)}}var g=n.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(l.callback=function(){bc(n,r),typeof h!="function"&&(Rn===null?Rn=new Set([this]):Rn.add(this));var E=r.stack;this.componentDidCatch(r.value,{componentStack:E!==null?E:""})}),l}function up(n,r,l){var h=n.pingCache;if(h===null){h=n.pingCache=new ZS;var f=new Set;h.set(r,f)}else f=h.get(r),f===void 0&&(f=new Set,h.set(r,f));f.has(l)||(f.add(l),n=fw.bind(null,n,r,l),r.then(n,n))}function hp(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function dp(n,r,l,h,f){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=an(-1,1),r.tag=2,En(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=f,n)}var ew=M.ReactCurrentOwner,si=!1;function Jt(n,r,l,h){r.child=n===null?Lf(r,null,l,h):Tr(r,n.child,l,h)}function fp(n,r,l,h,f){l=l.render;var g=r.ref;return Ir(r,f),h=fc(n,r,l,h,g,f),l=pc(),n!==null&&!si?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,ln(n,r,f)):(ht&&l&&Gl(r),r.flags|=1,Jt(n,r,h,f),r.child)}function pp(n,r,l,h,f){if(n===null){var g=l.type;return typeof g=="function"&&!Uc(g)&&g.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=g,mp(n,r,g,h,f)):(n=va(l.type,null,h,r,r.mode,f),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,(n.lanes&f)===0){var E=g.memoizedProps;if(l=l.compare,l=l!==null?l:ws,l(E,h)&&n.ref===r.ref)return ln(n,r,f)}return r.flags|=1,n=Ln(g,h),n.ref=r.ref,n.return=r,r.child=n}function mp(n,r,l,h,f){if(n!==null){var g=n.memoizedProps;if(ws(g,h)&&n.ref===r.ref)if(si=!1,r.pendingProps=h=g,(n.lanes&f)!==0)(n.flags&131072)!==0&&(si=!0);else return r.lanes=n.lanes,ln(n,r,f)}return kc(n,r,l,h,f)}function gp(n,r,l){var h=r.pendingProps,f=h.children,g=n!==null?n.memoizedState:null;if(h.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},at(Fr,gi),gi|=l;else{if((l&1073741824)===0)return n=g!==null?g.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,at(Fr,gi),gi|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},h=g!==null?g.baseLanes:l,at(Fr,gi),gi|=h}else g!==null?(h=g.baseLanes|l,r.memoizedState=null):h=l,at(Fr,gi),gi|=h;return Jt(n,r,f,l),r.child}function vp(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function kc(n,r,l,h,f){var g=ri(l)?qn:Vt.current;return g=Dr(r,g),Ir(r,f),l=fc(n,r,l,h,g,f),h=pc(),n!==null&&!si?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~f,ln(n,r,f)):(ht&&h&&Gl(r),r.flags|=1,Jt(n,r,l,f),r.child)}function _p(n,r,l,h,f){if(ri(l)){var g=!0;$o(r)}else g=!1;if(Ir(r,f),r.stateNode===null)oa(n,r),op(r,l,h),Sc(r,l,h,f),h=!0;else if(n===null){var E=r.stateNode,O=r.memoizedProps;E.props=O;var U=E.context,se=l.contextType;typeof se=="object"&&se!==null?se=Ci(se):(se=ri(l)?qn:Vt.current,se=Dr(r,se));var ve=l.getDerivedStateFromProps,_e=typeof ve=="function"||typeof E.getSnapshotBeforeUpdate=="function";_e||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(O!==h||U!==se)&&ap(r,E,h,se),xn=!1;var ge=r.memoizedState;E.state=ge,Qo(r,h,E,f),U=r.memoizedState,O!==h||ge!==U||ni.current||xn?(typeof ve=="function"&&(yc(r,l,ve,h),U=r.memoizedState),(O=xn||sp(r,l,O,h,ge,U,se))?(_e||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(r.flags|=4194308)):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=h,r.memoizedState=U),E.props=h,E.state=U,E.context=se,h=O):(typeof E.componentDidMount=="function"&&(r.flags|=4194308),h=!1)}else{E=r.stateNode,Tf(n,r),O=r.memoizedProps,se=r.type===r.elementType?O:Ii(r.type,O),E.props=se,_e=r.pendingProps,ge=E.context,U=l.contextType,typeof U=="object"&&U!==null?U=Ci(U):(U=ri(l)?qn:Vt.current,U=Dr(r,U));var Re=l.getDerivedStateFromProps;(ve=typeof Re=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(O!==_e||ge!==U)&&ap(r,E,h,U),xn=!1,ge=r.memoizedState,E.state=ge,Qo(r,h,E,f);var Le=r.memoizedState;O!==_e||ge!==Le||ni.current||xn?(typeof Re=="function"&&(yc(r,l,Re,h),Le=r.memoizedState),(se=xn||sp(r,l,se,h,ge,Le,U)||!1)?(ve||typeof E.UNSAFE_componentWillUpdate!="function"&&typeof E.componentWillUpdate!="function"||(typeof E.componentWillUpdate=="function"&&E.componentWillUpdate(h,Le,U),typeof E.UNSAFE_componentWillUpdate=="function"&&E.UNSAFE_componentWillUpdate(h,Le,U)),typeof E.componentDidUpdate=="function"&&(r.flags|=4),typeof E.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof E.componentDidUpdate!="function"||O===n.memoizedProps&&ge===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&ge===n.memoizedState||(r.flags|=1024),r.memoizedProps=h,r.memoizedState=Le),E.props=h,E.state=Le,E.context=U,h=se):(typeof E.componentDidUpdate!="function"||O===n.memoizedProps&&ge===n.memoizedState||(r.flags|=4),typeof E.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&ge===n.memoizedState||(r.flags|=1024),h=!1)}return Cc(n,r,l,h,g,f)}function Cc(n,r,l,h,f,g){vp(n,r);var E=(r.flags&128)!==0;if(!h&&!E)return f&&kf(r,l,!1),ln(n,r,g);h=r.stateNode,ew.current=r;var O=E&&typeof l.getDerivedStateFromError!="function"?null:h.render();return r.flags|=1,n!==null&&E?(r.child=Tr(r,n.child,null,g),r.child=Tr(r,null,O,g)):Jt(n,r,O,g),r.memoizedState=h.state,f&&kf(r,l,!0),r.child}function yp(n){var r=n.stateNode;r.pendingContext?wf(n,r.pendingContext,r.pendingContext!==r.context):r.context&&wf(n,r.context,!1),ac(n,r.containerInfo)}function Sp(n,r,l,h,f){return jr(),ec(f),r.flags|=256,Jt(n,r,l,h),r.child}var xc={dehydrated:null,treeContext:null,retryLane:0};function Ec(n){return{baseLanes:n,cachePool:null,transitions:null}}function wp(n,r,l){var h=r.pendingProps,f=ft.current,g=!1,E=(r.flags&128)!==0,O;if((O=E)||(O=n!==null&&n.memoizedState===null?!1:(f&2)!==0),O?(g=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(f|=1),at(ft,f&1),n===null)return Zl(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(E=h.children,n=h.fallback,g?(h=r.mode,g=r.child,E={mode:"hidden",children:E},(h&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=E):g=_a(E,h,0,null),n=ir(n,h,l,null),g.return=r,n.return=r,g.sibling=n,r.child=g,r.child.memoizedState=Ec(l),r.memoizedState=xc,n):Nc(r,E));if(f=n.memoizedState,f!==null&&(O=f.dehydrated,O!==null))return tw(n,r,E,h,O,f,l);if(g){g=h.fallback,E=r.mode,f=n.child,O=f.sibling;var U={mode:"hidden",children:h.children};return(E&1)===0&&r.child!==f?(h=r.child,h.childLanes=0,h.pendingProps=U,r.deletions=null):(h=Ln(f,U),h.subtreeFlags=f.subtreeFlags&14680064),O!==null?g=Ln(O,g):(g=ir(g,E,l,null),g.flags|=2),g.return=r,h.return=r,h.sibling=g,r.child=h,h=g,g=r.child,E=n.child.memoizedState,E=E===null?Ec(l):{baseLanes:E.baseLanes|l,cachePool:null,transitions:E.transitions},g.memoizedState=E,g.childLanes=n.childLanes&~l,r.memoizedState=xc,h}return g=n.child,n=g.sibling,h=Ln(g,{mode:"visible",children:h.children}),(r.mode&1)===0&&(h.lanes=l),h.return=r,h.sibling=null,n!==null&&(l=r.deletions,l===null?(r.deletions=[n],r.flags|=16):l.push(n)),r.child=h,r.memoizedState=null,h}function Nc(n,r){return r=_a({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function sa(n,r,l,h){return h!==null&&ec(h),Tr(r,n.child,null,l),n=Nc(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function tw(n,r,l,h,f,g,E){if(l)return r.flags&256?(r.flags&=-257,h=wc(Error(i(422))),sa(n,r,E,h)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(g=h.fallback,f=r.mode,h=_a({mode:"visible",children:h.children},f,0,null),g=ir(g,f,E,null),g.flags|=2,h.return=r,g.return=r,h.sibling=g,r.child=h,(r.mode&1)!==0&&Tr(r,n.child,null,E),r.child.memoizedState=Ec(E),r.memoizedState=xc,g);if((r.mode&1)===0)return sa(n,r,E,null);if(f.data==="$!"){if(h=f.nextSibling&&f.nextSibling.dataset,h)var O=h.dgst;return h=O,g=Error(i(419)),h=wc(g,h,void 0),sa(n,r,E,h)}if(O=(E&n.childLanes)!==0,si||O){if(h=jt,h!==null){switch(E&-E){case 4:f=2;break;case 16:f=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(h.suspendedLanes|E))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,on(n,f),zi(h,n,f,-1))}return Wc(),h=wc(Error(i(421))),sa(n,r,E,h)}return f.data==="$?"?(r.flags|=128,r.child=n.child,r=pw.bind(null,n),f._reactRetry=r,null):(n=g.treeContext,mi=wn(f.nextSibling),pi=r,ht=!0,Ai=null,n!==null&&(bi[ki++]=rn,bi[ki++]=sn,bi[ki++]=Vn,rn=n.id,sn=n.overflow,Vn=r),r=Nc(r,h.children),r.flags|=4096,r)}function bp(n,r,l){n.lanes|=r;var h=n.alternate;h!==null&&(h.lanes|=r),rc(n.return,r,l)}function Rc(n,r,l,h,f){var g=n.memoizedState;g===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:h,tail:l,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=h,g.tail=l,g.tailMode=f)}function kp(n,r,l){var h=r.pendingProps,f=h.revealOrder,g=h.tail;if(Jt(n,r,h.children,l),h=ft.current,(h&2)!==0)h=h&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&bp(n,l,r);else if(n.tag===19)bp(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}h&=1}if(at(ft,h),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(l=r.child,f=null;l!==null;)n=l.alternate,n!==null&&Jo(n)===null&&(f=l),l=l.sibling;l=f,l===null?(f=r.child,r.child=null):(f=l.sibling,l.sibling=null),Rc(r,!1,f,l,g);break;case"backwards":for(l=null,f=r.child,r.child=null;f!==null;){if(n=f.alternate,n!==null&&Jo(n)===null){r.child=f;break}n=f.sibling,f.sibling=l,l=f,f=n}Rc(r,!0,l,null,g);break;case"together":Rc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function oa(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function ln(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),Jn|=r.lanes,(l&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(i(153));if(r.child!==null){for(n=r.child,l=Ln(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Ln(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function iw(n,r,l){switch(r.tag){case 3:yp(r),jr();break;case 5:Bf(r);break;case 1:ri(r.type)&&$o(r);break;case 4:ac(r,r.stateNode.containerInfo);break;case 10:var h=r.type._context,f=r.memoizedProps.value;at(Yo,h._currentValue),h._currentValue=f;break;case 13:if(h=r.memoizedState,h!==null)return h.dehydrated!==null?(at(ft,ft.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?wp(n,r,l):(at(ft,ft.current&1),n=ln(n,r,l),n!==null?n.sibling:null);at(ft,ft.current&1);break;case 19:if(h=(l&r.childLanes)!==0,(n.flags&128)!==0){if(h)return kp(n,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),at(ft,ft.current),h)break;return null;case 22:case 23:return r.lanes=0,gp(n,r,l)}return ln(n,r,l)}var Cp,Pc,xp,Ep;Cp=function(n,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)n.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Pc=function(){},xp=function(n,r,l,h){var f=n.memoizedProps;if(f!==h){n=r.stateNode,Gn(Wi.current);var g=null;switch(l){case"input":f=rt(n,f),h=rt(n,h),g=[];break;case"select":f=q({},f,{value:void 0}),h=q({},h,{value:void 0}),g=[];break;case"textarea":f=be(n,f),h=be(n,h),g=[];break;default:typeof f.onClick!="function"&&typeof h.onClick=="function"&&(n.onclick=zo)}Ne(l,h);var E;l=null;for(se in f)if(!h.hasOwnProperty(se)&&f.hasOwnProperty(se)&&f[se]!=null)if(se==="style"){var O=f[se];for(E in O)O.hasOwnProperty(E)&&(l||(l={}),l[E]="")}else se!=="dangerouslySetInnerHTML"&&se!=="children"&&se!=="suppressContentEditableWarning"&&se!=="suppressHydrationWarning"&&se!=="autoFocus"&&(o.hasOwnProperty(se)?g||(g=[]):(g=g||[]).push(se,null));for(se in h){var U=h[se];if(O=f!=null?f[se]:void 0,h.hasOwnProperty(se)&&U!==O&&(U!=null||O!=null))if(se==="style")if(O){for(E in O)!O.hasOwnProperty(E)||U&&U.hasOwnProperty(E)||(l||(l={}),l[E]="");for(E in U)U.hasOwnProperty(E)&&O[E]!==U[E]&&(l||(l={}),l[E]=U[E])}else l||(g||(g=[]),g.push(se,l)),l=U;else se==="dangerouslySetInnerHTML"?(U=U?U.__html:void 0,O=O?O.__html:void 0,U!=null&&O!==U&&(g=g||[]).push(se,U)):se==="children"?typeof U!="string"&&typeof U!="number"||(g=g||[]).push(se,""+U):se!=="suppressContentEditableWarning"&&se!=="suppressHydrationWarning"&&(o.hasOwnProperty(se)?(U!=null&&se==="onScroll"&&lt("scroll",n),g||O===U||(g=[])):(g=g||[]).push(se,U))}l&&(g=g||[]).push("style",l);var se=g;(r.updateQueue=se)&&(r.flags|=4)}},Ep=function(n,r,l,h){l!==h&&(r.flags|=4)};function Is(n,r){if(!ht)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var h=null;l!==null;)l.alternate!==null&&(h=l),l=l.sibling;h===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:h.sibling=null}}function Xt(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,h=0;if(r)for(var f=n.child;f!==null;)l|=f.lanes|f.childLanes,h|=f.subtreeFlags&14680064,h|=f.flags&14680064,f.return=n,f=f.sibling;else for(f=n.child;f!==null;)l|=f.lanes|f.childLanes,h|=f.subtreeFlags,h|=f.flags,f.return=n,f=f.sibling;return n.subtreeFlags|=h,n.childLanes=l,r}function nw(n,r,l){var h=r.pendingProps;switch(Ql(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xt(r),null;case 1:return ri(r.type)&&Ho(),Xt(r),null;case 3:return h=r.stateNode,Br(),ct(ni),ct(Vt),uc(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(n===null||n.child===null)&&(qo(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ai!==null&&(Fc(Ai),Ai=null))),Pc(n,r),Xt(r),null;case 5:lc(r);var f=Gn(Ms.current);if(l=r.type,n!==null&&r.stateNode!=null)xp(n,r,l,h,f),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!h){if(r.stateNode===null)throw Error(i(166));return Xt(r),null}if(n=Gn(Wi.current),qo(r)){h=r.stateNode,l=r.type;var g=r.memoizedProps;switch(h[$i]=r,h[Es]=g,n=(r.mode&1)!==0,l){case"dialog":lt("cancel",h),lt("close",h);break;case"iframe":case"object":case"embed":lt("load",h);break;case"video":case"audio":for(f=0;f<ks.length;f++)lt(ks[f],h);break;case"source":lt("error",h);break;case"img":case"image":case"link":lt("error",h),lt("load",h);break;case"details":lt("toggle",h);break;case"input":St(h,g),lt("invalid",h);break;case"select":h._wrapperState={wasMultiple:!!g.multiple},lt("invalid",h);break;case"textarea":Se(h,g),lt("invalid",h)}Ne(l,g),f=null;for(var E in g)if(g.hasOwnProperty(E)){var O=g[E];E==="children"?typeof O=="string"?h.textContent!==O&&(g.suppressHydrationWarning!==!0&&Oo(h.textContent,O,n),f=["children",O]):typeof O=="number"&&h.textContent!==""+O&&(g.suppressHydrationWarning!==!0&&Oo(h.textContent,O,n),f=["children",""+O]):o.hasOwnProperty(E)&&O!=null&&E==="onScroll"&&lt("scroll",h)}switch(l){case"input":Ye(h),Be(h,g,!0);break;case"textarea":Ye(h),ce(h);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(h.onclick=zo)}h=f,r.updateQueue=h,h!==null&&(r.flags|=4)}else{E=f.nodeType===9?f:f.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Me(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=E.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof h.is=="string"?n=E.createElement(l,{is:h.is}):(n=E.createElement(l),l==="select"&&(E=n,h.multiple?E.multiple=!0:h.size&&(E.size=h.size))):n=E.createElementNS(n,l),n[$i]=r,n[Es]=h,Cp(n,r,!1,!1),r.stateNode=n;e:{switch(E=Ve(l,h),l){case"dialog":lt("cancel",n),lt("close",n),f=h;break;case"iframe":case"object":case"embed":lt("load",n),f=h;break;case"video":case"audio":for(f=0;f<ks.length;f++)lt(ks[f],n);f=h;break;case"source":lt("error",n),f=h;break;case"img":case"image":case"link":lt("error",n),lt("load",n),f=h;break;case"details":lt("toggle",n),f=h;break;case"input":St(n,h),f=rt(n,h),lt("invalid",n);break;case"option":f=h;break;case"select":n._wrapperState={wasMultiple:!!h.multiple},f=q({},h,{value:void 0}),lt("invalid",n);break;case"textarea":Se(n,h),f=be(n,h),lt("invalid",n);break;default:f=h}Ne(l,f),O=f;for(g in O)if(O.hasOwnProperty(g)){var U=O[g];g==="style"?st(n,U):g==="dangerouslySetInnerHTML"?(U=U?U.__html:void 0,U!=null&&Oe(n,U)):g==="children"?typeof U=="string"?(l!=="textarea"||U!=="")&&$e(n,U):typeof U=="number"&&$e(n,""+U):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?U!=null&&g==="onScroll"&&lt("scroll",n):U!=null&&j(n,g,U,E))}switch(l){case"input":Ye(n),Be(n,h,!1);break;case"textarea":Ye(n),ce(n);break;case"option":h.value!=null&&n.setAttribute("value",""+ae(h.value));break;case"select":n.multiple=!!h.multiple,g=h.value,g!=null?fe(n,!!h.multiple,g,!1):h.defaultValue!=null&&fe(n,!!h.multiple,h.defaultValue,!0);break;default:typeof f.onClick=="function"&&(n.onclick=zo)}switch(l){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}}h&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Xt(r),null;case 6:if(n&&r.stateNode!=null)Ep(n,r,n.memoizedProps,h);else{if(typeof h!="string"&&r.stateNode===null)throw Error(i(166));if(l=Gn(Ms.current),Gn(Wi.current),qo(r)){if(h=r.stateNode,l=r.memoizedProps,h[$i]=r,(g=h.nodeValue!==l)&&(n=pi,n!==null))switch(n.tag){case 3:Oo(h.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Oo(h.nodeValue,l,(n.mode&1)!==0)}g&&(r.flags|=4)}else h=(l.nodeType===9?l:l.ownerDocument).createTextNode(h),h[$i]=r,r.stateNode=h}return Xt(r),null;case 13:if(ct(ft),h=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(ht&&mi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Pf(),jr(),r.flags|=98560,g=!1;else if(g=qo(r),h!==null&&h.dehydrated!==null){if(n===null){if(!g)throw Error(i(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(i(317));g[$i]=r}else jr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Xt(r),g=!1}else Ai!==null&&(Fc(Ai),Ai=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(h=h!==null,h!==(n!==null&&n.memoizedState!==null)&&h&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(ft.current&1)!==0?Rt===0&&(Rt=3):Wc())),r.updateQueue!==null&&(r.flags|=4),Xt(r),null);case 4:return Br(),Pc(n,r),n===null&&Cs(r.stateNode.containerInfo),Xt(r),null;case 10:return nc(r.type._context),Xt(r),null;case 17:return ri(r.type)&&Ho(),Xt(r),null;case 19:if(ct(ft),g=r.memoizedState,g===null)return Xt(r),null;if(h=(r.flags&128)!==0,E=g.rendering,E===null)if(h)Is(g,!1);else{if(Rt!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(E=Jo(n),E!==null){for(r.flags|=128,Is(g,!1),h=E.updateQueue,h!==null&&(r.updateQueue=h,r.flags|=4),r.subtreeFlags=0,h=l,l=r.child;l!==null;)g=l,n=h,g.flags&=14680066,E=g.alternate,E===null?(g.childLanes=0,g.lanes=n,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=E.childLanes,g.lanes=E.lanes,g.child=E.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=E.memoizedProps,g.memoizedState=E.memoizedState,g.updateQueue=E.updateQueue,g.type=E.type,n=E.dependencies,g.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),l=l.sibling;return at(ft,ft.current&1|2),r.child}n=n.sibling}g.tail!==null&&wt()>Hr&&(r.flags|=128,h=!0,Is(g,!1),r.lanes=4194304)}else{if(!h)if(n=Jo(E),n!==null){if(r.flags|=128,h=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),Is(g,!0),g.tail===null&&g.tailMode==="hidden"&&!E.alternate&&!ht)return Xt(r),null}else 2*wt()-g.renderingStartTime>Hr&&l!==1073741824&&(r.flags|=128,h=!0,Is(g,!1),r.lanes=4194304);g.isBackwards?(E.sibling=r.child,r.child=E):(l=g.last,l!==null?l.sibling=E:r.child=E,g.last=E)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=wt(),r.sibling=null,l=ft.current,at(ft,h?l&1|2:l&1),r):(Xt(r),null);case 22:case 23:return $c(),h=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==h&&(r.flags|=8192),h&&(r.mode&1)!==0?(gi&1073741824)!==0&&(Xt(r),r.subtreeFlags&6&&(r.flags|=8192)):Xt(r),null;case 24:return null;case 25:return null}throw Error(i(156,r.tag))}function rw(n,r){switch(Ql(r),r.tag){case 1:return ri(r.type)&&Ho(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Br(),ct(ni),ct(Vt),uc(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return lc(r),null;case 13:if(ct(ft),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(i(340));jr()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return ct(ft),null;case 4:return Br(),null;case 10:return nc(r.type._context),null;case 22:case 23:return $c(),null;case 24:return null;default:return null}}var aa=!1,Gt=!1,sw=typeof WeakSet=="function"?WeakSet:Set,De=null;function zr(n,r){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(h){vt(n,r,h)}else l.current=null}function Dc(n,r,l){try{l()}catch(h){vt(n,r,h)}}var Np=!1;function ow(n,r){if($l=No,n=sf(),Tl(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var h=l.getSelection&&l.getSelection();if(h&&h.rangeCount!==0){l=h.anchorNode;var f=h.anchorOffset,g=h.focusNode;h=h.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var E=0,O=-1,U=-1,se=0,ve=0,_e=n,ge=null;t:for(;;){for(var Re;_e!==l||f!==0&&_e.nodeType!==3||(O=E+f),_e!==g||h!==0&&_e.nodeType!==3||(U=E+h),_e.nodeType===3&&(E+=_e.nodeValue.length),(Re=_e.firstChild)!==null;)ge=_e,_e=Re;for(;;){if(_e===n)break t;if(ge===l&&++se===f&&(O=E),ge===g&&++ve===h&&(U=E),(Re=_e.nextSibling)!==null)break;_e=ge,ge=_e.parentNode}_e=Re}l=O===-1||U===-1?null:{start:O,end:U}}else l=null}l=l||{start:0,end:0}}else l=null;for(Wl={focusedElem:n,selectionRange:l},No=!1,De=r;De!==null;)if(r=De,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,De=n;else for(;De!==null;){r=De;try{var Le=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Le!==null){var Te=Le.memoizedProps,bt=Le.memoizedState,te=r.stateNode,Y=te.getSnapshotBeforeUpdate(r.elementType===r.type?Te:Ii(r.type,Te),bt);te.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var ie=r.stateNode.containerInfo;ie.nodeType===1?ie.textContent="":ie.nodeType===9&&ie.documentElement&&ie.removeChild(ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(ye){vt(r,r.return,ye)}if(n=r.sibling,n!==null){n.return=r.return,De=n;break}De=r.return}return Le=Np,Np=!1,Le}function Bs(n,r,l){var h=r.updateQueue;if(h=h!==null?h.lastEffect:null,h!==null){var f=h=h.next;do{if((f.tag&n)===n){var g=f.destroy;f.destroy=void 0,g!==void 0&&Dc(r,l,g)}f=f.next}while(f!==h)}}function la(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&n)===n){var h=l.create;l.destroy=h()}l=l.next}while(l!==r)}}function Mc(n){var r=n.ref;if(r!==null){var l=n.stateNode;switch(n.tag){case 5:n=l;break;default:n=l}typeof r=="function"?r(n):r.current=n}}function Rp(n){var r=n.alternate;r!==null&&(n.alternate=null,Rp(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[$i],delete r[Es],delete r[Vl],delete r[$S],delete r[WS])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Pp(n){return n.tag===5||n.tag===3||n.tag===4}function Dp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Pp(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Lc(n,r,l){var h=n.tag;if(h===5||h===6)n=n.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(n,r):l.insertBefore(n,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(n,l)):(r=l,r.appendChild(n)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=zo));else if(h!==4&&(n=n.child,n!==null))for(Lc(n,r,l),n=n.sibling;n!==null;)Lc(n,r,l),n=n.sibling}function jc(n,r,l){var h=n.tag;if(h===5||h===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(h!==4&&(n=n.child,n!==null))for(jc(n,r,l),n=n.sibling;n!==null;)jc(n,r,l),n=n.sibling}var Ht=null,Bi=!1;function Nn(n,r,l){for(l=l.child;l!==null;)Mp(n,r,l),l=l.sibling}function Mp(n,r,l){if(Hi&&typeof Hi.onCommitFiberUnmount=="function")try{Hi.onCommitFiberUnmount(wo,l)}catch{}switch(l.tag){case 5:Gt||zr(l,r);case 6:var h=Ht,f=Bi;Ht=null,Nn(n,r,l),Ht=h,Bi=f,Ht!==null&&(Bi?(n=Ht,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):Ht.removeChild(l.stateNode));break;case 18:Ht!==null&&(Bi?(n=Ht,l=l.stateNode,n.nodeType===8?ql(n.parentNode,l):n.nodeType===1&&ql(n,l),ms(n)):ql(Ht,l.stateNode));break;case 4:h=Ht,f=Bi,Ht=l.stateNode.containerInfo,Bi=!0,Nn(n,r,l),Ht=h,Bi=f;break;case 0:case 11:case 14:case 15:if(!Gt&&(h=l.updateQueue,h!==null&&(h=h.lastEffect,h!==null))){f=h=h.next;do{var g=f,E=g.destroy;g=g.tag,E!==void 0&&((g&2)!==0||(g&4)!==0)&&Dc(l,r,E),f=f.next}while(f!==h)}Nn(n,r,l);break;case 1:if(!Gt&&(zr(l,r),h=l.stateNode,typeof h.componentWillUnmount=="function"))try{h.props=l.memoizedProps,h.state=l.memoizedState,h.componentWillUnmount()}catch(O){vt(l,r,O)}Nn(n,r,l);break;case 21:Nn(n,r,l);break;case 22:l.mode&1?(Gt=(h=Gt)||l.memoizedState!==null,Nn(n,r,l),Gt=h):Nn(n,r,l);break;default:Nn(n,r,l)}}function Lp(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new sw),r.forEach(function(h){var f=mw.bind(null,n,h);l.has(h)||(l.add(h),h.then(f,f))})}}function Oi(n,r){var l=r.deletions;if(l!==null)for(var h=0;h<l.length;h++){var f=l[h];try{var g=n,E=r,O=E;e:for(;O!==null;){switch(O.tag){case 5:Ht=O.stateNode,Bi=!1;break e;case 3:Ht=O.stateNode.containerInfo,Bi=!0;break e;case 4:Ht=O.stateNode.containerInfo,Bi=!0;break e}O=O.return}if(Ht===null)throw Error(i(160));Mp(g,E,f),Ht=null,Bi=!1;var U=f.alternate;U!==null&&(U.return=null),f.return=null}catch(se){vt(f,r,se)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)jp(r,n),r=r.sibling}function jp(n,r){var l=n.alternate,h=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Oi(r,n),Ki(n),h&4){try{Bs(3,n,n.return),la(3,n)}catch(Te){vt(n,n.return,Te)}try{Bs(5,n,n.return)}catch(Te){vt(n,n.return,Te)}}break;case 1:Oi(r,n),Ki(n),h&512&&l!==null&&zr(l,l.return);break;case 5:if(Oi(r,n),Ki(n),h&512&&l!==null&&zr(l,l.return),n.flags&32){var f=n.stateNode;try{$e(f,"")}catch(Te){vt(n,n.return,Te)}}if(h&4&&(f=n.stateNode,f!=null)){var g=n.memoizedProps,E=l!==null?l.memoizedProps:g,O=n.type,U=n.updateQueue;if(n.updateQueue=null,U!==null)try{O==="input"&&g.type==="radio"&&g.name!=null&&ne(f,g),Ve(O,E);var se=Ve(O,g);for(E=0;E<U.length;E+=2){var ve=U[E],_e=U[E+1];ve==="style"?st(f,_e):ve==="dangerouslySetInnerHTML"?Oe(f,_e):ve==="children"?$e(f,_e):j(f,ve,_e,se)}switch(O){case"input":le(f,g);break;case"textarea":Ae(f,g);break;case"select":var ge=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var Re=g.value;Re!=null?fe(f,!!g.multiple,Re,!1):ge!==!!g.multiple&&(g.defaultValue!=null?fe(f,!!g.multiple,g.defaultValue,!0):fe(f,!!g.multiple,g.multiple?[]:"",!1))}f[Es]=g}catch(Te){vt(n,n.return,Te)}}break;case 6:if(Oi(r,n),Ki(n),h&4){if(n.stateNode===null)throw Error(i(162));f=n.stateNode,g=n.memoizedProps;try{f.nodeValue=g}catch(Te){vt(n,n.return,Te)}}break;case 3:if(Oi(r,n),Ki(n),h&4&&l!==null&&l.memoizedState.isDehydrated)try{ms(r.containerInfo)}catch(Te){vt(n,n.return,Te)}break;case 4:Oi(r,n),Ki(n);break;case 13:Oi(r,n),Ki(n),f=n.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Ic=wt())),h&4&&Lp(n);break;case 22:if(ve=l!==null&&l.memoizedState!==null,n.mode&1?(Gt=(se=Gt)||ve,Oi(r,n),Gt=se):Oi(r,n),Ki(n),h&8192){if(se=n.memoizedState!==null,(n.stateNode.isHidden=se)&&!ve&&(n.mode&1)!==0)for(De=n,ve=n.child;ve!==null;){for(_e=De=ve;De!==null;){switch(ge=De,Re=ge.child,ge.tag){case 0:case 11:case 14:case 15:Bs(4,ge,ge.return);break;case 1:zr(ge,ge.return);var Le=ge.stateNode;if(typeof Le.componentWillUnmount=="function"){h=ge,l=ge.return;try{r=h,Le.props=r.memoizedProps,Le.state=r.memoizedState,Le.componentWillUnmount()}catch(Te){vt(h,l,Te)}}break;case 5:zr(ge,ge.return);break;case 22:if(ge.memoizedState!==null){Ip(_e);continue}}Re!==null?(Re.return=ge,De=Re):Ip(_e)}ve=ve.sibling}e:for(ve=null,_e=n;;){if(_e.tag===5){if(ve===null){ve=_e;try{f=_e.stateNode,se?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(O=_e.stateNode,U=_e.memoizedProps.style,E=U!=null&&U.hasOwnProperty("display")?U.display:null,O.style.display=Xe("display",E))}catch(Te){vt(n,n.return,Te)}}}else if(_e.tag===6){if(ve===null)try{_e.stateNode.nodeValue=se?"":_e.memoizedProps}catch(Te){vt(n,n.return,Te)}}else if((_e.tag!==22&&_e.tag!==23||_e.memoizedState===null||_e===n)&&_e.child!==null){_e.child.return=_e,_e=_e.child;continue}if(_e===n)break e;for(;_e.sibling===null;){if(_e.return===null||_e.return===n)break e;ve===_e&&(ve=null),_e=_e.return}ve===_e&&(ve=null),_e.sibling.return=_e.return,_e=_e.sibling}}break;case 19:Oi(r,n),Ki(n),h&4&&Lp(n);break;case 21:break;default:Oi(r,n),Ki(n)}}function Ki(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(Pp(l)){var h=l;break e}l=l.return}throw Error(i(160))}switch(h.tag){case 5:var f=h.stateNode;h.flags&32&&($e(f,""),h.flags&=-33);var g=Dp(n);jc(n,g,f);break;case 3:case 4:var E=h.stateNode.containerInfo,O=Dp(n);Lc(n,O,E);break;default:throw Error(i(161))}}catch(U){vt(n,n.return,U)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function aw(n,r,l){De=n,Tp(n)}function Tp(n,r,l){for(var h=(n.mode&1)!==0;De!==null;){var f=De,g=f.child;if(f.tag===22&&h){var E=f.memoizedState!==null||aa;if(!E){var O=f.alternate,U=O!==null&&O.memoizedState!==null||Gt;O=aa;var se=Gt;if(aa=E,(Gt=U)&&!se)for(De=f;De!==null;)E=De,U=E.child,E.tag===22&&E.memoizedState!==null?Bp(f):U!==null?(U.return=E,De=U):Bp(f);for(;g!==null;)De=g,Tp(g),g=g.sibling;De=f,aa=O,Gt=se}Ap(n)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,De=g):Ap(n)}}function Ap(n){for(;De!==null;){var r=De;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Gt||la(5,r);break;case 1:var h=r.stateNode;if(r.flags&4&&!Gt)if(l===null)h.componentDidMount();else{var f=r.elementType===r.type?l.memoizedProps:Ii(r.type,l.memoizedProps);h.componentDidUpdate(f,l.memoizedState,h.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&If(r,g,h);break;case 3:var E=r.updateQueue;if(E!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}If(r,E,l)}break;case 5:var O=r.stateNode;if(l===null&&r.flags&4){l=O;var U=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":U.autoFocus&&l.focus();break;case"img":U.src&&(l.src=U.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var se=r.alternate;if(se!==null){var ve=se.memoizedState;if(ve!==null){var _e=ve.dehydrated;_e!==null&&ms(_e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}Gt||r.flags&512&&Mc(r)}catch(ge){vt(r,r.return,ge)}}if(r===n){De=null;break}if(l=r.sibling,l!==null){l.return=r.return,De=l;break}De=r.return}}function Ip(n){for(;De!==null;){var r=De;if(r===n){De=null;break}var l=r.sibling;if(l!==null){l.return=r.return,De=l;break}De=r.return}}function Bp(n){for(;De!==null;){var r=De;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{la(4,r)}catch(U){vt(r,l,U)}break;case 1:var h=r.stateNode;if(typeof h.componentDidMount=="function"){var f=r.return;try{h.componentDidMount()}catch(U){vt(r,f,U)}}var g=r.return;try{Mc(r)}catch(U){vt(r,g,U)}break;case 5:var E=r.return;try{Mc(r)}catch(U){vt(r,E,U)}}}catch(U){vt(r,r.return,U)}if(r===n){De=null;break}var O=r.sibling;if(O!==null){O.return=r.return,De=O;break}De=r.return}}var lw=Math.ceil,ca=M.ReactCurrentDispatcher,Tc=M.ReactCurrentOwner,Ei=M.ReactCurrentBatchConfig,et=0,jt=null,Ct=null,$t=0,gi=0,Fr=bn(0),Rt=0,Os=null,Jn=0,ua=0,Ac=0,zs=null,oi=null,Ic=0,Hr=1/0,cn=null,ha=!1,Bc=null,Rn=null,da=!1,Pn=null,fa=0,Fs=0,Oc=null,pa=-1,ma=0;function Zt(){return(et&6)!==0?wt():pa!==-1?pa:pa=wt()}function Dn(n){return(n.mode&1)===0?1:(et&2)!==0&&$t!==0?$t&-$t:KS.transition!==null?(ma===0&&(ma=Pd()),ma):(n=nt,n!==0||(n=window.event,n=n===void 0?16:Od(n.type)),n)}function zi(n,r,l,h){if(50<Fs)throw Fs=0,Oc=null,Error(i(185));us(n,l,h),((et&2)===0||n!==jt)&&(n===jt&&((et&2)===0&&(ua|=l),Rt===4&&Mn(n,$t)),ai(n,h),l===1&&et===0&&(r.mode&1)===0&&(Hr=wt()+500,Wo&&Cn()))}function ai(n,r){var l=n.callbackNode;Ky(n,r);var h=Co(n,n===jt?$t:0);if(h===0)l!==null&&Ed(l),n.callbackNode=null,n.callbackPriority=0;else if(r=h&-h,n.callbackPriority!==r){if(l!=null&&Ed(l),r===1)n.tag===0?US(zp.bind(null,n)):Cf(zp.bind(null,n)),FS(function(){(et&6)===0&&Cn()}),l=null;else{switch(Dd(h)){case 1:l=vl;break;case 4:l=Nd;break;case 16:l=So;break;case 536870912:l=Rd;break;default:l=So}l=Vp(l,Op.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function Op(n,r){if(pa=-1,ma=0,(et&6)!==0)throw Error(i(327));var l=n.callbackNode;if($r()&&n.callbackNode!==l)return null;var h=Co(n,n===jt?$t:0);if(h===0)return null;if((h&30)!==0||(h&n.expiredLanes)!==0||r)r=ga(n,h);else{r=h;var f=et;et|=2;var g=Hp();(jt!==n||$t!==r)&&(cn=null,Hr=wt()+500,er(n,r));do try{hw();break}catch(O){Fp(n,O)}while(!0);ic(),ca.current=g,et=f,Ct!==null?r=0:(jt=null,$t=0,r=Rt)}if(r!==0){if(r===2&&(f=_l(n),f!==0&&(h=f,r=zc(n,f))),r===1)throw l=Os,er(n,0),Mn(n,h),ai(n,wt()),l;if(r===6)Mn(n,h);else{if(f=n.current.alternate,(h&30)===0&&!cw(f)&&(r=ga(n,h),r===2&&(g=_l(n),g!==0&&(h=g,r=zc(n,g))),r===1))throw l=Os,er(n,0),Mn(n,h),ai(n,wt()),l;switch(n.finishedWork=f,n.finishedLanes=h,r){case 0:case 1:throw Error(i(345));case 2:tr(n,oi,cn);break;case 3:if(Mn(n,h),(h&130023424)===h&&(r=Ic+500-wt(),10<r)){if(Co(n,0)!==0)break;if(f=n.suspendedLanes,(f&h)!==h){Zt(),n.pingedLanes|=n.suspendedLanes&f;break}n.timeoutHandle=Kl(tr.bind(null,n,oi,cn),r);break}tr(n,oi,cn);break;case 4:if(Mn(n,h),(h&4194240)===h)break;for(r=n.eventTimes,f=-1;0<h;){var E=31-ji(h);g=1<<E,E=r[E],E>f&&(f=E),h&=~g}if(h=f,h=wt()-h,h=(120>h?120:480>h?480:1080>h?1080:1920>h?1920:3e3>h?3e3:4320>h?4320:1960*lw(h/1960))-h,10<h){n.timeoutHandle=Kl(tr.bind(null,n,oi,cn),h);break}tr(n,oi,cn);break;case 5:tr(n,oi,cn);break;default:throw Error(i(329))}}}return ai(n,wt()),n.callbackNode===l?Op.bind(null,n):null}function zc(n,r){var l=zs;return n.current.memoizedState.isDehydrated&&(er(n,r).flags|=256),n=ga(n,r),n!==2&&(r=oi,oi=l,r!==null&&Fc(r)),n}function Fc(n){oi===null?oi=n:oi.push.apply(oi,n)}function cw(n){for(var r=n;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var h=0;h<l.length;h++){var f=l[h],g=f.getSnapshot;f=f.value;try{if(!Ti(g(),f))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Mn(n,r){for(r&=~Ac,r&=~ua,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-ji(r),h=1<<l;n[l]=-1,r&=~h}}function zp(n){if((et&6)!==0)throw Error(i(327));$r();var r=Co(n,0);if((r&1)===0)return ai(n,wt()),null;var l=ga(n,r);if(n.tag!==0&&l===2){var h=_l(n);h!==0&&(r=h,l=zc(n,h))}if(l===1)throw l=Os,er(n,0),Mn(n,r),ai(n,wt()),l;if(l===6)throw Error(i(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,tr(n,oi,cn),ai(n,wt()),null}function Hc(n,r){var l=et;et|=1;try{return n(r)}finally{et=l,et===0&&(Hr=wt()+500,Wo&&Cn())}}function Zn(n){Pn!==null&&Pn.tag===0&&(et&6)===0&&$r();var r=et;et|=1;var l=Ei.transition,h=nt;try{if(Ei.transition=null,nt=1,n)return n()}finally{nt=h,Ei.transition=l,et=r,(et&6)===0&&Cn()}}function $c(){gi=Fr.current,ct(Fr)}function er(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,zS(l)),Ct!==null)for(l=Ct.return;l!==null;){var h=l;switch(Ql(h),h.tag){case 1:h=h.type.childContextTypes,h!=null&&Ho();break;case 3:Br(),ct(ni),ct(Vt),uc();break;case 5:lc(h);break;case 4:Br();break;case 13:ct(ft);break;case 19:ct(ft);break;case 10:nc(h.type._context);break;case 22:case 23:$c()}l=l.return}if(jt=n,Ct=n=Ln(n.current,null),$t=gi=r,Rt=0,Os=null,Ac=ua=Jn=0,oi=zs=null,Xn!==null){for(r=0;r<Xn.length;r++)if(l=Xn[r],h=l.interleaved,h!==null){l.interleaved=null;var f=h.next,g=l.pending;if(g!==null){var E=g.next;g.next=f,h.next=E}l.pending=h}Xn=null}return n}function Fp(n,r){do{var l=Ct;try{if(ic(),Zo.current=na,ea){for(var h=pt.memoizedState;h!==null;){var f=h.queue;f!==null&&(f.pending=null),h=h.next}ea=!1}if(Qn=0,Lt=Nt=pt=null,Ls=!1,js=0,Tc.current=null,l===null||l.return===null){Rt=1,Os=r,Ct=null;break}e:{var g=n,E=l.return,O=l,U=r;if(r=$t,O.flags|=32768,U!==null&&typeof U=="object"&&typeof U.then=="function"){var se=U,ve=O,_e=ve.tag;if((ve.mode&1)===0&&(_e===0||_e===11||_e===15)){var ge=ve.alternate;ge?(ve.updateQueue=ge.updateQueue,ve.memoizedState=ge.memoizedState,ve.lanes=ge.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Re=hp(E);if(Re!==null){Re.flags&=-257,dp(Re,E,O,g,r),Re.mode&1&&up(g,se,r),r=Re,U=se;var Le=r.updateQueue;if(Le===null){var Te=new Set;Te.add(U),r.updateQueue=Te}else Le.add(U);break e}else{if((r&1)===0){up(g,se,r),Wc();break e}U=Error(i(426))}}else if(ht&&O.mode&1){var bt=hp(E);if(bt!==null){(bt.flags&65536)===0&&(bt.flags|=256),dp(bt,E,O,g,r),ec(Or(U,O));break e}}g=U=Or(U,O),Rt!==4&&(Rt=2),zs===null?zs=[g]:zs.push(g),g=E;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var te=lp(g,U,r);Af(g,te);break e;case 1:O=U;var Y=g.type,ie=g.stateNode;if((g.flags&128)===0&&(typeof Y.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(Rn===null||!Rn.has(ie)))){g.flags|=65536,r&=-r,g.lanes|=r;var ye=cp(g,O,r);Af(g,ye);break e}}g=g.return}while(g!==null)}Wp(l)}catch(Ie){r=Ie,Ct===l&&l!==null&&(Ct=l=l.return);continue}break}while(!0)}function Hp(){var n=ca.current;return ca.current=na,n===null?na:n}function Wc(){(Rt===0||Rt===3||Rt===2)&&(Rt=4),jt===null||(Jn&268435455)===0&&(ua&268435455)===0||Mn(jt,$t)}function ga(n,r){var l=et;et|=2;var h=Hp();(jt!==n||$t!==r)&&(cn=null,er(n,r));do try{uw();break}catch(f){Fp(n,f)}while(!0);if(ic(),et=l,ca.current=h,Ct!==null)throw Error(i(261));return jt=null,$t=0,Rt}function uw(){for(;Ct!==null;)$p(Ct)}function hw(){for(;Ct!==null&&!Iy();)$p(Ct)}function $p(n){var r=qp(n.alternate,n,gi);n.memoizedProps=n.pendingProps,r===null?Wp(n):Ct=r,Tc.current=null}function Wp(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=nw(l,r,gi),l!==null){Ct=l;return}}else{if(l=rw(l,r),l!==null){l.flags&=32767,Ct=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{Rt=6,Ct=null;return}}if(r=r.sibling,r!==null){Ct=r;return}Ct=r=n}while(r!==null);Rt===0&&(Rt=5)}function tr(n,r,l){var h=nt,f=Ei.transition;try{Ei.transition=null,nt=1,dw(n,r,l,h)}finally{Ei.transition=f,nt=h}return null}function dw(n,r,l,h){do $r();while(Pn!==null);if((et&6)!==0)throw Error(i(327));l=n.finishedWork;var f=n.finishedLanes;if(l===null)return null;if(n.finishedWork=null,n.finishedLanes=0,l===n.current)throw Error(i(177));n.callbackNode=null,n.callbackPriority=0;var g=l.lanes|l.childLanes;if(qy(n,g),n===jt&&(Ct=jt=null,$t=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||da||(da=!0,Vp(So,function(){return $r(),null})),g=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||g){g=Ei.transition,Ei.transition=null;var E=nt;nt=1;var O=et;et|=4,Tc.current=null,ow(n,l),jp(l,n),LS(Wl),No=!!$l,Wl=$l=null,n.current=l,aw(l),By(),et=O,nt=E,Ei.transition=g}else n.current=l;if(da&&(da=!1,Pn=n,fa=f),g=n.pendingLanes,g===0&&(Rn=null),Fy(l.stateNode),ai(n,wt()),r!==null)for(h=n.onRecoverableError,l=0;l<r.length;l++)f=r[l],h(f.value,{componentStack:f.stack,digest:f.digest});if(ha)throw ha=!1,n=Bc,Bc=null,n;return(fa&1)!==0&&n.tag!==0&&$r(),g=n.pendingLanes,(g&1)!==0?n===Oc?Fs++:(Fs=0,Oc=n):Fs=0,Cn(),null}function $r(){if(Pn!==null){var n=Dd(fa),r=Ei.transition,l=nt;try{if(Ei.transition=null,nt=16>n?16:n,Pn===null)var h=!1;else{if(n=Pn,Pn=null,fa=0,(et&6)!==0)throw Error(i(331));var f=et;for(et|=4,De=n.current;De!==null;){var g=De,E=g.child;if((De.flags&16)!==0){var O=g.deletions;if(O!==null){for(var U=0;U<O.length;U++){var se=O[U];for(De=se;De!==null;){var ve=De;switch(ve.tag){case 0:case 11:case 15:Bs(8,ve,g)}var _e=ve.child;if(_e!==null)_e.return=ve,De=_e;else for(;De!==null;){ve=De;var ge=ve.sibling,Re=ve.return;if(Rp(ve),ve===se){De=null;break}if(ge!==null){ge.return=Re,De=ge;break}De=Re}}}var Le=g.alternate;if(Le!==null){var Te=Le.child;if(Te!==null){Le.child=null;do{var bt=Te.sibling;Te.sibling=null,Te=bt}while(Te!==null)}}De=g}}if((g.subtreeFlags&2064)!==0&&E!==null)E.return=g,De=E;else e:for(;De!==null;){if(g=De,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Bs(9,g,g.return)}var te=g.sibling;if(te!==null){te.return=g.return,De=te;break e}De=g.return}}var Y=n.current;for(De=Y;De!==null;){E=De;var ie=E.child;if((E.subtreeFlags&2064)!==0&&ie!==null)ie.return=E,De=ie;else e:for(E=Y;De!==null;){if(O=De,(O.flags&2048)!==0)try{switch(O.tag){case 0:case 11:case 15:la(9,O)}}catch(Ie){vt(O,O.return,Ie)}if(O===E){De=null;break e}var ye=O.sibling;if(ye!==null){ye.return=O.return,De=ye;break e}De=O.return}}if(et=f,Cn(),Hi&&typeof Hi.onPostCommitFiberRoot=="function")try{Hi.onPostCommitFiberRoot(wo,n)}catch{}h=!0}return h}finally{nt=l,Ei.transition=r}}return!1}function Up(n,r,l){r=Or(l,r),r=lp(n,r,1),n=En(n,r,1),r=Zt(),n!==null&&(us(n,1,r),ai(n,r))}function vt(n,r,l){if(n.tag===3)Up(n,n,l);else for(;r!==null;){if(r.tag===3){Up(r,n,l);break}else if(r.tag===1){var h=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Rn===null||!Rn.has(h))){n=Or(l,n),n=cp(r,n,1),r=En(r,n,1),n=Zt(),r!==null&&(us(r,1,n),ai(r,n));break}}r=r.return}}function fw(n,r,l){var h=n.pingCache;h!==null&&h.delete(r),r=Zt(),n.pingedLanes|=n.suspendedLanes&l,jt===n&&($t&l)===l&&(Rt===4||Rt===3&&($t&130023424)===$t&&500>wt()-Ic?er(n,0):Ac|=l),ai(n,r)}function Kp(n,r){r===0&&((n.mode&1)===0?r=1:(r=ko,ko<<=1,(ko&130023424)===0&&(ko=4194304)));var l=Zt();n=on(n,r),n!==null&&(us(n,r,l),ai(n,l))}function pw(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),Kp(n,l)}function mw(n,r){var l=0;switch(n.tag){case 13:var h=n.stateNode,f=n.memoizedState;f!==null&&(l=f.retryLane);break;case 19:h=n.stateNode;break;default:throw Error(i(314))}h!==null&&h.delete(r),Kp(n,l)}var qp;qp=function(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps||ni.current)si=!0;else{if((n.lanes&l)===0&&(r.flags&128)===0)return si=!1,iw(n,r,l);si=(n.flags&131072)!==0}else si=!1,ht&&(r.flags&1048576)!==0&&xf(r,Ko,r.index);switch(r.lanes=0,r.tag){case 2:var h=r.type;oa(n,r),n=r.pendingProps;var f=Dr(r,Vt.current);Ir(r,l),f=fc(null,r,h,n,f,l);var g=pc();return r.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,ri(h)?(g=!0,$o(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,oc(r),f.updater=ra,r.stateNode=f,f._reactInternals=r,Sc(r,h,n,l),r=Cc(null,r,h,!0,g,l)):(r.tag=0,ht&&g&&Gl(r),Jt(null,r,f,l),r=r.child),r;case 16:h=r.elementType;e:{switch(oa(n,r),n=r.pendingProps,f=h._init,h=f(h._payload),r.type=h,f=r.tag=vw(h),n=Ii(h,n),f){case 0:r=kc(null,r,h,n,l);break e;case 1:r=_p(null,r,h,n,l);break e;case 11:r=fp(null,r,h,n,l);break e;case 14:r=pp(null,r,h,Ii(h.type,n),l);break e}throw Error(i(306,h,""))}return r;case 0:return h=r.type,f=r.pendingProps,f=r.elementType===h?f:Ii(h,f),kc(n,r,h,f,l);case 1:return h=r.type,f=r.pendingProps,f=r.elementType===h?f:Ii(h,f),_p(n,r,h,f,l);case 3:e:{if(yp(r),n===null)throw Error(i(387));h=r.pendingProps,g=r.memoizedState,f=g.element,Tf(n,r),Qo(r,h,null,l);var E=r.memoizedState;if(h=E.element,g.isDehydrated)if(g={element:h,isDehydrated:!1,cache:E.cache,pendingSuspenseBoundaries:E.pendingSuspenseBoundaries,transitions:E.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Or(Error(i(423)),r),r=Sp(n,r,h,l,f);break e}else if(h!==f){f=Or(Error(i(424)),r),r=Sp(n,r,h,l,f);break e}else for(mi=wn(r.stateNode.containerInfo.firstChild),pi=r,ht=!0,Ai=null,l=Lf(r,null,h,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(jr(),h===f){r=ln(n,r,l);break e}Jt(n,r,h,l)}r=r.child}return r;case 5:return Bf(r),n===null&&Zl(r),h=r.type,f=r.pendingProps,g=n!==null?n.memoizedProps:null,E=f.children,Ul(h,f)?E=null:g!==null&&Ul(h,g)&&(r.flags|=32),vp(n,r),Jt(n,r,E,l),r.child;case 6:return n===null&&Zl(r),null;case 13:return wp(n,r,l);case 4:return ac(r,r.stateNode.containerInfo),h=r.pendingProps,n===null?r.child=Tr(r,null,h,l):Jt(n,r,h,l),r.child;case 11:return h=r.type,f=r.pendingProps,f=r.elementType===h?f:Ii(h,f),fp(n,r,h,f,l);case 7:return Jt(n,r,r.pendingProps,l),r.child;case 8:return Jt(n,r,r.pendingProps.children,l),r.child;case 12:return Jt(n,r,r.pendingProps.children,l),r.child;case 10:e:{if(h=r.type._context,f=r.pendingProps,g=r.memoizedProps,E=f.value,at(Yo,h._currentValue),h._currentValue=E,g!==null)if(Ti(g.value,E)){if(g.children===f.children&&!ni.current){r=ln(n,r,l);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var O=g.dependencies;if(O!==null){E=g.child;for(var U=O.firstContext;U!==null;){if(U.context===h){if(g.tag===1){U=an(-1,l&-l),U.tag=2;var se=g.updateQueue;if(se!==null){se=se.shared;var ve=se.pending;ve===null?U.next=U:(U.next=ve.next,ve.next=U),se.pending=U}}g.lanes|=l,U=g.alternate,U!==null&&(U.lanes|=l),rc(g.return,l,r),O.lanes|=l;break}U=U.next}}else if(g.tag===10)E=g.type===r.type?null:g.child;else if(g.tag===18){if(E=g.return,E===null)throw Error(i(341));E.lanes|=l,O=E.alternate,O!==null&&(O.lanes|=l),rc(E,l,r),E=g.sibling}else E=g.child;if(E!==null)E.return=g;else for(E=g;E!==null;){if(E===r){E=null;break}if(g=E.sibling,g!==null){g.return=E.return,E=g;break}E=E.return}g=E}Jt(n,r,f.children,l),r=r.child}return r;case 9:return f=r.type,h=r.pendingProps.children,Ir(r,l),f=Ci(f),h=h(f),r.flags|=1,Jt(n,r,h,l),r.child;case 14:return h=r.type,f=Ii(h,r.pendingProps),f=Ii(h.type,f),pp(n,r,h,f,l);case 15:return mp(n,r,r.type,r.pendingProps,l);case 17:return h=r.type,f=r.pendingProps,f=r.elementType===h?f:Ii(h,f),oa(n,r),r.tag=1,ri(h)?(n=!0,$o(r)):n=!1,Ir(r,l),op(r,h,f),Sc(r,h,f,l),Cc(null,r,h,!0,n,l);case 19:return kp(n,r,l);case 22:return gp(n,r,l)}throw Error(i(156,r.tag))};function Vp(n,r){return xd(n,r)}function gw(n,r,l,h){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=h,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ni(n,r,l,h){return new gw(n,r,l,h)}function Uc(n){return n=n.prototype,!(!n||!n.isReactComponent)}function vw(n){if(typeof n=="function")return Uc(n)?1:0;if(n!=null){if(n=n.$$typeof,n===A)return 11;if(n===I)return 14}return 2}function Ln(n,r){var l=n.alternate;return l===null?(l=Ni(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&14680064,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l}function va(n,r,l,h,f,g){var E=2;if(h=n,typeof n=="function")Uc(n)&&(E=1);else if(typeof n=="string")E=5;else e:switch(n){case T:return ir(l.children,f,g,r);case X:E=8,f|=8;break;case K:return n=Ni(12,l,r,f|2),n.elementType=K,n.lanes=g,n;case N:return n=Ni(13,l,r,f),n.elementType=N,n.lanes=g,n;case R:return n=Ni(19,l,r,f),n.elementType=R,n.lanes=g,n;case $:return _a(l,f,g,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case G:E=10;break e;case ee:E=9;break e;case A:E=11;break e;case I:E=14;break e;case z:E=16,h=null;break e}throw Error(i(130,n==null?n:typeof n,""))}return r=Ni(E,l,r,f),r.elementType=n,r.type=h,r.lanes=g,r}function ir(n,r,l,h){return n=Ni(7,n,h,r),n.lanes=l,n}function _a(n,r,l,h){return n=Ni(22,n,h,r),n.elementType=$,n.lanes=l,n.stateNode={isHidden:!1},n}function Kc(n,r,l){return n=Ni(6,n,null,r),n.lanes=l,n}function qc(n,r,l){return r=Ni(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function _w(n,r,l,h,f){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=yl(0),this.expirationTimes=yl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=yl(0),this.identifierPrefix=h,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Vc(n,r,l,h,f,g,E,O,U){return n=new _w(n,r,l,O,U),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ni(3,null,null,r),n.current=g,g.stateNode=n,g.memoizedState={element:h,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},oc(g),n}function yw(n,r,l){var h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:F,key:h==null?null:""+h,children:n,containerInfo:r,implementation:l}}function Yp(n){if(!n)return kn;n=n._reactInternals;e:{if(Un(n)!==n||n.tag!==1)throw Error(i(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(ri(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(i(171))}if(n.tag===1){var l=n.type;if(ri(l))return bf(n,l,r)}return r}function Xp(n,r,l,h,f,g,E,O,U){return n=Vc(l,h,!0,n,f,g,E,O,U),n.context=Yp(null),l=n.current,h=Zt(),f=Dn(l),g=an(h,f),g.callback=r??null,En(l,g,f),n.current.lanes=f,us(n,f,h),ai(n,h),n}function ya(n,r,l,h){var f=r.current,g=Zt(),E=Dn(f);return l=Yp(l),r.context===null?r.context=l:r.pendingContext=l,r=an(g,E),r.payload={element:n},h=h===void 0?null:h,h!==null&&(r.callback=h),n=En(f,r,E),n!==null&&(zi(n,f,E,g),Go(n,f,E)),E}function Sa(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function Gp(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function Yc(n,r){Gp(n,r),(n=n.alternate)&&Gp(n,r)}function Sw(){return null}var Qp=typeof reportError=="function"?reportError:function(n){console.error(n)};function Xc(n){this._internalRoot=n}wa.prototype.render=Xc.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(i(409));ya(n,r,null,null)},wa.prototype.unmount=Xc.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;Zn(function(){ya(null,n,null,null)}),r[tn]=null}};function wa(n){this._internalRoot=n}wa.prototype.unstable_scheduleHydration=function(n){if(n){var r=jd();n={blockedOn:null,target:n,priority:r};for(var l=0;l<_n.length&&r!==0&&r<_n[l].priority;l++);_n.splice(l,0,n),l===0&&Id(n)}};function Gc(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function ba(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function Jp(){}function ww(n,r,l,h,f){if(f){if(typeof h=="function"){var g=h;h=function(){var se=Sa(E);g.call(se)}}var E=Xp(r,h,n,0,null,!1,!1,"",Jp);return n._reactRootContainer=E,n[tn]=E.current,Cs(n.nodeType===8?n.parentNode:n),Zn(),E}for(;f=n.lastChild;)n.removeChild(f);if(typeof h=="function"){var O=h;h=function(){var se=Sa(U);O.call(se)}}var U=Vc(n,0,!1,null,null,!1,!1,"",Jp);return n._reactRootContainer=U,n[tn]=U.current,Cs(n.nodeType===8?n.parentNode:n),Zn(function(){ya(r,U,l,h)}),U}function ka(n,r,l,h,f){var g=l._reactRootContainer;if(g){var E=g;if(typeof f=="function"){var O=f;f=function(){var U=Sa(E);O.call(U)}}ya(r,E,n,f)}else E=ww(l,r,n,f,h);return Sa(E)}Md=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=cs(r.pendingLanes);l!==0&&(Sl(r,l|1),ai(r,wt()),(et&6)===0&&(Hr=wt()+500,Cn()))}break;case 13:Zn(function(){var h=on(n,1);if(h!==null){var f=Zt();zi(h,n,1,f)}}),Yc(n,1)}},wl=function(n){if(n.tag===13){var r=on(n,134217728);if(r!==null){var l=Zt();zi(r,n,134217728,l)}Yc(n,134217728)}},Ld=function(n){if(n.tag===13){var r=Dn(n),l=on(n,r);if(l!==null){var h=Zt();zi(l,n,r,h)}Yc(n,r)}},jd=function(){return nt},Td=function(n,r){var l=nt;try{return nt=n,r()}finally{nt=l}},fl=function(n,r,l){switch(r){case"input":if(le(n,l),r=l.name,l.type==="radio"&&r!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var h=l[r];if(h!==n&&h.form===n.form){var f=Fo(h);if(!f)throw Error(i(90));qe(h),le(h,f)}}}break;case"textarea":Ae(n,l);break;case"select":r=l.value,r!=null&&fe(n,!!l.multiple,r,!1)}},_d=Hc,yd=Zn;var bw={usingClientEntryPoint:!1,Events:[Ns,Rr,Fo,gd,vd,Hc]},Hs={findFiberByHostInstance:Kn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},kw={bundleType:Hs.bundleType,version:Hs.version,rendererPackageName:Hs.rendererPackageName,rendererConfig:Hs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=kd(n),n===null?null:n.stateNode},findFiberByHostInstance:Hs.findFiberByHostInstance||Sw,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ca=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ca.isDisabled&&Ca.supportsFiber)try{wo=Ca.inject(kw),Hi=Ca}catch{}}return li.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=bw,li.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Gc(r))throw Error(i(200));return yw(n,r,null,l)},li.createRoot=function(n,r){if(!Gc(n))throw Error(i(299));var l=!1,h="",f=Qp;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(h=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=Vc(n,1,!1,null,null,l,!1,h,f),n[tn]=r.current,Cs(n.nodeType===8?n.parentNode:n),new Xc(r)},li.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=kd(r),n=n===null?null:n.stateNode,n},li.flushSync=function(n){return Zn(n)},li.hydrate=function(n,r,l){if(!ba(r))throw Error(i(200));return ka(null,n,r,!0,l)},li.hydrateRoot=function(n,r,l){if(!Gc(n))throw Error(i(405));var h=l!=null&&l.hydratedSources||null,f=!1,g="",E=Qp;if(l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(g=l.identifierPrefix),l.onRecoverableError!==void 0&&(E=l.onRecoverableError)),r=Xp(r,null,n,1,l??null,f,!1,g,E),n[tn]=r.current,Cs(n),h)for(n=0;n<h.length;n++)l=h[n],f=l._getVersion,f=f(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,f]:r.mutableSourceEagerHydrationData.push(l,f);return new wa(r)},li.render=function(n,r,l){if(!ba(r))throw Error(i(200));return ka(null,n,r,!1,l)},li.unmountComponentAtNode=function(n){if(!ba(n))throw Error(i(40));return n._reactRootContainer?(Zn(function(){ka(null,null,n,!1,function(){n._reactRootContainer=null,n[tn]=null})}),!0):!1},li.unstable_batchedUpdates=Hc,li.unstable_renderSubtreeIntoContainer=function(n,r,l,h){if(!ba(l))throw Error(i(200));if(n==null||n._reactInternals===void 0)throw Error(i(38));return ka(n,r,l,!1,h)},li.version="18.3.1-next-f1338f8080-20240426",li}var om;function Lw(){if(om)return Zc.exports;om=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(),Zc.exports=Mw(),Zc.exports}var am;function jw(){if(am)return xa;am=1;var e=Lw();return xa.createRoot=e.createRoot,xa.hydrateRoot=e.hydrateRoot,xa}var Tw=jw();const Aw=Fh(Tw);function zt(e,t,i={}){return fetch(e,{...i,headers:{...i.headers||{},Authorization:`Bearer ${t}`}})}const Pv=e=>`nc_seen_${e}`;async function Ke(e,t,i={}){const s=await zt(e,t,{method:i.method||"GET",headers:{"content-type":"application/json"},body:i.body?JSON.stringify(i.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const hi=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Kt=(e,t)=>`${hi(e)}/fleet/${t}`,mr=(e,t)=>Ke(Kt(t,"status"),e),$h=(e,t,i)=>Ke(Kt(i,"up"),e,{method:"POST",body:t}),Ua=(e,t,i)=>Ke(Kt(i,"down"),e,{method:"POST",body:t}),Js=(e,t,i)=>Ke(Kt(i,"restart"),e,{method:"POST",body:{cell:t}}),Wh=(e,t)=>Ke(Kt(t,"definitions"),e),Iw=(e,t)=>Ke(Kt(t,"credentials/status"),e),lm=(e,t,i,s)=>Ke(Kt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:i}}),Bw=(e,t,i)=>Ke(Kt(i,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),Ow=(e,t,i)=>Ke(Kt(i,"define-engine"),e,{method:"POST",body:{def:t}}),zw=(e,t,i,s,o)=>Ke(Kt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:i,envChanges:s}}),Fw=(e,t,i)=>Ke(Kt(i,"remove-engine"),e,{method:"POST",body:{id:t}}),Hw=(e,t,i)=>Ke(Kt(i,"define-cell"),e,{method:"POST",body:{def:t}}),$w=(e,t,i,s)=>Ke(Kt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:i}}),Dv=(e,t,i=!1,s)=>Ke(Kt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:i}}),Ww=(e,t,i)=>Ke(Kt(i,"import-cell"),e,{method:"POST",body:t}),Uw=(e,t,i)=>Ke(Kt(i,"restore-cells"),e,{method:"POST",body:{cells:t}}),Kw=(e,t,i,s)=>Ke(Kt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!i}}),Uh=(e,t,i)=>Ke(`${hi(i)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Mv=(e,t,i,s)=>Ke(`${hi(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!i}}),Lv=(e,t,i)=>Ke(`${hi(i)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),jv=e=>Ke("/api/settings",e),qw=e=>Ke("/api/nodes",e),Vw=e=>Ke("/api/peers",e),Yw=e=>Ke("/api/topology",e),Tv=(e,t)=>Ke(`${hi(t)}/sessions`,e),Kh=(e,t)=>Ke(`${hi(t)}/config`,e),cm=(e,t)=>Ke(`${hi(t)}/topology`,e),Av=(e,t)=>Ke("/api/settings/config",e,{method:"POST",body:t}),Xw=e=>Ke("/api/settings/token/rotate",e,{method:"POST"}),Gw=(e,t)=>Ke("/api/settings/nodes/pair",e,{method:"POST",body:t}),um=(e,t,i=[])=>Ke(`${hi(i)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),Iv=(e,t,i)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:i}}),Qw=(e,t,i)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:i}),Jw=(e,t)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),qh=(e,t,i)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}/${i}`,e,{method:"POST"}),Zw=(e,t,i)=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:i}}),hm=(e,t,i,s=[])=>Ke(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:i,selected:s}}),e0=e=>Ke("/api/settings/service/regenerate",e,{method:"POST"}),t0=e=>Ke("/api/settings/update/check",e,{method:"POST"}),i0=e=>Ke("/api/settings/update/apply",e,{method:"POST"}),n0=(e,t=!0)=>Ke(`/api/asks${t?"?open=1":""}`,e),r0=(e,t,i)=>Ke(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:i}}),Ea=(e,t=[])=>Ke(`${hi(t)}/decks`,e),dm=(e,t,i=[])=>Ke(`${hi(i)}/decks`,e,{method:"POST",body:{name:t}}),Na=(e,t,i,s,o=[])=>Ke(`${hi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:i,expectedRevision:s}}),s0=(e,t,i,s,o=[])=>Ke(`${hi(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:i,expectedRevision:s}}),o0=(e,t,i,s=[])=>Ke(`${hi(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:i}}),a0={power:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M12 3v8"}),u.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:u.jsx("path",{d:"M4 6a2 2 0 0 1 2-2h3.6a2 2 0 0 1 1.4.6L12.4 6H18a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z"}),keyboard:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),u.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),u.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),u.jsx("path",{d:"M12 18v3"})]}),enter:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),u.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),u.jsx("path",{d:"M22 2 11 13"})]}),trash:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M4 7h16"}),u.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),u.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),u.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:u.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),u.jsx("polyline",{points:"21 3 21 8 16 8"})]}),upload:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M12 16V5"}),u.jsx("polyline",{points:"8 9 12 5 16 9"}),u.jsx("path",{d:"M5 20h14"})]}),chevronLeft:u.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:u.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:u.jsx("polyline",{points:"6 10 12 16 18 10"}),history:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),u.jsx("polyline",{points:"3 3 3 8 8 8"}),u.jsx("path",{d:"M12 7v5l3 2"})]}),attach:u.jsx("path",{d:"M21.44 11.05 12.25 20.24a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"}),file:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:u.jsxs(u.Fragment,{children:[u.jsx("path",{d:"M14.5 4h-5L7.5 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.5z"}),u.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),u.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),u.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:u.jsxs(u.Fragment,{children:[u.jsx("circle",{cx:"11",cy:"11",r:"7"}),u.jsx("path",{d:"M21 21l-4.35-4.35"}),u.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:u.jsxs(u.Fragment,{children:[u.jsx("circle",{cx:"11",cy:"11",r:"7"}),u.jsx("path",{d:"M21 21l-4.35-4.35"}),u.jsx("path",{d:"M8 11h6"})]}),gear:u.jsxs(u.Fragment,{children:[u.jsx("circle",{cx:"12",cy:"12",r:"3"}),u.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),copy:u.jsxs(u.Fragment,{children:[u.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),u.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function tt({name:e,size:t=20}){return u.jsx("svg",{className:"nc-icon",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a0[e]||null})}const l0=["all","pinned","active","off","technical"],Bv="nc_sidebar_views_v1",Ov="nc_sidebar_order_v1";function zv(e){return l0.includes(e)?e:"all"}function c0(e,t=[],i="all"){const s=zv(i);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function u0(e,t,i=[],s=[]){const o=i.indexOf(e.key),a=i.indexOf(t.key),c=o===-1?Number.MAX_SAFE_INTEGER:o,d=a===-1?Number.MAX_SAFE_INTEGER:a,m=s.indexOf(e.key),p=s.indexOf(t.key),_=m===-1?Number.MAX_SAFE_INTEGER:m,S=p===-1?Number.MAX_SAFE_INTEGER:p;return c-d||_-S||+!!t.live-+!!e.live||+!!t.fresh-+!!e.fresh||Number(t.activity||0)-Number(e.activity||0)||String(e.label||"").localeCompare(String(t.label||""))||String(e.key||"").localeCompare(String(t.key||""))}function h0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Ov));if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);a.length&&(i[s]=a)}return i}catch{return{}}}function Hn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function d0(e,t=globalThis.localStorage){try{t.setItem(Ov,JSON.stringify(e))}catch{}return e}function f0(e,t,i,s,o=[]){if(typeof t!="string"||!t||i===s)return e;const a=[...new Set(o.filter(y=>typeof y=="string"&&y))];if(!a.includes(i)||!a.includes(s))return e;const c=Hn(e,t).filter(y=>a.includes(y)),d=[...c,...a.filter(y=>!c.includes(y))],m=d.indexOf(i),p=d.indexOf(s);d.splice(m,1);const _=d.indexOf(s),S=m<p?_+1:_;return d.splice(S,0,i),{...e,[t]:d}}function p0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Bv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function fm(e,t){var i,s;return{open:((i=e==null?void 0:e[t])==null?void 0:i.open)!==!1,filter:zv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function m0(e,t=globalThis.localStorage){try{t.setItem(Bv,JSON.stringify(e))}catch{}return e}function pm(e,t=""){const i=String(t||"").trim().toLocaleLowerCase();return i?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(i):!0}function ur(e=[],t=[],i="all",s=[]){return[...e].filter(o=>c0(o,t,i)).sort((o,a)=>u0(o,a,t,s))}const Vh=["it","en","es"];function g0(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Vh.includes(t)?t:"en"}catch{return"en"}}const Ba=g0(),Fv="nc_lang",Uu="nc-lang";function Hv(){return typeof localStorage<"u"?localStorage:null}const Ra={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nuovo nome del nodo in NexusCrew","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","fleet-editor-unavailable":"Editor disponibile solo con il provider fleet builtin.","fleet-managed":"gestito da NexusCrew","fleet-custom":"comando personalizzato","fleet-managed-help":"Client, provider e avvio sono gestiti internamente; i segreti non vengono mostrati.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato e non entra in engine, backup o federazione.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata.","fleet-model-default":"modello predefinito (opzionale)","fleet-model-required":"modello (obbligatorio)","fleet-standard-permissions":"permessi standard","fleet-unsafe-permissions":"non sicuro · ignora approvazioni/sandbox","fleet-unsafe-warning":"Modalità non sicura esplicita: il worker può agire senza le normali approvazioni o protezioni sandbox.","fleet-provider-display":"nome visualizzato del provider","fleet-custom-provider-default":"Provider personalizzato","fleet-api-key-env":"NOME_VARIABILE_API_KEY","fleet-provider-id":"id-provider","fleet-custom-secret-help":"NexusCrew salva solo il nome della variabile d’ambiente, mai il suo valore.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle e system prompt. Token, API key e segreti provider non entrano mai nel file.","fleet-backup-export":"esporta","fleet-backup-import":"importa","fleet-backup-download":"scarica backup","fleet-backup-restore":"ripristina selezionate","fleet-backup-import-help":"Scegli un backup JSON, controlla le celle e seleziona l’engine di destinazione prima del ripristino.","fleet-backup-overwrite":"sovrascrive la cella esistente","fleet-backup-new":"nuova cella","fleet-backup-engine-missing":"scegli un engine disponibile","fleet-backup-restore-unavailable":"Il nodo selezionato supporta solo l’esportazione; aggiornalo per ripristinare backup.","fleet-backup-restored":"{n} celle ripristinate","fleet-backup-confirm-overwrite":"Sovrascrivere queste celle? {cells}","fleet-backup-needs-restart":"riavvio necessario: {cells}","fleet-backup-empty":"nessuna cella da esportare","fleet-backup-select-one":"seleziona almeno una cella","fleet-backup-too-large":"backup troppo grande (massimo 1 MB)","fleet-backup-invalid-json":"il file non contiene JSON valido","fleet-backup-invalid-format":"formato o versione del backup non supportati","fleet-backup-invalid-cell":"il backup contiene una cella non valida","fleet-backup-duplicate-cell":"il backup contiene ID cella duplicati","fleet-backup-invalid-engine":"il backup contiene un engine non valido","fleet-backup-duplicate-engine":"il backup contiene ID engine duplicati","fleet-backup-confirm-engine-overwrite":"Sovrascrivere questi engine? I valori ambiente già configurati sul target restano invariati. {engines}","fleet-backup-env-names":"nomi ambiente","fleet-backup-env-values-required":"i valori ambiente vanno configurati sul dispositivo","fleet-system-prompt":"system prompt",characters:"caratteri","select-all":"seleziona tutte","select-none":"nessuna",edit:"modifica",save:"salva",label:"etichetta","command-path":"path assoluto del comando","args-lines":"argomenti, uno per riga","env-write-only":"I valori env sono write-only: vuoto mantiene il valore esistente.","fleet-new-engine":"Nuovo engine","fleet-new-cell":"Nuova cella","fleet-saved":"Definizione salvata.","fleet-restart-confirm":"Modifica salvata. Riavviare ora: {cells}?","fleet-remove-engine":'Eliminare l’engine "{id}"?',"fleet-remove-cell":'Eliminare la cella "{id}"? Se è attiva verrà prima fermata.',"settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-remove-warning":"Elimina associazione, credenziali e tunnel locale. Non spegne il dispositivo remoto.","peer-inventory-title":"Nodi collegati al hub","peer-group-hubs":"Hub diretti","peer-group-clients":"Client collegati","peer-group-routed":"Nodi raggiungibili tramite la rete","peer-routed":"instradato","peer-routed-stale":"instradato, non raggiungibile","peer-visibility":"Visibilità nella rete","node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-pending":"Condivisione richiesta, ma il tunnel è giù: questo dispositivo non è ancora raggiungibile.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-local-private-down":"Privato, ma il collegamento all’hub è giù. Riconnetti per applicare e verificare la modalità privata.","share-local-reconnect":"Riconnetti e riconcilia","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-ssh":"ssh non valido (atteso user@host o alias)","err-port":"porta non valida (1–65535)","err-ssh-port":"porta SSH non valida (1–65535)","err-node-port":"porta NexusCrew non valida (1–65535)","node-sessions":"{n} sessioni","tunnel-down-since":"tunnel giù da {t}","node-unreachable":"nodo non raggiungibile","node-passive":"client offline · stato normale","node-offline":"nodo offline","node-offline-seen":"offline · visto {t} fa","node-needs-repair":"legacy · ripeti il pairing","asks-title":"domande dalle celle","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-off":"push non attive","push-denied":"permesso notifiche negato dal browser","push-unsupported":"push non supportate in questo browser","node-display-label":"Nome (etichetta)","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-unavailable-hint":"Configurazione engine non disponibile su questo nodo.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso completo. Se sei già collegato a un hub, viene usato automaticamente; altrimenti serve solo il suo indirizzo SSH raggiungibile.","invite-network-hint":"Crea un invito per la rete a cui sei già collegato. Il nuovo dispositivo entrerà attraverso l’hub, non si collegherà direttamente a questo dispositivo.","invite-network-label":"Rete di destinazione","invite-network-via":"Hub","invite-network-route":"Un solo collegamento verso l’hub; nodi, celle e deck vengono smistati internamente.","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"New node name in NexusCrew","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","fleet-editor-unavailable":"The editor is available only with the builtin fleet provider.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node and never enters engines, backups or federation.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified.","fleet-model-default":"default model (optional)","fleet-model-required":"model (required)","fleet-standard-permissions":"standard permissions","fleet-unsafe-permissions":"unsafe · bypass approvals/sandbox","fleet-unsafe-warning":"Explicit unsafe mode: the worker can act without normal approval or sandbox gates.","fleet-provider-display":"provider display name","fleet-custom-provider-default":"Custom provider","fleet-api-key-env":"API_KEY_ENV_NAME","fleet-provider-id":"provider-id","fleet-custom-secret-help":"NexusCrew stores only the environment-variable name, never its value.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, and system prompts. Tokens, API keys, and provider secrets never enter the file.","fleet-backup-export":"export","fleet-backup-import":"import","fleet-backup-download":"download backup","fleet-backup-restore":"restore selected","fleet-backup-import-help":"Choose a JSON backup, review the cells and select a destination engine before restoring.","fleet-backup-overwrite":"overwrites existing cell","fleet-backup-new":"new cell","fleet-backup-engine-missing":"choose an available engine","fleet-backup-restore-unavailable":"The selected node supports export only; update it to restore backups.","fleet-backup-restored":"{n} cells restored","fleet-backup-confirm-overwrite":"Overwrite these cells? {cells}","fleet-backup-needs-restart":"restart required: {cells}","fleet-backup-empty":"no cells to export","fleet-backup-select-one":"select at least one cell","fleet-backup-too-large":"backup is too large (1 MB maximum)","fleet-backup-invalid-json":"the file does not contain valid JSON","fleet-backup-invalid-format":"unsupported backup format or version","fleet-backup-invalid-cell":"the backup contains an invalid cell","fleet-backup-duplicate-cell":"the backup contains duplicate cell IDs","fleet-backup-invalid-engine":"the backup contains an invalid engine","fleet-backup-duplicate-engine":"the backup contains duplicate engine IDs","fleet-backup-confirm-engine-overwrite":"Overwrite these engines? Environment values already configured on the target stay unchanged. {engines}","fleet-backup-env-names":"environment names","fleet-backup-env-values-required":"environment values must be configured on this device","fleet-system-prompt":"system prompt",characters:"characters","select-all":"select all","select-none":"select none",edit:"edit",save:"save",label:"label","command-path":"absolute command path","args-lines":"arguments, one per line","env-write-only":"Environment values are write-only: blank keeps the existing value.","fleet-new-engine":"New engine","fleet-new-cell":"New cell","fleet-saved":"Definition saved.","fleet-restart-confirm":"Change saved. Restart now: {cells}?","fleet-remove-engine":'Delete engine "{id}"?',"fleet-remove-cell":'Delete cell "{id}"? If active it will be stopped first.',"settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-remove-warning":"Deletes the pairing, credentials and local tunnel. It does not power off the remote device.","peer-inventory-title":"Nodes connected to the hub","peer-group-hubs":"Direct hubs","peer-group-clients":"Connected clients","peer-group-routed":"Nodes reachable through the network","peer-routed":"routed","peer-routed-stale":"routed, unreachable","peer-visibility":"Network visibility","node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-pending":"Sharing is requested, but the tunnel is down: this device is not reachable yet.","share-local-private":"Private: only this device can use its hub connection.","share-local-private-down":"Private, but the hub connection is down. Reconnect to apply and verify private mode.","share-local-reconnect":"Reconnect and reconcile","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-ssh":"invalid ssh (expected user@host or alias)","err-port":"invalid port (1–65535)","err-ssh-port":"invalid SSH port (1–65535)","err-node-port":"invalid NexusCrew port (1–65535)","node-sessions":"{n} sessions","tunnel-down-since":"tunnel down for {t}","node-unreachable":"node unreachable","node-passive":"client offline · expected","node-offline":"node offline","node-offline-seen":"offline · seen {t} ago","node-needs-repair":"legacy · pair again","asks-title":"questions from the cells","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-off":"push not active","push-denied":"notification permission denied by the browser","push-unsupported":"push not supported in this browser","node-display-label":"Name (label)","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-unavailable-hint":"Engine configuration is unavailable on this node.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one complete one-time invitation. If this device already joined a hub, that hub is used automatically; otherwise only its reachable SSH address is required.","invite-network-hint":"Create an invitation for the network you already joined. The new device enters through the hub instead of connecting directly to this device.","invite-network-label":"Destination network","invite-network-via":"Hub","invite-network-route":"One connection to the hub; nodes, cells and decks are routed internally.","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nuevo nombre del nodo en NexusCrew","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","fleet-editor-unavailable":"El editor solo está disponible con el proveedor builtin.","fleet-managed":"gestionado por NexusCrew","fleet-custom":"comando personalizado","fleet-managed-help":"Cliente, proveedor e inicio se gestionan internamente; los secretos nunca se muestran.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado y nunca entra en motores, copias ni federación.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica.","fleet-model-default":"modelo predeterminado (opcional)","fleet-model-required":"modelo (obligatorio)","fleet-standard-permissions":"permisos estándar","fleet-unsafe-permissions":"inseguro · omitir aprobaciones/sandbox","fleet-unsafe-warning":"Modo inseguro explícito: el worker puede actuar sin las aprobaciones normales ni las protecciones del sandbox.","fleet-provider-display":"nombre visible del proveedor","fleet-custom-provider-default":"Proveedor personalizado","fleet-api-key-env":"NOMBRE_VARIABLE_API_KEY","fleet-provider-id":"id-proveedor","fleet-custom-secret-help":"NexusCrew guarda solo el nombre de la variable de entorno, nunca su valor.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas y system prompts. Tokens, claves API y secretos del proveedor nunca entran en el archivo.","fleet-backup-export":"exportar","fleet-backup-import":"importar","fleet-backup-download":"descargar copia","fleet-backup-restore":"restaurar seleccionadas","fleet-backup-import-help":"Elige una copia JSON, revisa las celdas y selecciona un motor de destino antes de restaurar.","fleet-backup-overwrite":"sobrescribe la celda existente","fleet-backup-new":"celda nueva","fleet-backup-engine-missing":"elige un motor disponible","fleet-backup-restore-unavailable":"El nodo seleccionado solo admite exportación; actualízalo para restaurar copias.","fleet-backup-restored":"{n} celdas restauradas","fleet-backup-confirm-overwrite":"¿Sobrescribir estas celdas? {cells}","fleet-backup-needs-restart":"reinicio necesario: {cells}","fleet-backup-empty":"no hay celdas para exportar","fleet-backup-select-one":"selecciona al menos una celda","fleet-backup-too-large":"copia demasiado grande (máximo 1 MB)","fleet-backup-invalid-json":"el archivo no contiene JSON válido","fleet-backup-invalid-format":"formato o versión de copia no compatible","fleet-backup-invalid-cell":"la copia contiene una celda no válida","fleet-backup-duplicate-cell":"la copia contiene IDs de celda duplicados","fleet-backup-invalid-engine":"la copia contiene un motor no válido","fleet-backup-duplicate-engine":"la copia contiene IDs de motor duplicados","fleet-backup-confirm-engine-overwrite":"¿Sobrescribir estos motores? Los valores de entorno ya configurados en el destino no cambian. {engines}","fleet-backup-env-names":"nombres de entorno","fleet-backup-env-values-required":"los valores de entorno deben configurarse en este dispositivo","fleet-system-prompt":"system prompt",characters:"caracteres","select-all":"seleccionar todas","select-none":"ninguna",edit:"editar",save:"guardar",label:"etiqueta","command-path":"ruta absoluta del comando","args-lines":"argumentos, uno por línea","env-write-only":"Los valores env son de solo escritura: vacío conserva el valor existente.","fleet-new-engine":"Nuevo motor","fleet-new-cell":"Nueva celda","fleet-saved":"Definición guardada.","fleet-restart-confirm":"Cambio guardado. ¿Reiniciar ahora: {cells}?","fleet-remove-engine":'¿Eliminar el motor "{id}"?',"fleet-remove-cell":'¿Eliminar la celda "{id}"? Si está activa se detendrá primero.',"settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-remove-warning":"Elimina el emparejamiento, las credenciales y el túnel local. No apaga el dispositivo remoto.","peer-inventory-title":"Nodos conectados al hub","peer-group-hubs":"Hubs directos","peer-group-clients":"Clientes conectados","peer-group-routed":"Nodos accesibles a través de la red","peer-routed":"enrutado","peer-routed-stale":"enrutado, no accesible","peer-visibility":"Visibilidad en la red","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","share-node":"Compartir este nodo","share-local-heading":"Compartir este dispositivo","share-local-hub":"Hub para compartir","share-local-through":"Compartir {device} mediante {hub}","share-local-active":"Compartido y accesible para la red conectada al hub.","share-local-pending":"Se solicitó compartir, pero el túnel está caído: este dispositivo aún no es accesible.","share-local-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-local-private-down":"Privado, pero la conexión al hub está caída. Reconecta para aplicar y verificar el modo privado.","share-local-reconnect":"Reconectar y reconciliar","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-ssh":"ssh inválido (se espera user@host o alias)","err-port":"puerto inválido (1–65535)","err-ssh-port":"puerto SSH inválido (1–65535)","err-node-port":"puerto NexusCrew inválido (1–65535)","node-sessions":"{n} sesiones","tunnel-down-since":"túnel caído desde hace {t}","node-unreachable":"nodo inalcanzable","node-passive":"cliente desconectado · estado normal","node-offline":"nodo desconectado","node-offline-seen":"sin conexión · visto hace {t}","node-needs-repair":"legacy · vuelve a enlazar","asks-title":"preguntas de las celdas","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-off":"push no activas","push-denied":"permiso de notificaciones denegado por el navegador","push-unsupported":"push no soportadas en este navegador","node-display-label":"Nombre (etiqueta)","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-unavailable-hint":"La configuración del motor no está disponible en este nodo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación completa de un solo uso. Si este dispositivo ya está unido a un hub, se usa automáticamente; si no, solo hace falta su dirección SSH alcanzable.","invite-network-hint":"Crea una invitación para la red a la que ya estás conectado. El nuevo dispositivo entra por el hub y no se conecta directamente a este dispositivo.","invite-network-label":"Red de destino","invite-network-via":"Hub","invite-network-route":"Una sola conexión al hub; nodos, celdas y decks se enrutan internamente.","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function Ku(){const e=Hv(),t=e?e.getItem(Fv):null;return Vh.includes(t)?t:Ba}function v0(e){const t=Hv();if(t)try{t.setItem(Fv,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Uu))}function v(e){const t=Ku(),i=Ra[t]||Ra[Ba];return Object.prototype.hasOwnProperty.call(i,e)?i[e]:Object.prototype.hasOwnProperty.call(Ra[Ba],e)?Ra[Ba][e]:e}function _0(e){return typeof window>"u"?()=>{}:(window.addEventListener(Uu,e),()=>window.removeEventListener(Uu,e))}const $v=Vh;function wi(){return[P.useSyncExternalStore(_0,Ku,Ku),v0]}function Ka({cell:e,token:t,route:i=[],onConfirm:s,onClose:o}){var I,z;wi();const a=!!(e&&e.active),c=Array.isArray(i)?i.join("/"):"",[d,m]=P.useState([]),[p,_]=P.useState(!1);P.useEffect(()=>{let $=!0;return(async()=>{if(t)try{const H=await mr(t,c?c.split("/"):[]);if(!$)return;if(_(H.provider==="builtin"&&(H.capabilities||[]).includes("edit")),H.provider==="builtin"&&(H.capabilities||[]).includes("definitions")){const re=await Wh(t,c?c.split("/"):[]);if(!$)return;const q=new Map((H.engines||[]).map(L=>[L.id,L]));m((re.engines||[]).map(L=>{var W,oe,me,V,Q,de,ae;return{id:L.id,label:L.label||L.id,client:((W=L.managed)==null?void 0:W.client)||"",models:[...new Set([...((oe=q.get(L.id))==null?void 0:oe.models)||[],...((me=L.managedInfo)==null?void 0:me.models)||[]])].filter(Boolean),defaultModel:((V=L.managed)==null?void 0:V.model)||((Q=L.managedInfo)==null?void 0:Q.defaultModel)||"",policyDefault:((de=L.managed)==null?void 0:de.permissionPolicy)||((ae=L.managed)!=null&&ae.client&&L.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{$=!1}},[t,c]);const S=(e==null?void 0:e.engine)||((I=d[0])==null?void 0:I.id)||"",y=$=>(e==null?void 0:e.models)&&e.models[$]||"",k=$=>{const H=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[$];if(H==="standard"||H==="unsafe")return H;const re=d.find(q=>q.id===$);return re?re.policyDefault:"standard"},[w,x]=P.useState(S),[b,C]=P.useState((e==null?void 0:e.model)||""),D=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((z=e==null?void 0:e.permissionPolicies)==null?void 0:z[e==null?void 0:e.engine])||"",[j,M]=P.useState(D),[Z,F]=P.useState((e==null?void 0:e.boot)??!0),[T,X]=P.useState(!1),[K,G]=P.useState(null);P.useEffect(()=>{d.length&&(x($=>$||S),C($=>$||y((e==null?void 0:e.engine)||S)||""),M($=>$==="standard"||$==="unsafe"?$:k((e==null?void 0:e.engine)||S)))},[d.length]);const ee=P.useMemo(()=>d.find($=>$.id===w)||null,[d,w]),A=!!(ee&&["claude","codex","codex-vl"].includes(ee.client));function N($){x($);const H=d.find(re=>re.id===$);C(y($)||(H==null?void 0:H.defaultModel)||""),M(k($))}async function R($){$.preventDefault(),X(!0),G(null);try{if(a)await s({action:"down",boot:Z});else{const H=j==="standard"||j==="unsafe"?j:(ee==null?void 0:ee.policyDefault)||"standard";await s({action:"up",...p?{engine:w,model:b||"",...A?{permissionPolicy:H}:(ee==null?void 0:ee.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:Z})}o()}catch(H){G(String(H&&H.message||H)),X(!1)}}return u.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:u.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:$=>$.stopPropagation(),onSubmit:R,children:[u.jsxs("div",{className:"nc-sheet-head",children:[u.jsx("b",{children:e==null?void 0:e.cell}),u.jsx("span",{className:"nc-sheet-state",children:v(a?"state-on":"state-off")})]}),a?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"nc-power-config",children:[u.jsx("span",{children:v("engine")}),u.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&u.jsxs("small",{children:[v("model"),": ",e.model]}),u.jsx("small",{children:v("power-on-hint")})]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:Z,onChange:$=>F($.target.checked)}),v("remove-boot")]})]}):u.jsxs(u.Fragment,{children:[p&&d.length>0?u.jsxs("div",{className:"nc-launch-fields",children:[u.jsxs("label",{className:"nc-field",children:[v("engine"),u.jsx("select",{value:w,onChange:$=>N($.target.value),children:d.map($=>u.jsx("option",{value:$.id,children:$.label},$.id))})]}),u.jsxs("label",{className:"nc-field",children:[v("model"),u.jsx("input",{value:b,list:"nc-launch-models",placeholder:v("model-default"),onChange:$=>C($.target.value)}),u.jsx("datalist",{id:"nc-launch-models",children:((ee==null?void 0:ee.models)||[]).map($=>u.jsx("option",{value:$},$))})]}),A?u.jsxs("label",{className:"nc-field",children:[v("permissions"),u.jsxs("select",{value:j,onChange:$=>M($.target.value),children:[u.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),u.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]})]}):u.jsx("small",{className:"nc-note",children:v("fleet-standard-permissions")}),A&&j==="unsafe"&&u.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),u.jsx("small",{className:"nc-note",children:v("launch-engine-help")})]}):u.jsxs("div",{className:"nc-power-config",children:[u.jsx("span",{children:v("engine")}),u.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&u.jsxs("small",{children:[v("model"),": ",e.model]}),u.jsx("small",{children:v("launch-unavailable-hint")})]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:Z,onChange:$=>F($.target.checked)}),v("boot-persist")]})]}),K&&u.jsx("div",{className:"nc-err",children:K}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:T,children:v("cancel")}),u.jsx("button",{type:"submit",className:"nc-btn primary",disabled:T,children:v(a?"power-off":"save-and-start")})]})]})})}const mm=/^[a-z0-9-]{1,32}$/;function qa(e,t){const i=Array.isArray(e)?e:[];return i.length?`${i.map(encodeURIComponent).join("/")}:${t}`:String(t)}function y0(e,t,i){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const c=a.join("/"),d=o.status==="up"||o.tunnel&&o.tunnel.status==="up",m=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!d&&!m&&(s[c]=e&&e[c]||i)}return s}function gm(e,t,i){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${i}:${s.tmuxSession||s.cell}`}))}function vm({nodes:e,topology:t,remote:i,down:s,fleet:o}={}){var m,p,_,S;const a=[],c=new Set,d=new Set;for(const y of Array.isArray(e)?e:[]){if(!y||typeof y.name!="string"||!mm.test(y.name)||y.direction==="inbound"&&y.shared!==!0)continue;const k=[y.name],w=y.name;c.add(w);const x=((m=y.tunnel)==null?void 0:m.status)||"unknown",b=x==="up",C={name:y.name,label:y.label||y.name,route:k,direct:!0,instanceId:y.nodeId||null,shared:y.shared===!0,tunnelStatus:x,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:y.health||null,direction:y.direction||"outbound",roles:y.roles||null,rolesKnown:y.rolesKnown===!0};if(y.nodeId&&d.add(y.nodeId),!y.nodeId&&y.paired===!1){a.push({...C,status:"needs-repair",downSince:s&&s[w]||null});continue}if(((p=y.health)==null?void 0:p.auth)==="failed"||x==="degraded"&&((_=y.health)==null?void 0:_.status)==="degraded"){a.push({...C,status:"needs-repair",downSince:s&&s[w]||null});continue}if(x==="passive"||((S=y.health)==null?void 0:S.status)==="passive"){a.push({...C,status:"passive",downSince:null});continue}if(!b){a.push({...C,status:"down",downSince:s&&s[w]||null});continue}const D=i&&(i[w]||i[y.name])||null,j=o&&(o[w]||o[y.name]),M=!!(D&&!D.error&&Array.isArray(D.sessions)),Z=!!(j&&j.available===!0&&Array.isArray(j.cells));if(!M&&!Z){a.push({...C,status:"unreachable"});continue}const F=(M?D.sessions:[]).filter(K=>K&&typeof K.name=="string"&&K.name).map(K=>({...K,node:w,route:k,key:`${w}:${K.name}`})),T=gm(j,k,w),X=new Set(T.map(K=>K.tmuxSession).filter(Boolean));a.push({...C,status:"up",sessions:F,cells:T,unmanaged:F.filter(K=>!X.has(K.name)),fleetAvailable:!!(j&&j.available),capabilities:j&&j.capabilities||[],engines:j&&j.engines||[],fleetProvider:j&&j.provider||null,sessionsAvailable:M,inventoryPartial:!M})}for(const y of Array.isArray(t)?t:[]){if(!y||!Array.isArray(y.route)||y.route.length<1||y.route.some(F=>!mm.test(F)))continue;const k=y.route.join("/");if(c.has(k)||y.instanceId&&d.has(y.instanceId))continue;y.instanceId&&d.add(y.instanceId);const w={name:y.name,label:y.label||y.route.join(" › "),route:[...y.route],direct:!1,instanceId:y.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:y.health||null,lastSeen:y.lastSeen||null};if(y.stale){a.push({...w,status:"offline",downSince:s&&s[k]||y.lastSeen||null});continue}const x=i&&i[k]||null,b=o&&o[k],C=!!(x&&!x.error&&Array.isArray(x.sessions)),D=!!(b&&b.available===!0&&Array.isArray(b.cells));if(!C&&!D){a.push({...w,status:"unreachable",downSince:s&&s[k]||null});continue}const j=(C?x.sessions:[]).filter(F=>F&&typeof F.name=="string"&&F.name).map(F=>({...F,node:k,route:y.route,key:`${k}:${F.name}`})),M=gm(b,y.route,k),Z=new Set(M.map(F=>F.tmuxSession).filter(Boolean));a.push({...w,status:"up",sessions:j,cells:M,unmanaged:j.filter(F=>!Z.has(F.name)),fleetAvailable:!!(b&&b.available),capabilities:b&&b.capabilities||[],engines:b&&b.engines||[],fleetProvider:b&&b.provider||null,lastSeen:y.lastSeen||null,sessionsAvailable:C,inventoryPartial:!C})}return a.sort((y,k)=>y.label.localeCompare(k.label))}const S0=4e3;function Yh(e,t=!0){const[i,s]=P.useState([]),o=P.useRef({});return P.useEffect(()=>{if(!t||!e){s([]);return}let a=!0;async function c(){var x;let m=[],p=[];if(await Promise.all([qw(e).then(b=>{m=Array.isArray(b.nodes)?b.nodes:[]}).catch(()=>{}),Yw(e).then(b=>{p=Array.isArray(b.nodes)?b.nodes:[]}).catch(()=>{})]),!a)return;const _={},S={},y=new Set(m.map(b=>b.name)),k=[];for(const b of m)((x=b.tunnel)==null?void 0:x.status)==="up"&&(b.nodeId||b.paired!==!1)&&(b.direction!=="inbound"||b.shared===!0)&&k.push([b.name]);for(const b of p)!b.stale&&Array.isArray(b.route)&&!(b.route.length===1&&y.has(b.route[0]))&&k.push(b.route);if(await Promise.all(k.map(async b=>{const C=b.join("/");try{_[C]=await Tv(e,b)}catch{_[C]={error:"unreachable"}}try{S[C]=await mr(e,b)}catch{S[C]={available:!1}}})),!a)return;const w=vm({nodes:m,topology:p,remote:_,fleet:S,down:o.current});o.current=y0(o.current,w,Math.floor(Date.now()/1e3)),s(vm({nodes:m,topology:p,remote:_,fleet:S,down:o.current}))}c();const d=setInterval(c,S0);return()=>{a=!1,clearInterval(d)}},[e,t]),i}const _m=52,ym=14;function zn({position:e,itemKey:t,label:i,onMove:s,onStep:o,canMove:a=()=>!0,scope:c="roster"}){const d=P.useRef(null),m=P.useRef(0),[p,_]=P.useState(!1),S=()=>{var C,D,j,M;const b=d.current;(D=(C=b==null?void 0:b.over)==null?void 0:C.classList)==null||D.remove("nc-roster-over"),(M=(j=b==null?void 0:b.source)==null?void 0:j.classList)==null||M.remove("nc-roster-dragging"),m.current&&cancelAnimationFrame(m.current),m.current=0},y=(b=!1)=>{const C=d.current;if(!C)return;const D=C.target;S(),d.current=null,_(!1);try{C.handle.releasePointerCapture(C.pointerId)}catch{}b&&D&&D!==t&&a(t,D)&&s(t,D)},k=(b,C)=>{var X,K,G,ee,A,N,R,I,z;const D=d.current;if(!D)return;D.x=b,D.y=C;const j=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",M=(K=(X=document.elementFromPoint(b,C))==null?void 0:X.closest)==null?void 0:K.call(X,j),Z=c==="node"?(G=M==null?void 0:M.dataset)==null?void 0:G.nodeOrderKey:(ee=M==null?void 0:M.dataset)==null?void 0:ee.rosterKey,T=(c==="node"||((A=M==null?void 0:M.dataset)==null?void 0:A.position)===e)&&Z&&Z!==t&&a(t,Z);D.over!==(T?M:null)&&((R=(N=D.over)==null?void 0:N.classList)==null||R.remove("nc-roster-over"),D.over=T?M:null,(z=(I=D.over)==null?void 0:I.classList)==null||z.add("nc-roster-over")),D.target=T?Z:null},w=()=>{const b=d.current;if(!b){m.current=0;return}const C=b.container;if(C){const D=C.getBoundingClientRect(),j=b.y<D.top+_m?-ym:b.y>D.bottom-_m?ym:0;j&&(C.scrollTop+=j,k(b.x,b.y))}m.current=requestAnimationFrame(w)};P.useEffect(()=>{const b=D=>{D.key==="Escape"&&d.current&&(D.preventDefault(),y(!1))},C=()=>y(!1);return window.addEventListener("keydown",b),window.addEventListener("blur",C),()=>{window.removeEventListener("keydown",b),window.removeEventListener("blur",C),S(),d.current=null}},[t,e,c]);const x=b=>{var M;if(b.pointerType==="mouse"&&b.button!==0)return;b.preventDefault(),b.stopPropagation(),b.currentTarget.focus({preventScroll:!0});const C=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",D=b.currentTarget.closest(C),j=b.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");d.current={pointerId:b.pointerId,handle:b.currentTarget,source:D,container:j,target:null,over:null,x:b.clientX,y:b.clientY},(M=D==null?void 0:D.classList)==null||M.add("nc-roster-dragging");try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}_(!0),m.current=requestAnimationFrame(w)};return u.jsx("button",{type:"button",className:`nc-roster-handle${p?" active":""}`,"aria-label":`${v("reorder")} ${i}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:v("reorder-help"),onClick:b=>{b.preventDefault(),b.stopPropagation()},onDragStart:b=>b.preventDefault(),onKeyDown:b=>{b.key!=="ArrowUp"&&b.key!=="ArrowDown"||(b.preventDefault(),b.stopPropagation(),o(b.key==="ArrowUp"?-1:1))},onPointerDown:x,onPointerMove:b=>{!d.current||b.pointerId!==d.current.pointerId||(b.preventDefault(),b.stopPropagation(),k(b.clientX,b.clientY))},onPointerUp:b=>{!d.current||b.pointerId!==d.current.pointerId||(b.preventDefault(),b.stopPropagation(),y(!0))},onPointerCancel:()=>y(!1),onLostPointerCapture:()=>{d.current&&y(!1)},children:"↕"})}const Xh="nc_pins";function w0(){try{const e=JSON.parse(localStorage.getItem(Xh));return Array.isArray(e)?e:[]}catch{return[]}}function b0(e,t){const i=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(Xh,JSON.stringify(i))}catch{}return i}function k0(e,t,i){if(!e.includes(t)||!e.includes(i)||t===i)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(i);s.splice(o,1);const c=s.indexOf(i);s.splice(o<a?c+1:c,0,t);try{localStorage.setItem(Xh,JSON.stringify(s))}catch{}return s}function C0(e,t,i){const s=e.indexOf(t);return[s===-1?1e9:s,-(i||0)]}function x0(e,t){return e[0]-t[0]||e[1]-t[1]}function Wv(){const[e,t]=P.useState(w0),[i,s]=P.useState(p0),[o,a]=P.useState(h0),c=y=>t(k=>b0(k,y)),d=y=>fm(i,y),m=(y,k)=>s(w=>{const x={...w,[y]:{...fm(w,y),...k}};return m0(x)}),p=(y,k)=>e.includes(y)===e.includes(k);function _(y,k,w,x){const b=e.includes(k),C=e.includes(w);if(b===C){if(b){t(D=>k0(D,k,w));return}a(D=>{var Z;const j=((Z=x.find(F=>F.key===k))==null?void 0:Z.technical)===!0,M=ur(x,e,j?"technical":"all",Hn(D,y)).map(F=>F.key);return d0(f0(D,y,k,w,M))})}}function S(y,k,w,x){var Z;const b=((Z=x.find(F=>F.key===k))==null?void 0:Z.technical)===!0,C=e.includes(k),D=ur(x,e,b?"technical":"all",Hn(o,y)).map(F=>F.key).filter(F=>e.includes(F)===C),j=D.indexOf(k),M=D[j+w];j>=0&&M&&_(y,k,M,x)}return{pins:e,views:i,orders:o,togglePin:c,viewFor:d,updateView:m,canMoveRoster:p,moveRoster:_,stepRoster:S}}const Uv="nc_node_order_v1",E0=/^[a-f0-9]{16,64}$/;function lr(e){if(E0.test(String((e==null?void 0:e.instanceId)||"")))return`id:${e.instanceId}`;const t=Array.isArray(e==null?void 0:e.route)?e.route.filter(i=>typeof i=="string"&&i):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function Sm(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Uv));return Array.isArray(t)?[...new Set(t.filter(i=>typeof i=="string"&&i&&i.length<=192))].slice(0,128):[]}catch{return[]}}function N0(e,t=globalThis.localStorage){try{t.setItem(Uv,JSON.stringify(e))}catch{}return e}function wm(e=[],t=[]){const i=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=i.has(lr(s.group))?i.get(lr(s.group)):Number.MAX_SAFE_INTEGER,c=i.has(lr(o.group))?i.get(lr(o.group)):Number.MAX_SAFE_INTEGER;return a-c||s.index-o.index}).map(({group:s})=>s)}function R0(e,t,i,s=[]){if(!t||!i||t===i)return e;const o=s.map(lr).filter(Boolean);if(!o.includes(t)||!o.includes(i))return e;const a=[...e.filter(p=>o.includes(p)),...o.filter(p=>!e.includes(p))],c=a.indexOf(t),d=a.indexOf(i);a.splice(c,1);const m=a.indexOf(i);return a.splice(c<d?m+1:m,0,t),a}const qu="nexuscrew-node-preferences";function P0(){try{window.dispatchEvent(new Event(qu))}catch{}}function Kv(){const[e,t]=P.useState(Sm);P.useEffect(()=>{const a=()=>t(Sm());return window.addEventListener("storage",a),window.addEventListener(qu,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(qu,a)}},[]);const i=a=>wm(a,e),s=(a,c,d)=>t(m=>{const p=R0(m,a,c,d);return N0(p),P0(),p});return{order:e,groupsFor:i,moveNode:s,stepNode:(a,c,d)=>{const m=wm(d,e).map(lr),p=m.indexOf(a),_=m[p+c];p>=0&&_&&s(a,_,d)},nodeKey:lr}}function Jr(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const i=t-e;return i<0||i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function Yr(e){return e.status==="passive"?v("node-passive"):e.status==="down"?e.downSince?v("tunnel-down-since").replace("{t}",Jr(e.downSince)):v("tunnel-down"):e.status==="unreachable"?v("node-unreachable"):e.status==="offline"?e.lastSeen?v("node-offline-seen").replace("{t}",Jr(e.lastSeen)):v("node-offline"):e.status==="needs-repair"?v("node-needs-repair"):""}function qv(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function Va(e){return e&&(e.detail||e.status)||""}function Ya(e,t,i=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(i.getItem(Pv(t))||0);return e.outbox.latest>s}function Vv(e,t={}){const i=e||{};if(!i.tmux){const s=`${i.engine||""}${i.key?`·${i.key}`:""}`,o=[s,i.model&&i.model!==s?i.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||v("cell-off")).trim()}}if(t.working===!0){const s=v("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:v("cell-idle")}:{working:!1,subtitle:String(t.preview||i.preview||v("cell-on")).trim()}}function Yv(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function Xv(e,t,i,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=i.get(o.tmuxSession)||{},c=qa([],o.tmuxSession),d=Vv(o,a);return{type:"cell",value:o,key:c,label:o.cell,live:!!o.tmux,fresh:Ya(a,c,s),activity:a.activity||0,working:d.working,subtitle:d.subtitle,searchText:Yv(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=qa([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:Ya(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function Gv(e,t=globalThis.localStorage){const i=e||{},s=Array.isArray(i.route)?i.route:[],o=new Map((i.sessions||[]).map(c=>[c.name,c])),a=[...(i.cells||[]).map(c=>{const d=o.get(c.tmuxSession)||{},m=qa(s,c.tmuxSession||c.cell),p=Vv(c,d);return{type:"cell",value:c,key:m,label:c.cell,live:!!c.tmux,fresh:Ya(d,m,t),activity:d.activity||c.activity||0,working:p.working,subtitle:p.subtitle,searchText:Yv(c,d)}}),...(i.unmanaged||[]).map(c=>{const d=qa(s,c.name);return{type:"session",value:c,key:d,label:c.name,live:!0,technical:c.technical===!0,fresh:Ya(c,d,t),activity:c.activity||0,searchText:`${c.preview||""} ${c.cmd||""}`}})];return{route:s,rawItems:a}}const Gh=9,Xa=.2,D0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Zr=/^[a-f0-9]{16,64}$/,Vu=e=>D0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Wn(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const i=e.slice(0,t),s=e.slice(t+1);return!Vu(i)||!s?null:{session:s,node:i}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&Zr.test(e.ownerId)?e.ownerId:null;return t===null?null:e.node===void 0||e.node===null||e.node===""?{session:e.session,...t?{ownerId:t}:{}}:typeof e.node=="string"&&Vu(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function yi(e){const t=Wn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const Qv=9,Jv=24,uo=11,M0=e=>{const t=Number(e);return t>=Qv&&t<=Jv?t:uo};function Xr(){return{columns:[]}}function Qi(e){return e.columns.flatMap(t=>t.tiles.map(i=>yi(i)))}function L0(e){const t=[],i=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<i;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(yi(o.tiles[s]));return t}const is=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))});function Qh(e,t,i,s){const o=Wn(t);if(!o||Qi(e).includes(yi(o))||Qi(e).length>=Gh)return e;const a=is(e),c={session:o.session,height:1,fontSize:uo,...s||{}};if(o.node&&(c.node=o.node),o.ownerId&&(c.ownerId=o.ownerId),i==="end")return a.columns.push({width:1,tiles:[c]}),a;if(i&&typeof i.col=="number"&&typeof i.row=="number"&&a.columns[i.col])return a.columns[i.col].tiles.splice(i.row,0,c),a;if(i&&typeof i.col=="number"){const d=Math.max(0,Math.min(a.columns.length,i.col));return a.columns.splice(d,0,{width:1,tiles:[c]}),a}return a.columns.push({width:1,tiles:[c]}),a}function Zv(e,t){const i=yi(t);if(!i||Qi(e).includes(i)||Qi(e).length>=Gh)return e;const s=Qi(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let _=0;for(let S=1;S<e.columns.length;S+=1)e.columns[S].tiles.length<e.columns[_].tiles.length&&(_=S);return Qh(e,t,{col:_,row:e.columns[_].tiles.length})}const a=[...L0(e),i],c=new Map(e.columns.flatMap(_=>_.tiles.map(S=>[yi(S),S]))),d=Wn(t),m=e.columns.length?e.columns.reduce((_,S)=>_+(Number(S.width)||1),0)/e.columns.length:1,p=Array.from({length:o},(_,S)=>{var y;return{width:((y=e.columns[S])==null?void 0:y.width)||m,tiles:[]}});return a.forEach((_,S)=>{const y=Wn(_);if(!y)return;const k=c.get(_)||(_===i?d:{})||{},w={session:y.session,height:k.height||1,fontSize:k.fontSize||uo};y.node&&(w.node=y.node),k.ownerId&&(w.ownerId=k.ownerId),k.unavailable===!0&&(w.unavailable=!0),p[S%o].tiles.push(w)}),{columns:p.filter(_=>_.tiles.length)}}function Ga(e,t){const i=yi(t),s=is(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>yi(a)!==i);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function j0(e,t,i){const s=yi(t);if(!Qi(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>yi(a)===s);return Qh(Ga(e,s),s,i,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function T0(e,t){if(!(t instanceof Map)||t.size===0)return e;let i=!1;const s=is(e);for(const o of s.columns)for(const a of o.tiles){const c=t.get(yi(a));if(!c)continue;const d=Wn(c);d&&(a.session=d.session,d.node?a.node=d.node:delete a.node,d.ownerId&&(a.ownerId=d.ownerId),i=!0)}return i?hr(s):e}function A0(e,t,i){const s=is(e);return s.columns[t]&&(s.columns[t].width=Math.max(Xa,Number(i)||1)),s}function I0(e,t,i,s){const o=is(e),a=o.columns[t]&&o.columns[t].tiles[i];return a&&(a.height=Math.max(Xa,Number(s)||1)),o}function B0(e,t,i,s){if(!(e.columns[t]&&e.columns[t].tiles[i]))return e;const a=is(e),c=a.columns[t].tiles[i],d=Number(c.fontSize)||uo;return c.fontSize=Math.max(Qv,Math.min(Jv,d+(Number(s)||0))),a}function O0(e,t,i,s){const o=e.columns[t];if(!o||!o.tiles[i])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:i};case"bottom":return{col:t,row:i+1};default:return null}}function bm(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function hr(e){if(!e||!Array.isArray(e.columns))return Xr();const t=e.columns.map(s=>({width:Math.max(Xa,Number(s&&s.width)||1),tiles:(Array.isArray(s&&s.tiles)?s.tiles:[]).filter(o=>o&&typeof o.session=="string"&&o.session).filter(o=>o.node==null||typeof o.node=="string"&&Vu(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&Zr.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(Xa,Number(o.height)||1),fontSize:M0(o.fontSize)};return o.node!=null&&(a.node=o.node),o.ownerId!=null&&(a.ownerId=o.ownerId),o.unavailable===!0&&(a.unavailable=!0),a})})).filter(s=>s.tiles.length>0),i=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!i.has(yi(o))&&i.add(yi(o))&&i.size<=Gh);return{columns:t.filter(s=>s.tiles.length>0)}}const e_=/^[a-z0-9-]{1,32}$/,z0=/^[A-Za-z0-9._-]{1,32}$/,F0=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,H0=320;function $0(e){return typeof e=="string"&&e_.test(e)}const W0=64;function so(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=W0&&!/[\x00-\x1f\x7f]/.test(t)}function Gr(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function t_(e){if(typeof e!="string"||!e||e.length>H0||e.startsWith("-")||/[\0-\x20\x7f]/.test(e))return!1;if(!e.includes("@"))return/^[A-Za-z0-9][A-Za-z0-9._:-]{0,254}$/.test(e);const t=e.indexOf("@");return t<=0||t!==e.lastIndexOf("@")?!1:z0.test(e.slice(0,t))&&F0.test(e.slice(t+1))}function km(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const i=Number(t);return Number.isInteger(i)&&i>=1&&i<=65535?i:void 0}function Cm({name:e,ssh:t,sshPort:i,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!$0(o))return{ok:!1,error:"err-node-name"};if(!t_(a))return{ok:!1,error:"err-ssh"};const c=km(i);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const d=km(s);if(d===void 0)return{ok:!1,error:"err-node-port"};const m={name:o,ssh:a};return c!==null&&(m.sshPort=c),d!==null&&(m.remotePort=d),{ok:!0,value:m}}function U0(e,t){if(!e||!t||t<e)return null;const i=Math.floor((t-e)/1e3);return i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function xm(e,t){const i=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:i,...s?{passive:!0}:{},label:i?"tunnel-up":s?"node-passive":"tunnel-down",since:i?U0(e.since,t):null}}const K0=new Set(["v","instanceId","port","label","invite"]),q0=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function V0(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),i=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(i):Buffer.from(i,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function Y0(e){let t="";try{const c=new URL(String(e));t=new URLSearchParams(c.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let i;try{i=JSON.parse(V0(t))}catch{return{ok:!1}}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1};const s=i.v===1?K0:i.v===2?q0:null;if(!s)return{ok:!1};for(const c of Object.keys(i))if(!s.has(c))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(i.instanceId)))return{ok:!1};const o=Number(i.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof i.label!="string")return{ok:!1};if(typeof i.invite!="string"||!i.invite)return{ok:!1};const a={ok:!0,version:i.v,label:i.label,invite:i.invite,instanceId:i.instanceId,port:o};if(i.v===2){if(i.name!==void 0){if(typeof i.name!="string"||!e_.test(i.name))return{ok:!1};a.name=i.name}if(i.ssh!==void 0){if(!t_(i.ssh))return{ok:!1};a.ssh=String(i.ssh).trim()}if(i.sshPort!==void 0){const c=Number(i.sshPort);if(!Number.isInteger(c)||c<1||c>65535)return{ok:!1};a.sshPort=c}}return a}function X0(e,t,i=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,c)=>{c==null||c===""||i.has(a)||(s[a]=c)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Gr(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function G0({onPick:e,token:t,onSettings:i}){const[s,o]=wi(),a=Yh(t),[c,d]=P.useState(null),[m,p]=P.useState(null),[_,S]=P.useState(""),[y,k]=P.useState(""),[w,x]=P.useState({bind:"127.0.0.1",port:""}),[b,C]=P.useState(""),[D,j]=P.useState([]),[M,Z]=P.useState(null),[F,T]=P.useState(null),{pins:X,orders:K,togglePin:G,viewFor:ee,updateView:A,canMoveRoster:N,moveRoster:R,stepRoster:I}=Wv(),{groupsFor:z,moveNode:$,stepNode:H,nodeKey:re}=Kv(),q=z(a);async function L(){try{const fe=await(await zt("/api/sessions",t)).json();fe.error?(p(fe.error),d([])):(p(null),d(fe.sessions||[]))}catch(B){p(String(B)),d([])}try{const B=await mr(t);j(B.available?B.cells||[]:[])}catch{j([])}}P.useEffect(()=>{L(),zt("/api/config",t).then(fe=>fe.json()).then(fe=>{k(fe.version||""),x({bind:fe.bind||"127.0.0.1",port:fe.port||""}),C(Zr.test(String(fe.instanceId||""))?fe.instanceId:"")}).catch(()=>{});const B=setInterval(L,4e3);return()=>clearInterval(B)},[]);async function W(){if(!w.port)return;const B=`http://${w.bind}:${w.port}/#token=${t}`;try{await navigator.clipboard.writeText(B)}catch{}}async function oe(B){if(!M)return;const{cell:fe}=M,be=Array.isArray(M.route)?M.route:[];B.action==="up"?await $h(t,{cell:fe,boot:!!B.boot,...B.engine?{engine:B.engine}:{},...B.model!==void 0?{model:B.model}:{},...B.permissionPolicy?{permissionPolicy:B.permissionPolicy}:{}},be):await Ua(t,{cell:fe,boot:!!B.boot},be),L()}async function me(B,fe=[]){try{await Uh(t,B,fe)}catch{return}L()}async function V(B,fe,be=[]){try{await Mv(t,B,fe,be)}catch{return}L()}async function Q(B){if(!(!(B!=null&&B.direct)||F)){T(B.name);try{await qh(t,B.name,B.tunnelStatus==="up"?"down":"up")}catch{}T(null)}}async function de(B){if(!(B!=null&&B.direct))return;const fe=window.prompt(v("rename-node-prompt"),B.label||B.name);if(fe===null)return;const be=String(fe).trim();if(!so(be)){window.alert(v("rename-node-invalid"));return}try{await Iv(t,B.name,be)}catch(Se){window.alert(String((Se==null?void 0:Se.message)||Se))}}const ae=P.useMemo(()=>new Map((c||[]).map(B=>[B.name,B])),[c]),ke=P.useMemo(()=>new Set(D.map(B=>B.tmuxSession)),[D]),je=P.useMemo(()=>(c||[]).filter(B=>!ke.has(B.name)),[c,ke]),Ye=P.useMemo(()=>Xv(D,je,ae),[D,je,ae]),qe=ee("local"),Ce=P.useMemo(()=>ur(Ye,X,qe.filter,Hn(K,"local")).filter(B=>pm(B,_)),[Ye,X,qe.filter,_,K]),rt=q.reduce((B,fe)=>B+(fe.cells||[]).length+(fe.unmanaged||[]).filter(be=>!be.technical).length,0),St=ur(Ye,X,"all",Hn(K,"local")).length+rt,ne=c?c.length:0,le=(c||[]).filter(B=>B.attached).length,Be=w.port?`${w.bind}:${w.port}`:w.bind;function J(B,fe=null,be=Ye){var $e,he;const Se=Array.isArray(fe==null?void 0:fe.route)?fe.route:[],Ae=Se.join("/"),ce=Ae||"local",Me=Se.length?fe==null?void 0:fe.instanceId:b,Pe=Ee=>e({session:Ee,...Ae?{node:Ae}:{},...Zr.test(String(Me||""))?{ownerId:Me}:{}}),He=N;if(B.type==="cell"){const Ee=B.value,Xe=Se.length?((fe==null?void 0:fe.sessions)||[]).find(Ne=>Ne.name===Ee.tmuxSession):ae.get(Ee.tmuxSession),st=Ee.degraded?v("cell-degraded"):B.working?B.subtitle:Ee.tmux?v("cell-idle"):v("cell-off"),ue=Se.length===0||((fe==null?void 0:fe.capabilities)||[]).includes(Ee.active?"down":"up");return u.jsxs("div",{className:"nc-mcard","data-roster-key":B.key,"data-position":ce,children:[u.jsx(zn,{position:ce,itemKey:B.key,label:Ee.cell,canMove:He,onMove:(Ne,Ve)=>R(ce,Ne,Ve,be),onStep:Ne=>I(ce,B.key,Ne,be)}),u.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ee.tmux&&Pe(Ee.tmuxSession),title:st,"aria-label":`${Ee.cell}, ${st}`,children:[u.jsx("span",{className:`dot ${Ee.degraded?"warn":Ee.tmux?`on${B.working?" working":""}`:""}`}),u.jsxs("span",{className:"nc-mcard-text",children:[u.jsx("b",{children:Ee.cell}),u.jsx("small",{title:B.subtitle,children:B.subtitle})]})]}),B.activity?u.jsx("span",{className:"nc-rel",children:Jr(B.activity)}):null,B.fresh&&(($e=Xe==null?void 0:Xe.outbox)==null?void 0:$e.count)>0&&u.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:Xe.outbox.count}),u.jsx("button",{className:`nc-act pin${X.includes(B.key)?" on":""}`,"aria-label":`${v("pin")} ${Ee.cell}`,title:v("pin"),onClick:()=>G(B.key),children:X.includes(B.key)?"★":"☆"}),ue&&u.jsx("button",{className:`nc-act power${Ee.tmux?" on":""}${Ee.degraded?" warn":""}`,onClick:()=>Z(Se.length?{...Ee,route:Se,availableEngines:(fe==null?void 0:fe.engines)||[]}:Ee),title:Ee.active?v("power-off"):v("power-on"),"aria-label":`${Ee.active?v("power-off"):v("power-on")} ${Ee.cell}`,children:u.jsx(tt,{name:"power",size:16})})]},B.key)}const Oe=B.value;return u.jsxs("div",{className:"nc-mcard","data-roster-key":B.key,"data-position":ce,children:[u.jsx(zn,{position:ce,itemKey:B.key,label:Oe.name,canMove:He,onMove:(Ee,Xe)=>R(ce,Ee,Xe,be),onStep:Ee=>I(ce,B.key,Ee,be)}),u.jsxs("button",{className:"nc-mcard-main",onClick:()=>Pe(Oe.name),children:[u.jsx("span",{className:Oe.attached?"dot on":"dot"}),u.jsxs("span",{className:"nc-mcard-text",children:[u.jsx("b",{children:Oe.name}),u.jsx("small",{children:Oe.preview?Oe.preview:Oe.cmd?Oe.cmd:v("windows").replace("{n}",String(Oe.windows||0))})]})]}),B.activity?u.jsx("span",{className:"nc-rel",children:Jr(B.activity)}):null,B.fresh&&((he=Oe.outbox)==null?void 0:he.count)>0&&u.jsx("span",{className:"nc-badge",title:v("new-files-outbox"),children:Oe.outbox.count}),u.jsx("button",{className:`nc-act pin${X.includes(B.key)?" on":""}`,"aria-label":`${v("pin")} ${Oe.name}`,title:v("pin"),onClick:()=>G(B.key),children:X.includes(B.key)?"★":"☆"}),u.jsx("button",{className:`nc-act technical${Oe.technical?" on":""}`,title:Oe.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${Oe.technical?v("mark-normal"):v("mark-technical")} ${Oe.name}`,onClick:()=>V(Oe.name,!Oe.technical,Se),children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),"aria-label":`${v("terminate")} ${Oe.name}`,onClick:()=>{window.confirm(v("terminate-confirm").replace("{name}",Oe.name))&&me(Oe.name,Se)},children:"⋯"})]},B.key)}return u.jsxs("div",{className:"nc-home",children:[u.jsxs("header",{className:"nc-home-head",children:[u.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",u.jsx("span",{className:"nc-cursor"})]}),u.jsxs("div",{className:"nc-home-sub",children:[v("fleet-tmux")," · ",ne," ",v("sessions"),le>0&&` · ${le} attached`]}),u.jsxs("span",{className:"nc-head-actions",children:[u.jsx("button",{className:"nc-refresh",onClick:()=>i("nodes",!1),title:v("settings"),children:u.jsx(tt,{name:"gear",size:18})}),u.jsx("button",{className:"nc-refresh",onClick:L,title:v("refresh"),children:u.jsx(tt,{name:"refresh",size:18})})]})]}),u.jsxs("main",{className:"nc-home-scroll",children:[St>8&&u.jsx("input",{className:"nc-filter",type:"search",placeholder:v("filter-placeholder"),"aria-label":v("filter-placeholder"),value:_,onChange:B=>S(B.target.value)}),m&&u.jsx("div",{className:"nc-err",children:m}),u.jsxs("section",{className:"nc-group","data-position":"local",children:[u.jsx(Em,{label:v("position-local"),count:Ce.length,state:qe,dotClass:"on",onToggle:()=>A("local",{open:!qe.open}),onFilter:B=>A("local",{filter:B})}),qe.open&&Ce.map(B=>J(B,null,Ye)),qe.open&&c===null&&u.jsx("div",{className:"nc-empty",children:v("loading-fleet")}),qe.open&&c!==null&&Ce.length===0&&!m&&u.jsx("div",{className:"nc-empty",children:_?v("no-match").replace("{q}",_):v("no-sessions-short")})]}),q.map(B=>{const be=qv(B.health,{passive:"warn"})||(B.status==="up"?"on":B.status==="passive"?"":"warn"),Se=B.health?Va(B.health):B.status==="up"?"":Yr(B),ce=(B.route||[B.name]).join("/"),Me=ee(ce),{rawItems:Pe}=Gv(B),He=ur(Pe,X,Me.filter,Hn(K,ce)).filter(he=>pm(he,_)),Oe=B.direct&&B.health&&B.health.managed!==!1?u.jsx("button",{type:"button",className:`nc-act power${B.tunnelStatus==="up"?" on":""}`,disabled:F===B.name,title:B.tunnelStatus==="up"?v("power-off"):v("power-on"),"aria-label":`${B.tunnelStatus==="up"?v("power-off"):v("power-on")} ${B.label||B.name}`,onClick:()=>Q(B),children:u.jsx(tt,{name:"power",size:15})}):null,$e=u.jsxs("span",{className:"nc-node-actions",children:[u.jsx(zn,{scope:"node",position:"nodes",itemKey:re(B),label:B.label||B.name,onMove:(he,Ee)=>$(he,Ee,a),onStep:he=>H(re(B),he,a)}),B.direct&&u.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${B.label||B.name}`,onClick:()=>de(B),children:"✎"}),Oe]});return u.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":ce,"data-node-order-key":re(B),children:[u.jsx(Em,{label:B.label||B.name,count:He.length,state:Me,dotClass:be,dotTitle:Se,detail:B.status==="up"?"":B.health&&Va(B.health)||Yr(B),onToggle:()=>A(ce,{open:!Me.open}),onFilter:he=>A(ce,{filter:he}),onRename:B.direct?()=>de(B):null,action:$e}),B.status==="up"&&Me.open&&He.map(he=>J(he,B,Pe)),B.status==="up"&&Me.open&&He.length===0&&u.jsx("div",{className:"nc-empty",children:_?v("no-match").replace("{q}",_):v("no-sessions-short")})]},`nodo-${ce}`)}),u.jsxs("footer",{className:"nc-home-foot",onClick:W,title:v("copy-url"),children:[u.jsxs("span",{className:"nc-home-meta",children:[y&&u.jsxs("span",{className:"nc-home-version",children:["v",y]}),u.jsxs("span",{className:"nc-home-endpoint",children:[Be," · ",v("ssh-only")]})]}),u.jsx("span",{className:"nc-lang",onClick:B=>B.stopPropagation(),children:$v.map((B,fe)=>u.jsxs("span",{children:[fe>0&&" · ",u.jsx("button",{className:`nc-lang-btn${s===B?" on":""}`,onClick:()=>o(B),title:B,children:B.toUpperCase()})]},B))})]})]}),u.jsx("button",{className:"nc-fab",onClick:()=>i("fleet",!0),title:v("fleet-new-cell"),"aria-label":v("fleet-new-cell"),children:"+"}),M&&u.jsx(Ka,{cell:M,token:t,route:Array.isArray(M.route)?M.route:[],onConfirm:oe,onClose:()=>Z(null)})]})}function Em({label:e,count:t,state:i,dotClass:s="",dotTitle:o="",detail:a="",onToggle:c,onFilter:d,onRename:m=null,action:p=null}){return u.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:m?_=>{_.preventDefault(),m()}:void 0,children:[u.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":i.open,"aria-label":`${e} · ${v("node-sessions").replace("{n}",String(t))}`,children:[u.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:i.open?"⌄":"›"}),u.jsx("span",{className:`dot ${s}`,title:o}),u.jsxs("span",{className:"nc-mobile-position-copy",children:[u.jsx("b",{children:e}),u.jsx("small",{children:a||v("node-sessions").replace("{n}",String(t))})]})]}),u.jsxs("select",{className:"nc-mobile-position-filter",value:i.filter,"aria-label":`${e} · ${v("filter-placeholder")}`,title:v(`view-${i.filter}`),onChange:_=>d(_.target.value),children:[u.jsx("option",{value:"all",children:v("view-all")}),u.jsx("option",{value:"pinned",children:v("view-pinned")}),u.jsx("option",{value:"active",children:v("view-active")}),u.jsx("option",{value:"off",children:v("view-off")}),u.jsx("option",{value:"technical",children:v("view-technical")})]}),p]})}/**
41
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
42
+ * @license MIT
43
+ *
44
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
45
+ * @license MIT
46
+ *
47
+ * Originally forked from (with the author's permission):
48
+ * Fabrice Bellard's javascript vt100 for jslinux:
49
+ * http://bellard.org/jslinux/
50
+ * Copyright (c) 2011 Fabrice Bellard
51
+ */var i_=Object.defineProperty,Q0=Object.getOwnPropertyDescriptor,J0=(e,t)=>{for(var i in t)i_(e,i,{get:t[i],enumerable:!0})},yt=(e,t,i,s)=>{for(var o=s>1?void 0:s?Q0(t,i):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(o=(s?c(t,i,o):c(o))||o);return s&&o&&i_(t,i,o),o},xe=(e,t)=>(i,s)=>t(i,s,e),Nm="Terminal input",Yu={get:()=>Nm,set:e=>Nm=e},Rm="Too much output to announce, navigate to rows manually to read",Xu={get:()=>Rm,set:e=>Rm=e};function Z0(e){return e.replace(/\r?\n/g,"\r")}function eb(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function tb(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function ib(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");n_(o,t,i,s)}}function n_(e,t,i,s){e=Z0(e),e=eb(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function r_(e,t,i){let s=i.getBoundingClientRect(),o=e.clientX-s.left-10,a=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${a}px`,t.style.zIndex="1000",t.focus()}function Pm(e,t,i,s,o){r_(e,t,i),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function On(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function sl(e,t=0,i=e.length){let s="";for(let o=t;o<i;++o){let a=e[o];a>65535?(a-=65536,s+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):s+=String.fromCharCode(a)}return s}var nb=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o=0;if(this._interim){let a=e.charCodeAt(o++);56320<=a&&a<=57343?t[s++]=(this._interim-55296)*1024+a-56320+65536:(t[s++]=this._interim,t[s++]=a),this._interim=0}for(let a=o;a<i;++a){let c=e.charCodeAt(a);if(55296<=c&&c<=56319){if(++a>=i)return this._interim=c,s;let d=e.charCodeAt(a);56320<=d&&d<=57343?t[s++]=(c-55296)*1024+d-56320+65536:(t[s++]=c,t[s++]=d);continue}c!==65279&&(t[s++]=c)}return s}},rb=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o,a,c,d,m=0,p=0;if(this.interim[0]){let y=!1,k=this.interim[0];k&=(k&224)===192?31:(k&240)===224?15:7;let w=0,x;for(;(x=this.interim[++w]&63)&&w<4;)k<<=6,k|=x;let b=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,C=b-w;for(;p<C;){if(p>=i)return 0;if(x=e[p++],(x&192)!==128){p--,y=!0;break}else this.interim[w++]=x,k<<=6,k|=x&63}y||(b===2?k<128?p--:t[s++]=k:b===3?k<2048||k>=55296&&k<=57343||k===65279||(t[s++]=k):k<65536||k>1114111||(t[s++]=k)),this.interim.fill(0)}let _=i-4,S=p;for(;S<i;){for(;S<_&&!((o=e[S])&128)&&!((a=e[S+1])&128)&&!((c=e[S+2])&128)&&!((d=e[S+3])&128);)t[s++]=o,t[s++]=a,t[s++]=c,t[s++]=d,S+=4;if(o=e[S++],o<128)t[s++]=o;else if((o&224)===192){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(m=(o&31)<<6|a&63,m<128){S--;continue}t[s++]=m}else if((o&240)===224){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,s;if(c=e[S++],(c&192)!==128){S--;continue}if(m=(o&15)<<12|(a&63)<<6|c&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[s++]=m}else if((o&248)===240){if(S>=i)return this.interim[0]=o,s;if(a=e[S++],(a&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,s;if(c=e[S++],(c&192)!==128){S--;continue}if(S>=i)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=c,s;if(d=e[S++],(d&192)!==128){S--;continue}if(m=(o&7)<<18|(a&63)<<12|(c&63)<<6|d&63,m<65536||m>1114111)continue;t[s++]=m}}return s}},s_="",Fn=" ",ho=class o_{constructor(){this.fg=0,this.bg=0,this.extended=new Qa}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 o_;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}},Qa=class a_{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}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 a_(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Mi=class l_ extends ho{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Qa,this.combinedData=""}static fromCharData(t){let i=new l_;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?On(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 i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Dm="di$target",Gu="di$dependencies",iu=new Map;function sb(e){return e[Gu]||[]}function Ft(e){if(iu.has(e))return iu.get(e);let t=function(i,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");ob(t,i,o)};return t._id=e,iu.set(e,t),t}function ob(e,t,i){t[Dm]===t?t[Gu].push({id:e,index:i}):(t[Gu]=[{id:e,index:i}],t[Dm]=t)}var ti=Ft("BufferService"),c_=Ft("CoreMouseService"),gr=Ft("CoreService"),ab=Ft("CharsetService"),Jh=Ft("InstantiationService"),u_=Ft("LogService"),ii=Ft("OptionsService"),h_=Ft("OscLinkService"),lb=Ft("UnicodeService"),fo=Ft("DecorationService"),Qu=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var _;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new Mi,c=i.getTrimmedLength(),d=-1,m=-1,p=!1;for(let S=0;S<c;S++)if(!(m===-1&&!i.hasContent(S))){if(i.loadCell(S,a),a.hasExtendedAttrs()&&a.extended.urlId)if(m===-1){m=S,d=a.extended.urlId;continue}else p=a.extended.urlId!==d;else m!==-1&&(p=!0);if(p||m!==-1&&S===c-1){let y=(_=this._oscLinkService.getLinkData(d))==null?void 0:_.uri;if(y){let k={start:{x:m+1,y:e},end:{x:S+(!p&&S===c-1?1:0),y:e}},w=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let x=new URL(y);["http:","https:"].includes(x.protocol)||(w=!0)}catch{w=!0}w||s.push({text:y,range:k,activate:(x,b)=>o?o.activate(x,b,k):cb(x,b),hover:(x,b)=>{var C;return(C=o==null?void 0:o.hover)==null?void 0:C.call(o,x,b,k)},leave:(x,b)=>{var C;return(C=o==null?void 0:o.leave)==null?void 0:C.call(o,x,b,k)}})}p=!1,a.hasExtendedAttrs()&&a.extended.urlId?(m=S,d=a.extended.urlId):(m=-1,d=-1)}}t(s)}};Qu=yt([xe(0,ti),xe(1,ii),xe(2,h_)],Qu);function cb(e,t){if(confirm(`Do you want to navigate to ${t}?
52
+
53
+ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var ol=Ft("CharSizeService"),fn=Ft("CoreBrowserService"),Zh=Ft("MouseService"),pn=Ft("RenderService"),ub=Ft("SelectionService"),d_=Ft("CharacterJoinerService"),ns=Ft("ThemeService"),f_=Ft("LinkProviderService"),hb=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Mm.isErrorNoTelemetry(e)?new Mm(e.message+`
54
+
55
+ `+e.stack):new Error(e.message+`
56
+
57
+ `+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)}},db=new hb;function Oa(e){fb(e)||db.onUnexpectedError(e)}var Ju="Canceled";function fb(e){return e instanceof pb?!0:e instanceof Error&&e.name===Ju&&e.message===Ju}var pb=class extends Error{constructor(){super(Ju),this.name=this.message}};function mb(e){return new Error(`Illegal argument: ${e}`)}var Mm=class Zu extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Zu)return t;let i=new Zu;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},eh=class p_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,p_.prototype)}};function vi(e,t=0){return e[e.length-(1+t)]}var gb;(e=>{function t(a){return a<0}e.isLessThan=t;function i(a){return a<=0}e.isLessThanOrEqual=i;function s(a){return a>0}e.isGreaterThan=s;function o(a){return a===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(gb||(gb={}));function vb(e,t){let i=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(i,arguments))),o}}var m_;(e=>{function t(M){return M&&typeof M=="object"&&typeof M[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*o(M){yield M}e.single=o;function a(M){return t(M)?M:o(M)}e.wrap=a;function c(M){return M||i}e.from=c;function*d(M){for(let Z=M.length-1;Z>=0;Z--)yield M[Z]}e.reverse=d;function m(M){return!M||M[Symbol.iterator]().next().done===!0}e.isEmpty=m;function p(M){return M[Symbol.iterator]().next().value}e.first=p;function _(M,Z){let F=0;for(let T of M)if(Z(T,F++))return!0;return!1}e.some=_;function S(M,Z){for(let F of M)if(Z(F))return F}e.find=S;function*y(M,Z){for(let F of M)Z(F)&&(yield F)}e.filter=y;function*k(M,Z){let F=0;for(let T of M)yield Z(T,F++)}e.map=k;function*w(M,Z){let F=0;for(let T of M)yield*Z(T,F++)}e.flatMap=w;function*x(...M){for(let Z of M)yield*Z}e.concat=x;function b(M,Z,F){let T=F;for(let X of M)T=Z(T,X);return T}e.reduce=b;function*C(M,Z,F=M.length){for(Z<0&&(Z+=M.length),F<0?F+=M.length:F>M.length&&(F=M.length);Z<F;Z++)yield M[Z]}e.slice=C;function D(M,Z=Number.POSITIVE_INFINITY){let F=[];if(Z===0)return[F,M];let T=M[Symbol.iterator]();for(let X=0;X<Z;X++){let K=T.next();if(K.done)return[F,e.empty()];F.push(K.value)}return[F,{[Symbol.iterator](){return T}}]}e.consume=D;async function j(M){let Z=[];for await(let F of M)Z.push(F);return Promise.resolve(Z)}e.asyncToArray=j})(m_||(m_={}));function fr(e){if(m_.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function _b(...e){return dt(()=>fr(e))}function dt(e){return{dispose:vb(()=>{e()})}}var g_=class v_{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{fr(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?v_.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)}};g_.DISABLE_DISPOSED_WARNING=!1;var $n=g_,Je=class{constructor(){this._store=new $n,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)}};Je.None=Object.freeze({dispose(){}});var es=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},dn=typeof window=="object"?window:globalThis,th=class ih{constructor(t){this.element=t,this.next=ih.Undefined,this.prev=ih.Undefined}};th.Undefined=new th(void 0);var mt=th,Lm=class{constructor(){this._first=mt.Undefined,this._last=mt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===mt.Undefined}clear(){let e=this._first;for(;e!==mt.Undefined;){let t=e.next;e.prev=mt.Undefined,e.next=mt.Undefined,e=t}this._first=mt.Undefined,this._last=mt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new mt(e);if(this._first===mt.Undefined)this._first=i,this._last=i;else if(t){let o=this._last;this._last=i,i.prev=o,o.next=i}else{let o=this._first;this._first=i,i.next=o,o.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==mt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==mt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==mt.Undefined&&e.next!==mt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===mt.Undefined&&e.next===mt.Undefined?(this._first=mt.Undefined,this._last=mt.Undefined):e.next===mt.Undefined?(this._last=this._last.prev,this._last.next=mt.Undefined):e.prev===mt.Undefined&&(this._first=this._first.next,this._first.prev=mt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==mt.Undefined;)yield e.element,e=e.next}},yb=globalThis.performance&&typeof globalThis.performance.now=="function",Sb=class __{static create(t){return new __(t)}constructor(t){this._now=yb&&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}},Ut;(e=>{e.None=()=>Je.None;function t(A,N){return S(A,()=>{},0,void 0,!0,void 0,N)}e.defer=t;function i(A){return(N,R=null,I)=>{let z=!1,$;return $=A(H=>{if(!z)return $?$.dispose():z=!0,N.call(R,H)},null,I),z&&$.dispose(),$}}e.once=i;function s(A,N,R){return p((I,z=null,$)=>A(H=>I.call(z,N(H)),null,$),R)}e.map=s;function o(A,N,R){return p((I,z=null,$)=>A(H=>{N(H),I.call(z,H)},null,$),R)}e.forEach=o;function a(A,N,R){return p((I,z=null,$)=>A(H=>N(H)&&I.call(z,H),null,$),R)}e.filter=a;function c(A){return A}e.signal=c;function d(...A){return(N,R=null,I)=>{let z=_b(...A.map($=>$(H=>N.call(R,H))));return _(z,I)}}e.any=d;function m(A,N,R,I){let z=R;return s(A,$=>(z=N(z,$),z),I)}e.reduce=m;function p(A,N){let R,I={onWillAddFirstListener(){R=A(z.fire,z)},onDidRemoveLastListener(){R==null||R.dispose()}},z=new we(I);return N==null||N.add(z),z.event}function _(A,N){return N instanceof Array?N.push(A):N&&N.add(A),A}function S(A,N,R=100,I=!1,z=!1,$,H){let re,q,L,W=0,oe,me={leakWarningThreshold:$,onWillAddFirstListener(){re=A(Q=>{W++,q=N(q,Q),I&&!L&&(V.fire(q),q=void 0),oe=()=>{let de=q;q=void 0,L=void 0,(!I||W>1)&&V.fire(de),W=0},typeof R=="number"?(clearTimeout(L),L=setTimeout(oe,R)):L===void 0&&(L=0,queueMicrotask(oe))})},onWillRemoveListener(){z&&W>0&&(oe==null||oe())},onDidRemoveLastListener(){oe=void 0,re.dispose()}},V=new we(me);return H==null||H.add(V),V.event}e.debounce=S;function y(A,N=0,R){return e.debounce(A,(I,z)=>I?(I.push(z),I):[z],N,void 0,!0,void 0,R)}e.accumulate=y;function k(A,N=(I,z)=>I===z,R){let I=!0,z;return a(A,$=>{let H=I||!N($,z);return I=!1,z=$,H},R)}e.latch=k;function w(A,N,R){return[e.filter(A,N,R),e.filter(A,I=>!N(I),R)]}e.split=w;function x(A,N=!1,R=[],I){let z=R.slice(),$=A(q=>{z?z.push(q):re.fire(q)});I&&I.add($);let H=()=>{z==null||z.forEach(q=>re.fire(q)),z=null},re=new we({onWillAddFirstListener(){$||($=A(q=>re.fire(q)),I&&I.add($))},onDidAddFirstListener(){z&&(N?setTimeout(H):H())},onDidRemoveLastListener(){$&&$.dispose(),$=null}});return I&&I.add(re),re.event}e.buffer=x;function b(A,N){return(R,I,z)=>{let $=N(new D);return A(function(H){let re=$.evaluate(H);re!==C&&R.call(I,re)},void 0,z)}}e.chain=b;let C=Symbol("HaltChainable");class D{constructor(){this.steps=[]}map(N){return this.steps.push(N),this}forEach(N){return this.steps.push(R=>(N(R),R)),this}filter(N){return this.steps.push(R=>N(R)?R:C),this}reduce(N,R){let I=R;return this.steps.push(z=>(I=N(I,z),I)),this}latch(N=(R,I)=>R===I){let R=!0,I;return this.steps.push(z=>{let $=R||!N(z,I);return R=!1,I=z,$?z:C}),this}evaluate(N){for(let R of this.steps)if(N=R(N),N===C)break;return N}}function j(A,N,R=I=>I){let I=(...re)=>H.fire(R(...re)),z=()=>A.on(N,I),$=()=>A.removeListener(N,I),H=new we({onWillAddFirstListener:z,onDidRemoveLastListener:$});return H.event}e.fromNodeEventEmitter=j;function M(A,N,R=I=>I){let I=(...re)=>H.fire(R(...re)),z=()=>A.addEventListener(N,I),$=()=>A.removeEventListener(N,I),H=new we({onWillAddFirstListener:z,onDidRemoveLastListener:$});return H.event}e.fromDOMEventEmitter=M;function Z(A){return new Promise(N=>i(A)(N))}e.toPromise=Z;function F(A){let N=new we;return A.then(R=>{N.fire(R)},()=>{N.fire(void 0)}).finally(()=>{N.dispose()}),N.event}e.fromPromise=F;function T(A,N){return A(R=>N.fire(R))}e.forward=T;function X(A,N,R){return N(R),A(I=>N(I))}e.runAndSubscribe=X;class K{constructor(N,R){this._observable=N,this._counter=0,this._hasChanged=!1;let I={onWillAddFirstListener:()=>{N.addObserver(this)},onDidRemoveLastListener:()=>{N.removeObserver(this)}};this.emitter=new we(I),R&&R.add(this.emitter)}beginUpdate(N){this._counter++}handlePossibleChange(N){}handleChange(N,R){this._hasChanged=!0}endUpdate(N){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function G(A,N){return new K(A,N).emitter.event}e.fromObservable=G;function ee(A){return(N,R,I)=>{let z=0,$=!1,H={beginUpdate(){z++},endUpdate(){z--,z===0&&(A.reportChanges(),$&&($=!1,N.call(R)))},handlePossibleChange(){},handleChange(){$=!0}};A.addObserver(H),A.reportChanges();let re={dispose(){A.removeObserver(H)}};return I instanceof $n?I.add(re):Array.isArray(I)&&I.push(re),re}}e.fromObservableLight=ee})(Ut||(Ut={}));var nh=class rh{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${rh._idPool++}`,rh.all.add(this)}start(t){this._stopWatch=new Sb,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}}};nh.all=new Set,nh._idPool=0;var wb=nh,bb=-1,y_=class S_{constructor(t,i,s=(S_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)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=s*.5;let[a,c]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${c}):`;console.warn(d),console.warn(a);let m=new xb(d,a);this._errorHandler(m)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,o]of this._stacks)(!t||i<o)&&(t=[s,o],i=o);return t}};y_._idPool=1;var kb=y_,Cb=class w_{constructor(t){this.value=t}static create(){let t=new Error;return new w_(t.stack??"")}print(){console.warn(this.value.split(`
58
+ `).slice(2).join(`
59
+ `))}},xb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Eb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Nb=0,nu=class{constructor(e){this.value=e,this.id=Nb++}},Rb=2,Pb,we=class{constructor(e){var t,i,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new kb((e==null?void 0:e.onListenerError)??Oa,((i=this._options)==null?void 0:i.leakWarningThreshold)??bb):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new wb(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var c,d,m,p,_;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let S=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(S);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],k=new Eb(`${S}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((c=this._options)==null?void 0:c.onListenerError)||Oa)(k),Je.None}if(this._disposed)return Je.None;t&&(e=e.bind(t));let s=new nu(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Cb.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof nu?(this._deliveryQueue??(this._deliveryQueue=new Db),this._listeners=[this._listeners,s]):this._listeners.push(s):((m=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||m.call(d,this),this._listeners=s,(_=(p=this._options)==null?void 0:p.onDidAddFirstListener)==null||_.call(p,this)),this._size++;let a=dt(()=>{o==null||o(),this._removeListener(s)});return i instanceof $n?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(e){var o,a,c,d;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.call(c,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-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[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*Rb<=t.length){let m=0;for(let p=0;p<t.length;p++)t[p]?t[m++]=t[p]:s&&(this._deliveryQueue.end--,m<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=m}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Oa;if(!i){e.value(t);return}try{e.value(t)}catch(o){i(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof nu)this._deliver(this._listeners,e);else{let a=this._deliveryQueue;a.enqueue(this,e,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},Db=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},sh=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new we,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new we,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};sh.INSTANCE=new sh;var ed=sh;function Mb(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}ed.INSTANCE.onDidChangeZoomLevel;function Lb(e){return ed.INSTANCE.getZoomFactor(e)}ed.INSTANCE.onDidChangeFullscreen;var rs=typeof navigator=="object"?navigator.userAgent:"",oh=rs.indexOf("Firefox")>=0,jb=rs.indexOf("AppleWebKit")>=0,td=rs.indexOf("Chrome")>=0,Tb=!td&&rs.indexOf("Safari")>=0;rs.indexOf("Electron/")>=0;rs.indexOf("Android")>=0;var ru=!1;if(typeof dn.matchMedia=="function"){let e=dn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=dn.matchMedia("(display-mode: fullscreen)");ru=e.matches,Mb(dn,e,({matches:i})=>{ru&&t.matches||(ru=i)})}var Vr="en",ah=!1,lh=!1,za=!1,b_=!1,Pa,Fa=Vr,jm=Vr,Ab,Fi,dr=globalThis,Wt,Ev;typeof dr.vscode<"u"&&typeof dr.vscode.process<"u"?Wt=dr.vscode.process:typeof process<"u"&&typeof((Ev=process==null?void 0:process.versions)==null?void 0:Ev.node)=="string"&&(Wt=process);var Nv,Ib=typeof((Nv=Wt==null?void 0:Wt.versions)==null?void 0:Nv.electron)=="string",Bb=Ib&&(Wt==null?void 0:Wt.type)==="renderer",Rv;if(typeof Wt=="object"){ah=Wt.platform==="win32",lh=Wt.platform==="darwin",za=Wt.platform==="linux",za&&Wt.env.SNAP&&Wt.env.SNAP_REVISION,Wt.env.CI||Wt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Pa=Vr,Fa=Vr;let e=Wt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Pa=t.userLocale,jm=t.osLocale,Fa=t.resolvedLanguage||Vr,Ab=(Rv=t.languagePack)==null?void 0:Rv.translationsConfigFile}catch{}b_=!0}else typeof navigator=="object"&&!Bb?(Fi=navigator.userAgent,ah=Fi.indexOf("Windows")>=0,lh=Fi.indexOf("Macintosh")>=0,(Fi.indexOf("Macintosh")>=0||Fi.indexOf("iPad")>=0||Fi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,za=Fi.indexOf("Linux")>=0,(Fi==null?void 0:Fi.indexOf("Mobi"))>=0,Fa=globalThis._VSCODE_NLS_LANGUAGE||Vr,Pa=navigator.language.toLowerCase(),jm=Pa):console.error("Unable to resolve platform.");var k_=ah,Ji=lh,Ob=za,Tm=b_,en=Fi,Tn=Fa,zb;(e=>{function t(){return Tn}e.value=t;function i(){return Tn.length===2?Tn==="en":Tn.length>=3?Tn[0]==="e"&&Tn[1]==="n"&&Tn[2]==="-":!1}e.isDefaultVariant=i;function s(){return Tn==="en"}e.isDefault=s})(zb||(zb={}));var Fb=typeof dr.postMessage=="function"&&!dr.importScripts;(()=>{if(Fb){let e=[];dr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),dr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Hb=!!(en&&en.indexOf("Chrome")>=0);en&&en.indexOf("Firefox")>=0;!Hb&&en&&en.indexOf("Safari")>=0;en&&en.indexOf("Edg/")>=0;en&&en.indexOf("Android")>=0;var Wr=typeof navigator=="object"?navigator:{};Tm||document.queryCommandSupported&&document.queryCommandSupported("copy")||Wr&&Wr.clipboard&&Wr.clipboard.writeText,Tm||Wr&&Wr.clipboard&&Wr.clipboard.readText;var id=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}},su=new id,Am=new id,Im=new id,$b=new Array(230),C_;(e=>{function t(d){return su.keyCodeToStr(d)}e.toString=t;function i(d){return su.strToKeyCode(d)}e.fromString=i;function s(d){return Am.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return Im.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function a(d){return Am.strToKeyCode(d)||Im.strToKeyCode(d)}e.fromUserSettings=a;function c(d){if(d>=98&&d<=113)return null;switch(d){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return su.keyCodeToStr(d)}e.toElectronAccelerator=c})(C_||(C_={}));var Wb=class x_{constructor(t,i,s,o,a){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof x_&&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",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${i}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Ub([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Ub=class{constructor(e){if(e.length===0)throw mb("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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 Kb(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return C_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(oh)switch(t){case 59:return 85;case 60:if(Ob)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ji)return 57;break}else if(jb&&(Ji&&t===93||!Ji&&t===92))return 57;return $b[t]||0}var qb=Ji?256:2048,Vb=512,Yb=1024,Xb=Ji?2048:256,Bm=class{constructor(e){var i;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=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=Kb(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|=qb),this.altKey&&(t|=Vb),this.shiftKey&&(t|=Yb),this.metaKey&&(t|=Xb),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Wb(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Om=new WeakMap;function Gb(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Qb=class{static getSameOriginWindowChain(e){let t=Om.get(e);if(!t){t=[],Om.set(e,t);let i=e,s;do s=Gb(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let c=a.window.deref();if(i+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===t||!a.iframeElement)break;let d=a.iframeElement.getBoundingClientRect();i+=d.top,s+=d.left}return{top:i,left:s}}},Da=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 i=Qb.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},zm=class{constructor(e,t=0,i=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(td){let a=navigator.userAgent.match(/Chrome\/(\d+)/);s=(a?parseInt(a[1]):123)<=122}if(e){let a=e,c=e,d=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")s?this.deltaY=a.wheelDeltaY/(120*d):this.deltaY=a.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?oh&&!Ji?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")Tb&&k_?this.deltaX=-(a.wheelDeltaX/120):s?this.deltaX=a.wheelDeltaX/(120*d):this.deltaX=a.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let m=e;m.deltaMode===m.DOM_DELTA_LINE?oh&&!Ji?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*d):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},E_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Jb;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Zb?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ut.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:E_})})(Jb||(Jb={}));var Zb=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?E_:(this._emitter||(this._emitter=new we),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},nd=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 eh("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new eh("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},e1=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new eh("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=dt(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},t1;(e=>{async function t(s){let o,a=await Promise.all(s.map(c=>c.then(d=>d,d=>{o||(o=d)})));if(typeof o<"u")throw o;return a}e.settled=t;function i(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(c){a(c)}})}e.withAsyncBody=i})(t1||(t1={}));var Fm=class Pi{static fromArray(t){return new Pi(i=>{i.emitMany(t)})}static fromPromise(t){return new Pi(async i=>{i.emitMany(await t)})}static fromPromises(t){return new Pi(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new Pi(async i=>{await Promise.all(t.map(async s=>{for await(let o of s)i.emitOne(o)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new we,queueMicrotask(async()=>{let s={emitOne:o=>this.emitOne(o),emitMany:o=>this.emitMany(o),reject:o=>this.reject(o)};try{await Promise.resolve(t(s)),this.resolve()}catch(o){this.reject(o)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ut.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new Pi(async s=>{for await(let o of t)s.emitOne(i(o))})}map(t){return Pi.map(this,t)}static filter(t,i){return new Pi(async s=>{for await(let o of t)i(o)&&s.emitOne(o)})}filter(t){return Pi.filter(this,t)}static coalesce(t){return Pi.filter(t,i=>!!i)}coalesce(){return Pi.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return Pi.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())}};Fm.EMPTY=Fm.fromArray([]);var{getWindow:Gi,getWindowId:i1,onDidRegisterWindow:n1}=(function(){let e=new Map,t={window:dn,disposables:new $n};e.set(dn.vscodeWindowId,t);let i=new we,s=new we,o=new we;function a(c,d){return(typeof c=="number"?e.get(c):void 0)??(d?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return Je.None;let d=new $n,m={window:c,disposables:d.add(new $n)};return e.set(c.vscodeWindowId,m),d.add(dt(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),d.add(Ue(c,At.BEFORE_UNLOAD,()=>{o.fire(c)})),i.fire(m),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:a,getWindow(c){var p;let d=c;if((p=d==null?void 0:d.ownerDocument)!=null&&p.defaultView)return d.ownerDocument.defaultView.window;let m=c;return m!=null&&m.view?m.view.window:dn},getDocument(c){return Gi(c).document}}})(),r1=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ue(e,t,i,s){return new r1(e,t,i,s)}var Hm=function(e,t,i,s){return Ue(e,t,i,s)},rd,s1=class extends e1{constructor(e){super(),this.defaultTarget=e&&Gi(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},$m=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){Oa(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,o=a=>{i.set(a,!1);let c=e.get(a)??[];for(t.set(a,c),e.set(a,[]),s.set(a,!0);c.length>0;)c.sort($m.sort),c.shift().execute();s.set(a,!1)};rd=(a,c,d=0)=>{let m=i1(a),p=new $m(c,d),_=e.get(m);return _||(_=[],e.set(m,_)),_.push(p),i.get(m)||(i.set(m,!0),a.requestAnimationFrame(()=>o(m))),p}})();function o1(e){let t=e.getBoundingClientRect(),i=Gi(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var At={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"},a1=class{constructor(t){this.domNode=t,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(t){let i=ci(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=ci(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=ci(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=ci(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=ci(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=ci(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=ci(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=ci(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=ci(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=ci(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=ci(t);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let i=ci(t);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let i=ci(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=ci(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function ci(e){return typeof e=="number"?`${e}px`:e}function ro(e){return new a1(e)}var N_=class{constructor(){this._hooks=new $n,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(dt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Gi(e)}this._hooks.add(Ue(a,At.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ue(a,At.POINTER_UP,c=>this.stopMonitoring(!0)))}};function l1(e,t,i){let s=null,o=null;if(typeof i.value=="function"?(s="value",o=i.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",o=i.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;i[s]=function(...c){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,c)}),this[a]}}var Xi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Xi||(Xi={}));var Zs=class Qt extends Je{constructor(){super(),this.dispatched=!1,this.targets=new Lm,this.ignoreTargets=new Lm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ut.runAndSubscribe(n1,({window:t,disposables:i})=>{i.add(Ue(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ue(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ue(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:dn,disposables:this._store}))}static addTarget(t){if(!Qt.isTouchDevice())return Je.None;Qt.INSTANCE||(Qt.INSTANCE=new Qt);let i=Qt.INSTANCE.targets.push(t);return dt(i)}static ignoreTarget(t){if(!Qt.isTouchDevice())return Je.None;Qt.INSTANCE||(Qt.INSTANCE=new Qt);let i=Qt.INSTANCE.ignoreTargets.push(t);return dt(i)}static isTouchDevice(){return"ontouchstart"in dn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let a=t.targetTouches.item(s);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:i,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[i],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let c=this.newGestureEvent(Xi.Start,a.target);c.pageX=a.pageX,c.pageY=a.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,c=i.changedTouches.length;a<c;a++){let d=i.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let m=this.activeTouches[d.identifier],p=Date.now()-m.initialTimeStamp;if(p<Qt.HOLD_DELAY&&Math.abs(m.initialPageX-vi(m.rollingPageX))<30&&Math.abs(m.initialPageY-vi(m.rollingPageY))<30){let _=this.newGestureEvent(Xi.Tap,m.initialTarget);_.pageX=vi(m.rollingPageX),_.pageY=vi(m.rollingPageY),this.dispatchEvent(_)}else if(p>=Qt.HOLD_DELAY&&Math.abs(m.initialPageX-vi(m.rollingPageX))<30&&Math.abs(m.initialPageY-vi(m.rollingPageY))<30){let _=this.newGestureEvent(Xi.Contextmenu,m.initialTarget);_.pageX=vi(m.rollingPageX),_.pageY=vi(m.rollingPageY),this.dispatchEvent(_)}else if(o===1){let _=vi(m.rollingPageX),S=vi(m.rollingPageY),y=vi(m.rollingTimestamps)-m.rollingTimestamps[0],k=_-m.rollingPageX[0],w=S-m.rollingPageY[0],x=[...this.targets].filter(b=>m.initialTarget instanceof Node&&b.contains(m.initialTarget));this.inertia(t,x,s,Math.abs(k)/y,k>0?1:-1,_,Math.abs(w)/y,w>0?1:-1,S)}this.dispatchEvent(this.newGestureEvent(Xi.End,m.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Xi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Qt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Xi.Change||t.type===Xi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;i.push([o,s])}i.sort((s,o)=>s[0]-o[0]);for(let[s,o]of i)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,o,a,c,d,m,p){this.handle=rd(t,()=>{let _=Date.now(),S=_-s,y=0,k=0,w=!0;o+=Qt.SCROLL_FRICTION*S,d+=Qt.SCROLL_FRICTION*S,o>0&&(w=!1,y=a*o*S),d>0&&(w=!1,k=m*d*S);let x=this.newGestureEvent(Xi.Change);x.translationX=y,x.translationY=k,i.forEach(b=>b.dispatchEvent(x)),w||this.inertia(t,i,_,o,a,c+y,d,m,p+k)})}onTouchMove(t){let i=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let a=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],d=this.newGestureEvent(Xi.Change,c.initialTarget);d.translationX=a.pageX-vi(c.rollingPageX),d.translationY=a.pageY-vi(c.rollingPageY),d.pageX=a.pageX,d.pageY=a.pageY,this.dispatchEvent(d),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(a.pageX),c.rollingPageY.push(a.pageY),c.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Zs.SCROLL_FRICTION=-.005,Zs.HOLD_DELAY=700,Zs.CLEAR_TAP_COUNT_TIME=400,yt([l1],Zs,"isTouchDevice",1);var c1=Zs,sd=class extends Je{onclick(e,t){this._register(Ue(e,At.CLICK,i=>t(new Da(Gi(e),i))))}onmousedown(e,t){this._register(Ue(e,At.MOUSE_DOWN,i=>t(new Da(Gi(e),i))))}onmouseover(e,t){this._register(Ue(e,At.MOUSE_OVER,i=>t(new Da(Gi(e),i))))}onmouseleave(e,t){this._register(Ue(e,At.MOUSE_LEAVE,i=>t(new Da(Gi(e),i))))}onkeydown(e,t){this._register(Ue(e,At.KEY_DOWN,i=>t(new Bm(i))))}onkeyup(e,t){this._register(Ue(e,At.KEY_UP,i=>t(new Bm(i))))}oninput(e,t){this._register(Ue(e,At.INPUT,t))}onblur(e,t){this._register(Ue(e,At.BLUR,t))}onfocus(e,t){this._register(Ue(e,At.FOCUS,t))}onchange(e,t){this._register(Ue(e,At.CHANGE,t))}ignoreGesture(e){return c1.ignoreTarget(e)}},Wm=11,u1=class extends sd{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=Wm+"px",this.domNode.style.height=Wm+"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 N_),this._register(Hm(this.bgDomNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Hm(this.domNode,At.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new s1),this._pointerdownScheduleRepeatTimer=this._register(new nd)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Gi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},h1=class ch{constructor(t,i,s,o,a,c,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,o=o|0,a=a|0,c=c|0,d=d|0),this.rawScrollLeft=o,this.rawScrollTop=d,i<0&&(i=0),o+i>s&&(o=s-i),o<0&&(o=0),a<0&&(a=0),d+a>c&&(d=c-a),d<0&&(d=0),this.width=i,this.scrollWidth=s,this.scrollLeft=o,this.height=a,this.scrollHeight=c,this.scrollTop=d}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,i){return new ch(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new ch(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,i){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,m=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:a,heightChanged:c,scrollHeightChanged:d,scrollTopChanged:m}}},d1=class extends Je{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new h1(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){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new Km(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Km.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Um=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function ou(e,t){let i=t-e;return function(s){return e+i*m1(s)}}function f1(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Km=class uh{constructor(t,i,s,o){this.from=t,this.to=i,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let o,a;return t<i?(o=t+.75*s,a=i-.75*s):(o=t-.75*s,a=i+.75*s),f1(ou(t,o),ou(a,i),.33)}return ou(t,i)}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 i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),o=this.scrollTop(i);return new Um(s,o,!1)}return new Um(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return uh.start(t,i,s)}static start(t,i,s){s=s+10;let o=Date.now()-10;return new uh(t,i,o,s)}};function p1(e){return Math.pow(e,3)}function m1(e){return 1-p1(1-e)}var g1=class extends Je{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new nd)}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(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},v1=140,R_=class extends sd{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 g1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new N_),this._shouldRender=!0,this.domNode=ro(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(Ue(this.domNode.domNode,At.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new u1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=ro(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ue(this.slider.domNode,At.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,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);i<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let o=o1(this.domNode.domNode);t=e.pageX-o.left,i=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),c=Math.abs(a-i);if(k_&&c>v1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let d=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(d))},()=>{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()}},P_=class hh{constructor(t,i,s,o,a,c){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=a,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new hh(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,o,a){let c=Math.max(0,s-t),d=Math.max(0,c-2*i),m=o>0&&o>s;if(!m)return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let p=Math.round(Math.max(20,Math.floor(s*d/o))),_=(d-p)/(o-s),S=a*_;return{computedAvailableSize:Math.round(c),computedIsNeeded:m,computedSliderSize:Math.round(p),computedSliderRatio:_,computedSliderPosition:Math.round(S)}}_refreshComputedValues(){let t=hh._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 i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},_1=class extends R_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new P_(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.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}},y1=class extends R_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new P_(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.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}},S1=500,qm=50,w1=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},dh=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,i=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,i+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(td){let i=Gi(t.browserEvent),s=Lb(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let o=null,a=new w1(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,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]=a),a.score=this._computeScore(a,o)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),c=Math.abs(i.deltaX),d=Math.abs(i.deltaY),m=Math.max(Math.min(o,c),1),p=Math.max(Math.min(a,d),1),_=Math.max(o,c),S=Math.max(a,d);_%m===0&&S%p===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};dh.INSTANCE=new dh;var b1=dh,k1=class extends sd{constructor(e,t,i){super(),this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new we),this.onWillScroll=this._onWillScroll.event,this._options=x1(t),this._scrollable=i,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new y1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new _1(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=ro(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=ro(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=ro(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 nd),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=fr(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,Ji&&(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 zm(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=fr(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new zm(i))};this._mouseWheelToDispose.push(Ue(this._listenOnDomNode,At.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=b1.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+a===0?c=a=0:Math.abs(a)>=Math.abs(c)?c=0:a=0),this._options.flipAxes&&([a,c]=[c,a]);let d=!Ji&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let m=this._scrollable.getFutureScrollPosition(),p={};if(a){let _=qm*a,S=m.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(p,S)}if(c){let _=qm*c,S=m.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(p,S)}p=this._scrollable.validateScrollPosition(p),(m.scrollLeft!==p.scrollLeft||m.scrollTop!==p.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(p):this._scrollable.setScrollPositionNow(p),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",o=t?" top":"",a=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),S1)}},C1=class extends k1{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function x1(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,Ji&&(t.className+=" mac"),t}var fh=class extends Je{constructor(e,t,i,s,o,a,c,d){super(),this._bufferService=i,this._optionsService=c,this._renderService=d,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let m=this._register(new d1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:p=>rd(s.window,p)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{m.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new C1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},m)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(p=>{this._scrollableElement.updateOptions({handleMouseWheel:!(p&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ut.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(dt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(dt(()=>this._styleElement.remove())),this._register(Ut.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
60
+ `)})),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(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};fh=yt([xe(2,ti),xe(3,fn),xe(4,c_),xe(5,ns),xe(6,ii),xe(7,pn)],fh);var ph=class extends Je{constructor(e,t,i,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,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(a=>this._removeDecoration(a))),this._register(dt(()=>{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){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};ph=yt([xe(1,ti),xe(2,fn),xe(3,fo),xe(4,pn)],ph);var E1=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},qi={full:0,left:0,center:0,right:0},An={full:0,left:0,center:0,right:0},Ws={full:0,left:0,center:0,right:0},Ja=class extends Je{constructor(e,t,i,s,o,a,c,d){var p;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=c,this._coreBrowserService=d,this._colorZoneStore=new E1,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(),(p=this._viewportElement.parentElement)==null||p.insertBefore(this._canvas,this._viewportElement),this._register(dt(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let m=this._canvas.getContext("2d");if(m)this._ctx=m;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);An.full=this._canvas.width,An.left=e,An.center=t,An.right=e,this._refreshDrawHeightConstants(),Ws.full=1,Ws.left=1,Ws.center=1+An.left,Ws.right=1+An.left+An.center}_refreshDrawHeightConstants(){qi.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);qi.left=t,qi.center=t,qi.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qi.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(Ws[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-qi[e.position||"full"]/2),An[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+qi[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}))}};Ja=yt([xe(2,ti),xe(3,fo),xe(4,pn),xe(5,ii),xe(6,ns),xe(7,fn)],Ja);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=`
61
+ `,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||(pe={}));var Ha;(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="Ÿ"))(Ha||(Ha={}));var D_;(e=>e.ST=`${pe.ESC}\\`)(D_||(D_={}));var mh=class{constructor(e,t,i,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=o,this._renderService=a,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 i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!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,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!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),i=this._renderService.dimensions.css.cell.height,s=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=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};mh=yt([xe(2,ti),xe(3,ii),xe(4,gr),xe(5,pn)],mh);var It=0,Bt=0,Ot=0,_t=0,Vm={css:"#00000000",rgba:0},Et;(e=>{function t(o,a,c,d){return d!==void 0?`#${nr(o)}${nr(a)}${nr(c)}${nr(d)}`:`#${nr(o)}${nr(a)}${nr(c)}`}e.toCss=t;function i(o,a,c,d=255){return(o<<24|a<<16|c<<8|d)>>>0}e.toRgba=i;function s(o,a,c,d){return{css:e.toCss(o,a,c,d),rgba:e.toRgba(o,a,c,d)}}e.toColor=s})(Et||(Et={}));var ut;(e=>{function t(m,p){if(_t=(p.rgba&255)/255,_t===1)return{css:p.css,rgba:p.rgba};let _=p.rgba>>24&255,S=p.rgba>>16&255,y=p.rgba>>8&255,k=m.rgba>>24&255,w=m.rgba>>16&255,x=m.rgba>>8&255;It=k+Math.round((_-k)*_t),Bt=w+Math.round((S-w)*_t),Ot=x+Math.round((y-x)*_t);let b=Et.toCss(It,Bt,Ot),C=Et.toRgba(It,Bt,Ot);return{css:b,rgba:C}}e.blend=t;function i(m){return(m.rgba&255)===255}e.isOpaque=i;function s(m,p,_){let S=$a.ensureContrastRatio(m.rgba,p.rgba,_);if(S)return Et.toColor(S>>24&255,S>>16&255,S>>8&255)}e.ensureContrastRatio=s;function o(m){let p=(m.rgba|255)>>>0;return[It,Bt,Ot]=$a.toChannels(p),{css:Et.toCss(It,Bt,Ot),rgba:p}}e.opaque=o;function a(m,p){return _t=Math.round(p*255),[It,Bt,Ot]=$a.toChannels(m.rgba),{css:Et.toCss(It,Bt,Ot,_t),rgba:Et.toRgba(It,Bt,Ot,_t)}}e.opacity=a;function c(m,p){return _t=m.rgba&255,a(m,_t*p/255)}e.multiplyOpacity=c;function d(m){return[m.rgba>>24&255,m.rgba>>16&255,m.rgba>>8&255]}e.toColorRGB=d})(ut||(ut={}));var gt;(e=>{let t,i;try{let o=document.createElement("canvas");o.width=1,o.height=1;let a=o.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return It=parseInt(o.slice(1,2).repeat(2),16),Bt=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),Et.toColor(It,Bt,Ot);case 5:return It=parseInt(o.slice(1,2).repeat(2),16),Bt=parseInt(o.slice(2,3).repeat(2),16),Ot=parseInt(o.slice(3,4).repeat(2),16),_t=parseInt(o.slice(4,5).repeat(2),16),Et.toColor(It,Bt,Ot,_t);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 a=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(a)return It=parseInt(a[1]),Bt=parseInt(a[2]),Ot=parseInt(a[3]),_t=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),Et.toColor(It,Bt,Ot,_t);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[It,Bt,Ot,_t]=t.getImageData(0,0,1,1).data,_t!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Et.toRgba(It,Bt,Ot,_t),css:o}}e.toColor=s})(gt||(gt={}));var ei;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,o,a){let c=s/255,d=o/255,m=a/255,p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),_=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),S=m<=.03928?m/12.92:Math.pow((m+.055)/1.055,2.4);return p*.2126+_*.7152+S*.0722}e.relativeLuminance2=i})(ei||(ei={}));var $a;(e=>{function t(c,d){if(_t=(d&255)/255,_t===1)return d;let m=d>>24&255,p=d>>16&255,_=d>>8&255,S=c>>24&255,y=c>>16&255,k=c>>8&255;return It=S+Math.round((m-S)*_t),Bt=y+Math.round((p-y)*_t),Ot=k+Math.round((_-k)*_t),Et.toRgba(It,Bt,Ot)}e.blend=t;function i(c,d,m){let p=ei.relativeLuminance(c>>8),_=ei.relativeLuminance(d>>8);if(un(p,_)<m){if(_<p){let k=s(c,d,m),w=un(p,ei.relativeLuminance(k>>8));if(w<m){let x=o(c,d,m),b=un(p,ei.relativeLuminance(x>>8));return w>b?k:x}return k}let S=o(c,d,m),y=un(p,ei.relativeLuminance(S>>8));if(y<m){let k=s(c,d,m),w=un(p,ei.relativeLuminance(k>>8));return y>w?S:k}return S}}e.ensureContrastRatio=i;function s(c,d,m){let p=c>>24&255,_=c>>16&255,S=c>>8&255,y=d>>24&255,k=d>>16&255,w=d>>8&255,x=un(ei.relativeLuminance2(y,k,w),ei.relativeLuminance2(p,_,S));for(;x<m&&(y>0||k>0||w>0);)y-=Math.max(0,Math.ceil(y*.1)),k-=Math.max(0,Math.ceil(k*.1)),w-=Math.max(0,Math.ceil(w*.1)),x=un(ei.relativeLuminance2(y,k,w),ei.relativeLuminance2(p,_,S));return(y<<24|k<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(c,d,m){let p=c>>24&255,_=c>>16&255,S=c>>8&255,y=d>>24&255,k=d>>16&255,w=d>>8&255,x=un(ei.relativeLuminance2(y,k,w),ei.relativeLuminance2(p,_,S));for(;x<m&&(y<255||k<255||w<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),x=un(ei.relativeLuminance2(y,k,w),ei.relativeLuminance2(p,_,S));return(y<<24|k<<16|w<<8|255)>>>0}e.increaseLuminance=o;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=a})($a||($a={}));function nr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function un(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var N1=class extends ho{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}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()]}},Za=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Mi}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 i=[],s=t.translateToString(!0),o=0,a=0,c=0,d=t.getFg(0),m=t.getBg(0);for(let p=0;p<t.getTrimmedLength();p++)if(t.loadCell(p,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==m){if(p-o>1){let _=this._getJoinedRanges(s,c,a,t,o);for(let S=0;S<_.length;S++)i.push(_[S])}o=p,c=a,d=this._workCell.fg,m=this._workCell.bg}a+=this._workCell.getChars().length||Fn.length}if(this._bufferService.cols-o>1){let p=this._getJoinedRanges(s,c,a,t,o);for(let _=0;_<p.length;_++)i.push(p[_])}return i}_getJoinedRanges(e,t,i,s,o){let a=e.substring(t,i),c=[];try{c=this._characterJoiners[0].handler(a)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let m=this._characterJoiners[d].handler(a);for(let p=0;p<m.length;p++)Za._mergeRanges(c,m[p])}catch(m){console.error(m)}return this._stringRangesToCellRanges(c,s,o),c}_stringRangesToCellRanges(e,t,i){let s=0,o=!1,a=0,c=e[s];if(c){for(let d=i;d<this._bufferService.cols;d++){let m=t.getWidth(d),p=t.getString(d).length||Fn.length;if(m!==0){if(!o&&c[0]<=a&&(c[0]=d,o=!0),c[1]<=a){if(c[1]=d,c=e[++s],!c)break;c[0]<=a?(c[0]=d,o=!0):o=!1}a+=p}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let o=e[s];if(i){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,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]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};Za=yt([xe(0,ti)],Za);function R1(e){return 57508<=e&&e<=57558}function P1(e){return 9472<=e&&e<=9631}function D1(e){return R1(e)||P1(e)}function M1(){return{css:{canvas:Ma(),cell:Ma()},device:{canvas:Ma(),cell:Ma(),char:{width:0,height:0,left:0,top:0}}}}function Ma(){return{width:0,height:0}}var gh=class{constructor(e,t,i,s,o,a,c){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=c,this._workCell=new Mi,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,o,a,c,d,m,p,_){let S=[],y=this._characterJoinerService.getJoinedCharacters(t),k=this._themeService.colors,w=e.getNoBgTrimmedLength();i&&w<a+1&&(w=a+1);let x,b=0,C="",D=0,j=0,M=0,Z=0,F=!1,T=0,X=!1,K=0,G=0,ee=[],A=p!==-1&&_!==-1;for(let N=0;N<w;N++){e.loadCell(N,this._workCell);let R=this._workCell.getWidth();if(R===0)continue;let I=!1,z=N>=G,$=N,H=this._workCell;if(y.length>0&&N===y[0][0]&&z){let Ce=y.shift(),rt=this._isCellInSelection(Ce[0],t);for(D=Ce[0]+1;D<Ce[1];D++)z&&(z=rt===this._isCellInSelection(D,t));z&&(z=!i||a<Ce[0]||a>=Ce[1]),z?(I=!0,H=new N1(this._workCell,e.translateToString(!0,Ce[0],Ce[1]),Ce[1]-Ce[0]),$=Ce[1]-1,R=H.getWidth()):G=Ce[1]}let re=this._isCellInSelection(N,t),q=i&&N===a,L=A&&N>=p&&N<=_,W=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Ce=>{W=!0});let oe=H.getChars()||Fn;if(oe===" "&&(H.isUnderline()||H.isOverline())&&(oe=" "),K=R*d-m.get(oe,H.isBold(),H.isItalic()),!x)x=this._document.createElement("span");else if(b&&(re&&X||!re&&!X&&H.bg===j)&&(re&&X&&k.selectionForeground||H.fg===M)&&H.extended.ext===Z&&L===F&&K===T&&!q&&!I&&!W&&z){H.isInvisible()?C+=Fn:C+=oe,b++;continue}else b&&(x.textContent=C),x=this._document.createElement("span"),b=0,C="";if(j=H.bg,M=H.fg,Z=H.extended.ext,F=L,T=K,X=re,I&&a>=N&&a<=$&&(a=N),!this._coreService.isCursorHidden&&q&&this._coreService.isCursorInitialized){if(ee.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&ee.push("xterm-cursor-blink"),ee.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":ee.push("xterm-cursor-outline");break;case"block":ee.push("xterm-cursor-block");break;case"bar":ee.push("xterm-cursor-bar");break;case"underline":ee.push("xterm-cursor-underline");break}}if(H.isBold()&&ee.push("xterm-bold"),H.isItalic()&&ee.push("xterm-italic"),H.isDim()&&ee.push("xterm-dim"),H.isInvisible()?C=Fn:C=H.getChars()||Fn,H.isUnderline()&&(ee.push(`xterm-underline-${H.extended.underlineStyle}`),C===" "&&(C=" "),!H.isUnderlineColorDefault()))if(H.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${ho.toColorRGB(H.getUnderlineColor()).join(",")})`;else{let Ce=H.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&H.isBold()&&Ce<8&&(Ce+=8),x.style.textDecorationColor=k.ansi[Ce].css}H.isOverline()&&(ee.push("xterm-overline"),C===" "&&(C=" ")),H.isStrikethrough()&&ee.push("xterm-strikethrough"),L&&(x.style.textDecoration="underline");let me=H.getFgColor(),V=H.getFgColorMode(),Q=H.getBgColor(),de=H.getBgColorMode(),ae=!!H.isInverse();if(ae){let Ce=me;me=Q,Q=Ce;let rt=V;V=de,de=rt}let ke,je,Ye=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Ce=>{Ce.options.layer!=="top"&&Ye||(Ce.backgroundColorRGB&&(de=50331648,Q=Ce.backgroundColorRGB.rgba>>8&16777215,ke=Ce.backgroundColorRGB),Ce.foregroundColorRGB&&(V=50331648,me=Ce.foregroundColorRGB.rgba>>8&16777215,je=Ce.foregroundColorRGB),Ye=Ce.options.layer==="top")}),!Ye&&re&&(ke=this._coreBrowserService.isFocused?k.selectionBackgroundOpaque:k.selectionInactiveBackgroundOpaque,Q=ke.rgba>>8&16777215,de=50331648,Ye=!0,k.selectionForeground&&(V=50331648,me=k.selectionForeground.rgba>>8&16777215,je=k.selectionForeground)),Ye&&ee.push("xterm-decoration-top");let qe;switch(de){case 16777216:case 33554432:qe=k.ansi[Q],ee.push(`xterm-bg-${Q}`);break;case 50331648:qe=Et.toColor(Q>>16,Q>>8&255,Q&255),this._addStyle(x,`background-color:#${Ym((Q>>>0).toString(16),"0",6)}`);break;case 0:default:ae?(qe=k.foreground,ee.push("xterm-bg-257")):qe=k.background}switch(ke||H.isDim()&&(ke=ut.multiplyOpacity(qe,.5)),V){case 16777216:case 33554432:H.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(x,qe,k.ansi[me],H,ke,void 0)||ee.push(`xterm-fg-${me}`);break;case 50331648:let Ce=Et.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(x,qe,Ce,H,ke,je)||this._addStyle(x,`color:#${Ym(me.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,qe,k.foreground,H,ke,je)||ae&&ee.push("xterm-fg-257")}ee.length&&(x.className=ee.join(" "),ee.length=0),!q&&!I&&!W&&z?b++:x.textContent=C,K!==this.defaultSpacing&&(x.style.letterSpacing=`${K}px`),S.push(x),N=$}return x&&b&&(x.textContent=C),S}_applyMinimumContrast(e,t,i,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||D1(s.getCode()))return!1;let c=this._getContrastCache(s),d;if(!o&&!a&&(d=c.getColor(t.rgba,i.rgba)),d===void 0){let m=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=ut.ensureContrastRatio(o||t,a||i,m),c.setColor((o||t).rgba,(a||i).rgba,d??null)}return d?(this._addStyle(e,`color:${d.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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};gh=yt([xe(1,d_),xe(2,ii),xe(3,fn),xe(4,gr),xe(5,fo),xe(6,ns)],gh);function Ym(e,t,i){for(;e.length<i;)e=t+e;return e}var L1=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[i,s,o,a],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(a),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let c=this._measure(e,0);return c>0&&(this._flat[s]=c),c}let o=e;t&&(o+="B"),i&&(o+="I");let a=this._holey.get(o);if(a===void 0){let c=0;t&&(c|=1),i&&(c|=2),a=this._measure(e,c),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},j1=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,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,c=i[1]-o,d=Math.max(a,0),m=Math.min(c,e.rows-1);if(d>=e.rows||m<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=c,this.viewportCappedStartRow=d,this.viewportCappedEndRow=m,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function T1(){return new j1}var au="xterm-dom-renderer-owner-",Ri="xterm-rows",La="xterm-fg-",Xm="xterm-bg-",Us="xterm-focus",ja="xterm-selection",A1=1,vh=class extends Je{constructor(e,t,i,s,o,a,c,d,m,p,_,S,y,k){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=c,this._charSizeService=m,this._optionsService=p,this._bufferService=_,this._coreService=S,this._coreBrowserService=y,this._themeService=k,this._terminalClass=A1++,this._rowElements=[],this._selectionRenderModel=T1(),this.onRequestRedraw=this._register(new we).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ri),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(ja),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=M1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(w=>this._injectCss(w))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(gh,document),this._element.classList.add(au+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(w=>this._handleLinkHover(w))),this._register(this._linkifier2.onHideLinkUnderline(w=>this._handleLinkLeave(w))),this._register(dt(()=>{this._element.classList.remove(au+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new L1(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ri} 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} .${Ri} { 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} .${Ri} .xterm-dim { color: ${ut.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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 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} .${Ri}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ri}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ri}.${Us} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ri} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ja} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ja} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ja} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,c]of e.ansi.entries())t+=`${this._terminalSelector} .${La}${a} { color: ${c.css}; }${this._terminalSelector} .${La}${a}.xterm-dim { color: ${ut.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Xm}${a} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${La}257 { color: ${ut.opaque(e.background).css}; }${this._terminalSelector} .${La}257.xterm-dim { color: ${ut.multiplyOpacity(ut.opaque(e.background),.5).css}; }${this._terminalSelector} .${Xm}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 i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Us),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Us),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(i){let m=e[0]>t[0];d.appendChild(this._createSelectionElement(a,m?t[0]:e[0],m?e[0]:t[0],c-a+1))}else{let m=s===a?e[0]:0,p=a===o?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(a,m,p));let _=c-a-1;if(d.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,_)),a!==c){let S=o===c?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(c,0,S))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,i,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(i-t);return a+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${c}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 i=this._bufferService.buffer,s=i.ybase+i.y,o=Math.min(i.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=e;m<=t;m++){let p=m+i.ydisp,_=this._rowElements[m],S=i.lines.get(p);if(!_||!S)break;_.replaceChildren(...this._rowFactory.createRow(S,p,p===s,c,d,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${au}${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,i,s,o,a){i<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;i=Math.max(Math.min(i,c),0),s=Math.max(Math.min(s,c),0),o=Math.min(o,this._bufferService.cols);let d=this._bufferService.buffer,m=d.ybase+d.y,p=Math.min(d.x,o-1),_=this._optionsService.rawOptions.cursorBlink,S=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let k=i;k<=s;++k){let w=k+d.ydisp,x=this._rowElements[k],b=d.lines.get(w);if(!x||!b)break;x.replaceChildren(...this._rowFactory.createRow(b,w,w===m,S,y,p,_,this.dimensions.css.cell.width,this._widthCache,a?k===i?e:0:-1,a?(k===s?t:o)-1:-1))}}};vh=yt([xe(7,Jh),xe(8,ol),xe(9,ii),xe(10,ti),xe(11,gr),xe(12,fn),xe(13,ns)],vh);var _h=class extends Je{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new we),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new B1(this._optionsService))}catch{this._measureStrategy=this._register(new I1(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())}};_h=yt([xe(2,ii)],_h);var M_=class extends Je{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)}},I1=class extends M_{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},B1=class extends M_{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}},O1=class extends Je{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new z1(this._window)),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new we),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ut.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ue(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ue(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}},z1=class extends Je{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new es),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(dt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ue(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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)}},F1=class extends Je{constructor(){super(),this.linkProviders=[],this._register(dt(()=>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 od(e,t,i){let s=i.getBoundingClientRect(),o=e.getComputedStyle(i),a=parseInt(o.getPropertyValue("padding-left")),c=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-c]}function H1(e,t,i,s,o,a,c,d,m){if(!a)return;let p=od(e,t,i);if(p)return p[0]=Math.ceil((p[0]+(m?c/2:0))/c),p[1]=Math.ceil(p[1]/d),p[0]=Math.min(Math.max(p[0],1),s+(m?1:0)),p[1]=Math.min(Math.max(p[1],1),o),p}var yh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,o){return H1(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let i=od(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};yh=yt([xe(0,pn),xe(1,ol)],yh);var $1=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,i){this._rowCount=i,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=[]}},L_={};J0(L_,{getSafariVersion:()=>U1,isChromeOS:()=>I_,isFirefox:()=>j_,isIpad:()=>K1,isIphone:()=>q1,isLegacyEdge:()=>W1,isLinux:()=>ad,isMac:()=>el,isNode:()=>al,isSafari:()=>T_,isWindows:()=>A_});var al=typeof process<"u"&&"title"in process,po=al?"node":navigator.userAgent,mo=al?"node":navigator.platform,j_=po.includes("Firefox"),W1=po.includes("Edge"),T_=/^((?!chrome|android).)*safari/i.test(po);function U1(){if(!T_)return 0;let e=po.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var el=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(mo),K1=mo==="iPad",q1=mo==="iPhone",A_=["Windows","Win16","Win32","WinCE"].includes(mo),ad=mo.indexOf("Linux")>=0,I_=/\bCrOS\b/.test(po),B_=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,i=0,s=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),i=Math.max(t,i),o=e.timeRemaining(),i*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},V1=class extends B_{_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())}}},Y1=class extends B_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},tl=!al&&"requestIdleCallback"in window?Y1:V1,X1=class{constructor(){this._queue=new tl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Sh=class extends Je{constructor(e,t,i,s,o,a,c,d,m){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=o,this._coreBrowserService=d,this._renderer=this._register(new es),this._pausedResizeTask=new X1,this._observerDisposable=this._register(new es),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 we),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new we),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new we),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new $1((p,_)=>this._renderRows(p,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new G1(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(dt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var p;return(p=this._renderer.value)==null?void 0:p.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(m.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(p=>this._registerIntersectionObserver(p,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=dt(()=>i.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,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(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(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),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(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Sh=yt([xe(2,ii),xe(3,ol),xe(4,gr),xe(5,fo),xe(6,ti),xe(7,fn),xe(8,ns)],Sh);var G1=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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 Q1(e,t,i,s){let o=i.buffer.x,a=i.buffer.y;if(!i.buffer.hasScrollback)return ek(o,a,e,t,i,s)+ll(a,t,i,s)+tk(o,a,e,t,i,s);let c;if(a===t)return c=o>e?"D":"C",ao(Math.abs(o-e),oo(c,s));c=a>t?"D":"C";let d=Math.abs(a-t),m=Z1(a>t?e:o,i)+(d-1)*i.cols+1+J1(a>t?o:e);return ao(m,oo(c,s))}function J1(e,t){return e-1}function Z1(e,t){return t.cols-e}function ek(e,t,i,s,o,a){return ll(t,s,o,a).length===0?"":ao(z_(e,t,e,t-pr(t,o),!1,o).length,oo("D",a))}function ll(e,t,i,s){let o=e-pr(e,i),a=t-pr(t,i),c=Math.abs(o-a)-ik(e,t,i);return ao(c,oo(O_(e,t),s))}function tk(e,t,i,s,o,a){let c;ll(t,s,o,a).length>0?c=s-pr(s,o):c=t;let d=s,m=nk(e,t,i,s,o,a);return ao(z_(e,c,i,d,m==="C",o).length,oo(m,a))}function ik(e,t,i){var c;let s=0,o=e-pr(e,i),a=t-pr(t,i);for(let d=0;d<Math.abs(o-a);d++){let m=O_(e,t)==="A"?-1:1;(c=i.buffer.lines.get(o+m*d))!=null&&c.isWrapped&&s++}return s}function pr(e,t){let i=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return i}function nk(e,t,i,s,o,a){let c;return ll(i,s,o,a).length>0?c=s-pr(s,o):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function O_(e,t){return e>t?"A":"B"}function z_(e,t,i,s,o,a){let c=e,d=t,m="";for(;(c!==i||d!==s)&&d>=0&&d<a.buffer.lines.length;)c+=o?1:-1,o&&c>a.cols-1?(m+=a.buffer.translateBufferLineToString(d,!1,e,c),c=0,e=0,d++):!o&&c<0&&(m+=a.buffer.translateBufferLineToString(d,!1,0,e+1),c=a.cols-1,e=c,d--);return m+a.buffer.translateBufferLineToString(d,!1,e,c)}function oo(e,t){let i=t?"O":"[";return pe.ESC+i+e}function ao(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var rk=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 Gm(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 lu=50,sk=15,ok=50,ak=500,lk=" ",ck=new RegExp(lk,"g"),wh=class extends Je{constructor(e,t,i,s,o,a,c,d,m){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=c,this._renderService=d,this._coreBrowserService=m,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Mi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new we),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new we),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new we),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 rk(this._bufferService),this._activeSelectionMode=0,this._register(dt(()=>{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 i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let d=i.translateBufferLineToString(c,!0,o,a);s.push(d)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let c=i.lines.get(a),d=i.translateBufferLineToString(a,!0);c!=null&&c.isWrapped?s[s.length-1]+=d:s.push(d)}if(e[1]!==t[1]){let a=i.lines.get(t[1]),c=i.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(o=>o.replace(ck," ")).join(A_?`\r
62
+ `:`
63
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),ad&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let i=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=Gm(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=od(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-lu),lu),t/=lu,t/Math.abs(t)+Math.round(t*(sk-1)))}shouldForceSelection(e){return el?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(),ok)}_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&&!(el&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<ak&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=Q1(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:o>1&&t!==s&&(i+=o-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let c=o.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(a,e[0]),m=d,p=e[0]-d,_=0,S=0,y=0,k=0;if(c.charAt(d)===" "){for(;d>0&&c.charAt(d-1)===" ";)d--;for(;m<c.length&&c.charAt(m+1)===" ";)m++}else{let b=e[0],C=e[0];a.getWidth(b)===0&&(_++,b--),a.getWidth(C)===2&&(S++,C++);let D=a.getString(C).length;for(D>1&&(k+=D-1,m+=D-1);b>0&&d>0&&!this._isCharWordSeparator(a.loadCell(b-1,this._workCell));){a.loadCell(b-1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,b--):j>1&&(y+=j-1,d-=j-1),d--,b--}for(;C<a.length&&m+1<c.length&&!this._isCharWordSeparator(a.loadCell(C+1,this._workCell));){a.loadCell(C+1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===2?(S++,C++):j>1&&(k+=j-1,m+=j-1),m++,C++}}m++;let w=d+p-_+y,x=Math.min(this._bufferService.cols,m-d+_+S-y-k);if(!(!t&&c.slice(d,m).trim()==="")){if(i&&w===0&&a.getCodePoint(0)!==32){let b=o.lines.get(e[1]-1);if(b&&a.isWrapped&&b.getCodePoint(this._bufferService.cols-1)!==32){let C=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(C){let D=this._bufferService.cols-C.start;w-=D,x+=D}}}if(s&&w+x===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let b=o.lines.get(e[1]+1);if(b!=null&&b.isWrapped&&b.getCodePoint(0)!==32){let C=this._getWordAt([0,e[1]+1],!1,!1,!0);C&&(x+=C.length)}}return{start:w,length:x}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=Gm(i,this._bufferService.cols)}};wh=yt([xe(3,ti),xe(4,gr),xe(5,Zh),xe(6,ii),xe(7,pn),xe(8,fn)],wh);var Qm=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Jm=class{constructor(){this._color=new Qm,this._css=new Qm}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Pt=Object.freeze((()=>{let e=[gt.toColor("#2e3436"),gt.toColor("#cc0000"),gt.toColor("#4e9a06"),gt.toColor("#c4a000"),gt.toColor("#3465a4"),gt.toColor("#75507b"),gt.toColor("#06989a"),gt.toColor("#d3d7cf"),gt.toColor("#555753"),gt.toColor("#ef2929"),gt.toColor("#8ae234"),gt.toColor("#fce94f"),gt.toColor("#729fcf"),gt.toColor("#ad7fa8"),gt.toColor("#34e2e2"),gt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],o=t[i/6%6|0],a=t[i%6];e.push({css:Et.toCss(s,o,a),rgba:Et.toRgba(s,o,a)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Et.toCss(s,s,s),rgba:Et.toRgba(s,s,s)})}return e})()),sr=gt.toColor("#ffffff"),eo=gt.toColor("#000000"),Zm=gt.toColor("#ffffff"),eg=eo,Ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},uk=sr,bh=class extends Je{constructor(e){super(),this._optionsService=e,this._contrastCache=new Jm,this._halfContrastCache=new Jm,this._onChangeColors=this._register(new we),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:sr,background:eo,cursor:Zm,cursorAccent:eg,selectionForeground:void 0,selectionBackgroundTransparent:Ks,selectionBackgroundOpaque:ut.blend(eo,Ks),selectionInactiveBackgroundTransparent:Ks,selectionInactiveBackgroundOpaque:ut.blend(eo,Ks),scrollbarSliderBackground:ut.opacity(sr,.2),scrollbarSliderHoverBackground:ut.opacity(sr,.4),scrollbarSliderActiveBackground:ut.opacity(sr,.5),overviewRulerBorder:sr,ansi:Pt.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=ot(e.foreground,sr),t.background=ot(e.background,eo),t.cursor=ut.blend(t.background,ot(e.cursor,Zm)),t.cursorAccent=ut.blend(t.background,ot(e.cursorAccent,eg)),t.selectionBackgroundTransparent=ot(e.selectionBackground,Ks),t.selectionBackgroundOpaque=ut.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ot(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ut.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ot(e.selectionForeground,Vm):void 0,t.selectionForeground===Vm&&(t.selectionForeground=void 0),ut.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ut.opacity(t.selectionBackgroundTransparent,.3)),ut.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ut.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ot(e.scrollbarSliderBackground,ut.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ot(e.scrollbarSliderHoverBackground,ut.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ot(e.scrollbarSliderActiveBackground,ut.opacity(t.foreground,.5)),t.overviewRulerBorder=ot(e.overviewRulerBorder,uk),t.ansi=Pt.slice(),t.ansi[0]=ot(e.black,Pt[0]),t.ansi[1]=ot(e.red,Pt[1]),t.ansi[2]=ot(e.green,Pt[2]),t.ansi[3]=ot(e.yellow,Pt[3]),t.ansi[4]=ot(e.blue,Pt[4]),t.ansi[5]=ot(e.magenta,Pt[5]),t.ansi[6]=ot(e.cyan,Pt[6]),t.ansi[7]=ot(e.white,Pt[7]),t.ansi[8]=ot(e.brightBlack,Pt[8]),t.ansi[9]=ot(e.brightRed,Pt[9]),t.ansi[10]=ot(e.brightGreen,Pt[10]),t.ansi[11]=ot(e.brightYellow,Pt[11]),t.ansi[12]=ot(e.brightBlue,Pt[12]),t.ansi[13]=ot(e.brightMagenta,Pt[13]),t.ansi[14]=ot(e.brightCyan,Pt[14]),t.ansi[15]=ot(e.brightWhite,Pt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=ot(e.extendedAnsi[s],Pt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};bh=yt([xe(0,ii)],bh);function ot(e,t){if(e!==void 0)try{return gt.toColor(e)}catch{}return t}var hk=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},dk=class{constructor(){this._services=new hk,this._services.set(Jh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=sb(e).sort((a,c)=>a.index-c.index),s=[];for(let a of i){let c=this._services.get(a.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);s.push(c)}let o=i.length>0?i[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,...s)}},fk={trace:0,debug:1,info:2,warn:3,error:4,off:5},pk="xterm.js: ",kh=class extends Je{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=fk[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":pk)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};kh=yt([xe(0,ii)],kh);var tg=class extends Je{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new we),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new we),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new we),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 i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let o=t-1;o>=0;o--)this.set(e+o+i,this.get(e+o));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Qe=3,xt=Object.freeze(new ho),Ta=0,cu=2,to=class F_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Qe);let o=i||Mi.fromCharData([0,s_,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let i=this._data[t*Qe+0],s=i&2097151;return[this._data[t*Qe+1],i&2097152?this._combined[t]:s?On(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Qe+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Qe+0]=t|2097152|i[2]<<22):this._data[t*Qe+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Qe+0]>>22}hasWidth(t){return this._data[t*Qe+0]&12582912}getFg(t){return this._data[t*Qe+1]}getBg(t){return this._data[t*Qe+2]}hasContent(t){return this._data[t*Qe+0]&4194303}getCodePoint(t){let i=this._data[t*Qe+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Qe+0]&2097152}getString(t){let i=this._data[t*Qe+0];return i&2097152?this._combined[t]:i&2097151?On(i&2097151):""}isProtected(t){return this._data[t*Qe+2]&536870912}loadCell(t,i){return Ta=t*Qe,i.content=this._data[Ta+0],i.fg=this._data[Ta+1],i.bg=this._data[Ta+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Qe+0]=i.content,this._data[t*Qe+1]=i.fg,this._data[t*Qe+2]=i.bg}setCellFromCodepoint(t,i,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Qe+0]=i|s<<22,this._data[t*Qe+1]=o.fg,this._data[t*Qe+2]=o.bg}addCodepointToCell(t,i,s){let o=this._data[t*Qe+0];o&2097152?this._combined[t]+=On(i):o&2097151?(this._combined[t]=On(o&2097151)+On(i),o&=-2097152,o|=2097152):o=i|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Qe+0]=o}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let o=new Mi;for(let a=this.length-t-i-1;a>=0;--a)this.setCell(t+i+a,this.loadCell(t+a,o));for(let a=0;a<i;++a)this.setCell(t+a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let o=new Mi;for(let a=0;a<this.length-t-i;++a)this.setCell(t+a,this.loadCell(t+i+a,o));for(let a=this.length-i;a<this.length;++a)this.setCell(a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*cu<this._data.buffer.byteLength;let s=t*Qe;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,i)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let c=0;c<o.length;c++){let d=parseInt(o[c],10);d>=t&&delete this._combined[d]}let a=Object.keys(this._extendedAttrs);for(let c=0;c<a.length;c++){let d=parseInt(a[c],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*cu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*cu<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new F_(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Qe+0]&4194303)return t+(this._data[t*Qe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Qe+0]&4194303||this._data[t*Qe+2]&50331648)return t+(this._data[t*Qe+0]>>22);return 0}copyCellsFrom(t,i,s,o,a){let c=t._data;if(a)for(let m=o-1;m>=0;m--){for(let p=0;p<Qe;p++)this._data[(s+m)*Qe+p]=c[(i+m)*Qe+p];c[(i+m)*Qe+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}else for(let m=0;m<o;m++){for(let p=0;p<Qe;p++)this._data[(s+m)*Qe+p]=c[(i+m)*Qe+p];c[(i+m)*Qe+2]&268435456&&(this._extendedAttrs[s+m]=t._extendedAttrs[i+m])}let d=Object.keys(t._combined);for(let m=0;m<d.length;m++){let p=parseInt(d[m],10);p>=i&&(this._combined[p-i+s]=t._combined[p])}}translateToString(t,i,s,o){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;i<s;){let c=this._data[i*Qe+0],d=c&2097151,m=c&2097152?this._combined[i]:d?On(d):Fn;if(a+=m,o)for(let p=0;p<m.length;++p)o.push(i);i+=c>>22||1}return o&&o.push(i),a}};function mk(e,t,i,s,o,a){let c=[];for(let d=0;d<e.length-1;d++){let m=d,p=e.get(++m);if(!p.isWrapped)continue;let _=[e.get(d)];for(;m<e.length&&p.isWrapped;)_.push(p),p=e.get(++m);if(!a&&s>=d&&s<m){d+=_.length-1;continue}let S=0,y=lo(_,S,t),k=1,w=0;for(;k<_.length;){let b=lo(_,k,t),C=b-w,D=i-y,j=Math.min(C,D);_[S].copyCellsFrom(_[k],w,y,j,!1),y+=j,y===i&&(S++,y=0),w+=j,w===b&&(k++,w=0),y===0&&S!==0&&_[S-1].getWidth(i-1)===2&&(_[S].copyCellsFrom(_[S-1],i-1,y++,1,!1),_[S-1].setCell(i-1,o))}_[S].replaceCells(y,i,o);let x=0;for(let b=_.length-1;b>0&&(b>S||_[b].getTrimmedLength()===0);b--)x++;x>0&&(c.push(d+_.length-x),c.push(x)),d+=_.length-1}return c}function gk(e,t){let i=[],s=0,o=t[s],a=0;for(let c=0;c<e.length;c++)if(o===c){let d=t[++s];e.onDeleteEmitter.fire({index:c-a,amount:d}),c+=d-1,a+=d,o=t[++s]}else i.push(c);return{layout:i,countRemoved:a}}function vk(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function _k(e,t,i){let s=[],o=e.map((m,p)=>lo(e,p,t)).reduce((m,p)=>m+p),a=0,c=0,d=0;for(;d<o;){if(o-d<i){s.push(o-d);break}a+=i;let m=lo(e,c,t);a>m&&(a-=m,c++);let p=e[c].getWidth(a-1)===2;p&&a--;let _=p?i-1:i;s.push(_),d+=_}return s}function lo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?i-1:i}var H_=class $_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=$_._nextId++,this._onDispose=this.register(new we),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),fr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};H_._nextId=1;var yk=H_,Mt={},or=Mt.B;Mt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Mt.A={"#":"£"};Mt.B=void 0;Mt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Mt.C=Mt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Mt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Mt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Mt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Mt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Mt.E=Mt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Mt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Mt.H=Mt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Mt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ig=4294967295,ng=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=xt.clone(),this.savedCharset=or,this.markers=[],this._nullCell=Mi.fromCharData([0,s_,1,0]),this._whitespaceCell=Mi.fromCharData([0,Fn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new tl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new tg(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 Qa),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 Qa),this._whitespaceCell}getBlankLine(e,t){return new to(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>ig?ig:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=xt);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 tg(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(xt),s=0,o=this._getCorrectBufferLength(t);if(o>this.lines.maxLength&&(this.lines.maxLength=o),this.lines.length>0){if(this._cols<e)for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,i);let a=0;if(this._rows<t)for(let c=this._rows;c<t;c++)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 to(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new to(e,i)));else for(let c=this._rows;c>t;c--)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 c=this.lines.length-o;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),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 a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=mk(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(xt),i);if(s.length>0){let o=gk(this.lines,s);vk(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(xt),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new to(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(xt),o=[],a=0;for(let c=this.lines.length-1;c>=0;c--){let d=this.lines.get(c);if(!d||!d.isWrapped&&d.getTrimmedLength()<=e)continue;let m=[d];for(;d.isWrapped&&c>0;)d=this.lines.get(--c),m.unshift(d);if(!i){let j=this.ybase+this.y;if(j>=c&&j<c+m.length)continue}let p=m[m.length-1].getTrimmedLength(),_=_k(m,this._cols,e),S=_.length-m.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+S):y=Math.max(0,this.lines.length-this.lines.maxLength+S);let k=[];for(let j=0;j<S;j++){let M=this.getBlankLine(xt,!0);k.push(M)}k.length>0&&(o.push({start:c+m.length+a,newLines:k}),a+=k.length),m.push(...k);let w=_.length-1,x=_[w];x===0&&(w--,x=_[w]);let b=m.length-S-1,C=p;for(;b>=0;){let j=Math.min(C,x);if(m[w]===void 0)break;if(m[w].copyCellsFrom(m[b],C-j,x-j,j,!0),x-=j,x===0&&(w--,x=_[w]),C-=j,C===0){b--;let M=Math.max(b,0);C=lo(m,M,this._cols)}}for(let j=0;j<m.length;j++)_[j]<e&&m[j].setCell(_[j],s);let D=S-y;for(;D-- >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+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+S,this.ybase+t-1)}if(o.length>0){let c=[],d=[];for(let x=0;x<this.lines.length;x++)d.push(this.lines.get(x));let m=this.lines.length,p=m-1,_=0,S=o[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let y=0;for(let x=Math.min(this.lines.maxLength-1,m+a-1);x>=0;x--)if(S&&S.start>p+y){for(let b=S.newLines.length-1;b>=0;b--)this.lines.set(x--,S.newLines[b]);x++,c.push({index:p+1,amount:S.newLines.length}),y+=S.newLines.length,S=o[++_]}else this.lines.set(x,d[p--]);let k=0;for(let x=c.length-1;x>=0;x--)c[x].index+=k,this.lines.onInsertEmitter.fire(c[x]),k+=c[x].amount;let w=Math.max(0,m+a-this.lines.maxLength);w>0&&this.lines.onTrimEmitter.fire(w)}}translateBufferLineToString(e,t,i=0,s){let o=this.lines.get(e);return o?o.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}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 yk(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Sk=class extends Je{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new we),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 ng(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ng(!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)}},W_=2,U_=1,Ch=class extends Je{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,W_),this.rows=Math.max(e.rawOptions.rows||0,U_),this.buffers=this._register(new Sk(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=i.ybase+i.scrollTop,a=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;a===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(a+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=a-o+1;i.lines.shiftElements(o+1,c-1,-1),i.lines.set(a,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Ch=yt([xe(0,ii)],Ch);var Ur={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:el,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},wk=["normal","bold","100","200","300","400","500","600","700","800","900"],bk=class extends Je{constructor(e){super(),this._onOptionChange=this._register(new we),this.onOptionChange=this._onOptionChange.event;let t={...Ur};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(dt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Ur))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Ur))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ur[e]),!kk(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ur[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=wk.includes(t)?t:Ur[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 kk(e){return e==="block"||e==="underline"||e==="bar"}function io(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&io(e[s],t-1);return i}var rg=Object.freeze({insertMode:!1}),sg=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),xh=class extends Je{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new we),this.onData=this._onData.event,this._onUserInput=this._register(new we),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new we),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=io(rg),this.decPrivateModes=io(sg)}reset(){this.modes=io(rg),this.decPrivateModes=io(sg)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};xh=yt([xe(0,ti),xe(1,u_),xe(2,ii)],xh);var og={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 uu(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var hu=String.fromCharCode,ag={DEFAULT:e=>{let t=[uu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${hu(t[0])}${hu(t[1])}${hu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${uu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${uu(e,!0)};${e.x};${e.y}${t}`}},Eh=class extends Je{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new we),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(og))this.addProtocol(s,og[s]);for(let s of Object.keys(ag))this.addEncoding(s,ag[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+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,i){if(i){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)}};Eh=yt([xe(0,ti),xe(1,gr),xe(2,ii)],Eh);var du=[[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]],Ck=[[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]],Dt;function xk(e,t){let i=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(o=i+s>>1,e>t[o][1])i=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var Ek=class{constructor(){if(this.version="6",!Dt){Dt=new Uint8Array(65536),Dt.fill(1),Dt[0]=0,Dt.fill(0,1,32),Dt.fill(0,127,160),Dt.fill(2,4352,4448),Dt[9001]=2,Dt[9002]=2,Dt.fill(2,11904,42192),Dt[12351]=1,Dt.fill(2,44032,55204),Dt.fill(2,63744,64256),Dt.fill(2,65040,65050),Dt.fill(2,65072,65136),Dt.fill(2,65280,65377),Dt.fill(2,65504,65511);for(let e=0;e<du.length;++e)Dt.fill(0,du[e][0],du[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Dt[e]:xk(e,Ck)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let o=cr.extractWidth(t);o===0?s=!1:o>i&&(i=o)}return cr.createPropertyValue(0,i,s)}},cr=class Wa{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new we,this.onChange=this._onChange.event;let t=new Ek;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,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,o=t.length;for(let a=0;a<o;++a){let c=t.charCodeAt(a);if(55296<=c&&c<=56319){if(++a>=o)return i+this.wcwidth(c);let p=t.charCodeAt(a);56320<=p&&p<=57343?c=(c-55296)*1024+p-56320+65536:i+=this.wcwidth(p)}let d=this.charProperties(c,s),m=Wa.extractWidth(d);Wa.extractShouldJoin(d)&&(m-=Wa.extractWidth(s)),i+=m,s=d}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Nk=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 lg(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var qs=2147483647,Rk=256,K_=class Nh{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>Rk)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Nh;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)i.addSubParam(o[a]);else i.addParam(o)}return i}clone(){let t=new Nh(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 i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,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>qs?qs: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>qs?qs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&(t[i]=this._subParams.slice(s,o))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[i-1];s[i-1]=~o?Math.min(o*10+t,qs):t}},Vs=[],Pk=class{constructor(){this._state=0,this._active=Vs,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Vs}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=Vs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Vs,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",sl(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}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 i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Vs,this._id=-1,this._state=0}}},_i=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=sl(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},Ys=[],Dk=class{constructor(){this._handlers=Object.create(null),this._active=Ys,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ys}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Ys,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ys,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",sl(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=Ys,this._ident=0}},no=new K_;no.addParam(0);var cg=class{constructor(e){this._handler=e,this._data="",this._params=no,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():no,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=sl(e,t,i),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(i=>(this._params=no,this._data="",this._hitLimit=!1,i));return this._params=no,this._data="",this._hitLimit=!1,t}},Mk=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=i<<4|s}},Di=160,Lk=(function(){let e=new Mk(4095),t=Array.apply(null,Array(256)).map((d,m)=>m),i=(d,m)=>t.slice(d,m),s=i(32,127),o=i(0,24);o.push(25),o.push.apply(o,i(28,32));let a=i(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in a)e.addMany([24,26,153,154],c,3,0),e.addMany(i(128,144),c,3,0),e.addMany(i(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,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(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,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(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(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(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Di,0,2,0),e.add(Di,8,5,8),e.add(Di,6,0,6),e.add(Di,11,0,11),e.add(Di,13,13,13),e})(),jk=class extends Je{constructor(e=Lk){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 K_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},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(dt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Pk),this._dcsParser=this._register(new Dk),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>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 a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.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,i,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,i){let s=0,o=0,a=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,m=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&m>-1){for(;m>=0&&(c=d[m](this._params),c!==!0);m--)if(c instanceof Promise)return this._parseStack.handlerPos=m,c}this._parseStack.handlers=[];break;case 4:if(i===!1&&m>-1){for(;m>=0&&(c=d[m](),c!==!0);m--)if(c instanceof Promise)return this._parseStack.handlerPos=m,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=a;d<t;++d){switch(s=e[d],o=this._transitions.table[this.currentState<<8|(s<160?s:Di)],o>>4){case 2:for(let y=d+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s<Di){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Di){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Di){this._printHandler(e,d,y),d=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<Di){this._printHandler(e,d,y),d=y-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:d,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let m=this._csiHandlers[this._collect<<8|s],p=m?m.length-1:-1;for(;p>=0&&(c=m[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._preserveStack(3,m,p,o,d),c;p<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++d<t&&(s=e[d])>47&&s<60);d--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let _=this._escHandlers[this._collect<<8|s],S=_?_.length-1:-1;for(;S>=0&&(c=_[S](),c!==!0);S--)if(c instanceof Promise)return this._preserveStack(4,_,S,o,d),c;S<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=d+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s<Di){this._dcsParser.put(e,d,y),d=y-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,o,d),c;s===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 y=d+1;;y++)if(y>=t||(s=e[y])<32||s>127&&s<Di){this._oscParser.put(e,d,y),d=y-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,o,d),c;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},Tk=/^([\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})$/,Ak=/^[\da-f]+$/;function ug(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Tk.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Ak.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(i*o,i*o+i),16);s[o]=i===1?a<<4:i===2?a:i===3?a>>4:a>>8}return s}}function fu(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function Ik(e,t=16){let[i,s,o]=e;return`rgb:${fu(i,t)}/${fu(s,t)}/${fu(o,t)}`}var Bk={"(":0,")":1,"*":2,"+":3,"-":1,".":2},In=131072,hg=10;function dg(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 fg=5e3,pg=0,Ok=class extends Je{constructor(e,t,i,s,o,a,c,d,m=new jk){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=c,this._unicodeService=d,this._parser=m,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new nb,this._utf8Decoder=new rb,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=xt.clone(),this._eraseAttrDataInternal=xt.clone(),this._onRequestBell=this._register(new we),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new we),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new we),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new we),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new we),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new we),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new we),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new we),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new we),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 Rh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(p=>this._activeBuffer=p.activeBuffer)),this._parser.setCsiHandlerFallback((p,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(p),params:_.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,_,S)=>{this._logService.debug("Unknown OSC code: ",{identifier:p,action:_,data:S})}),this._parser.setDcsHandlerFallback((p,_,S)=>{_==="HOOK"&&(S=S.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(p),action:_,payload:S})}),this._parser.setPrintHandler((p,_,S)=>this.print(p,_,S)),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(Ha.IND,()=>this.index()),this._parser.setExecuteHandler(Ha.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ha.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new _i(p=>(this.setTitle(p),this.setIconName(p),!0))),this._parser.registerOscHandler(1,new _i(p=>this.setIconName(p))),this._parser.registerOscHandler(2,new _i(p=>this.setTitle(p))),this._parser.registerOscHandler(4,new _i(p=>this.setOrReportIndexedColor(p))),this._parser.registerOscHandler(8,new _i(p=>this.setHyperlink(p))),this._parser.registerOscHandler(10,new _i(p=>this.setOrReportFgColor(p))),this._parser.registerOscHandler(11,new _i(p=>this.setOrReportBgColor(p))),this._parser.registerOscHandler(12,new _i(p=>this.setOrReportCursorColor(p))),this._parser.registerOscHandler(104,new _i(p=>this.restoreIndexedColor(p))),this._parser.registerOscHandler(110,new _i(p=>this.restoreFgColor(p))),this._parser.registerOscHandler(111,new _i(p=>this.restoreBgColor(p))),this._parser.registerOscHandler(112,new _i(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 Mt)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 cg((p,_)=>this.requestStatusString(p,_)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),fg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${fg} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,c=this._parseStack.paused;if(c){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>In&&(a=this._parseStack.position+In)}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<In&&(this._parseBuffer=new Uint32Array(Math.min(e.length,In))),c||this._dirtyRowTracker.clearRange(),e.length>In)for(let p=a;p<e.length;p+=In){let _=p+In<e.length?p+In:e.length,S=typeof e=="string"?this._stringDecoder.decode(e.substring(p,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(p,_),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,S))return this._preserveStack(s,o,S,p),this._logSlowResolvingAsync(i),i}else if(!c){let p=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,p))return this._preserveStack(s,o,p,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),m=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);m<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(m,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,i){let s,o,a=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,m=this._coreService.decPrivateModes.wraparound,p=this._coreService.modes.insertMode,_=this._curAttrData,S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&S.getWidth(this._activeBuffer.x-1)===2&&S.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let y=this._parser.precedingJoinState;for(let k=t;k<i;++k){if(s=e[k],s<127&&a){let C=a[String.fromCharCode(s)];C&&(s=C.charCodeAt(0))}let w=this._unicodeService.charProperties(s,y);o=cr.extractWidth(w);let x=cr.extractShouldJoin(w),b=x?cr.extractWidth(y):0;if(y=w,c&&this._onA11yChar.fire(On(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-b>d){if(m){let C=S,D=this._activeBuffer.x-b;for(this._activeBuffer.x=b,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),S=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),b>0&&S instanceof to&&S.copyCellsFrom(C,D,0,b,!1);D<d;)C.setCellFromCodepoint(D++,0,1,_)}else if(this._activeBuffer.x=d-1,o===2)continue}if(x&&this._activeBuffer.x){let C=S.getWidth(this._activeBuffer.x-1)?1:2;S.addCodepointToCell(this._activeBuffer.x-C,s,o);for(let D=o-b;--D>=0;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(p&&(S.insertCells(this._activeBuffer.x,o-b,this._activeBuffer.getNullCell(_)),S.getWidth(d-1)===2&&S.setCellFromCodepoint(d-1,0,1,_)),S.setCellFromCodepoint(this._activeBuffer.x++,s,o,_),o>0)for(;--o;)S.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=y,this._activeBuffer.x<d&&i-t>0&&S.getWidth(this._activeBuffer.x)===0&&!S.hasContent(this._activeBuffer.x)&&S.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>dg(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new cg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new _i(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(){var e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.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,i,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(i,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(xt));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=cr.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),c=new Uint32Array(a.length*i),d=0;for(let p=0;p<a.length;){let _=a.codePointAt(p)||0;c[d++]=_,p+=_>65535?2:1}let m=d;for(let p=1;p<i;++p)c.copyWithin(m,0,d),m+=d;return this.print(c,0,m),!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,or),this._charsetService.setgCharset(1,or),this._charsetService.setgCharset(2,or),this._charsetService.setgCharset(3,or);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){(x=>(x[x.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",x[x.SET=1]="SET",x[x.RESET=2]="RESET",x[x.PERMANENTLY_SET=3]="PERMANENTLY_SET",x[x.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,c=this._coreService,{buffers:d,cols:m}=this._bufferService,{active:p,alt:_}=d,S=this._optionsService.rawOptions,y=(x,b)=>(c.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${x};${b}$y`),!0),k=x=>x?1:2,w=e.params[0];return t?w===2?y(w,4):w===4?y(w,k(c.modes.insertMode)):w===12?y(w,3):w===20?y(w,k(S.convertEol)):y(w,0):w===1?y(w,k(s.applicationCursorKeys)):w===3?y(w,S.windowOptions.setWinLines?m===80?2:m===132?1:0:0):w===6?y(w,k(s.origin)):w===7?y(w,k(s.wraparound)):w===8?y(w,3):w===9?y(w,k(o==="X10")):w===12?y(w,k(S.cursorBlink)):w===25?y(w,k(!c.isCursorHidden)):w===45?y(w,k(s.reverseWraparound)):w===66?y(w,k(s.applicationKeypad)):w===67?y(w,4):w===1e3?y(w,k(o==="VT200")):w===1002?y(w,k(o==="DRAG")):w===1003?y(w,k(o==="ANY")):w===1004?y(w,k(s.sendFocus)):w===1005?y(w,4):w===1006?y(w,k(a==="SGR")):w===1015?y(w,4):w===1016?y(w,k(a==="SGR_PIXELS")):w===1048?y(w,1):w===47||w===1047||w===1049?y(w,k(p===_)):w===2004?y(w,k(s.bracketedPasteMode)):w===2026?y(w,k(s.synchronizedOutput)):y(w,0)}_updateAttrColor(e,t,i,s,o){return t===2?(e|=50331648,e&=-16777216,e|=ho.fromColorRGB([i,s,o])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let c=e.getSubParams(t+a),d=0;do s[1]===5&&(o=1),s[a+d+1+o]=c[d];while(++d<c.length&&d+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_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=xt.fg,e.bg=xt.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,i,s=this._curAttrData;for(let o=0;o<t;o++)i=e.params[o],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=xt.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=xt.bg&16777215):i===38||i===48||i===58?o+=this._extractColor(e,o,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=xt.fg&16777215,s.bg&=-67108864,s.bg|=xt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);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,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[?${t};${i}R`);break}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=xt.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 i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!dg(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>hg&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>hg&&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=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),o=i.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(mg(a))if(o==="?")t.push({type:0,index:a});else{let c=ug(o);c&&t.push({type:1,index:a,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,o=i.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=i[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=ug(i[s]);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=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let o=parseInt(i[s]);mg(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,or),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Bk[e[0]],Mt[e[1]]||or),!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=xt.clone(),this._eraseAttrDataInternal=xt.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 Mi;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 i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=c=>(this._coreService.triggerDataEvent(`${pe.ESC}${c}${pe.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Rh=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&&(pg=e,e=t,t=pg),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Rh=yt([xe(0,ti)],Rh);function mg(e){return 0<=e&&e<256}var zk=5e7,gg=12,Fk=50,Hk=class extends Je{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 we),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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>zk)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 i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let c=d=>performance.now()-i>=gg?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(i,d);o.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(c);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=gg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Fk&&(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()}},Ph=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 d=t.addMarker(t.ybase+t.y),m={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(m,d)),this._dataByLinkId.set(m.id,m),m.id}let i=e,s=this._getEntryIdKey(i),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Ph=yt([xe(0,ti)],Ph);var vg=!1,$k=class extends Je{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new es),this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onData=this._register(new we),this.onData=this._onData.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new we),this._instantiationService=new dk,this.optionsService=this._register(new bk(e)),this._instantiationService.setService(ii,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ch)),this._instantiationService.setService(ti,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(kh)),this._instantiationService.setService(u_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(xh)),this._instantiationService.setService(gr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Eh)),this._instantiationService.setService(c_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(cr)),this._instantiationService.setService(lb,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Nk),this._instantiationService.setService(ab,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ph),this._instantiationService.setService(h_,this._oscLinkService),this._inputHandler=this._register(new Ok(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ut.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ut.forward(this._bufferService.onResize,this._onResize)),this._register(Ut.forward(this.coreService.onData,this._onData)),this._register(Ut.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 Hk((t,i)=>this._inputHandler.parse(t,i))),this._register(Ut.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new we),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.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&&!vg&&(this._logService.warn("writeSync is unreliable and will be removed soon."),vg=!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,W_),t=Math.max(t,U_),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(lg.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(lg(this._bufferService),!1))),this._windowsWrappingHeuristics.value=dt(()=>{for(let t of e)t.dispose()})}}},Wk={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 Uk(e,t,i,s){var c;let o={type:0,cancel:!1,key:void 0},a=(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;a?o.key=pe.ESC+"[1;"+(a+1)+"D":t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=pe.ESC+"[1;"+(a+1)+"C":t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=pe.ESC+"[1;"+(a+1)+"A":t?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=pe.ESC+"[1;"+(a+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:a?o.key=pe.ESC+"[3;"+(a+1)+"~":o.key=pe.ESC+"[3~";break;case 36:a?o.key=pe.ESC+"[1;"+(a+1)+"H":t?o.key=pe.ESC+"OH":o.key=pe.ESC+"[H";break;case 35:a?o.key=pe.ESC+"[1;"+(a+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;"+(a+1)+"~":o.key=pe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=pe.ESC+"[6;"+(a+1)+"~":o.key=pe.ESC+"[6~";break;case 112:a?o.key=pe.ESC+"[1;"+(a+1)+"P":o.key=pe.ESC+"OP";break;case 113:a?o.key=pe.ESC+"[1;"+(a+1)+"Q":o.key=pe.ESC+"OQ";break;case 114:a?o.key=pe.ESC+"[1;"+(a+1)+"R":o.key=pe.ESC+"OR";break;case 115:a?o.key=pe.ESC+"[1;"+(a+1)+"S":o.key=pe.ESC+"OS";break;case 116:a?o.key=pe.ESC+"[15;"+(a+1)+"~":o.key=pe.ESC+"[15~";break;case 117:a?o.key=pe.ESC+"[17;"+(a+1)+"~":o.key=pe.ESC+"[17~";break;case 118:a?o.key=pe.ESC+"[18;"+(a+1)+"~":o.key=pe.ESC+"[18~";break;case 119:a?o.key=pe.ESC+"[19;"+(a+1)+"~":o.key=pe.ESC+"[19~";break;case 120:a?o.key=pe.ESC+"[20;"+(a+1)+"~":o.key=pe.ESC+"[20~";break;case 121:a?o.key=pe.ESC+"[21;"+(a+1)+"~":o.key=pe.ESC+"[21~";break;case 122:a?o.key=pe.ESC+"[23;"+(a+1)+"~":o.key=pe.ESC+"[23~";break;case 123:a?o.key=pe.ESC+"[24;"+(a+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((!i||s)&&e.altKey&&!e.metaKey){let d=(c=Wk[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(d)o.key=pe.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let m=e.ctrlKey?e.keyCode-64:e.keyCode+32,p=String.fromCharCode(m);e.shiftKey&&(p=p.toUpperCase()),o.key=pe.ESC+p}else if(e.keyCode===32)o.key=pe.ESC+(e.ctrlKey?pe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let m=e.code.slice(3,4);e.shiftKey||(m=m.toLowerCase()),o.key=pe.ESC+m,o.cancel=!0}}else i&&!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 kt=0,Kk=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new tl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new tl,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,a)=>this._getKey(o)-this._getKey(a)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[o]=e[t],t++):s[o]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(kt=this._search(t),kt===-1)||this._getKey(this._array[kt])!==t)return!1;do if(this._array[kt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(kt),!0;while(++kt<this._array.length&&this._getKey(this._array[kt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,i=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:i[s++]=this._array[o];this._array=i,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&&(kt=this._search(e),!(kt<0||kt>=this._array.length)&&this._getKey(this._array[kt])===e))do yield this._array[kt];while(++kt<this._array.length&&this._getKey(this._array[kt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(kt=this._search(e),!(kt<0||kt>=this._array.length)&&this._getKey(this._array[kt])===e))do t(this._array[kt]);while(++kt<this._array.length&&this._getKey(this._array[kt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,o=this._getKey(this._array[s]);if(o>e)i=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},pu=0,_g=0,qk=class extends Je{constructor(){super(),this._decorations=new Kk(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new we),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new we),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(dt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Vk(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!i||(a.options.layer??"bottom")===i)&&(yield a)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,o=>{pu=o.options.x??0,_g=pu+(o.options.width??1),e>=pu&&e<_g&&(!i||(o.options.layer??"bottom")===i)&&s(o)})}},Vk=class extends $n{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new we),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new we),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=gt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=gt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Yk=1e3,Xk=class{constructor(e,t=Yk){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,a=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_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)}},yg=20,il=class extends Je{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,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 a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,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 Xk(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(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
64
+ `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ue(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(dt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<yg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
65
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===yg+1&&(this._liveRegion.textContent+=Xu.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 i=this._terminal.buffer,s=i.lines.length.toString();for(let o=e;o<=t;o++){let a=i.lines.get(i.ydisp+o),c=[],d=(a==null?void 0:a.translateToString(!0,void 0,void 0,c))||"",m=(i.ydisp+o+1).toString(),p=this._rowElements[o];p&&(d.length===0?(p.textContent=" ",this._rowColumns.set(p,[0,1])):(p.textContent=d,this._rowColumns.set(p,c)),p.setAttribute("aria-posinset",m),p.setAttribute("aria-setsize",s),this._alignRowWidth(p))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=i.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let c,d;if(t===0?(c=i,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=i,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let m=this._createAccessibilityTreeNode();this._rowElements.unshift(m),this._rowContainer.insertAdjacentElement("afterbegin",m)}else{let m=this._createAccessibilityTreeNode();this._rowElements.push(m),this._rowContainer.appendChild(m)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var d;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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(i.node))return;let o=({node:m,offset:p})=>{let _=m instanceof Text?m.parentNode:m,S=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(S))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(_);if(!y)return console.warn("columns is null. Race condition?"),null;let k=p<y.length?y[p]:y.slice(-1)[0]+1;return k>=this._terminal.cols&&(++S,k=0),{row:S,column:k}},a=o(t),c=o(i);if(!(!a||!c)){if(a.row>c.row||a.row===c.row&&a.column>=c.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(c.row-a.row)*this._terminal.cols-a.column+c.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){var o,a;e.style.transform="";let t=e.getBoundingClientRect().width,i=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};il=yt([xe(1,Jh),xe(2,fn),xe(3,pn)],il);var Dh=class extends Je{constructor(e,t,i,s,o){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new we),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new we),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(dt(()=>{var a;fr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ue(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ue(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ue(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ue(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 i=e.composedPath();for(let s=0;s<i.length;s++){let o=i[s];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){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[a,c]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(i=this._checkLinkProviderResult(a,e,i)):c.provideLinks(e.y,d=>{var p,_;if(this._isMouseOut)return;let m=d==null?void 0:d.map(S=>({link:S}));(p=this._activeProviderReplies)==null||p.set(a,m),i=this._checkLinkProviderResult(a,e,i),((_=this._activeProviderReplies)==null?void 0:_.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let a=0;a<o.length;a++){let c=o[a],d=c.link.range.start.y<e?0:c.link.range.start.x,m=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let p=d;p<=m;p++){if(i.has(p)){o.splice(a--,1);break}i.add(p)}}}}_checkLinkProviderResult(e,t,i){var a;if(!this._activeProviderReplies)return i;let s=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&&s){let c=s.find(d=>this._linkAtPosition(d.link,t));c&&(i=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let c=0;c<this._activeProviderReplies.size;c++){let d=(a=this._activeProviderReplies.get(c))==null?void 0:a.find(m=>this._linkAtPosition(m.link,t));if(d){i=!0,this._handleNewLink(d);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Gk(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,fr(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:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,o,a;(s=this._currentLink)!=null&&s.state&&((a=(o=this._currentLink)==null?void 0:o.state)==null?void 0:a.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return i<=o&&o<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,o){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:o}}};Dh=yt([xe(1,Zh),xe(2,pn),xe(3,ti),xe(4,f_)],Dh);function Gk(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 Qk=class extends $k{constructor(e={}){super(e),this._linkifier=this._register(new es),this.browser=L_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new es),this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new we),this.onKey=this._onKey.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new we),this.onBell=this._onBell.event,this._onFocus=this._register(new we),this._onBlur=this._register(new we),this._onA11yCharEmitter=this._register(new we),this._onA11yTabEmitter=this._register(new we),this._onWillOpen=this._register(new we),this._setup(),this._decorationService=this._instantiationService.createInstance(qk),this._instantiationService.setService(fo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(F1),this._instantiationService.setService(f_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Qu)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 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(Ut.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ut.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ut.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ut.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(dt(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.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 i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let o=ut.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${pe.ESC}]${s};${Ik(o)}${D_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=Et.toColor(...t.color));else{let a=i;this._themeService.modifyColors(c=>c[a]=Et.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(il,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(){var e;return(e=this.textarea)==null?void 0:e.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 i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(i),a=this._renderService.dimensions.css.cell.width*o,c=this.buffer.y*this._renderService.dimensions.css.cell.height,d=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=c+"px",this.textarea.style.width=a+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ue(this.element,"copy",t=>{this.hasSelection()&&tb(t,this._selectionService)}));let e=t=>ib(t,this.textarea,this.coreService,this.optionsService);this._register(Ue(this.textarea,"paste",e)),this._register(Ue(this.element,"paste",e)),j_?this._register(Ue(this.element,"mousedown",t=>{t.button===2&&Pm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ue(this.element,"contextmenu",t=>{Pm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),ad&&this._register(Ue(this.element,"auxclick",t=>{t.button===1&&r_(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ue(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ue(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ue(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ue(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ue(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ue(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ue(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;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"),((o=this.element)==null?void 0:o.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(Ue(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Yu.get()),I_||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(O1,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(fn,this._coreBrowserService),this._register(Ue(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Ue(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(_h,this._document,this._helperContainer),this._instantiationService.setService(ol,this._charSizeService),this._themeService=this._instantiationService.createInstance(bh),this._instantiationService.setService(ns,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Za),this._instantiationService.setService(d_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Sh,this.rows,this.screenElement)),this._instantiationService.setService(pn,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(mh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(yh),this._instantiationService.setService(Zh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Dh,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(fh,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(wh,this.element,this.screenElement,s)),this._instantiationService.setService(ub,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(Ut.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(ph,this.screenElement)),this._register(Ue(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),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(il,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ja,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ja,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(vh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(a){var p,_,S,y,k;let c=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!c)return!1;let d,m;switch(a.overrideType||a.type){case"mousemove":m=32,a.buttons===void 0?(d=3,a.button!==void 0&&(d=a.button<3?a.button:3)):d=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":m=0,d=a.button<3?a.button:3;break;case"mousedown":m=1,d=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let w=a.deltaY;if(w===0||e.coreMouseService.consumeWheelEvent(a,(y=(S=(_=(p=e._renderService)==null?void 0:p.dimensions)==null?void 0:_.device)==null?void 0:S.cell)==null?void 0:y.height,(k=e._coreBrowserService)==null?void 0:k.dpr)===0)return!1;m=w<0?0:1,d=4;break;default:return!1}return m===void 0||d===void 0||d>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:d,action:m,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:a=>(i(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(i(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&i(a)},mousemove:a=>{a.buttons||i(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),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()),a&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),a&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),a&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),a&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ue(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return i(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(Ue(t,"wheel",a=>{var c,d,m,p,_;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(p=(m=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:m.cell)==null?void 0:p.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(a,!0);let S=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(S,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.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){n_(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,i){this._selectionService.setSelection(e,t,i)}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(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.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 i=Uk(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===pe.ETX||i.key===pe.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Jk(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){var i;(i=this._charSizeService)==null||i.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(xt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.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),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Jk(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Zk=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;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)}},eC=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 Mi)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Sg=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 eC(t)}getNullCell(){return new Mi}},tC=class extends Je{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new we),this.onBufferChange=this._onBufferChange.event,this._normal=new Sg(this._core.buffers.normal,"normal"),this._alternate=new Sg(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)}},iC=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},nC=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}},rC=["cols","rows"],Vi=0,sC=class extends Je{constructor(e){super(),this._core=this._register(new Qk(e)),this._addonManager=this._register(new Zk),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(rC.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 iC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new nC(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 tC(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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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
66
+ `,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 Yu.get()},set promptLabel(e){Yu.set(e)},get tooMuchOutput(){return Xu.get()},set tooMuchOutput(e){Xu.set(e)}}}_verifyIntegers(...e){for(Vi of e)if(Vi===1/0||isNaN(Vi)||Vi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Vi of e)if(Vi&&(Vi===1/0||isNaN(Vi)||Vi%1!==0||Vi<0))throw new Error("This API only accepts positive integers")}};/**
67
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
68
+ * @license MIT
69
+ *
70
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
71
+ * @license MIT
72
+ *
73
+ * Originally forked from (with the author's permission):
74
+ * Fabrice Bellard's javascript vt100 for jslinux:
75
+ * http://bellard.org/jslinux/
76
+ * Copyright (c) 2011 Fabrice Bellard
77
+ */var oC=2,aC=1,lC=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(){var S;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:((S=this._terminal.options.overviewRuler)==null?void 0:S.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),o=Math.max(0,parseInt(i.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),c={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},d=c.top+c.bottom,m=c.right+c.left,p=s-d,_=o-m-t;return{cols:Math.max(oC,Math.floor(_/e.css.cell.width)),rows:Math.max(aC,Math.floor(p/e.css.cell.height))}}};function cC(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function uC({session:e,node:t,token:i,cols:s,rows:o,readonly:a=!1,takeSize:c,focused:d,onData:m,onExit:p,onFiles:_,retryBaseMs:S=250}){const y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const w=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${cC(t,i)}`;let x=null,b=!1,C=!1,D=null,j=0,M=d;const Z=()=>{if(b||C||D)return;const T=Math.min(5e3,Math.max(0,S)*2**Math.min(j++,5));D=setTimeout(()=>{D=null,F()},T)},F=()=>{if(b||C)return;const T=new WebSocket(w);x=T,T.binaryType="arraybuffer",T.onopen=()=>{if(x!==T||b)return;j=0;const X={type:"attach",session:e,token:i,cols:s,rows:o,readonly:a};c!==void 0&&(X.takeSize=c),T.send(JSON.stringify(X)),M!==void 0&&T.send(JSON.stringify({type:"focus",on:!!M}))},T.onmessage=X=>{if(!(x!==T||b))if(typeof X.data=="string"){let K;try{K=JSON.parse(X.data)}catch{return}K.type==="exit"&&(C=!0,p&&p(K.code)),K.type==="files"&&_&&_(K)}else m&&m(new Uint8Array(X.data))},T.onerror=()=>{if(x===T)try{T.close()}catch{}},T.onclose=X=>{x!==T||b||C||[1e3,1002,4401,4404].includes(X==null?void 0:X.code)||Z()}};return F(),{sendInput:T=>{if(!x||x.readyState!==1)return!1;try{return x.send(typeof T=="string"?new TextEncoder().encode(T):T),!0}catch{try{x.close()}catch{}return!1}},isReady:()=>!!x&&x.readyState===1,resize:(T,X)=>{s=T,o=X,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"resize",cols:T,rows:X}))},action:T=>{(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"action",name:T}))},focus:T=>{M=T,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"focus",on:!!T}))},close:()=>{if(b=!0,D&&clearTimeout(D),D=null,x)try{x.close()}catch{}},get raw(){return x}}}async function wg(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const i=document.createElement("textarea");i.value=t,i.readOnly=!0,i.style.position="fixed",i.style.opacity="0",i.style.pointerEvents="none",document.body.appendChild(i),i.select();const s=document.execCommand&&document.execCommand("copy");if(i.remove(),s)return!0}catch{}return!1}const hC="\r";function dC(e){const t=String(e||"");let i=t.length;for(;i>0;){const s=t.charCodeAt(i-1);if(s===10||s===13)i-=1;else break}return t.slice(0,i)}function fC({isReady:e,paste:t,send:i}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:i(hC)!==!1}catch{return!1}}}function pC(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function mC(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const gC=450,bg=8;function vC(e,t,i,s){return Math.abs(Number(i)-Number(e))>bg||Math.abs(Number(s)-Number(t))>bg}const _C=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function mu(e){return e?e.files&&e.files.length>0||Array.from(e.items||[]).some(t=>t&&t.kind==="file")?!0:Array.from(e.types||[]).includes("Files"):!1}function kg(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(i=>i&&i.kind==="file"&&typeof i.getAsFile=="function").map(i=>i.getAsFile()).filter(Boolean)}function yC(e,t=0,i=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=_C.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${i}-${t+1}.${o}`}async function q_({files:e,token:t,session:i,node:s="",paste:o=!0,fetchImpl:a=zt,onProgress:c=()=>{},now:d=Date.now()}={}){const m=Array.from(e||[]).filter(Boolean),p=[],_=[];if(!i||!m.length)return{paths:p,errors:_};const S=hi(s?String(s).split("/"):[]);for(let y=0;y<m.length;y+=1){const k=m[y],w=yC(k,y,d);c({index:y,total:m.length,name:w,state:"uploading"});try{const x=new FormData;x.append("session",i),x.append("paste",o?"true":"false"),x.append("file",k,w);const b=await a(`${S}/files/upload`,t,{method:"POST",body:x}),C=await b.json().catch(()=>({}));if(!b.ok||C.error)throw new Error(C.error||`HTTP ${b.status}`);p.push(C.path),c({index:y,total:m.length,name:w,state:"done",path:C.path})}catch(x){const b=String((x==null?void 0:x.message)||x);_.push({name:w,message:b}),c({index:y,total:m.length,name:w,state:"error",error:b})}}return{paths:p,errors:_}}function V_({session:e,node:t,token:i,readonly:s,takeSize:o,focused:a,sendRef:c,composerRef:d,actionRef:m,ctrlRef:p,setCtrlArmed:_,onFiles:S,fontSize:y=13,selectionMode:k=!1,onSelectionModeChange:w}){const x=P.useRef(null),b=P.useRef(null),C=P.useRef(y);C.current=y;const D=P.useRef(a);D.current=a;const j=P.useRef(k);j.current=k;const[M,Z]=P.useState(""),[F,T]=P.useState(""),[X,K]=P.useState(null),G=async()=>{var R,I,z,$;const A=((I=(R=b.current)==null?void 0:R.term)==null?void 0:I.getSelection())||M;if(!A){T(v("copy-empty")),setTimeout(()=>T(""),1500);return}const N=await wg(A);T(v(N?"copied":"copy-manual")),N&&(($=(z=b.current)==null?void 0:z.term)==null||$.clearSelection(),w==null||w(!1)),setTimeout(()=>T(""),1800)},ee=P.useRef(G);return ee.current=G,P.useEffect(()=>{const A=b.current;A&&A.sock&&A.sock.focus&&A.sock.focus(!!a)},[a]),P.useEffect(()=>{const A=b.current;A&&(A.term.options.fontSize=y,A.fit.fit(),A.sock.resize(A.term.cols,A.term.rows))},[y]),P.useEffect(()=>{const A=new sC({cursorBlink:!0,fontSize:C.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),N=new lC;A.loadAddon(N),A.open(x.current),N.fit();const R=new TextDecoder;let I;try{I=uC({session:e,node:t,token:i,readonly:s,takeSize:o,focused:D.current,onFiles:S,cols:A.cols,rows:A.rows,onData:he=>A.write(R.decode(he)),onExit:()=>A.write(`\r
78
+ \x1B[33m[sessione finita]\x1B[0m\r
79
+ `)})}catch(he){return A.write(`\r
80
+ \x1B[31m${he.message}\x1B[0m\r
81
+ `),()=>A.dispose()}b.current={term:A,fit:N,sock:I};let z=null;const $=A.onData(he=>{if(s){z&&(z.ok=!1);return}if(!z&&p&&p.current&&he.length===1){const Xe=he.charCodeAt(0);let st=Xe;Xe>=97&&Xe<=122?st=Xe-96:Xe>=64&&Xe<=95?st=Xe-64:Xe===32&&(st=0),he=String.fromCharCode(st),p.current=!1,_&&_(!1)}const Ee=I.sendInput(he);z&&(z.seen=!0,z.ok=z.ok&&Ee)});c&&(c.current=he=>I.sendInput(he)),m&&(m.current=he=>I.action(he)),d&&(d.current=fC({isReady:()=>!s&&I.isReady(),paste:he=>{const Ee={seen:!1,ok:!0};z=Ee;try{A.paste(he)}catch{Ee.ok=!1}finally{z=null}return Ee.seen&&Ee.ok},send:he=>I.sendInput(he)}));const H=A.onSelectionChange(()=>Z(A.getSelection()));A.attachCustomKeyEventHandler(he=>(he.ctrlKey||he.metaKey)&&he.key.toLowerCase()==="c"&&A.getSelection()?(he.type==="keydown"&&wg(A.getSelection()),!1):!0);const re=x.current;let q=!1;const L=async he=>{if(!he.length||q)return;if(s){K({error:v("settings-readonly")});return}q=!0,K({current:0,total:he.length,name:""});const Ee=await q_({files:he,token:i,session:e,node:t,paste:!0,onProgress:({index:Xe,total:st,name:ue,state:Ne,error:Ve})=>K({current:Xe+1,total:st,name:ue,...Ne==="error"?{error:Ve}:{}})});q=!1,Ee.errors.length?K({error:Ee.errors.map(Xe=>`${Xe.name}: ${Xe.message}`).join(" · ")}):(K({done:!0,total:Ee.paths.length}),setTimeout(()=>K(null),1600))},W=he=>{const Ee=he.clipboardData;if(!mu(Ee))return;const Xe=kg(Ee);Xe.length&&(he.preventDefault(),he.stopPropagation(),L(Xe))},oe=he=>{mu(he.dataTransfer)&&(he.preventDefault(),he.stopPropagation())},me=he=>{mu(he.dataTransfer)&&(he.preventDefault(),he.stopPropagation(),L(kg(he.dataTransfer)))};re.addEventListener("paste",W,!0),re.addEventListener("dragenter",oe,!0),re.addEventListener("dragover",oe,!0),re.addEventListener("drop",me,!0);const V=24;let Q=null,de=null,ae=0,ke=null,je=null,Ye=null,qe=!1;const Ce=()=>{Ye&&clearTimeout(Ye),Ye=null},rt=(he,Ee)=>{const st=(re.querySelector(".xterm-screen")||re).getBoundingClientRect(),ue=Math.max(0,Math.min(A.cols-1,Math.floor((he-st.left)/Math.max(1,st.width)*A.cols))),Ne=Math.max(0,Math.min(A.rows-1,Math.floor((Ee-st.top)/Math.max(1,st.height)*A.rows)));return{col:ue,row:A.buffer.active.viewportY+Ne}},St=he=>rt(he.clientX,he.clientY),ne=he=>{if(Ce(),qe=!1,he.touches.length!==1){Q=null;return}if(j.current){he.preventDefault(),he.stopPropagation(),je=St(he.touches[0]),A.clearSelection();return}Q=he.touches[0].clientY,de=he.touches[0].clientX,ae=0,ke=null;const Ee={x:de,y:Q};Ye=setTimeout(()=>{Ye=null,qe=!0,j.current=!0,w==null||w(!0),je=rt(Ee.x,Ee.y),A.clearSelection(),A.select(je.col,je.row,1),Q=null,de=null,ke=null,ae=0},gC)},le=he=>{if((j.current||qe)&&je&&he.touches.length===1){he.preventDefault(),he.stopPropagation();const Xe=St(he.touches[0]),st=je.row*A.cols+je.col,ue=Xe.row*A.cols+Xe.col,Ne=st<=ue?je:Xe;A.select(Ne.col,Ne.row,Math.abs(ue-st)+1);return}if(Q===null||he.touches.length!==1)return;he.preventDefault(),he.stopPropagation();const Ee=he.touches[0];if(Ye&&vC(de,Q,Ee.clientX,Ee.clientY)&&Ce(),ke===null&&(Math.abs(Ee.clientY-Q)>8||Math.abs(Ee.clientX-de)>8)&&(ke=Math.abs(Ee.clientY-Q)>Math.abs(Ee.clientX-de)),!!ke){for(ae+=Ee.clientY-Q,Q=Ee.clientY;ae>=V;)I.action("scroll-up"),ae-=V;for(;ae<=-V;)I.action("scroll-down"),ae+=V}},Be=()=>{Ce(),Q=null,de=null,je=null,qe=!1};let J=0;const B=he=>{for(he.preventDefault(),he.stopPropagation(),J+=he.deltaY;J<=-V;)I.action("scroll-up"),J+=V;for(;J>=V;)I.action("scroll-down"),J-=V};re.addEventListener("touchstart",ne,{passive:!1}),re.addEventListener("touchmove",le,{passive:!1,capture:!0}),re.addEventListener("touchend",Be,{passive:!0}),re.addEventListener("touchcancel",Be,{passive:!0});const fe=he=>{(j.current||qe)&&(he.preventDefault(),he.stopPropagation())};re.addEventListener("contextmenu",fe,!0),re.addEventListener("wheel",B,{passive:!1,capture:!0});let be=null;const Se=he=>{pC(he)&&(he.preventDefault(),he.stopPropagation(),be=rt(he.clientX,he.clientY),A.clearSelection())},Ae=he=>{if(!be)return;he.preventDefault(),he.stopPropagation();const Ee=rt(he.clientX,he.clientY),Xe=be.row*A.cols+be.col,st=Ee.row*A.cols+Ee.col,ue=Xe<=st?be:Ee;A.select(ue.col,ue.row,Math.abs(st-Xe)+1)},ce=he=>{be&&(he.stopPropagation(),be=null)};re.addEventListener("mousedown",Se,!0),re.addEventListener("mousemove",Ae,!0),re.addEventListener("mouseup",ce,!0);const Me=he=>{!mC(he)||!(b.current&&b.current.term&&b.current.term.getSelection())||(he.preventDefault(),he.stopPropagation(),ee.current&&ee.current())};re.addEventListener("keydown",Me,!0);const Pe=()=>{N.fit(),I.resize(A.cols,A.rows)};window.addEventListener("resize",Pe);const He=window.visualViewport;He&&(He.addEventListener("resize",Pe),He.addEventListener("scroll",Pe));let Oe=null,$e=0;return typeof ResizeObserver<"u"&&(Oe=new ResizeObserver(()=>{$e&&cancelAnimationFrame($e),$e=requestAnimationFrame(Pe)}),Oe.observe(re)),()=>{b.current=null,c&&(c.current=()=>!1),d&&(d.current=()=>!1),m&&(m.current=()=>!1),$.dispose(),H.dispose(),re.removeEventListener("touchstart",ne),re.removeEventListener("touchmove",le,{capture:!0}),re.removeEventListener("touchend",Be),re.removeEventListener("touchcancel",Be),re.removeEventListener("contextmenu",fe,!0),Ce(),re.removeEventListener("wheel",B,{capture:!0}),re.removeEventListener("mousedown",Se,!0),re.removeEventListener("mousemove",Ae,!0),re.removeEventListener("mouseup",ce,!0),re.removeEventListener("keydown",Me,!0),re.removeEventListener("paste",W,!0),re.removeEventListener("dragenter",oe,!0),re.removeEventListener("dragover",oe,!0),re.removeEventListener("drop",me,!0),window.removeEventListener("resize",Pe),He&&(He.removeEventListener("resize",Pe),He.removeEventListener("scroll",Pe)),Oe&&Oe.disconnect(),$e&&cancelAnimationFrame($e),I.close(),A.dispose()}},[e,t,i,s,o,c,d,m,p,_,S]),u.jsxs("div",{className:`nc-terminal${k?" selecting":""}`,children:[u.jsx("div",{className:"nc-terminal-host",ref:x}),X&&u.jsx("div",{className:`nc-upload-state${X.error?" error":""}`,role:"status",children:X.error?X.error:X.done?v("attach-uploaded").replace("{n}",String(X.total||0)):v("attach-upload-progress").replace("{n}",String(X.current||0)).replace("{total}",String(X.total||0))}),(M||k)&&u.jsxs("div",{className:"nc-selection-tools",children:[M?u.jsx("button",{type:"button",onClick:G,children:F||v("copy")}):u.jsx("span",{children:v("select-drag")}),u.jsx("button",{type:"button",onClick:()=>{var A,N;(N=(A=b.current)==null?void 0:A.term)==null||N.clearSelection(),Z(""),w==null||w(!1)},children:v("cancel")}),F===v("copy-manual")&&u.jsx("textarea",{readOnly:!0,value:M,onFocus:A=>A.target.select()})]})]})}const Cg="",ui="\x1B",SC=[{label:"↑",seq:ui+"[A"},{label:"↓",seq:ui+"[B"},{label:"PGUP",seq:ui+"[5~"},{label:"PGDN",seq:ui+"[6~"}];function wC({send:e,action:t,ctrlArmed:i=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:c}){const[d,m]=P.useState(!1),[p,_]=P.useState(!1),[S,y]=P.useState(!1),k=b=>{S?(e(ui+b),y(!1)):e(b)},w=(b,C,D)=>u.jsx("button",{onMouseDown:j=>{j.preventDefault(),k(C),D&&D()},children:b},b),x=(b,C)=>u.jsx("button",{onMouseDown:D=>{D.preventDefault(),t(C),_(!1)},children:b},b);return d?u.jsxs("div",{className:"nc-keybar copy",children:[u.jsx("span",{className:"tag",children:"copy-mode"}),SC.map(b=>w(b.label,b.seq)),w("ESCI (q)","q",()=>m(!1))]}):u.jsxs("div",{className:"nc-keybar termux",children:[p&&u.jsxs("div",{className:"nc-keymenu",children:[x("←WIN","prev-window"),x("WIN→","next-window"),x("⬅PANE","pane-left"),x("PANE➡","pane-right"),w("SCROLL",Cg+"[",()=>{m(!0),_(!1)}),u.jsx("button",{className:a?"armed":"",onMouseDown:b=>{b.preventDefault(),c==null||c(!a),_(!1)},children:"SELECT"}),w("⌃C","",()=>_(!1)),w("DETACH",Cg+"d",()=>_(!1))]}),u.jsxs("div",{className:"row",children:[w("ESC",ui),u.jsx("button",{className:p?"armed":"",onMouseDown:b=>{b.preventDefault(),_(C=>!C)},children:"☰"},"menu"),w("/","/"),w("—","-"),w("HOME",ui+"[H"),w("↑",ui+"[A"),w("END",ui+"[F"),w("PGUP",ui+"[5~")]}),u.jsxs("div",{className:"row",children:[w("⇥"," "),u.jsx("button",{onMouseDown:b=>{b.preventDefault(),o&&o()},children:"⌨"},"kbd"),u.jsx("button",{className:i?"armed":"",onMouseDown:b=>{b.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),u.jsx("button",{className:S?"armed":"",onMouseDown:b=>{b.preventDefault(),y(C=>!C)},children:"ALT"},"alt"),w("←",ui+"[D"),w("↓",ui+"[B"),w("→",ui+"[C"),w("PGDN",ui+"[6~")]})]})}const bC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function Y_({session:e,node:t,token:i,filesEvent:s,onClose:o}){wi();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=t?`${t}:${e}`:e,[d,m]=P.useState("outbox"),[p,_]=P.useState({inbox:[],outbox:[]}),[S,y]=P.useState(""),k=P.useRef(null);async function w(){try{const j=await(await zt(`${a}/files?session=${encodeURIComponent(e)}`,i)).json();if(j.error){y(j.error);return}_(j);const M=j.outbox[0]?j.outbox[0].mtime:0;localStorage.setItem(Pv(c),String(M))}catch(D){y(String(D))}}P.useEffect(()=>{w()},[e,t]),P.useEffect(()=>{s&&s.session===e&&w()},[s]);async function x(D){for(const j of D){y(`carico ${j.name}…`);const M=new FormData;M.append("session",e),M.append("file",j);try{const F=await(await zt(`${a}/files/upload`,i,{method:"POST",body:M})).json();y(F.error?`errore: ${F.error}`:"")}catch(Z){y(String(Z))}}w()}async function b(D){const j=await zt(`${a}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(D)}`,i);if(!j.ok){y("errore download");return}const M=await j.blob(),Z=URL.createObjectURL(M),F=document.createElement("a");F.href=Z,F.download=D,F.click(),URL.revokeObjectURL(Z)}async function C(D){await zt(`${a}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(D)}`,i,{method:"DELETE"}),w()}return u.jsxs("div",{className:"nc-files",children:[u.jsxs("header",{children:[u.jsx("b",{children:t?`${t}:${e}`:e}),u.jsx("button",{onClick:o,title:v("close"),children:u.jsx(tt,{name:"x",size:20})})]}),u.jsxs("nav",{children:[u.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>m("outbox"),children:"outbox"}),u.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>m("inbox"),children:"inbox"}),u.jsxs("button",{className:"up",onClick:()=>k.current&&k.current.click(),children:[u.jsx(tt,{name:"upload",size:18})," ",v("upload")]}),u.jsx("input",{type:"file",multiple:!0,ref:k,style:{display:"none"},onChange:D=>{x(Array.from(D.target.files||[])),D.target.value=""}})]}),S&&u.jsx("div",{className:"nc-busy",children:S}),u.jsxs("ul",{children:[p[d].map(D=>u.jsxs("li",{children:[u.jsx("span",{className:"name",onClick:()=>b(D.name),children:D.name}),u.jsx("small",{children:bC(D.size)}),u.jsx("button",{onClick:()=>C(D.name),title:"elimina",children:u.jsx(tt,{name:"trash",size:18})})]},D.name)),p[d].length===0&&u.jsx("li",{className:"empty",children:v("empty-files")})]})]})}const cl="nc_composer_v1",Mh="nc-composer-reset",kC=50,X_=256*1024,G_=512*1024,CC=768*1024,xg=2*1024*1024,Q_=720*60*60*1e3,Lh=1;function J_(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function ld(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function nl(){return{version:Lh,cells:{}}}function Z_(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=J_(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>X_)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=kC))break}let i=0;return t.filter(s=>i+s.text.length>CC?!1:(i+=s.text.length,!0))}function rl(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=G_?e.draft:"",i=Z_(e.history),s=J_(e.updatedAt),o=e.expanded===!0;return!t&&!i.length&&!o?null:{draft:t,history:i,expanded:o,updatedAt:s}}function xC(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return nl()}if(!t||typeof t!="object"||t.version!==Lh||!t.cells||typeof t.cells!="object")return nl();const i=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=rl(o);a&&(i[s]=a)}return{version:Lh,cells:i}}function ey(e){const t=ld(e);if(!t)return nl();try{return xC(t.getItem(cl))}catch{return nl()}}function Eg(e){try{return JSON.stringify(e).length}catch{return 1/0}}function EC(e,t,i){for(const[s,o]of Object.entries(e.cells))s!==i&&o.updatedAt>0&&t-o.updatedAt>Q_&&delete e.cells[s]}function ty(e,t){return Object.entries(e.cells).filter(([i])=>i!==t).sort((i,s)=>i[1].updatedAt-s[1].updatedAt).map(([i])=>i)}function NC(e,t){for(;Eg(e)>xg;){const i=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!i.length)break;i[0][1].history.pop()}for(const i of ty(e,t)){if(Eg(e)<=xg)break;delete e.cells[i]}}function iy(e,t,i){const s=ld(e);if(!s)return!1;NC(t,i);const o=()=>(s.setItem(cl,JSON.stringify(t)),!0);try{return o()}catch{for(const c of ty(t,i)){delete t.cells[c];try{return o()}catch{}}return!1}}function go(e,t,i,s){const o=ey(t);EC(o,i,e);const a=rl(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...a,history:[...a.history]}),d=rl(c);return d?o.cells[e]={...d,updatedAt:i}:delete o.cells[e],{ok:iy(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:i}}}function RC({ownerId:e,node:t,session:i}){const s=String(i||"");if(!s)return"";const o=Zr.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Xs(e,t,i=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=ey(t),o=rl(s.cells[e]);return!o||o.updatedAt>0&&i-o.updatedAt>Q_?(s.cells[e]&&(delete s.cells[e],iy(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function Ng(e,t,i,s=Date.now()){const o=String(t||"");return!e||o.length>G_?!1:go(e,i,s,a=>({...a,draft:o})).ok}function Rg(e,t,i=Date.now()){return e?go(e,t,i,s=>({...s,draft:""})).ok:!1}function PC(e,t,i,s=Date.now()){return e?go(e,i,s,o=>({...o,expanded:!!t})).ok:!1}function DC(e,t,i,s=Date.now()){const o=String(t||"");return!e||!o||o.length>X_?!1:go(e,i,s,a=>{const c=a.history.filter(d=>d.text!==o);return c.unshift({text:o,at:s}),{...a,history:Z_(c)}}).ok}function MC(e,t,i=Date.now()){return e?go(e,t,i,s=>({...s,history:[]})).ok:!1}function LC(e){const t=ld(e);if(!t)return!1;try{return t.removeItem(cl),!0}catch{return!1}}const jC=300;function TC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function AC({ownerId:e,node:t,session:i,storage:s=TC()}){const o=P.useMemo(()=>RC({ownerId:e,node:t,session:i}),[e,t,i]),a=P.useMemo(()=>Xs(o,s),[]),[c,d]=P.useState(a.draft),[m,p]=P.useState(a.expanded),[_,S]=P.useState(a.history),[y,k]=P.useState(-1),w=P.useRef(o),x=P.useRef(a.draft),b=P.useRef(null),C=P.useRef(a.updatedAt||0),D=P.useRef(a.draft),j=P.useCallback(()=>{b.current&&clearTimeout(b.current),b.current=null},[]),M=P.useCallback(()=>{j(),Ng(w.current,x.current,s)},[j,s]),Z=P.useCallback(()=>{j(),b.current=setTimeout(()=>{b.current=null,Ng(w.current,x.current,s)},jC)},[j,s]),F=P.useCallback(R=>{const I=String(typeof R=="function"?R(x.current):R||"");x.current=I,C.current=Date.now(),D.current=I,k(-1),d(I),Z()},[Z]),T=P.useCallback((R,I)=>{j(),x.current=R,C.current=Date.now(),d(R),k(I),Z()},[j,Z]),X=P.useCallback(()=>{if(!_.length)return!1;const R=Math.min(y+1,_.length-1);return y<0&&(D.current=x.current),T(_[R].text,R),!0},[T,_,y]),K=P.useCallback(()=>{if(y<0)return!1;const R=y-1;return T(R<0?D.current:_[R].text,R),!0},[T,_,y]),G=P.useCallback(R=>{D.current=x.current;const I=_.findIndex(z=>z.text===R);T(String(R||""),I)},[T,_]),ee=P.useCallback(()=>{p(R=>{const I=!R;return PC(w.current,I,s),I})},[s]),A=P.useCallback((R,I,z)=>{if(!R)return;if(DC(R,z,s),!(w.current===R)){Xs(R,s).draft===I&&Rg(R,s);return}S(Xs(R,s).history),D.current="",k(-1),x.current===I?(j(),x.current="",C.current=Date.now(),d(""),Rg(R,s)):Z()},[j,Z,s]),N=P.useCallback(()=>{MC(w.current,s),S([]),k(-1),D.current=x.current},[s]);return P.useEffect(()=>{if(w.current===o)return;M(),w.current=o;const R=Xs(o,s);x.current=R.draft,C.current=R.updatedAt||0,D.current=R.draft,d(R.draft),p(R.expanded),S(R.history),k(-1)},[o,M,s]),P.useEffect(()=>{const R=()=>M(),I=()=>{document.visibilityState==="hidden"&&M()};return window.addEventListener("pagehide",R),document.addEventListener("visibilitychange",I),()=>{window.removeEventListener("pagehide",R),document.removeEventListener("visibilitychange",I),M()}},[M]),P.useEffect(()=>{const R=()=>{j(),x.current="",C.current=0,D.current="",d(""),p(!1),S([]),k(-1)},I=$=>{if($.key!==cl)return;if($.newValue==null){R();return}const H=Xs(w.current,s);H.updatedAt<C.current||(j(),x.current=H.draft,C.current=H.updatedAt,D.current=H.draft,d(H.draft),p(H.expanded),S(H.history),k(-1))},z=()=>R();return window.addEventListener("storage",I),window.addEventListener(Mh,z),()=>{window.removeEventListener("storage",I),window.removeEventListener(Mh,z)}},[j,s]),{cellKey:o,text:c,setText:F,expanded:m,toggleExpanded:ee,history:_,historyCursor:y,recallPrevious:X,recallNext:K,selectHistory:G,confirmSubmitted:A,clearHistory:N,flush:M}}function ny({submitText:e,token:t,session:i,node:s,ownerId:o}){wi();const a=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:c,text:d,setText:m,expanded:p,toggleExpanded:_,history:S,historyCursor:y,recallPrevious:k,recallNext:w,selectHistory:x,confirmSubmitted:b,clearHistory:C,flush:D}=AC({ownerId:o,node:s,session:i}),[j,M]=P.useState(!1),[Z,F]=P.useState(""),[T,X]=P.useState(!1),K=P.useRef(null),G=P.useRef(null),ee=P.useRef(null),[A,N]=P.useState(!1),[R,I]=P.useState({left:0,bottom:0}),[z,$]=P.useState(!1),[H,re]=P.useState(!1),q=P.useRef(null),L=P.useRef(null),W=P.useRef(null),oe=P.useRef(null),me=P.useRef(null),V=P.useRef(null),Q=P.useRef(null),de=P.useRef(!1),[ae,ke]=P.useState(!1),[je,Ye]=P.useState({left:0,bottom:0,width:320}),qe=P.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);P.useEffect(()=>{let ce=!1;if(s){X(!1);return}return zt(`${a}/voice/status`,t).then(Me=>Me.json()).then(Me=>{ce||X(!!Me.serverSttConfigured)}).catch(()=>{ce||X(!1)}),()=>{ce=!0}},[t,a]);const rt=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||T);async function St(){const ce=d,Me=dC(ce);if(!Me||H)return;re(!0),F("");let Pe=!1;try{Pe=!!await e(Me)}catch{Pe=!1}Pe?b(c,ce,Me):F(v("composer-send-failed")),re(!1),requestAnimationFrame(()=>{var He;return(He=ee.current)==null?void 0:He.focus({preventScroll:!0})})}function ne(){const ce=q.current&&q.current.getBoundingClientRect();ce&&I({left:Math.max(6,Math.min(ce.left,window.innerWidth-186)),bottom:window.innerHeight-ce.top+6}),N(!0)}function le(ce){N(!1),ce&&q.current&&q.current.focus()}function Be(){const ce=W.current&&W.current.getBoundingClientRect();if(ce){const Me=Math.max(220,Math.min(360,window.innerWidth-12));Ye({left:Math.max(6,Math.min(ce.right-Me,window.innerWidth-Me-6)),bottom:window.innerHeight-ce.top+6,width:Me})}ke(!0)}function J(ce){ke(!1),ce&&W.current&&W.current.focus()}P.useEffect(()=>{if(!A)return;const ce=Pe=>{Pe.key==="Escape"&&le(!0)},Me=Pe=>{const He=L.current&&L.current.contains(Pe.target),Oe=q.current&&q.current.contains(Pe.target);!He&&!Oe&&le(!1)};return document.addEventListener("keydown",ce),document.addEventListener("pointerdown",Me),()=>{document.removeEventListener("keydown",ce),document.removeEventListener("pointerdown",Me)}},[A]),P.useEffect(()=>{if(!ae)return;const ce=Pe=>{Pe.key==="Escape"&&J(!0)},Me=Pe=>{const He=oe.current&&oe.current.contains(Pe.target),Oe=W.current&&W.current.contains(Pe.target);!He&&!Oe&&J(!1)};return document.addEventListener("keydown",ce),document.addEventListener("pointerdown",Me),()=>{document.removeEventListener("keydown",ce),document.removeEventListener("pointerdown",Me)}},[ae]);function B(ce){if(!(ce.isComposing||de.current||ce.altKey||ce.ctrlKey||ce.metaKey)){if(ce.key==="ArrowUp"&&ce.currentTarget.selectionStart===0&&ce.currentTarget.selectionEnd===0){k()&&ce.preventDefault();return}ce.key==="ArrowDown"&&y>=0&&ce.currentTarget.selectionStart===d.length&&ce.currentTarget.selectionEnd===d.length&&w()&&ce.preventDefault()}}function fe(ce){le(!1),ce.current&&ce.current.click()}async function be(ce){if(!ce.length||!i)return;$(!0),F("");const{paths:Me,errors:Pe}=await q_({files:ce,token:t,session:i,node:s,paste:!1});Pe.length&&F(Pe.map(He=>`${He.name}: ${He.message}`).join(" · ")),Me.length&&m(He=>He+(He&&!He.endsWith(" ")?" ":"")+Me.join(" ")),$(!1)}function Se(){K.current&&K.current.stop(),G.current&&G.current.stop(),M(!1)}async function Ae(){F("");const ce=window.SpeechRecognition||window.webkitSpeechRecognition;if(ce){const Me=new ce;Me.lang="it-IT",Me.continuous=!1,Me.interimResults=!0;const Pe=d?`${d} `:"";Me.onresult=He=>{const Oe=Array.from(He.results).map($e=>$e[0].transcript).join("");m(Pe+Oe)},Me.onend=()=>M(!1),Me.onerror=He=>{F(`voice: ${He.error||"errore"}`),M(!1)},K.current=Me,Me.start(),M(!0);return}try{const Me=await navigator.mediaDevices.getUserMedia({audio:!0}),Pe=new MediaRecorder(Me),He=[];Pe.ondataavailable=Oe=>He.push(Oe.data),Pe.onstop=async()=>{Me.getTracks().forEach(Oe=>Oe.stop()),M(!1),F("trascrivo…");try{const Oe=new Blob(He,{type:Pe.mimeType||"audio/webm"}),he=await(await zt(`${a}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:Oe})).json();he.error?F(he.error):(F(""),m(Ee=>Ee+(Ee?" ":"")+(he.text||"")))}catch(Oe){F(String(Oe))}},G.current={stop:()=>Pe.state!=="inactive"&&Pe.stop()},Pe.start(),M(!0)}catch{F("microfono non disponibile"),M(!1)}}return u.jsxs("div",{className:"nc-composer",children:[Z&&u.jsx("div",{className:"nc-composer-err",children:Z}),u.jsxs("div",{className:"nc-composer-row",children:[i&&u.jsx("button",{ref:q,className:z?"attach busy":"attach",disabled:z,onClick:()=>A?le(!1):ne(),title:v(z?"attach-uploading":"attach"),"aria-label":v("attach"),"aria-haspopup":"menu","aria-expanded":A,"aria-controls":qe.current,children:u.jsx(tt,{name:"attach",size:22})}),A&&u.jsxs("div",{ref:L,id:qe.current,role:"menu",className:"nc-attach-menu",style:{left:R.left,bottom:R.bottom},children:[u.jsxs("button",{role:"menuitem",onClick:()=>fe(me),children:[u.jsx(tt,{name:"file",size:18})," ",v("attach-file")]}),u.jsxs("button",{role:"menuitem",onClick:()=>fe(V),children:[u.jsx(tt,{name:"camera",size:18})," ",v("attach-camera")]}),u.jsxs("button",{role:"menuitem",onClick:()=>fe(Q),children:[u.jsx(tt,{name:"image",size:18})," ",v("attach-gallery")]})]}),u.jsx("button",{ref:W,type:"button",className:"history",onPointerDown:ce=>ce.preventDefault(),onClick:()=>ae?J(!1):Be(),title:v("composer-history-tools"),"aria-label":v("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":ae,children:u.jsx(tt,{name:"history",size:21})}),ae&&u.jsxs("div",{ref:oe,role:"menu",className:"nc-composer-history-menu",style:{left:je.left,bottom:je.bottom,width:je.width},children:[u.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ce=>ce.preventDefault(),onClick:()=>{_(),J(!1),requestAnimationFrame(()=>{var ce;return(ce=ee.current)==null?void 0:ce.focus({preventScroll:!0})})},children:[u.jsx(tt,{name:p?"chevronDown":"chevronUp",size:18}),v(p?"composer-collapse":"composer-expand")]}),u.jsx("div",{className:"nc-composer-history-title",children:v("composer-history")}),S.length===0&&u.jsx("div",{className:"nc-composer-history-empty",children:v("composer-history-empty")}),S.map((ce,Me)=>u.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Pe=>Pe.preventDefault(),onClick:()=>{x(ce.text),J(!1),requestAnimationFrame(()=>{var Pe;return(Pe=ee.current)==null?void 0:Pe.focus({preventScroll:!0})})},children:[u.jsx("span",{children:ce.text.replace(/\s+/g," ").slice(0,180)}),ce.at>0&&u.jsx("small",{children:new Date(ce.at).toLocaleString()})]},`${ce.at}:${Me}`)),S.length>0&&u.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ce=>ce.preventDefault(),onClick:()=>{C(),J(!1)},children:v("composer-history-clear")})]}),u.jsx("input",{ref:me,type:"file",multiple:!0,hidden:!0,onChange:ce=>{be(Array.from(ce.target.files||[])),ce.target.value=""}}),u.jsx("input",{ref:V,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ce=>{be(Array.from(ce.target.files||[])),ce.target.value=""}}),u.jsx("input",{ref:Q,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ce=>{be(Array.from(ce.target.files||[])),ce.target.value=""}}),u.jsx("textarea",{ref:ee,className:p?"expanded":"",rows:p?8:2,value:d,placeholder:v("composer-placeholder"),onChange:ce=>m(ce.target.value),onKeyDown:B,onCompositionStart:()=>{de.current=!0},onCompositionEnd:()=>{de.current=!1},onBlur:D}),rt&&u.jsx("button",{className:j?"mic on":"mic",onClick:j?Se:Ae,title:v("voice"),children:u.jsx(tt,{name:"mic",size:22})}),u.jsx("button",{type:"button",className:"go",disabled:H,onPointerDown:ce=>ce.preventDefault(),onClick:St,title:v("send"),children:u.jsx(tt,{name:"enter",size:22})})]})]})}function Pg(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const IC=180,BC=480;function OC({sessions:e=[],cells:t=[],activeSessions:i=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:c,onNodePower:d,onKill:m,onVisibility:p,onNew:_,onNodeRename:S,onSettings:y,localNodeId:k,width:w=240,collapsed:x=!1,onResize:b,onToggleCollapse:C}){const[D,j]=wi(),{pins:M,orders:Z,togglePin:F,viewFor:T,updateView:X,canMoveRoster:K,moveRoster:G,stepRoster:ee}=Wv(),{groupsFor:A,moveNode:N,stepNode:R,nodeKey:I}=Kv(),z=new Set((t||[]).map(ne=>ne.tmuxSession)),$=new Map((e||[]).map(ne=>[ne.name,ne])),H=(ne,le)=>C0(M,ne,le),re=x0,q=[...t||[]].sort((ne,le)=>re(H(ne.tmuxSession,($.get(ne.tmuxSession)||{}).activity),H(le.tmuxSession,($.get(le.tmuxSession)||{}).activity))),L=(e||[]).filter(ne=>!z.has(ne.name)).sort((ne,le)=>re(H(ne.name,ne.activity),H(le.name,le.activity))||ne.name.localeCompare(le.name)),W=new Set(i||[]),oe=Xv(q,L,$),me=ur(oe,M,T("local").filter,Hn(Z,"local")),Q=A(s||[]).map(ne=>{const le=(ne.route||[ne.name]).join("/"),Be=T(le),{rawItems:J}=Gv(ne),B=ur(J,M,Be.filter,Hn(Z,le));return{g:ne,nodeRoute:le,groupView:Be,rawItems:J,items:B}}),de=(ne,le,Be)=>o&&o({session:ne,...le?{node:le}:{},...Zr.test(String(Be||""))?{ownerId:Be}:{}}),ae=async ne=>{if(!(ne!=null&&ne.direct)||!S)return;const le=window.prompt(v("rename-node-prompt"),ne.label||ne.name);if(le!==null)try{await S(ne,le)||window.alert(v("rename-node-invalid"))}catch(Be){window.alert(String((Be==null?void 0:Be.message)||Be))}},[ke,je]=P.useState(null),Ye=(ne,le)=>{const Be=ne.currentTarget.getBoundingClientRect();je({text:le,y:Be.top+Be.height/2})},qe=()=>je(null),Ce=P.useRef(null);P.useEffect(()=>()=>{Ce.current&&Ce.current()},[]);function rt(ne){ne.preventDefault(),ne.stopPropagation();const le=ne.clientX,Be=w,J=fe=>{const be=Math.max(IC,Math.min(BC,Be+(fe.clientX-le)));b&&b(be)},B=()=>{window.removeEventListener("pointermove",J),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",B),window.removeEventListener("blur",B),Ce.current=null};window.addEventListener("pointermove",J),window.addEventListener("pointerup",B),window.addEventListener("pointercancel",B),window.addEventListener("blur",B),Ce.current=B}const St=x?{width:48,flex:"0 0 48px"}:{width:w,flex:`0 0 ${w}px`};return x?u.jsxs("aside",{className:"nc-sidebar mini",style:St,children:[u.jsx("div",{className:"nc-side-head mini",children:u.jsx("button",{className:"nc-collapse-btn",onClick:C,title:v("expand"),children:"⟩"})}),u.jsx("button",{className:"nc-side-gear mini",onClick:()=>y&&y("nodes",!1),title:v("settings"),onMouseEnter:ne=>Ye(ne,v("settings")),onMouseLeave:qe,children:u.jsx(tt,{name:"gear",size:16})}),u.jsx("div",{className:"nc-side-scroll mini",children:u.jsxs("div",{className:"nc-side-group mini",children:[T("local").open&&me.map(ne=>ne.type==="cell"?(()=>{const le=ne.value,Be=le.degraded?"warn":le.tmux?"on":"",J=!!le.tmux;return u.jsx("button",{type:"button",className:`nc-mini-dot${W.has(le.tmuxSession)?" active":""}`,onMouseEnter:B=>Ye(B,`${le.cell}: ${ne.subtitle}`),onMouseLeave:qe,draggable:J,onDragStart:J?B=>B.dataTransfer.setData("text/nc-session",le.tmuxSession):void 0,onClick:J?()=>a&&a(le.tmuxSession):()=>c&&c(le),onDoubleClick:J?()=>de(le.tmuxSession,"",k):void 0,children:u.jsx("span",{className:`nc-dot ${Be}${ne.working?" working":""}`})},ne.key)})():(()=>{const le=ne.value;return u.jsx("button",{type:"button",className:`nc-mini-init${W.has(le.name)?" active":""}`,onMouseEnter:Be=>Ye(Be,le.name),onMouseLeave:qe,draggable:!0,onDragStart:Be=>Be.dataTransfer.setData("text/nc-session",le.name),onClick:()=>a&&a(le.name),onDoubleClick:()=>de(le.name,"",k),children:Pg(le.name)},ne.key)})()),Q.flatMap(({g:ne,nodeRoute:le,groupView:Be,items:J})=>ne.status==="up"?Be.open?J.map(B=>B.type==="cell"?(()=>{const fe=B.value,be=!!fe.tmux;return u.jsx("button",{type:"button",className:`nc-mini-dot${W.has(B.key)?" active":""}`,onMouseEnter:Se=>Ye(Se,`${ne.label||le}: ${fe.cell} · ${B.subtitle}`),onMouseLeave:qe,draggable:be,onDragStart:be?Se=>Se.dataTransfer.setData("text/nc-session",B.key):void 0,onClick:be?()=>a&&a(B.key):()=>c&&c({...fe,route:ne.route,availableEngines:ne.engines||[]}),onDoubleClick:be?()=>de(fe.tmuxSession,le,ne.instanceId):void 0,children:u.jsx("span",{className:`nc-dot ${fe.degraded?"warn":be?`on${B.working?" working":""}`:""}`})},B.key)})():(()=>{const fe=B.value;return u.jsx("button",{type:"button",className:`nc-mini-init${W.has(B.key)?" active":""}`,onMouseEnter:be=>Ye(be,`${ne.label||le}: ${fe.name}`),onMouseLeave:qe,draggable:!0,onDragStart:be=>be.dataTransfer.setData("text/nc-session",B.key),onClick:()=>a&&a(B.key),onDoubleClick:()=>de(fe.name,le,ne.instanceId),children:Pg(fe.name)},B.key)})()):[]:[u.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:B=>Ye(B,`${ne.label||(ne.route||[ne.name]).join(" › ")}: ${Yr(ne)}`),onMouseLeave:qe,children:u.jsx("span",{className:`nc-dot${ne.status==="passive"?"":" warn"}`})},`nodo-${(ne.route||[ne.name]).join("/")}`)])]})}),ke&&u.jsx("div",{className:"nc-mini-tip",style:{top:ke.y},children:ke.text})]}):u.jsxs("aside",{className:"nc-sidebar",style:St,children:[u.jsxs("div",{className:"nc-side-head",children:[u.jsx("button",{className:"nc-collapse-btn",onClick:C,title:v("collapse"),children:"⟨"}),u.jsx("span",{className:"nc-side-title",children:v("fleet")}),u.jsxs("button",{className:"nc-new-btn",onClick:_,title:v("fleet-new-cell"),children:["+ ",v("new")]})]}),u.jsxs("button",{className:"nc-side-gear",onClick:()=>y&&y("nodes",!1),title:v("settings"),children:[u.jsx(tt,{name:"gear",size:15})," ",v("settings")]}),u.jsxs("div",{className:"nc-side-scroll",children:[u.jsx(zC,{label:v("position-local"),count:me.length,state:T("local"),onToggle:()=>X("local",{open:!T("local").open}),onFilter:ne=>X("local",{filter:ne})}),T("local").open&&u.jsxs("div",{className:"nc-side-group",children:[me.map(ne=>ne.type==="cell"?(()=>{const le=ne.value,Be=le.degraded?"warn":le.tmux?"on":"",J=le.degraded?v("cell-degraded"):ne.working?ne.subtitle:le.tmux?v("cell-idle"):v("cell-off"),B=!!le.tmux;return u.jsxs("div",{"data-roster-key":ne.key,"data-position":"local",className:`nc-cell${B?" live":""}${W.has(le.tmuxSession)?" active":""}`,title:`${le.cell} · ${ne.subtitle}${J===ne.subtitle?"":` · ${J}`}`,"aria-label":`${le.cell}, ${ne.subtitle}${J===ne.subtitle?"":`, ${J}`}`,draggable:B,onDragStart:B?fe=>fe.dataTransfer.setData("text/nc-session",le.tmuxSession):void 0,onClick:B?()=>a&&a(le.tmuxSession):void 0,onDoubleClick:B?()=>de(le.tmuxSession,"",k):void 0,children:[u.jsx(zn,{position:"local",itemKey:ne.key,label:le.cell,canMove:K,onMove:(fe,be)=>G("local",fe,be,oe),onStep:fe=>ee("local",ne.key,fe,oe)}),u.jsx("span",{className:`nc-dot ${Be}${ne.working?" working":""}`}),u.jsxs("span",{className:"nc-cell-main",children:[u.jsx("b",{title:le.cell,children:le.cell}),u.jsx("small",{title:ne.subtitle,children:ne.subtitle})]}),u.jsx("button",{className:`nc-pin${M.includes(ne.key)?" on":""}`,title:v("pin"),onClick:fe=>{fe.stopPropagation(),F(ne.key)},children:M.includes(ne.key)?"★":"☆"}),u.jsx("button",{className:`nc-power${le.tmux?" on":""}${le.degraded?" warn":""}`,onClick:fe=>{fe.stopPropagation(),c&&c(le)},title:le.active?v("power-off"):v("power-on"),children:u.jsx(tt,{name:"power",size:14})})]},ne.key)})():(()=>{var Be;const le=ne.value;return u.jsxs("div",{"data-roster-key":ne.key,"data-position":"local",className:`nc-side-card${W.has(le.name)?" active":""}`,draggable:!0,onDragStart:J=>J.dataTransfer.setData("text/nc-session",le.name),onClick:()=>a&&a(le.name),onDoubleClick:()=>de(le.name,"",k),children:[u.jsx(zn,{position:"local",itemKey:ne.key,label:le.name,canMove:K,onMove:(J,B)=>G("local",J,B,oe),onStep:J=>ee("local",ne.key,J,oe)}),u.jsx("span",{className:le.attached?"nc-dot on":"nc-dot"}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:le.name}),u.jsxs("small",{children:[le.preview||le.cmd||v("windows").replace("{n}",String(le.windows||0)),((Be=le.outbox)==null?void 0:Be.count)>0?` · 📦${le.outbox.count}`:""]})]}),le.activity?u.jsx("span",{className:"nc-rel",children:Jr(le.activity)}):null,u.jsx("button",{className:`nc-pin${M.includes(ne.key)?" on":""}`,title:v("pin"),onClick:J=>{J.stopPropagation(),F(ne.key)},children:M.includes(ne.key)?"★":"☆"}),u.jsx("button",{className:`nc-technical${le.technical?" on":""}`,title:le.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${le.technical?v("mark-normal"):v("mark-technical")} ${le.name}`,onClick:J=>{J.stopPropagation(),p&&p(le.name,!le.technical,[])},children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:J=>{J.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",le.name))&&m&&m(le.name)},children:"⋯"})]},ne.key)})()),me.length===0&&u.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]}),Q.map(({g:ne,nodeRoute:le,groupView:Be,rawItems:J,items:B})=>{const be=qv(ne.health)||(ne.status==="up"?"on":ne.status==="passive"?"":"warn");return u.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":I(ne),children:[u.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:ne.direct&&S?Se=>{Se.preventDefault(),ae(ne)}:void 0,onClick:()=>X(le,{open:!Be.open}),onKeyDown:Se=>{(Se.key==="Enter"||Se.key===" ")&&(Se.preventDefault(),X(le,{open:!Be.open}))},children:[u.jsx(zn,{scope:"node",position:"nodes",itemKey:I(ne),label:ne.label||ne.name,onMove:(Se,Ae)=>N(Se,Ae,s||[]),onStep:Se=>R(I(ne),Se,s||[])}),u.jsx("span",{className:"nc-node-chevron",children:Be.open?"⌄":"›"}),u.jsx("span",{className:`nc-dot ${be}`,title:ne.health?Va(ne.health):""}),u.jsx("b",{children:ne.label||ne.name}),u.jsxs("small",{children:[" · ",ne.status==="up"?v("node-sessions").replace("{n}",String(B.length)):ne.health&&Va(ne.health)||Yr(ne)]}),u.jsxs("select",{className:"nc-node-filter",value:Be.filter,title:v(`view-${Be.filter}`),onClick:Se=>Se.stopPropagation(),onChange:Se=>X(le,{filter:Se.target.value}),children:[u.jsx("option",{value:"all",children:v("view-all")}),u.jsx("option",{value:"pinned",children:v("view-pinned")}),u.jsx("option",{value:"active",children:v("view-active")}),u.jsx("option",{value:"off",children:v("view-off")}),u.jsx("option",{value:"technical",children:v("view-technical")})]}),ne.direct&&S&&u.jsx("button",{type:"button",className:"nc-node-rename",title:v("rename-node"),"aria-label":`${v("rename-node")} ${ne.label||ne.name}`,onClick:Se=>{Se.stopPropagation(),ae(ne)},children:"✎"}),ne.direct&&ne.health&&ne.health.managed!==!1&&u.jsx("button",{type:"button",className:`nc-power${ne.tunnelStatus==="up"?" on":""}`,title:ne.tunnelStatus==="up"?v("power-off"):v("power-on"),onClick:Se=>{Se.stopPropagation(),d&&d(ne)},children:u.jsx(tt,{name:"power",size:14})})]}),ne.status==="up"&&Be.open&&u.jsxs("div",{className:"nc-side-group",children:[B.map(Se=>Se.type==="cell"?(()=>{const Ae=Se.value,ce=!!Ae.tmux,Me=Ae.degraded?"warn":Ae.tmux?"on":"";return u.jsxs("div",{"data-roster-key":Se.key,"data-position":le,className:`nc-side-card nc-cell${ce?" live":""}${W.has(Ae.key)?" active":""}`,title:Se.working?Se.subtitle:Ae.tmux?v("cell-idle"):v("cell-off"),draggable:ce,onDragStart:ce?Pe=>Pe.dataTransfer.setData("text/nc-session",Ae.key):void 0,onClick:ce?()=>a&&a(Ae.key):void 0,onDoubleClick:ce?()=>de(Ae.tmuxSession,le,ne.instanceId):void 0,children:[u.jsx(zn,{position:le,itemKey:Se.key,label:Ae.cell,canMove:K,onMove:(Pe,He)=>G(le,Pe,He,J),onStep:Pe=>ee(le,Se.key,Pe,J)}),u.jsx("span",{className:`nc-dot ${Me}${Se.working?" working":""}`}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:Ae.cell}),u.jsx("small",{title:Se.subtitle,children:Se.subtitle})]}),u.jsx("button",{className:`nc-pin${M.includes(Se.key)?" on":""}`,title:v("pin"),onClick:Pe=>{Pe.stopPropagation(),F(Se.key)},children:M.includes(Se.key)?"★":"☆"}),(ne.capabilities||[]).includes(Ae.active?"down":"up")&&u.jsx("button",{className:`nc-power${Ae.active?" on":""}${Ae.degraded?" warn":""}`,onClick:Pe=>{Pe.stopPropagation(),c&&c({...Ae,route:ne.route,availableEngines:ne.engines||[]})},title:Ae.active?v("power-off"):v("power-on"),children:u.jsx(tt,{name:"power",size:14})})]},Se.key)})():(()=>{const Ae=Se.value;return u.jsxs("div",{"data-roster-key":Se.key,"data-position":le,className:`nc-side-card${W.has(Ae.key)?" active":""}`,draggable:!0,onDragStart:ce=>ce.dataTransfer.setData("text/nc-session",Ae.key),onClick:()=>a&&a(Ae.key),onDoubleClick:()=>de(Ae.name,Ae.node||le,ne.instanceId),children:[u.jsx(zn,{position:le,itemKey:Se.key,label:Ae.name,canMove:K,onMove:(ce,Me)=>G(le,ce,Me,J),onStep:ce=>ee(le,Se.key,ce,J)}),u.jsx("span",{className:Ae.attached?"nc-dot on":"nc-dot"}),u.jsxs("span",{className:"nc-card-main",children:[u.jsx("b",{children:Ae.name}),u.jsx("small",{children:Ae.preview?Ae.preview:Ae.cmd?Ae.cmd:v("windows").replace("{n}",String(Ae.windows||0))})]}),Ae.activity?u.jsx("span",{className:"nc-rel",children:Jr(Ae.activity)}):null,u.jsx("button",{className:`nc-pin${M.includes(Se.key)?" on":""}`,title:v("pin"),onClick:ce=>{ce.stopPropagation(),F(Se.key)},children:M.includes(Se.key)?"★":"☆"}),u.jsx("button",{className:`nc-technical${Ae.technical?" on":""}`,title:Ae.technical?v("mark-normal"):v("mark-technical"),"aria-label":`${Ae.technical?v("mark-normal"):v("mark-technical")} ${Ae.name}`,onClick:ce=>{ce.stopPropagation(),p&&p(Ae.name,!Ae.technical,ne.route||[])},children:"T"}),u.jsx("button",{className:"nc-menu",title:v("terminate"),onClick:ce=>{ce.stopPropagation(),window.confirm(v("terminate-confirm").replace("{name}",Ae.name))&&m&&m(Ae.name,ne.route)},children:"⋯"})]},Se.key)})()),B.length===0&&u.jsx("div",{className:"nc-empty",children:v("no-sessions-short")})]})]},`nodo-${(ne.route||[ne.name]).join("/")}`)})]}),u.jsx("div",{className:"nc-side-lang",children:$v.map((ne,le)=>u.jsxs("span",{children:[le>0&&" · ",u.jsx("button",{className:`nc-lang-btn${D===ne?" on":""}`,onClick:()=>j(ne),title:ne,children:ne.toUpperCase()})]},ne))}),u.jsx("div",{className:"nc-side-resize",onPointerDown:rt,title:""})]})}function zC({label:e,count:t,state:i,onToggle:s,onFilter:o}){return u.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[u.jsx("span",{className:"nc-node-chevron",children:i.open?"⌄":"›"}),u.jsx("span",{className:"nc-dot on"}),u.jsx("b",{children:e}),u.jsxs("small",{children:[" · ",v("node-sessions").replace("{n}",String(t))]}),u.jsxs("select",{className:"nc-node-filter",value:i.filter,title:v(`view-${i.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[u.jsx("option",{value:"all",children:v("view-all")}),u.jsx("option",{value:"pinned",children:v("view-pinned")}),u.jsx("option",{value:"active",children:v("view-active")}),u.jsx("option",{value:"off",children:v("view-off")}),u.jsx("option",{value:"technical",children:v("view-technical")})]})]})}function FC(e,t,i){return!e&&t?i+1:i}function HC({session:e,node:t,ownerId:i,token:s,readonly:o=!1,focused:a,onFocus:c,onClose:d,onOpenSingle:m,alive:p=!0,available:_=!0,fontSize:S=uo,onZoom:y,decks:k=[],currentDeck:w,onSendToDeck:x}){const b=P.useRef(()=>{}),C=P.useRef(()=>!1),D=P.useRef(()=>{}),j=P.useRef(!1),[M,Z]=P.useState(!1),[F,T]=P.useState(!1),[X,K]=P.useState(!1),[G,ee]=P.useState(null),[A,N]=P.useState(0),R=P.useRef(p),I=t?`${t}:${e}`:e,z=k.filter($=>$.id!==w&&$.available!==!1);return P.useEffect(()=>{const $=R.current;!$&&p&&N(H=>FC($,p,H)),R.current=p},[p]),u.jsxs("div",{className:`nc-tile${a?" focused":""}`,onMouseDown:()=>c&&c(I),children:[u.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:$=>{$.dataTransfer.setData("text/nc-session",I),$.dataTransfer.effectAllowed="move"},children:[u.jsxs("button",{className:"nc-tile-name",onClick:()=>c&&c(I),children:[u.jsx("span",{className:p?"nc-dot on":"nc-dot"}),u.jsx("b",{children:e}),t&&u.jsxs("small",{className:"nc-tile-node",children:["@",t]})]}),u.jsxs("span",{className:"nc-tile-actions",children:[y&&u.jsx("button",{onClick:()=>y(-1),title:v("zoom-out"),children:u.jsx(tt,{name:"zoomOut",size:14})}),y&&u.jsx("button",{onClick:()=>y(1),title:v("zoom-in"),children:u.jsx(tt,{name:"zoomIn",size:14})}),x&&z.length>0&&u.jsxs("select",{className:"nc-tile-deck",title:v("send-to-deck"),value:"",onMouseDown:$=>$.stopPropagation(),onChange:$=>{const H=$.target.value;H&&x(I,H),$.target.value=""},children:[u.jsx("option",{value:"",children:v("send-to-deck")}),z.map($=>u.jsxs("option",{value:$.id,children:[$.ownerLabel," · ",$.name]},$.id))]}),u.jsx("button",{onClick:()=>T($=>!$),title:"composer",children:"⌨"}),u.jsx("button",{onClick:()=>K($=>!$),title:"file",children:"📁"}),m&&u.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:i}),title:"vista singola",children:"↗"}),d&&u.jsx("button",{className:"nc-tile-close",onClick:()=>d(I),title:"chiudi",children:"✕"})]})]}),u.jsxs("div",{className:"nc-tile-body",children:[_?u.jsx(V_,{session:e,node:t,token:s,readonly:o,takeSize:!1,focused:a,sendRef:b,composerRef:C,actionRef:D,ctrlRef:j,setCtrlArmed:Z,onFiles:ee,fontSize:S},`${I}:${A}`):u.jsx("div",{className:"nc-tile-unavailable",children:v("deck-owner-unavailable")}),_&&X&&u.jsx("div",{className:"nc-tile-files",onMouseDown:$=>$.stopPropagation(),children:u.jsx(Y_,{session:e,node:t,token:s,filesEvent:G,onClose:()=>K(!1)})})]}),_&&F&&u.jsx("div",{className:"nc-tile-composer",onMouseDown:$=>$.stopPropagation(),children:u.jsx(ny,{submitText:$=>C.current($),token:s,session:e,node:t,ownerId:i})})]})}const Dg=.2,Mg=.28,ry=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),gu=e=>ry(e,"text/nc-session"),Lg=e=>{var t;return ry(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function $C(e,t,i){const s=(e-i.left)/(i.width||1),o=(t-i.top)/(i.height||1);return s<Mg?"left":s>1-Mg?"right":o<.5?"top":"bottom"}function WC({layout:e,onLayoutChange:t,token:i,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:c,onOpenSingle:d,decks:m=[],currentDeck:p,onSendToDeck:_}){wi();const[S,y]=P.useState(null),k=P.useRef(null),w=P.useRef([]),x=P.useRef(null);function b(K,G){const ee=()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",ee),window.removeEventListener("pointercancel",ee),window.removeEventListener("blur",ee),x.current=null};window.addEventListener("pointermove",K),window.addEventListener("pointerup",ee),window.addEventListener("pointercancel",ee),window.addEventListener("blur",ee),x.current=ee}P.useEffect(()=>()=>{x.current&&x.current()},[]),P.useEffect(()=>{const K=()=>y(null);return window.addEventListener("dragend",K),window.addEventListener("drop",K),()=>{window.removeEventListener("dragend",K),window.removeEventListener("drop",K)}},[]);const C=e.columns.length,D=K=>S&&S.col===K&&S.row===void 0,j=!!S&&S.col===C,M=(K,G)=>S&&S.col===K&&S.row===G&&S.quadrant?` drop-${S.quadrant}`:"";function Z(K){if(K.preventDefault(),Lg(K.dataTransfer)){y(null);return}const G=K.dataTransfer.getData("text/nc-session"),ee=S;if(y(null),!G||!ee)return;let A;if(ee.quadrant){if(A=O0(e,ee.col,ee.row,ee.quadrant),!A)return}else A={col:ee.col};t(Qi(e).includes(G)?j0(e,G,A):Qh(e,G,A))}function F(K,G){K.preventDefault(),K.stopPropagation();const ee=K.clientX,A=e.columns[G].width,N=k.current&&k.current.clientWidth||1,R=e.columns[G+1];b(z=>{let $=Math.max(Dg,A+(z.clientX-ee)/N);if(R){const H=bm($/($+R.width));$=H/(1-H)*R.width}t(A0(e,G,$))})}function T(K,G,ee){K.preventDefault(),K.stopPropagation();const A=K.clientY,N=e.columns[G].tiles[ee].height,R=w.current[G],I=R&&R.clientHeight||1,z=e.columns[G].tiles[ee+1];b(H=>{let re=Math.max(Dg,N+(H.clientY-A)/I);if(z){const q=bm(re/(re+z.height));re=q/(1-q)*z.height}t(I0(e,G,ee,re))})}function X(K){t(Ga(e,K))}return u.jsxs("div",{className:"nc-grid",ref:k,onDragOver:K=>{if(Lg(K.dataTransfer)){K.preventDefault(),y(null);return}gu(K.dataTransfer)&&(K.preventDefault(),S&&S.col===C||y({col:C}))},onDrop:Z,onDragLeave:K=>{const G=K.relatedTarget;(!G||!(k.current&&k.current.contains(G)))&&y(null)},children:[e.columns.flatMap((K,G)=>{const ee=[];return ee.push(u.jsx("div",{className:`nc-col${D(G)?" drop-newcol":""}`,ref:A=>{w.current[G]=A},style:{flexGrow:K.width,flexBasis:0},onDragOver:A=>{gu(A.dataTransfer)&&(A.preventDefault(),A.stopPropagation(),S&&S.col===G&&S.row===void 0||y({col:G}))},children:K.tiles.flatMap((A,N)=>{const R=[],I=yi(A);return R.push(u.jsx("div",{className:`nc-tile-slot${M(G,N)}`,style:{flexGrow:A.height,flexBasis:0},onDragOver:z=>{if(!gu(z.dataTransfer))return;z.preventDefault(),z.stopPropagation();const $=$C(z.clientX,z.clientY,z.currentTarget.getBoundingClientRect());S&&S.col===G&&S.row===N&&S.quadrant===$||y({col:G,row:N,quadrant:$})},children:u.jsx(HC,{session:A.session,node:A.node,ownerId:A.ownerId,token:i,readonly:s,focused:a===I,onFocus:c,onClose:X,onOpenSingle:d,available:A.unavailable!==!0,alive:A.unavailable!==!0&&(!o||o.has(I)),fontSize:A.fontSize,onZoom:z=>t(B0(e,G,N,z)),decks:m,currentDeck:p,onSendToDeck:_})},I)),N<K.tiles.length-1&&R.push(u.jsx("div",{className:"nc-divider-h",onPointerDown:z=>T(z,G,N)},`h${N}`)),R})},`c${G}`)),G<C-1&&ee.push(u.jsx("div",{className:"nc-divider-v",onPointerDown:A=>F(A,G)},`v${G}`)),ee}),j&&u.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),C===0&&u.jsx("div",{className:"nc-grid-empty",children:v("grid-empty")})]})}const hn="local",Li=/^[a-f0-9]{16,64}$/;function Qr(e,t){return`${e&&Li.test(e)?e:hn}:${t}`}function cd(e){const t=String(e||""),i=t.indexOf(":");if(i<1)return null;const s=t.slice(0,i),o=t.slice(i+1);return s!==hn&&!Li.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===hn?null:s,name:o}}function ul(e){return Array.isArray(e)&&e.length?e.join("/"):""}function ud(e){return{columns:hr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))}}function UC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Li.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(ul(i.route),i.instanceId);return t}function KC(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Li.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(i.instanceId,[...i.route]);return t}function jh(e,t,i=[]){const s=ud(e),o=UC(i);for(const a of s.columns)for(const c of a.tiles)c.ownerId||(!c.node&&Li.test(String(t||""))?c.ownerId=t:c.node&&o.has(c.node)&&(c.ownerId=o.get(c.node)));return s}function Th(e,t,i=[]){const s=ud(e),o=new Map;for(const a of i)a&&Li.test(String(a.instanceId||""))&&Array.isArray(a.route)&&o.set(a.instanceId,[...a.route]);for(const a of s.columns)for(const c of a.tiles)c.ownerId&&(c.ownerId===t?(delete c.node,delete c.unavailable):o.has(c.ownerId)?(c.node=ul(o.get(c.ownerId)),delete c.unavailable):c.unavailable=!0);return s}function jg(e,t,i=[]){const s=ud(e),o=KC(i);for(const a of s.columns)for(const c of a.tiles)delete c.unavailable,c.ownerId&&(c.ownerId===t?delete c.node:o.has(c.ownerId)&&(c.node=ul(o.get(c.ownerId))));return s}function sy(e,t,i=[]){const s=Wn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Li.test(String(t||""))?{ownerId:t}:{}};const o=i.find(a=>ul(a&&a.route)===s.node);return{...s,...o&&Li.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const qC=/^[a-z0-9-]{1,32}$/,Si="main",oy="nc_decks",ay="nc_deck_order_v1",ly=24;function Tg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function ts(e){return typeof e=="string"&&qC.test(e)}function VC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let i;try{i=decodeURIComponent(t[1])}catch{i=t[1]}return ts(i)?i:Si}return Si}function YC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Qr(null,Si),ownerId:null,name:Si}}if(Li.test(s)&&ts(o))return{id:Qr(s,o),ownerId:s,name:o}}const i=VC(e);return{id:Qr(null,i),ownerId:null,name:i}}function vu(e,t){const i=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:cd(e)||{ownerId:null,name:e},s=ts(i.name)?i.name:Si,o=i.ownerId?`/deck/${encodeURIComponent(i.ownerId)}/${encodeURIComponent(s)}`:s===Si?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function cy(e){return e===Si?"nc_grid_v1":`nc_grid_v1__${e}`}function uy(e){const t=[Si];if(Array.isArray(e)){for(const i of e)if(ts(i)&&i!==Si&&!t.includes(i)&&t.push(i),t.length>=ly)break}return t}function ss(){return typeof localStorage<"u"?localStorage:null}function XC(){const e=ss();if(!e)return[Si];try{return uy(JSON.parse(e.getItem(oy)||"null"))}catch{return[Si]}}function GC(e){const t=ss();if(t)try{t.setItem(oy,JSON.stringify(uy(e)))}catch{}}function vo(e){return e==="local"||Li.test(String(e||""))}function hl(e,t){const i=cd(e);return!!i&&(i.ownerId||"local")===t}function Zi(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[i,s]of Object.entries(e).slice(0,64)){if(!vo(i)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&hl(a,i)))].slice(0,ly);o.length&&(t[i]=o)}return t}function Aa(e=ss()){if(!e)return{};try{return Zi(JSON.parse(e.getItem(ay)||"null"))}catch{return{}}}function _u(e,t=ss()){const i=Zi(e);if(t)try{t.setItem(ay,JSON.stringify(i))}catch{}return i}function dl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function QC(e,t,i,s,o=[]){if(!vo(t)||i===s)return Zi(e);const a=[...new Set(o.filter(S=>hl(S,t)))];if(!a.includes(i)||!a.includes(s))return Zi(e);const c=dl(e,t).filter(S=>a.includes(S)),d=[...c,...a.filter(S=>!c.includes(S))],m=d.indexOf(i),p=d.indexOf(s);d.splice(m,1);const _=d.indexOf(s);return d.splice(m<p?_+1:_,0,i),Zi({...e,[t]:d})}function JC(e,t,i,s){if(!vo(t)||!hl(s,t))return Zi(e);const o=dl(e,t);return o.includes(i)?Zi({...e,[t]:o.map(a=>a===i?s:a)}):Zi(e)}function ZC(e,t,i){return vo(t)?Zi({...e,[t]:dl(e,t).filter(s=>s!==i)}):Zi(e)}function Ag(e,t={}){const i=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!vo(a)||!hl(o==null?void 0:o.id,a)||(i.has(a)||i.set(a,[]),i.get(a).push(o))}const s=[];for(const[,o]of i){const a=o[0].local?"local":o[0].ownerId,c=dl(t,a),d=new Map(c.map((m,p)=>[m,p]));o.sort((m,p)=>{const _=d.has(m.id)?d.get(m.id):Number.MAX_SAFE_INTEGER,S=d.has(p.id)?d.get(p.id):Number.MAX_SAFE_INTEGER;return _-S}),s.push(...o)}return s}function Ah(e){const t=ss();if(!t)return null;try{return JSON.parse(t.getItem(cy(e))||"null")}catch{return null}}function ex(e,t){const i=ss();if(i)try{i.setItem(cy(e),JSON.stringify(t))}catch{}}const Ig=52,Bg=18;function tx({ownerKey:e,deckId:t,label:i,onMove:s,onStep:o}){const a=P.useRef(null),c=P.useRef(0),[d,m]=P.useState(!1),p=()=>{var x,b,C,D;const w=a.current;(b=(x=w==null?void 0:w.over)==null?void 0:x.classList)==null||b.remove("nc-deck-over"),(D=(C=w==null?void 0:w.source)==null?void 0:C.classList)==null||D.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},_=(w=!1)=>{const x=a.current;if(!x)return;const b=x.target;p(),a.current=null,m(!1);try{x.handle.releasePointerCapture(x.pointerId)}catch{}w&&b&&b!==t&&s(t,b)},S=(w,x)=>{var M,Z,F,T,X,K,G,ee;const b=a.current;if(!b)return;b.x=w,b.y=x;const C=(Z=(M=document.elementFromPoint(w,x))==null?void 0:M.closest)==null?void 0:Z.call(M,"[data-deck-id][data-owner-key]"),D=(F=C==null?void 0:C.dataset)==null?void 0:F.deckId,j=((T=C==null?void 0:C.dataset)==null?void 0:T.ownerKey)===e&&D&&D!==t;b.over!==(j?C:null)&&((K=(X=b.over)==null?void 0:X.classList)==null||K.remove("nc-deck-over"),b.over=j?C:null,(ee=(G=b.over)==null?void 0:G.classList)==null||ee.add("nc-deck-over")),b.target=j?D:null},y=()=>{var b,C;const w=a.current;if(!w){c.current=0;return}const x=(C=(b=w.container)==null?void 0:b.getBoundingClientRect)==null?void 0:C.call(b);if(x){const D=w.x<x.left+Ig?-Bg:w.x>x.right-Ig?Bg:0;D&&(w.container.scrollLeft+=D,S(w.x,w.y))}c.current=requestAnimationFrame(y)};P.useEffect(()=>{const w=b=>{b.key==="Escape"&&a.current&&(b.preventDefault(),_(!1))},x=()=>_(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",x),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",x),p(),a.current=null}},[t,e]);const k=w=>{var C;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const x=w.currentTarget.closest("[data-deck-id][data-owner-key]"),b=w.currentTarget.closest(".nc-deckbar");a.current={pointerId:w.pointerId,handle:w.currentTarget,source:x,container:b,target:null,over:null,x:w.clientX,y:w.clientY},(C=x==null?void 0:x.classList)==null||C.add("nc-deck-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}m(!0),c.current=requestAnimationFrame(y)};return u.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${v("reorder")} ${i}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:v("reorder-deck-help"),onClick:w=>{w.preventDefault(),w.stopPropagation()},onDragStart:w=>w.preventDefault(),onKeyDown:w=>{w.key!=="ArrowLeft"&&w.key!=="ArrowRight"||(w.preventDefault(),w.stopPropagation(),o(w.key==="ArrowLeft"?-1:1))},onPointerDown:k,onPointerMove:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(w.clientX,w.clientY))},onPointerUp:w=>{!a.current||w.pointerId!==a.current.pointerId||(w.preventDefault(),w.stopPropagation(),_(!0))},onPointerCancel:()=>_(!1),onLostPointerCapture:()=>{a.current&&_(!1)},children:"↔"})}function ix({decks:e=[],currentDeck:t="local:main",onCreate:i,onRename:s,onDelete:o,onReorder:a,onOpenWindow:c,onNavigate:d,saveState:m="idle",error:p="",sidebarVisible:_,onToggleSidebar:S}){wi();const[y,k]=P.useState(null),[w,x]=P.useState(""),[b,C]=P.useState(!1),[D,j]=P.useState(""),[M,Z]=P.useState(""),F=Tg(w),T=ts(F),X=[];for(const N of e){const R=N.local?"local":N.ownerId;let I=X.find(z=>z.key===R);I||(I={key:R,label:N.ownerLabel||(N.local?"Local":R),local:!!N.local,decks:[]},X.push(I)),I.decks.push(N)}const K=async()=>{if(T){C(!0),j("");try{i&&await i(F,y),x(""),k(null)}catch(N){j(String(N.message||N))}C(!1)}},G=N=>{Z(""),c&&c(N.id)||Z(N.id)},ee=async N=>{if(!(N.id===t||!d||b||N.available===!1)){C(!0),j("");try{await d(N.id)}catch(R){j(String((R==null?void 0:R.message)||R))}C(!1)}},A=(N,R,I)=>{const z=N.decks.findIndex(H=>H.id===R.id),$=N.decks[z+I];z>=0&&$&&a&&!b&&a(R.id,$.id)};return u.jsxs("div",{className:"nc-deckbar",children:[S&&u.jsx("button",{className:"nc-deck-sidebar-toggle",title:v("toggle-sidebar"),onClick:S,children:_?"◀":"☰"}),u.jsx("span",{className:"nc-deckbar-label",children:v("decks")}),u.jsx("div",{className:"nc-deck-chips",children:X.map(N=>u.jsxs("span",{className:"nc-deck-owner-group",children:[u.jsx("span",{className:"nc-deck-owner",children:N.local?"Local":N.label}),N.decks.map(R=>u.jsxs("span",{"data-deck-id":R.id,"data-owner-key":N.key,className:`nc-deck-chip${R.id===t?" current":""}${R.available===!1?" offline":""}`,children:[u.jsx(tx,{ownerKey:N.key,deckId:R.id,label:`${N.label} · ${R.name}`,onMove:(I,z)=>{a&&!b&&a(I,z)},onStep:I=>A(N,R,I)}),u.jsxs("button",{className:"nc-deck-open",title:R.available===!1?`${R.ownerLabel} offline`:R.id===t?v("deck-current"):`${R.ownerLabel} · ${R.name}`,disabled:b||R.available===!1,onClick:()=>ee(R),children:[R.name,R.id===t?" •":""]}),u.jsx("button",{className:"nc-deck-mini",disabled:R.available===!1,title:v("detach-deck"),onClick:()=>G(R),children:"↗"}),R.name!==Si&&u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"nc-deck-mini",disabled:R.available===!1,title:v("rename-deck"),onClick:()=>{const I=(typeof window<"u"?window.prompt(v("rename-deck"),R.name):"")||"",z=Tg(I);ts(z)&&z!==R.name&&s&&s(R.id,z).catch($=>j(String($.message||$)))},children:"✎"}),u.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:R.available===!1,title:v("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(v("delete-deck-confirm").replace("{name}",`${R.ownerLabel} · ${R.name}`)))&&o&&o(R.id).catch(I=>j(String(I.message||I)))},children:"✕"})]})]},R.id)),y===N.key?u.jsxs("span",{className:"nc-deck-add",children:[u.jsx("input",{autoFocus:!0,className:T||!w?"":"invalid",placeholder:v("deck-name"),value:w,onChange:R=>x(R.target.value),onKeyDown:R=>{R.key==="Enter"&&K(),R.key==="Escape"&&(x(""),k(null))}}),w&&T&&F!==w&&u.jsxs("span",{className:"nc-deck-slug",children:["→ ",F]}),u.jsx("button",{className:"nc-deck-ok",disabled:!T||b,onClick:K,children:v("create")}),u.jsx("button",{className:"nc-deck-cancel",onClick:()=>{x(""),k(null)},children:v("cancel")})]}):u.jsxs("button",{className:"nc-deck-newbtn",disabled:b||N.decks.every(R=>R.available===!1),title:`${v("new-deck")} · ${N.label}`,onClick:()=>{x(""),k(N.key)},children:["+ ",v("new")]})]},N.key))}),u.jsx("span",{className:`nc-deck-state ${m}`,title:v("deck-autosave"),children:v(m==="saving"?"saving":m==="saved"?"saved":"deck-autosave")}),(D||p)&&u.jsx("span",{className:"nc-deck-error",children:D||p}),M&&u.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(M),children:v("popup-blocked")})]})}var Kr={},yu,Og;function nx(){return Og||(Og=1,yu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),yu}var Su={},Bn={},zg;function vr(){if(zg)return Bn;zg=1;let e;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Bn.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},Bn.getSymbolTotalCodewords=function(s){return t[s]},Bn.getBCHDigit=function(i){let s=0;for(;i!==0;)s++,i>>>=1;return s},Bn.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},Bn.isKanjiModeEnabled=function(){return typeof e<"u"},Bn.toSJIS=function(s){return e(s)},Bn}var wu={},Fg;function hd(){return Fg||(Fg=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(wu)),wu}var bu,Hg;function rx(){if(Hg)return bu;Hg=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const i=Math.floor(t/8);return(this.buffer[i]>>>7-t%8&1)===1},put:function(t,i){for(let s=0;s<i;s++)this.putBit((t>>>i-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),t&&(this.buffer[i]|=128>>>this.length%8),this.length++}},bu=e,bu}var ku,$g;function sx(){if($g)return ku;$g=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,i,s,o){const a=t*this.size+i;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,i){return this.data[t*this.size+i]},e.prototype.xor=function(t,i,s){this.data[t*this.size+i]^=s},e.prototype.isReserved=function(t,i){return this.reservedBit[t*this.size+i]},ku=e,ku}var Cu={},Wg;function ox(){return Wg||(Wg=1,(function(e){const t=vr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),c=a===145?26:Math.ceil((a-13)/(2*o-2))*2,d=[a-7];for(let m=1;m<o-1;m++)d[m]=d[m-1]-c;return d.push(6),d.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),c=a.length;for(let d=0;d<c;d++)for(let m=0;m<c;m++)d===0&&m===0||d===0&&m===c-1||d===c-1&&m===0||o.push([a[d],a[m]]);return o}})(Cu)),Cu}var xu={},Ug;function ax(){if(Ug)return xu;Ug=1;const e=vr().getSymbolSize,t=7;return xu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},xu}var Eu={},Kg;function lx(){return Kg||(Kg=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let c=0,d=0,m=0,p=null,_=null;for(let S=0;S<a;S++){d=m=0,p=_=null;for(let y=0;y<a;y++){let k=o.get(S,y);k===p?d++:(d>=5&&(c+=t.N1+(d-5)),p=k,d=1),k=o.get(y,S),k===_?m++:(m>=5&&(c+=t.N1+(m-5)),_=k,m=1)}d>=5&&(c+=t.N1+(d-5)),m>=5&&(c+=t.N1+(m-5))}return c},e.getPenaltyN2=function(o){const a=o.size;let c=0;for(let d=0;d<a-1;d++)for(let m=0;m<a-1;m++){const p=o.get(d,m)+o.get(d,m+1)+o.get(d+1,m)+o.get(d+1,m+1);(p===4||p===0)&&c++}return c*t.N2},e.getPenaltyN3=function(o){const a=o.size;let c=0,d=0,m=0;for(let p=0;p<a;p++){d=m=0;for(let _=0;_<a;_++)d=d<<1&2047|o.get(p,_),_>=10&&(d===1488||d===93)&&c++,m=m<<1&2047|o.get(_,p),_>=10&&(m===1488||m===93)&&c++}return c*t.N3},e.getPenaltyN4=function(o){let a=0;const c=o.data.length;for(let m=0;m<c;m++)a+=o.data[m];return Math.abs(Math.ceil(a*100/c/5)-10)*t.N4};function i(s,o,a){switch(s){case e.Patterns.PATTERN000:return(o+a)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(o+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return o*a%2+o*a%3===0;case e.Patterns.PATTERN110:return(o*a%2+o*a%3)%2===0;case e.Patterns.PATTERN111:return(o*a%3+(o+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,a){const c=a.size;for(let d=0;d<c;d++)for(let m=0;m<c;m++)a.isReserved(m,d)||a.xor(m,d,i(o,m,d))},e.getBestMask=function(o,a){const c=Object.keys(e.Patterns).length;let d=0,m=1/0;for(let p=0;p<c;p++){a(p),e.applyMask(p,o);const _=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(p,o),_<m&&(m=_,d=p)}return d}})(Eu)),Eu}var Ia={},qg;function hy(){if(qg)return Ia;qg=1;const e=hd(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Ia.getBlocksCount=function(o,a){switch(a){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Ia.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return i[(o-1)*4+0];case e.M:return i[(o-1)*4+1];case e.Q:return i[(o-1)*4+2];case e.H:return i[(o-1)*4+3];default:return}},Ia}var Nu={},Gs={},Vg;function cx(){if(Vg)return Gs;Vg=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let s=1;for(let o=0;o<255;o++)e[o]=s,t[s]=o,s<<=1,s&256&&(s^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),Gs.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},Gs.exp=function(s){return e[s]},Gs.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},Gs}var Yg;function ux(){return Yg||(Yg=1,(function(e){const t=cx();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let c=0;c<s.length;c++)for(let d=0;d<o.length;d++)a[c+d]^=t.mul(s[c],o[d]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const c=a[0];for(let m=0;m<o.length;m++)a[m]^=t.mul(o[m],c);let d=0;for(;d<a.length&&a[d]===0;)d++;a=a.slice(d)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Nu)),Nu}var Ru,Xg;function hx(){if(Xg)return Ru;Xg=1;const e=ux();function t(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),c=this.degree-a.length;if(c>0){const d=new Uint8Array(this.degree);return d.set(a,c),d}return a},Ru=t,Ru}var Pu={},Du={},Mu={},Gg;function dy(){return Gg||(Gg=1,Mu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Mu}var Yi={},Qg;function fy(){if(Qg)return Yi;Qg=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
82
+ ]))+`;Yi.KANJI=new RegExp(i,"g"),Yi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Yi.BYTE=new RegExp(s,"g"),Yi.NUMERIC=new RegExp(e,"g"),Yi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+i+"$"),a=new RegExp("^"+e+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Yi.testKanji=function(m){return o.test(m)},Yi.testNumeric=function(m){return a.test(m)},Yi.testAlphanumeric=function(m){return c.test(m)},Yi}var Jg;function _r(){return Jg||(Jg=1,(function(e){const t=dy(),i=fy();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,c){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?a.ccBits[0]:c<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return i.testNumeric(a)?e.NUMERIC:i.testAlphanumeric(a)?e.ALPHANUMERIC:i.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(a,c){if(e.isValid(a))return a;try{return s(a)}catch{return c}}})(Du)),Du}var Zg;function dx(){return Zg||(Zg=1,(function(e){const t=vr(),i=hy(),s=hd(),o=_r(),a=dy(),c=7973,d=t.getBCHDigit(c);function m(y,k,w){for(let x=1;x<=40;x++)if(k<=e.getCapacity(x,w,y))return x}function p(y,k){return o.getCharCountIndicator(y,k)+4}function _(y,k){let w=0;return y.forEach(function(x){const b=p(x.mode,k);w+=b+x.getBitsLength()}),w}function S(y,k){for(let w=1;w<=40;w++)if(_(y,w)<=e.getCapacity(w,k,o.MIXED))return w}e.from=function(k,w){return a.isValid(k)?parseInt(k,10):w},e.getCapacity=function(k,w,x){if(!a.isValid(k))throw new Error("Invalid QR Code version");typeof x>"u"&&(x=o.BYTE);const b=t.getSymbolTotalCodewords(k),C=i.getTotalCodewordsCount(k,w),D=(b-C)*8;if(x===o.MIXED)return D;const j=D-p(x,k);switch(x){case o.NUMERIC:return Math.floor(j/10*3);case o.ALPHANUMERIC:return Math.floor(j/11*2);case o.KANJI:return Math.floor(j/13);case o.BYTE:default:return Math.floor(j/8)}},e.getBestVersionForData=function(k,w){let x;const b=s.from(w,s.M);if(Array.isArray(k)){if(k.length>1)return S(k,b);if(k.length===0)return 1;x=k[0]}else x=k;return m(x.mode,x.getLength(),b)},e.getEncodedBits=function(k){if(!a.isValid(k)||k<7)throw new Error("Invalid QR Code version");let w=k<<12;for(;t.getBCHDigit(w)-d>=0;)w^=c<<t.getBCHDigit(w)-d;return k<<12|w}})(Pu)),Pu}var Lu={},ev;function fx(){if(ev)return Lu;ev=1;const e=vr(),t=1335,i=21522,s=e.getBCHDigit(t);return Lu.getEncodedBits=function(a,c){const d=a.bit<<3|c;let m=d<<10;for(;e.getBCHDigit(m)-s>=0;)m^=t<<e.getBCHDigit(m)-s;return(d<<10|m)^i},Lu}var ju={},Tu,tv;function px(){if(tv)return Tu;tv=1;const e=_r();function t(i){this.mode=e.NUMERIC,this.data=i.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,a,c;for(o=0;o+3<=this.data.length;o+=3)a=this.data.substr(o,3),c=parseInt(a,10),s.put(c,10);const d=this.data.length-o;d>0&&(a=this.data.substr(o),c=parseInt(a,10),s.put(c,d*3+1))},Tu=t,Tu}var Au,iv;function mx(){if(iv)return Au;iv=1;const e=_r(),t=["0","1","2","3","4","5","6","7","8","9","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"," ","$","%","*","+","-",".","/",":"];function i(s){this.mode=e.ALPHANUMERIC,this.data=s}return i.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(o){let a;for(a=0;a+2<=this.data.length;a+=2){let c=t.indexOf(this.data[a])*45;c+=t.indexOf(this.data[a+1]),o.put(c,11)}this.data.length%2&&o.put(t.indexOf(this.data[a]),6)},Au=i,Au}var Iu,nv;function gx(){if(nv)return Iu;nv=1;const e=_r();function t(i){this.mode=e.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){for(let s=0,o=this.data.length;s<o;s++)i.put(this.data[s],8)},Iu=t,Iu}var Bu,rv;function vx(){if(rv)return Bu;rv=1;const e=_r(),t=vr();function i(s){this.mode=e.KANJI,this.data=s}return i.getBitsLength=function(o){return o*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let a=t.toSJIS(this.data[o]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
83
+ Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),s.put(a,13)}},Bu=i,Bu}var Ou={exports:{}},sv;function _x(){return sv||(sv=1,(function(e){var t={single_source_shortest_paths:function(i,s,o){var a={},c={};c[s]=0;var d=t.PriorityQueue.make();d.push(s,0);for(var m,p,_,S,y,k,w,x,b;!d.empty();){m=d.pop(),p=m.value,S=m.cost,y=i[p]||{};for(_ in y)y.hasOwnProperty(_)&&(k=y[_],w=S+k,x=c[_],b=typeof c[_]>"u",(b||x>w)&&(c[_]=w,d.push(_,w),a[_]=p))}if(typeof o<"u"&&typeof c[o]>"u"){var C=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(C)}return a},extract_shortest_path_from_predecessor_list:function(i,s){for(var o=[],a=s;a;)o.push(a),i[a],a=i[a];return o.reverse(),o},find_path:function(i,s,o){var a=t.single_source_shortest_paths(i,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(i){var s=t.PriorityQueue,o={},a;i=i||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=i.sorter||s.default_sorter,o},default_sorter:function(i,s){return i.cost-s.cost},push:function(i,s){var o={value:i,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Ou)),Ou.exports}var ov;function yx(){return ov||(ov=1,(function(e){const t=_r(),i=px(),s=mx(),o=gx(),a=vx(),c=fy(),d=vr(),m=_x();function p(C){return unescape(encodeURIComponent(C)).length}function _(C,D,j){const M=[];let Z;for(;(Z=C.exec(j))!==null;)M.push({data:Z[0],index:Z.index,mode:D,length:Z[0].length});return M}function S(C){const D=_(c.NUMERIC,t.NUMERIC,C),j=_(c.ALPHANUMERIC,t.ALPHANUMERIC,C);let M,Z;return d.isKanjiModeEnabled()?(M=_(c.BYTE,t.BYTE,C),Z=_(c.KANJI,t.KANJI,C)):(M=_(c.BYTE_KANJI,t.BYTE,C),Z=[]),D.concat(j,M,Z).sort(function(T,X){return T.index-X.index}).map(function(T){return{data:T.data,mode:T.mode,length:T.length}})}function y(C,D){switch(D){case t.NUMERIC:return i.getBitsLength(C);case t.ALPHANUMERIC:return s.getBitsLength(C);case t.KANJI:return a.getBitsLength(C);case t.BYTE:return o.getBitsLength(C)}}function k(C){return C.reduce(function(D,j){const M=D.length-1>=0?D[D.length-1]:null;return M&&M.mode===j.mode?(D[D.length-1].data+=j.data,D):(D.push(j),D)},[])}function w(C){const D=[];for(let j=0;j<C.length;j++){const M=C[j];switch(M.mode){case t.NUMERIC:D.push([M,{data:M.data,mode:t.ALPHANUMERIC,length:M.length},{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.ALPHANUMERIC:D.push([M,{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.KANJI:D.push([M,{data:M.data,mode:t.BYTE,length:p(M.data)}]);break;case t.BYTE:D.push([{data:M.data,mode:t.BYTE,length:p(M.data)}])}}return D}function x(C,D){const j={},M={start:{}};let Z=["start"];for(let F=0;F<C.length;F++){const T=C[F],X=[];for(let K=0;K<T.length;K++){const G=T[K],ee=""+F+K;X.push(ee),j[ee]={node:G,lastCount:0},M[ee]={};for(let A=0;A<Z.length;A++){const N=Z[A];j[N]&&j[N].node.mode===G.mode?(M[N][ee]=y(j[N].lastCount+G.length,G.mode)-y(j[N].lastCount,G.mode),j[N].lastCount+=G.length):(j[N]&&(j[N].lastCount=G.length),M[N][ee]=y(G.length,G.mode)+4+t.getCharCountIndicator(G.mode,D))}}Z=X}for(let F=0;F<Z.length;F++)M[Z[F]].end=0;return{map:M,table:j}}function b(C,D){let j;const M=t.getBestModeForData(C);if(j=t.from(D,M),j!==t.BYTE&&j.bit<M.bit)throw new Error('"'+C+'" cannot be encoded with mode '+t.toString(j)+`.
84
+ Suggested mode is: `+t.toString(M));switch(j===t.KANJI&&!d.isKanjiModeEnabled()&&(j=t.BYTE),j){case t.NUMERIC:return new i(C);case t.ALPHANUMERIC:return new s(C);case t.KANJI:return new a(C);case t.BYTE:return new o(C)}}e.fromArray=function(D){return D.reduce(function(j,M){return typeof M=="string"?j.push(b(M,null)):M.data&&j.push(b(M.data,M.mode)),j},[])},e.fromString=function(D,j){const M=S(D,d.isKanjiModeEnabled()),Z=w(M),F=x(Z,j),T=m.find_path(F.map,"start","end"),X=[];for(let K=1;K<T.length-1;K++)X.push(F.table[T[K]].node);return e.fromArray(k(X))},e.rawSplit=function(D){return e.fromArray(S(D,d.isKanjiModeEnabled()))}})(ju)),ju}var av;function Sx(){if(av)return Su;av=1;const e=vr(),t=hd(),i=rx(),s=sx(),o=ox(),a=ax(),c=lx(),d=hy(),m=hx(),p=dx(),_=fx(),S=_r(),y=yx();function k(F,T){const X=F.size,K=a.getPositions(T);for(let G=0;G<K.length;G++){const ee=K[G][0],A=K[G][1];for(let N=-1;N<=7;N++)if(!(ee+N<=-1||X<=ee+N))for(let R=-1;R<=7;R++)A+R<=-1||X<=A+R||(N>=0&&N<=6&&(R===0||R===6)||R>=0&&R<=6&&(N===0||N===6)||N>=2&&N<=4&&R>=2&&R<=4?F.set(ee+N,A+R,!0,!0):F.set(ee+N,A+R,!1,!0))}}function w(F){const T=F.size;for(let X=8;X<T-8;X++){const K=X%2===0;F.set(X,6,K,!0),F.set(6,X,K,!0)}}function x(F,T){const X=o.getPositions(T);for(let K=0;K<X.length;K++){const G=X[K][0],ee=X[K][1];for(let A=-2;A<=2;A++)for(let N=-2;N<=2;N++)A===-2||A===2||N===-2||N===2||A===0&&N===0?F.set(G+A,ee+N,!0,!0):F.set(G+A,ee+N,!1,!0)}}function b(F,T){const X=F.size,K=p.getEncodedBits(T);let G,ee,A;for(let N=0;N<18;N++)G=Math.floor(N/3),ee=N%3+X-8-3,A=(K>>N&1)===1,F.set(G,ee,A,!0),F.set(ee,G,A,!0)}function C(F,T,X){const K=F.size,G=_.getEncodedBits(T,X);let ee,A;for(ee=0;ee<15;ee++)A=(G>>ee&1)===1,ee<6?F.set(ee,8,A,!0):ee<8?F.set(ee+1,8,A,!0):F.set(K-15+ee,8,A,!0),ee<8?F.set(8,K-ee-1,A,!0):ee<9?F.set(8,15-ee-1+1,A,!0):F.set(8,15-ee-1,A,!0);F.set(K-8,8,1,!0)}function D(F,T){const X=F.size;let K=-1,G=X-1,ee=7,A=0;for(let N=X-1;N>0;N-=2)for(N===6&&N--;;){for(let R=0;R<2;R++)if(!F.isReserved(G,N-R)){let I=!1;A<T.length&&(I=(T[A]>>>ee&1)===1),F.set(G,N-R,I),ee--,ee===-1&&(A++,ee=7)}if(G+=K,G<0||X<=G){G-=K,K=-K;break}}}function j(F,T,X){const K=new i;X.forEach(function(R){K.put(R.mode.bit,4),K.put(R.getLength(),S.getCharCountIndicator(R.mode,F)),R.write(K)});const G=e.getSymbolTotalCodewords(F),ee=d.getTotalCodewordsCount(F,T),A=(G-ee)*8;for(K.getLengthInBits()+4<=A&&K.put(0,4);K.getLengthInBits()%8!==0;)K.putBit(0);const N=(A-K.getLengthInBits())/8;for(let R=0;R<N;R++)K.put(R%2?17:236,8);return M(K,F,T)}function M(F,T,X){const K=e.getSymbolTotalCodewords(T),G=d.getTotalCodewordsCount(T,X),ee=K-G,A=d.getBlocksCount(T,X),N=K%A,R=A-N,I=Math.floor(K/A),z=Math.floor(ee/A),$=z+1,H=I-z,re=new m(H);let q=0;const L=new Array(A),W=new Array(A);let oe=0;const me=new Uint8Array(F.buffer);for(let ke=0;ke<A;ke++){const je=ke<R?z:$;L[ke]=me.slice(q,q+je),W[ke]=re.encode(L[ke]),q+=je,oe=Math.max(oe,je)}const V=new Uint8Array(K);let Q=0,de,ae;for(de=0;de<oe;de++)for(ae=0;ae<A;ae++)de<L[ae].length&&(V[Q++]=L[ae][de]);for(de=0;de<H;de++)for(ae=0;ae<A;ae++)V[Q++]=W[ae][de];return V}function Z(F,T,X,K){let G;if(Array.isArray(F))G=y.fromArray(F);else if(typeof F=="string"){let I=T;if(!I){const z=y.rawSplit(F);I=p.getBestVersionForData(z,X)}G=y.fromString(F,I||40)}else throw new Error("Invalid data");const ee=p.getBestVersionForData(G,X);if(!ee)throw new Error("The amount of data is too big to be stored in a QR Code");if(!T)T=ee;else if(T<ee)throw new Error(`
85
+ The chosen QR Code version cannot contain this amount of data.
86
+ Minimum version required to store current data is: `+ee+`.
87
+ `);const A=j(T,X,G),N=e.getSymbolSize(T),R=new s(N);return k(R,T),w(R),x(R,T),C(R,X,0),T>=7&&b(R,T),D(R,A),isNaN(K)&&(K=c.getBestMask(R,C.bind(null,R,X))),c.applyMask(K,R),C(R,X,K),{modules:R,version:T,errorCorrectionLevel:X,maskPattern:K,segments:G}}return Su.create=function(T,X){if(typeof T>"u"||T==="")throw new Error("No input text");let K=t.M,G,ee;return typeof X<"u"&&(K=t.from(X.errorCorrectionLevel,t.M),G=p.from(X.version),ee=c.from(X.maskPattern),X.toSJISFunc&&e.setToSJISFunction(X.toSJISFunc)),Z(T,G,K,ee)},Su}var zu={},Fu={},lv;function py(){return lv||(lv=1,(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let s=i.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+i);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(a){return[a,a]}))),s.length===6&&s.push("F","F");const o=parseInt(s.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const o=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,c=s.scale||4;return{width:a,scale:a?4:c,margin:o,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,o){return o.width&&o.width>=s+o.margin*2?o.width/(s+o.margin*2):o.scale},e.getImageWidth=function(s,o){const a=e.getScale(s,o);return Math.floor((s+o.margin*2)*a)},e.qrToImageData=function(s,o,a){const c=o.modules.size,d=o.modules.data,m=e.getScale(c,a),p=Math.floor((c+a.margin*2)*m),_=a.margin*m,S=[a.color.light,a.color.dark];for(let y=0;y<p;y++)for(let k=0;k<p;k++){let w=(y*p+k)*4,x=a.color.light;if(y>=_&&k>=_&&y<p-_&&k<p-_){const b=Math.floor((y-_)/m),C=Math.floor((k-_)/m);x=S[d[b*c+C]?1:0]}s[w++]=x.r,s[w++]=x.g,s[w++]=x.b,s[w]=x.a}}})(Fu)),Fu}var cv;function wx(){return cv||(cv=1,(function(e){const t=py();function i(o,a,c){o.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=c,a.width=c,a.style.height=c+"px",a.style.width=c+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,c,d){let m=d,p=c;typeof m>"u"&&(!c||!c.getContext)&&(m=c,c=void 0),c||(p=s()),m=t.getOptions(m);const _=t.getImageWidth(a.modules.size,m),S=p.getContext("2d"),y=S.createImageData(_,_);return t.qrToImageData(y.data,a,m),i(S,p,_),S.putImageData(y,0,0),p},e.renderToDataURL=function(a,c,d){let m=d;typeof m>"u"&&(!c||!c.getContext)&&(m=c,c=void 0),m||(m={});const p=e.render(a,c,m),_=m.type||"image/png",S=m.rendererOpts||{};return p.toDataURL(_,S.quality)}})(zu)),zu}var Hu={},uv;function bx(){if(uv)return Hu;uv=1;const e=py();function t(o,a){const c=o.a/255,d=a+'="'+o.hex+'"';return c<1?d+" "+a+'-opacity="'+c.toFixed(2).slice(1)+'"':d}function i(o,a,c){let d=o+a;return typeof c<"u"&&(d+=" "+c),d}function s(o,a,c){let d="",m=0,p=!1,_=0;for(let S=0;S<o.length;S++){const y=Math.floor(S%a),k=Math.floor(S/a);!y&&!p&&(p=!0),o[S]?(_++,S>0&&y>0&&o[S-1]||(d+=p?i("M",y+c,.5+k+c):i("m",m,0),m=0,p=!1),y+1<a&&o[S+1]||(d+=i("h",_),_=0)):m++}return d}return Hu.render=function(a,c,d){const m=e.getOptions(c),p=a.modules.size,_=a.modules.data,S=p+m.margin*2,y=m.color.light.a?"<path "+t(m.color.light,"fill")+' d="M0 0h'+S+"v"+S+'H0z"/>':"",k="<path "+t(m.color.dark,"stroke")+' d="'+s(_,p,m.margin)+'"/>',w='viewBox="0 0 '+S+" "+S+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(m.width?'width="'+m.width+'" height="'+m.width+'" ':"")+w+' shape-rendering="crispEdges">'+y+k+`</svg>
88
+ `;return typeof d=="function"&&d(null,b),b},Hu}var hv;function kx(){if(hv)return Kr;hv=1;const e=nx(),t=Sx(),i=wx(),s=bx();function o(a,c,d,m,p){const _=[].slice.call(arguments,1),S=_.length,y=typeof _[S-1]=="function";if(!y&&!e())throw new Error("Callback required as last argument");if(y){if(S<2)throw new Error("Too few arguments provided");S===2?(p=d,d=c,c=m=void 0):S===3&&(c.getContext&&typeof p>"u"?(p=m,m=void 0):(p=m,m=d,d=c,c=void 0))}else{if(S<1)throw new Error("Too few arguments provided");return S===1?(d=c,c=m=void 0):S===2&&!c.getContext&&(m=d,d=c,c=void 0),new Promise(function(k,w){try{const x=t.create(d,m);k(a(x,c,m))}catch(x){w(x)}})}try{const k=t.create(d,m);p(null,a(k,c,m))}catch(k){p(k)}}return Kr.create=t.create,Kr.toCanvas=o.bind(null,i.render),Kr.toDataURL=o.bind(null,i.renderToDataURL),Kr.toString=o.bind(null,function(a,c,d){return s.render(a,d)}),Kr}var Cx=kx();const xx=Fh(Cx);function dv(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function Ex(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const i=Y0(t);if(!i||!i.ok)return{kind:"invalid"};const s=[];return i.ssh||s.push("ssh"),i.name||s.push("name"),s.length?{kind:"partial",decoded:i,missing:s}:{kind:"complete",decoded:i}}function Nx(e,t,i=new Set,s=!1){if(!t||!t.ok)return e;const o=X0(e,t,i);return t.version===2&&t.name&&!i.has("name")&&!s&&(o.name=t.name),!i.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function fv(e,t,i=new Set,s=!1){const o=String(t||"").trim(),a=Ex(o);let c={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(c={...Nx(c,a.decoded,i,s),pairingUrl:o}),{classification:a,form:c}}function Rx(e,{deviceDefault:t=""}={}){const i={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},s=e.localLabel||t;return s&&(i.localLabel=s),i}function Px(){const e=new Set;let t=!1;return{canAuto(i){return!t&&!e.has(String(i||""))},start(i){return t?!1:(t=!0,e.add(String(i||"")),!0)},finish(){t=!1},reset(i){e.delete(String(i||""))},isBusy(){return t}}}const Dx=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function Mx(e){const t=e&&e.data||{},i=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:i,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",retryable:typeof t.retryable=="boolean"?t.retryable:!i,message:s||String(e&&e.message||e)}}const Lx="modulepreload",jx=function(e){return"/"+e},pv={},Tx=function(t,i,s){let o=Promise.resolve();if(i&&i.length>0){let c=function(p){return Promise.all(p.map(_=>Promise.resolve(_).then(S=>({status:"fulfilled",value:S}),S=>({status:"rejected",reason:S}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),m=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=c(i.map(p=>{if(p=jx(p),p in pv)return;pv[p]=!0;const _=p.endsWith(".css"),S=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${S}`))return;const y=document.createElement("link");if(y.rel=_?"stylesheet":Lx,_||(y.as="script"),y.crossOrigin="",y.href=p,m&&y.setAttribute("nonce",m),document.head.appendChild(y),_)return new Promise((k,w)=>{y.addEventListener("load",k),y.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${p}`)))})}))}function a(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&a(d.reason);return t().catch(a)})};class Ge{constructor(t,i,s,o,a){this._legacyCanvasSize=Ge.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=i:(console.warn(s||o||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=i),i=typeof s=="object"?s:{},this._onDecodeError=i.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=i.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=i.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=i.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let c=!1;if(t.hidden&&(t.hidden=!1,c=!0),document.body.contains(t)||(document.body.appendChild(t),c=!0),s=t.parentElement,i.highlightScanRegion||i.highlightCodeOutline){if(o=!!i.overlay,this.$overlay=i.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&i.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}i.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let d=window.getComputedStyle(t);d.display==="none"&&(t.style.setProperty("display","block","important"),c=!0),d.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),c=!0),c&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),t.style.opacity="0",t.style.width="0",t.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),t.addEventListener("play",this._onPlay),t.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=Ge.createQrEngine()}static set WORKER_PATH(t){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await Ge.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let i=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await i()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await i()).map((o,a)=>({id:o.deviceId,label:o.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),Ge._stopVideoStream(s))}}async hasFlash(){let t;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;t=this.$video.srcObject}else t=(await this._getCameraStream()).stream;return"torch"in t.getVideoTracks()[0].getSettings()}catch{return!1}finally{t&&t!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),Ge._stopVideoStream(t))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(t){throw this._flashOn=!1,t}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),Ge._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:i}=await this._getCameraStream();!this._active||this._paused?Ge._stopVideoStream(t):(this._setVideoMirror(i),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let i=()=>{this.$video.srcObject instanceof MediaStream&&(Ge._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(i(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(i(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,i,s,o,a=!1,c=!1){let d,m=!1;i&&("scanRegion"in i||"qrEngine"in i||"canvas"in i||"disallowCanvasResizing"in i||"alsoTryWithoutScanRegion"in i||"returnDetailedScanResult"in i)?(d=i.scanRegion,s=i.qrEngine,o=i.canvas,a=i.disallowCanvasResizing||!1,c=i.alsoTryWithoutScanRegion||!1,m=!0):console.warn(i||s||o||a||c?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),i=!!s;try{let p,_;[s,p]=await Promise.all([s||Ge.createQrEngine(),Ge._loadImage(t)]),[o,_]=Ge._drawToCanvas(p,d,o,a);let S;if(s instanceof Worker){let y=s;i||Ge._postWorkerMessageSync(y,"inversionMode","both"),S=await new Promise((k,w)=>{let x,b,C,D=-1;b=M=>{M.data.id===D&&(y.removeEventListener("message",b),y.removeEventListener("error",C),clearTimeout(x),M.data.data!==null?k({data:M.data.data,cornerPoints:Ge._convertPoints(M.data.cornerPoints,d)}):w(Ge.NO_QR_CODE_FOUND))},C=M=>{y.removeEventListener("message",b),y.removeEventListener("error",C),clearTimeout(x),w("Scanner error: "+(M?M.message||M:"Unknown Error"))},y.addEventListener("message",b),y.addEventListener("error",C),x=setTimeout(()=>C("timeout"),1e4);let j=_.getImageData(0,0,o.width,o.height);D=Ge._postWorkerMessageSync(y,"decode",j,[j.data.buffer])})}else S=await Promise.race([new Promise((y,k)=>window.setTimeout(()=>k("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await s.detect(o);if(!y)throw Ge.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:Ge._convertPoints(y.cornerPoints,d)}}catch(k){if(y=k.message||k,/not implemented|service unavailable/.test(y))return Ge._disableBarcodeDetector=!0,Ge.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:c});throw`Scanner error: ${y}`}})()]);return m?S:S.data}catch(p){if(!d||!c)throw p;let _=await Ge.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return m?_:_.data}finally{i||Ge._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,i,s,o=!0){Ge._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:i,blue:s,useIntegerApproximation:o})}setInversionMode(t){Ge._postWorkerMessage(this._qrEnginePromise,"inversionMode",t)}static async createQrEngine(t){if(t&&console.warn("Specifying a worker path is not required and not supported anymore."),t=()=>Tx(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Ge._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let i=navigator.userAgentData;return i&&i.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(i.platform)&&await i.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let i=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-i)/2),y:Math.round((t.videoHeight-i)/2),width:i,height:i,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,i=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,c=t.offsetLeft,d=t.offsetTop,m=window.getComputedStyle(t),p=m.objectFit,_=i/s,S=o/a;switch(p){case"none":var y=i,k=s;break;case"fill":y=o,k=a;break;default:(p==="cover"?_>S:_<S)?(k=a,y=k*_):(y=o,k=y/_),p==="scale-down"&&(y=Math.min(y,i),k=Math.min(k,s))}var[w,x]=m.objectPosition.split(" ").map((C,D)=>{const j=parseFloat(C);return C.endsWith("%")?(D?a-k:o-y)*j/100:j});m=this._scanRegion.width||i,S=this._scanRegion.height||s,p=this._scanRegion.x||0;var b=this._scanRegion.y||0;_=this.$overlay.style,_.width=`${m/i*y}px`,_.height=`${S/s*k}px`,_.top=`${d+x+b/s*k}px`,s=/scaleX\(-1\)/.test(t.style.transform),_.left=`${c+(s?o-w-y:w)+(s?i-p-m:p)/i*y}px`,_.transform=t.style.transform}})}static _convertPoints(t,i){if(!i)return t;let s=i.x||0,o=i.y||0,a=i.width&&i.downScaledWidth?i.width/i.downScaledWidth:1;i=i.height&&i.downScaledHeight?i.height/i.downScaledHeight:1;for(let c of t)c.x=c.x*a+s,c.y=c.y*i+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,i=1e3/this._maxScansPerSecond;t<i&&await new Promise(o=>setTimeout(o,i-t)),this._lastScanTimestamp=Date.now();try{var s=await Ge.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Ge._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Ge.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y:a})=>`${o},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==Ge.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",i=[{width:{min:1024}},{width:{min:768}},{}],s=i.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...i])try{let a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),c=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:c}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let i of t.getTracks())i.stop(),t.removeTrack(i)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,i,s,o=!1){s=s||document.createElement("canvas");let a=i&&i.x?i.x:0,c=i&&i.y?i.y:0,d=i&&i.width?i.width:t.videoWidth||t.width,m=i&&i.height?i.height:t.videoHeight||t.height;return o||(o=i&&i.downScaledWidth?i.downScaledWidth:d,i=i&&i.downScaledHeight?i.downScaledHeight:m,s.width!==o&&(s.width=o),s.height!==i&&(s.height=i)),i=s.getContext("2d",{alpha:!1}),i.imageSmoothingEnabled=!1,i.drawImage(t,a,c,d,m,0,0,s.width,s.height),[s,i]}static async _loadImage(t){if(t instanceof Image)return await Ge._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let i=new Image;i.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await Ge._awaitImageLoad(i),i}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(i.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((i,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):i()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,i,s,o){return Ge._postWorkerMessageSync(await t,i,s,o)}static _postWorkerMessageSync(t,i,s,o){if(!(t instanceof Worker))return-1;let a=Ge._workerMessageId++;return t.postMessage({id:a,type:i,data:s},o),a}}Ge.DEFAULT_CANVAS_SIZE=400;Ge.NO_QR_CODE_FOUND="No QR code found";Ge._disableBarcodeDetector=!1;Ge._workerMessageId=0;function Ax({onResult:e,onClose:t}){const i=P.useRef(null),s=P.useRef(null),o=P.useRef(!1),[a,c]=P.useState("");P.useEffect(()=>{let m=!1;const p=i.current,_=S=>{m||o.current||(o.current=!0,e(S))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(v("qr-unsupported"));return}let S=!1;try{S=await Ge.hasCamera()}catch{S=!1}if(!S){c(v("qr-no-camera"));return}if(m||!p)return;const y=new Ge(p,k=>{const w=dv(k);w&&_(w)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:k=>{const w=k.videoWidth||640,x=k.videoHeight||480,b=Math.max(1,Math.round(Math.min(w,x)*.92));return{x:Math.round((w-b)/2),y:Math.round((x-b)/2),width:b,height:b,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=y;try{await y.start()}catch(k){if(m)return;const w=k&&k.name||"";c(v(w==="NotAllowedError"||w==="SecurityError"?"qr-permission":w==="NotFoundError"||w==="OverconstrainedError"||w==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{m=!0;const S=s.current;if(S){try{S.stop()}catch{}try{S.destroy()}catch{}s.current=null}const y=p,k=y&&y.srcObject;if(k&&typeof k.getTracks=="function"){for(const w of k.getTracks())try{w.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const d=async m=>{const p=m.target.files&&m.target.files[0];if(m.target.value="",!!p)try{const _=await Ge.scanImage(p,{returnDetailedScanResult:!0}),S=dv(_);if(!S)throw new Error("empty");o.current||(o.current=!0,e(S))}catch{c(v("pairing-qr-invalid"))}};return u.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:u.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:m=>m.stopPropagation(),children:[u.jsx("div",{className:"nc-sheet-head",children:u.jsx("b",{children:v("scan-qr")})}),u.jsx("video",{ref:i,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&u.jsx("div",{className:"nc-err",role:"alert",children:a}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[v("qr-upload"),u.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:d})]}),u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:v("cancel")})]})]})})}const mv=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function my({token:e,initial:t="",autoStart:i=!1,deviceDefault:s="",readonly:o=!1,onSuccess:a,onBusyChange:c}){const[d,m]=P.useState(mv),[p,_]=P.useState(!1),[S,y]=P.useState(!1),[k,w]=P.useState("idle"),[x,b]=P.useState(null),[C,D]=P.useState(""),[j,M]=P.useState(!1),Z=P.useRef(Px()),F=P.useRef(new Set),T=k==="busy";P.useEffect(()=>(c&&c(T),()=>{c&&c(!1)}),[T,c]);const X=async R=>{const I=String(R.pairingUrl||"").trim();if(Z.current.start(I)){w("busy"),b(null),D("");try{await Gw(e,Rx(R,{deviceDefault:s})),w("ok"),_(!1),m(mv()),F.current=new Set,M(!1),Z.current.finish(),a&&await a()}catch(z){const $=Mx(z);b($),w("idle"),Z.current.finish(),($.stage==="validation"||$.stage==="conflict"||$.stage==="ssh-start"||$.stage==="ssh-ready"||String($.code||"").startsWith("ssh-"))&&_(!0)}}},K=(R,I=!0)=>{const{classification:z,form:$}=fv(d,R,F.current,j),H=$.pairingUrl;if(b(null),D(""),k==="ok"&&w("idle"),m($),z.kind==="invalid"){b({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(z.kind==="partial"){_(!0),D(z.missing.includes("ssh")?v("pair-missing-ssh"):v("pair-missing-name"));return}z.kind==="complete"&&I&&!o&&Z.current.canAuto(H)&&X($)};P.useEffect(()=>{t&&K(t,i)},[]);const G=()=>{const R=String(d.pairingUrl||"").trim(),{classification:I,form:z}=fv(d,R,F.current,j);if(m(z),D(""),b(null),I.kind==="empty"){b({stage:"validation",message:v("pairing-required"),retryable:!0});return}if(I.kind==="invalid"){b({stage:"validation",code:"bad-link",message:v("pair-invalid-link"),hint:v("pair-invalid-hint"),retryable:!0});return}if(!z.ssh||!z.name){_(!0),D(z.ssh?v("pair-missing-name"):v("pair-missing-ssh"));return}if(z.label&&!so(z.label)){b({stage:"validation",message:v("err-label"),retryable:!0});return}if(z.localLabel&&!so(z.localLabel)){b({stage:"validation",message:v("err-label"),retryable:!0});return}Z.current.reset(R),X(z)},ee=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const R=await navigator.clipboard.readText();R&&R.trim()?K(R):D(v("pair-clipboard-empty"))}catch{D(v("pair-clipboard-denied"))}},A=(R,I)=>{F.current.add(R),m(z=>({...z,[R]:I}))},N=x&&x.stage&&(Dx.includes(x.stage)||x.stage==="internal")?v(`pair-stage-${x.stage}`):v("pair-stage-generic");return u.jsxs("div",{className:"nc-set-form nc-pair-card",children:[u.jsx("div",{className:"nc-sheet-label",children:v("pair-card-title")}),u.jsx("div",{className:"nc-set-info",children:v("pair-card-help")}),u.jsx("input",{className:"nc-pair-input",placeholder:v("pair-paste-ph"),value:d.pairingUrl,disabled:o||T,onChange:R=>{m({...d,pairingUrl:R.target.value}),b(null),D("")},onPaste:R=>{const I=R.clipboardData&&R.clipboardData.getData("text")||"";I.trim()&&(R.preventDefault(),K(I))},onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),G())}}),u.jsxs("div",{className:"nc-pair-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||T,onClick:ee,children:v("pair-paste-btn")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||T,onClick:()=>y(!0),children:v("scan-qr")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||T,title:o?v("settings-readonly"):"",onClick:G,children:v("test-and-connect")})]}),u.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[T&&u.jsx("div",{className:"nc-pair-progress",children:v("pair-progress")}),k==="ok"&&u.jsx("div",{className:"nc-set-test ok",children:v("node-connected")}),C&&u.jsx("div",{className:"nc-set-hint nc-pair-notice",children:C}),x&&u.jsxs("div",{className:"nc-err",role:"alert",children:[u.jsx("b",{children:N})," — ",x.message,x.hint&&u.jsx("div",{className:"nc-pair-hint",children:x.hint}),x.retryable&&u.jsx("div",{children:u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||T,onClick:G,children:v("pair-retry")})})]})]}),u.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:T,onClick:()=>_(R=>!R),children:[p?"▾":"▸"," ",v("pair-advanced")]}),p&&u.jsxs("div",{className:"nc-pair-advanced",children:[u.jsxs("label",{className:"nc-field",children:[v("node-display-label"),u.jsx("input",{placeholder:"Home Relay",value:d.label,disabled:o||T,onChange:R=>{F.current.add("label"),m(I=>({...I,label:R.target.value,name:j?I.name:Gr(R.target.value)}))}})]}),u.jsxs("label",{className:"nc-field",children:[v("node-name-label"),u.jsx("input",{placeholder:v("node-name-ph"),value:d.name,disabled:o||T,onChange:R=>{M(!0),F.current.add("name"),m(I=>({...I,name:R.target.value?Gr(R.target.value):""}))}})]}),u.jsx("small",{className:"nc-set-hint",children:v("node-slug-hint").replace("{slug}",d.name||"home-relay")}),u.jsxs("label",{className:"nc-field",children:[v("pair-ssh-local-label"),u.jsx("input",{placeholder:"my-relay",value:d.ssh,disabled:o||T,onChange:R=>{F.current.add("ssh"),A("ssh",R.target.value)}}),u.jsx("small",{className:"nc-set-hint",children:v("node-ssh-local-help")})]}),u.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),u.jsx("input",{inputMode:"numeric",placeholder:v("node-ssh-port-help"),value:d.sshPort,disabled:o||T,onChange:R=>A("sshPort",R.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),u.jsxs("label",{className:"nc-field",children:[v("device-name-label"),u.jsx("input",{placeholder:s||"NexusCrew",value:d.localLabel,disabled:o||T,onChange:R=>A("localLabel",R.target.value)}),u.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]})]}),S&&u.jsx(Ax,{onResult:R=>{y(!1),K(R)},onClose:()=>y(!1)})]})}function dd(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function Ix(e){const t="=".repeat((4-e.length%4)%4),i=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(i),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function Bx(){if(!dd())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function Ox(e){if(!dd())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const i=await zt("/api/push/vapid",e),{publicKey:s}=await i.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Ix(s)}),c=await zt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!c.ok){try{await a.unsubscribe()}catch{}const d=await c.json().catch(()=>({}));throw new Error(d.error||`HTTP ${c.status}`)}return!0}async function zx(e){if(!dd())return!1;const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!i)return!1;const s=i.endpoint;try{await i.unsubscribe()}catch{}try{await zt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const gy="nexuscrew.fleet",vy=2,Fx="nexuscrew.cells",Hx=/^[A-Za-z0-9._-]{1,32}$/,fd=/^[a-z0-9._-]{1,32}$/,_y=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,$x=new Set(["standard","unsafe"]),Wx=4096,gv=256,Ux=8192,Kx=32,qx=24,Vx=new Set(["format","version","exportedAt","cells","engines"]),Yx=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),Xx=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),Gx=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function ar(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function yy(e){const t=String(e||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(t)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(t)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(t)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(t)}function vv(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const i=Object.entries(e);if(i.length>128)return null;const s={};for(const[o,a]of i){if(!fd.test(o)||!t(a))return null;s[o]=a}return s}function Sy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!Yx.has(a))||!Hx.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Wx||!fd.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>gv)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const t=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof t!="string"||t.length>Ux)return null;const i=vv(e.models,a=>typeof a=="string"&&!!a&&a.length<=gv),s=vv(e.permissionPolicies,a=>$x.has(a));if(i===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(i).length&&(o.models=i),Object.keys(s).length&&(o.permissionPolicies=s),o}function Qx(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(i=>!Gx.has(i)))return null;const t={};for(const[i,s]of Object.entries(e)){if(typeof s!="string"||!ar(s,i==="baseUrl"?512:128)||yy(s))return null;t[i]=s}return!t.client||!t.provider||t.envKey&&!_y.test(t.envKey)?null:t}function wy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!Xx.has(s))||!fd.test(String(e.id||""))||!ar(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean")return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.managed!==void 0){const s=Qx(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!ar(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!ar(s,1024)||yy(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!ar(e.promptFlag,32)||/\s/.test(e.promptFlag)))return null;if(e.model!==void 0){if(!e.model||typeof e.model!="object"||Array.isArray(e.model)||Object.keys(e.model).some(s=>s!=="flag"&&s!=="value")||!ar(e.model.flag,32)||/\s/.test(e.model.flag)||!ar(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const i=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(i)||i.length>32||i.some(s=>!_y.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(i)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function by(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},i=wy(t);return i||null}function Jx(e,t,i=[],s=[],o=new Date){i instanceof Date&&(o=i,i=[],s=[]);const a=t instanceof Set?t:new Set(t||[]),c=s instanceof Set?s:new Set(s||[]),d=[];for(const p of Array.isArray(e)?e:[]){if(!a.has(p.id))continue;const _=Sy({id:p.id,cwd:p.cwd,engine:p.engine,boot:p.boot===!0,...p.model?{model:p.model}:{},...p.models?{models:p.models}:{},...p.permissionPolicies?{permissionPolicies:p.permissionPolicies}:{},systemPrompt:p.prompt||""});_&&d.push(_)}const m=[];for(const p of Array.isArray(i)?i:[]){if(!c.has(p.id))continue;const _=by(p);_&&m.push(_)}return{format:gy,version:vy,exportedAt:o.toISOString(),cells:d,engines:m}}function Zx(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const i=(t==null?void 0:t.format)===Fx&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!Vx.has(d))||!i&&(t.format!==gy||t.version!==vy)||!Array.isArray(t.cells)||t.cells.length>Kx||!i&&(!Array.isArray(t.engines)||t.engines.length>qx))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const d of t.cells){const m=Sy(d);if(!m)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(m.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(m.id),s.push(m)}const a=[],c=new Set;for(const d of i?[]:t.engines){const m=wy(d);if(!m)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(c.has(m.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};c.add(m.id),a.push(m)}return{ok:!0,cells:s,engines:a,legacy:i,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function eE(e,t,i){const s=new Set(i||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([p])=>s.has(p))),a={id:e.id,cwd:e.cwd,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const c=o(e.models),d=o(e.permissionPolicies);return Object.keys(c).length&&(a.models=c),Object.keys(d).length&&(a.permissionPolicies=d),a}const tE=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",displayName:"",protocol:"anthropic_messages",baseUrl:"",envKey:"",providerId:"nexuscrew-custom",command:"",argsText:"",rc:!0,promptMode:"send-keys",promptFlag:"",modelFlag:"",modelValue:"",envRows:[],credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}),_v=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),ky=e=>e==="claude"?"unsafe":"standard",co=(e,t)=>e.find(i=>i.client===t.client&&i.provider===t.provider&&(i.credentialProfile||"")===(t.credentialProfile||"")),iE=(e,t)=>{var i;return((i=co(e,t))==null?void 0:i.label)||`${t.client} · ${t.provider}`};function nE(e){var t,i,s,o,a,c,d,m,p,_,S,y,k,w;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
89
+ `),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((i=e.managed)==null?void 0:i.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((a=e.managed)==null?void 0:a.permissionPolicy)||ky((c=e.managed)==null?void 0:c.client),displayName:((d=e.managed)==null?void 0:d.displayName)||"",protocol:((m=e.managed)==null?void 0:m.protocol)||"",baseUrl:((p=e.managed)==null?void 0:p.baseUrl)||"",envKey:((_=e.managed)==null?void 0:_.envKey)||"",providerId:((S=e.managed)==null?void 0:S.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((y=e.managedInfo)==null?void 0:y.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((k=e.model)==null?void 0:k.flag)||"",modelValue:((w=e.model)==null?void 0:w.value)||"",envRows:(e.envKeys||[]).map(x=>({key:x,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}}function rE(e,t,i=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||ky(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const a=co(i,e);return(a==null?void 0:a.credentialEnv)===!0&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),{...t?{id:e.id}:{},label:e.label||iE(i,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
90
+ `).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function qr({children:e,onClose:t,label:i,error:s=""}){const o=P.useRef(null),a=P.useRef(null),c=P.useRef(t);return c.current=t,P.useEffect(()=>{const d=document.activeElement,m=o.current,p=()=>Array.from((m==null?void 0:m.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(y=>y.offsetParent!==null),_=requestAnimationFrame(()=>{var y;return(y=p()[0]||m)==null?void 0:y.focus({preventScroll:!0})}),S=y=>{var b;if(y.key==="Escape"){y.preventDefault(),(b=c.current)==null||b.call(c);return}if(y.key!=="Tab")return;const k=p();if(!k.length){y.preventDefault(),m==null||m.focus();return}const w=k[0],x=k[k.length-1];y.shiftKey&&document.activeElement===w?(y.preventDefault(),x.focus()):!y.shiftKey&&document.activeElement===x&&(y.preventDefault(),w.focus())};return document.addEventListener("keydown",S),()=>{cancelAnimationFrame(_),document.removeEventListener("keydown",S),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),P.useEffect(()=>{s&&requestAnimationFrame(()=>{var d;return(d=a.current)==null?void 0:d.scrollIntoView({block:"nearest"})})},[s]),u.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&t()},children:u.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":i||v("settings"),tabIndex:-1,children:[e,s&&u.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function yv({token:e,targets:t=[],readonly:i=!1,onPower:s,onImport:o}){const[a,c]=P.useState([]),[d,m]=P.useState(0);P.useEffect(()=>{let b=!0;async function C(){const j=[{route:[],label:v("local")}].concat((t||[]).map(Z=>({route:Array.isArray(Z.route)?Z.route:[],label:Z.label||(Z.route||[]).join(" › ")}))),M=await Promise.all(j.map(async Z=>{const F={...Z,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const T=await mr(e,Z.route);F.available=!!T.available,F.capabilities=T.capabilities||[],F.provider=T.provider||null,F.cells=(T.cells||[]).map(X=>({...X,route:Z.route}));try{F.readonly=!!(await Kh(e,Z.route)).readonlyDefault}catch{}try{const X=await Tv(e,Z.route),K=new Set(F.cells.map(G=>G.tmuxSession).filter(Boolean));F.unmanaged=(X.sessions||[]).filter(G=>G&&!K.has(G.name))}catch{}}catch(T){F.err=String(T&&T.message||T)}return F}));b&&c(M)}C();const D=setInterval(C,6e3);return()=>{b=!1,clearInterval(D)}},[e,t,d]);const p=(b,C)=>Array.isArray(b.capabilities)&&b.capabilities.includes(C)&&!i&&!b.readonly,_=()=>m(b=>b+1),S=(b,C)=>{s&&s({...b,route:C})},y=(b,C)=>{s&&s({...b,route:C})},k=async(b,C)=>{try{await Js(e,b.cell,C)}catch{}_()},w=async(b,C)=>{if(window.confirm(v("fleet-remove-cell").replace("{id}",b.cell))){try{await Dv(e,b.cell,!0,C)}catch{}_()}},x=async(b,C)=>{if(window.confirm(v("terminate-confirm").replace("{name}",b.name))){try{await Uh(e,b.name,C)}catch{}_()}};return u.jsxs("div",{className:"nc-fleet-inventory",children:[u.jsxs("div",{className:"nc-fleet-section-head",children:[u.jsx("b",{children:v("fleet-inventory")}),u.jsx("small",{children:v("fleet-inventory-help")})]}),a.map(b=>{const C=b.route.length?b.route.join("/"):"local";return u.jsxs("div",{className:"nc-fleet-pos",children:[u.jsxs("div",{className:"nc-fleet-pos-title",children:[u.jsx("span",{className:`dot ${b.available?"on":"warn"}`}),u.jsx("b",{children:b.label}),u.jsx("small",{children:b.available?`${b.cells.length} ${v("fleet-cells")} · ${b.unmanaged.length} ${v("fleet-tmux")}`:b.err||v("fleet-not-available")})]}),b.cells.map(D=>u.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[u.jsxs("span",{children:[u.jsx("b",{children:D.cell}),u.jsx("small",{children:`${D.engine||""}${D.key?`·${D.key}`:""}${D.active?"":` · ${v("cell-off")}`}`})]}),u.jsxs("span",{className:"nc-fleet-cell-actions",children:[D.active&&p(b,"down")&&u.jsx("button",{className:"nc-btn ghost",title:v("power-off"),onClick:()=>y(D,b.route),children:v("stop")}),!D.active&&p(b,"up")&&u.jsx("button",{className:"nc-btn ghost",title:v("power-on"),onClick:()=>S(D,b.route),children:v("start")}),p(b,"restart")&&D.active&&u.jsx("button",{className:"nc-btn ghost",title:v("restart"),onClick:()=>k(D,b.route),children:v("restart")}),p(b,"remove")&&u.jsx("button",{className:"nc-btn danger",title:v("delete"),onClick:()=>w(D,b.route),children:"×"})]})]},`${C}:${D.cell}`)),b.unmanaged.map(D=>u.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[u.jsxs("span",{children:[u.jsx("b",{children:D.name}),u.jsx("small",{children:v("fleet-tmux")})]}),u.jsxs("span",{className:"nc-fleet-cell-actions",children:[p(b,"import")&&o&&u.jsx("button",{className:"nc-btn ghost",title:v("import-as-cell"),onClick:()=>o(D,b.route),children:v("import-as-cell")}),u.jsx("button",{className:"nc-btn danger",title:v("terminate"),onClick:()=>x(D,b.route),children:"×"})]})]},`${C}:u:${D.name}`)),b.available&&b.cells.length===0&&b.unmanaged.length===0&&u.jsx("div",{className:"nc-empty",children:v("fleet-inventory-empty")})]},C)})]})}function sE({cells:e=[],engines:t=[],busy:i,canRestore:s=!1,onRestore:o,onClose:a}){const[c,d]=P.useState("export"),[m,p]=P.useState(()=>new Set(e.map(N=>N.id))),[_,S]=P.useState(()=>new Set(t.map(N=>N.id))),[y,k]=P.useState([]),[w,x]=P.useState([]),[b,C]=P.useState(""),D=new Set(t.map(N=>N.id)),j=new Set(e.map(N=>N.id)),M=(N,R)=>N(I=>{const z=new Set(I);return z.has(R)?z.delete(R):z.add(R),z}),Z=()=>{const N=Jx(e,m,t,_),R=t.filter(H=>_.has(H.id)).length;if(N.engines.length!==R){C(v("fleet-backup-invalid-engine"));return}if(!N.cells.length&&!N.engines.length){C(v("fleet-backup-select-one"));return}const I=new Blob([`${JSON.stringify(N,null,2)}
91
+ `],{type:"application/json"}),z=URL.createObjectURL(I),$=document.createElement("a");$.href=z,$.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild($),$.click(),$.remove(),setTimeout(()=>URL.revokeObjectURL(z),0),C("")},F=async N=>{if(C(""),k([]),x([]),!!N){if(N.size>1024*1024){C(v("fleet-backup-too-large"));return}try{const R=Zx(await N.text());if(!R.ok){C(v(`fleet-backup-${R.error}`));return}const I=new Set(R.engines.map(z=>z.id));x(R.engines.map(z=>({engine:z,exists:D.has(z.id),selected:!D.has(z.id)}))),k(R.cells.map(z=>{const $=D.has(z.engine)||I.has(z.engine),H=j.has(z.id);return{cell:z,engine:$?z.engine:"",selected:$&&!H,exists:H}}))}catch(R){C(String(R.message||R))}}},T=(N,R)=>k(I=>I.map((z,$)=>$===N?{...z,...R}:z)),X=(N,R)=>x(I=>I.map((z,$)=>$===N?{...z,...R}:z)),K=new Set([...D,...w.filter(N=>N.selected).map(N=>N.engine.id)]),G=y.filter(N=>N.selected&&N.engine&&K.has(N.engine)),ee=w.filter(N=>N.selected),A=[...new Map([...t.map(N=>[N.id,N.label||N.id]),...w.filter(N=>N.selected).map(N=>[N.engine.id,N.engine.label||N.engine.id])]).entries()];return u.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[u.jsx("b",{children:v("fleet-backup")}),u.jsx("small",{children:v("fleet-backup-help")}),u.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[u.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="export"?" on":""}`,onClick:()=>{d("export"),C("")},children:v("fleet-backup-export")}),u.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="import"?" on":""}`,disabled:!s,title:s?"":v("fleet-backup-restore-unavailable"),onClick:()=>{d("import"),C("")},children:v("fleet-backup-import")})]}),c==="export"?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set(e.map(N=>N.id))),S(new Set(t.map(N=>N.id)))},children:v("select-all")}),u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{p(new Set),S(new Set)},children:v("select-none")})]}),u.jsxs("div",{className:"nc-backup-list",children:[u.jsx("b",{children:v("fleet-engines")}),t.map(N=>{var R;return u.jsxs("label",{className:"nc-check nc-backup-row",children:[u.jsx("input",{type:"checkbox",checked:_.has(N.id),onChange:()=>M(S,N.id)}),u.jsxs("span",{children:[u.jsx("b",{children:N.label||N.id}),u.jsxs("small",{children:[N.id,(R=N.envKeys)!=null&&R.length?` · ${N.envKeys.length} ${v("fleet-backup-env-names")}`:""]})]})]},N.id)}),u.jsx("b",{children:v("fleet-cells")}),e.map(N=>u.jsxs("label",{className:"nc-check nc-backup-row",children:[u.jsx("input",{type:"checkbox",checked:m.has(N.id),onChange:()=>M(p,N.id)}),u.jsxs("span",{children:[u.jsx("b",{children:N.id}),u.jsxs("small",{children:[N.engine," · ",v("fleet-system-prompt")," ",(N.prompt||"").length," ",v("characters")]})]})]},N.id)),!e.length&&!t.length&&u.jsx("div",{className:"nc-empty",children:v("fleet-backup-empty")})]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:v("cancel")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:!m.size&&!_.size,onClick:Z,children:v("fleet-backup-download")})]})]}):u.jsxs(u.Fragment,{children:[u.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:N=>F(N.target.files&&N.target.files[0])}),u.jsx("small",{children:v("fleet-backup-import-help")}),!!(y.length||w.length)&&u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(N=>N.map(R=>({...R,selected:!0}))),k(N=>N.map(R=>({...R,selected:!!R.engine})))},children:v("select-all")}),u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(N=>N.map(R=>({...R,selected:!1}))),k(N=>N.map(R=>({...R,selected:!1})))},children:v("select-none")})]}),u.jsxs("div",{className:"nc-backup-list",children:[!!w.length&&u.jsx("b",{children:v("fleet-engines")}),w.map((N,R)=>{var I;return u.jsx("div",{className:"nc-backup-import-row",children:u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:N.selected,onChange:z=>X(R,{selected:z.target.checked})}),u.jsxs("span",{children:[u.jsx("b",{children:N.engine.label||N.engine.id}),u.jsxs("small",{children:[N.engine.id," · ",N.exists?v("fleet-backup-overwrite"):v("fleet-backup-new"),(I=N.engine.envKeys)!=null&&I.length?` · ${v("fleet-backup-env-values-required")}`:""]})]})]})},N.engine.id)}),!!y.length&&u.jsx("b",{children:v("fleet-cells")}),y.map((N,R)=>u.jsxs("div",{className:"nc-backup-import-row",children:[u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:N.selected,disabled:!N.engine||!K.has(N.engine),onChange:I=>T(R,{selected:I.target.checked})}),u.jsxs("span",{children:[u.jsx("b",{children:N.cell.id}),u.jsxs("small",{children:[N.exists?v("fleet-backup-overwrite"):v("fleet-backup-new")," · ",v("fleet-system-prompt")," ",N.cell.systemPrompt.length," ",v("characters")]})]})]}),u.jsxs("select",{value:N.engine,onChange:I=>T(R,{engine:I.target.value,selected:!!I.target.value}),children:[u.jsx("option",{value:"",children:v("fleet-backup-engine-missing")}),A.map(([I,z])=>u.jsx("option",{value:I,children:z},I))]})]},N.cell.id))]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:v("cancel")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!G.length&&!ee.length,onClick:()=>o({engineRows:w,cellRows:y}),children:v("fleet-backup-restore")})]})]}),b&&u.jsx("div",{className:"nc-err",children:b})]})}function oE({state:e,setState:t,busy:i,onSave:s,catalog:o}){var b;const a=e.form,c=C=>t({...e,form:{...a,...C}}),d=a.envRows||[],m=[...new Map(o.map(C=>[C.client,C.clientLabel||C.client])).entries()],p=o.filter(C=>C.client===a.client),_=co(o,a),S=typeof(_==null?void 0:_.credentialEnv)=="string"?_.credentialEnv:"",y=Array.isArray(_==null?void 0:_.credentialUsedBy)?_.credentialUsedBy:[],k=(_==null?void 0:_.credentialSource)||"missing",w=!!S&&e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,x=C=>{C&&c({client:C.client,provider:C.provider,credentialProfile:C.credentialProfile||"",managedModel:C.model||"",protocol:C.protocol||"",permissionPolicy:C.permissionPolicyDefault||"standard",rc:!!C.rc,displayName:C.custom?v("fleet-custom-provider-default"):"",baseUrl:C.custom?"":C.endpoint||"",envKey:C.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:C.id,label:""}:{}})};return u.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[u.jsx("b",{children:e.mode==="new"?v("fleet-new-engine"):`${v("edit")} ${a.id}`}),u.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:C=>c({id:C.target.value})}),u.jsx("input",{value:a.label,placeholder:v("label"),onChange:C=>c({label:C.target.value})}),u.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:C=>c({kind:C.target.value}),children:[u.jsx("option",{value:"managed",children:v("fleet-managed")}),u.jsx("option",{value:"custom",children:v("fleet-custom")})]}),a.kind==="managed"?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:C=>x(o.find(D=>D.client===C.target.value&&D.default)||o.find(D=>D.client===C.target.value)),children:m.map(([C,D])=>u.jsx("option",{value:C,children:D},C))}),u.jsx("select",{value:((b=co(o,a))==null?void 0:b.id)||"",disabled:e.mode!=="new",onChange:C=>x(o.find(D=>D.id===C.target.value)),children:p.map(C=>u.jsx("option",{value:C.id,children:C.label},C.id))})]}),u.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:v(_!=null&&_.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:C=>c({managedModel:C.target.value})}),u.jsx("datalist",{id:"nc-managed-models",children:[...(_==null?void 0:_.models)||[],...a.modelOptions||[]].filter((C,D,j)=>C&&j.indexOf(C)===D).map(C=>u.jsx("option",{value:C},C))}),_!=null&&_.supportsUnsafe?u.jsxs("select",{value:a.permissionPolicy,onChange:C=>c({permissionPolicy:C.target.value}),children:[u.jsx("option",{value:"standard",children:v("fleet-standard-permissions")}),u.jsx("option",{value:"unsafe",children:v("fleet-unsafe-permissions")})]}):u.jsx("small",{children:v("fleet-standard-permissions")}),(_==null?void 0:_.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&u.jsx("small",{className:"nc-err",children:v("fleet-unsafe-warning")}),(_==null?void 0:_.credentialEnv)===!0&&u.jsxs(u.Fragment,{children:[u.jsx("input",{value:a.envKey,placeholder:v("fleet-api-key-env"),onChange:C=>c({envKey:C.target.value})}),u.jsx("small",{children:v("fleet-custom-secret-help")})]}),S&&u.jsxs("section",{className:"nc-fleet-key","aria-label":v("fleet-key-section"),children:[u.jsxs("div",{className:"nc-fleet-key-head",children:[u.jsx("b",{children:v("fleet-key-section")}),u.jsx("span",{children:v(`fleet-credential-source-${k}`)})]}),u.jsxs("label",{className:"nc-field",children:[v("fleet-key-variable"),u.jsx("input",{value:S,readOnly:!0,"aria-label":v("fleet-key-variable")})]}),u.jsx("small",{children:y.length?v("fleet-key-used-by").replace("{engines}",y.join(", ")):v("fleet-key-used-by-none")}),y.length>0&&u.jsx("small",{children:v("fleet-key-shared-impact").replace("{key}",S).replace("{engines}",y.join(", "))}),u.jsxs("div",{className:"nc-fleet-key-input",children:[u.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":v("fleet-key-value").replace("{key}",S),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:_!=null&&_.authConfigured||e.mode==="edit"?v("fleet-key-blank-keeps"):v("fleet-key-enter"),onChange:C=>c({credentialValue:C.target.value,allowMissingCredential:C.target.value?!1:a.allowMissingCredential})}),u.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":v(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>c({credentialReveal:!a.credentialReveal}),children:v(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),u.jsx("small",{children:v("fleet-key-local-help")}),e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&u.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[u.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:C=>c({allowMissingCredential:C.target.checked})}),v("fleet-key-create-missing")]}),(_==null?void 0:_.notice)&&u.jsx("small",{className:"nc-fleet-provider-notice",children:v(`fleet-provider-notice-${_.notice}`)})]}),a.provider==="custom"&&u.jsxs(u.Fragment,{children:[u.jsx("input",{value:a.displayName,placeholder:v("fleet-provider-display"),onChange:C=>c({displayName:C.target.value})}),u.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:C=>c({baseUrl:C.target.value})}),((_==null?void 0:_.protocols)||[]).length>1&&u.jsx("select",{value:a.protocol,onChange:C=>c({protocol:C.target.value}),children:_.protocols.map(C=>u.jsx("option",{value:C,children:C},C))}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:a.envKey,placeholder:v("fleet-api-key-env"),onChange:C=>c({envKey:C.target.value})}),u.jsx("input",{value:a.providerId,placeholder:v("fleet-provider-id"),onChange:C=>c({providerId:C.target.value})})]}),u.jsxs("small",{children:[a.protocol," · ",v("fleet-custom-secret-help")]})]}),u.jsx("small",{children:v("fleet-managed-help")})]}):u.jsxs(u.Fragment,{children:[u.jsx("input",{value:a.command,placeholder:v("command-path"),onChange:C=>c({command:C.target.value})}),u.jsx("textarea",{value:a.argsText,placeholder:v("args-lines"),onChange:C=>c({argsText:C.target.value})}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:a.rc,onChange:C=>c({rc:C.target.checked})})," remote control"]}),u.jsxs("select",{value:a.promptMode,onChange:C=>c({promptMode:C.target.value}),children:[u.jsx("option",{value:"send-keys",children:"send-keys"}),u.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&u.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:C=>c({promptFlag:C.target.value})}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:C=>c({modelFlag:C.target.value})}),u.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:C=>c({modelValue:C.target.value})})]}),u.jsx("small",{children:v("env-write-only")}),d.map((C,D)=>u.jsxs("div",{className:"nc-fleet-env",children:[u.jsx("input",{value:C.key,disabled:C.configured,placeholder:"ENV_KEY",onChange:j=>{const M=d.slice();M[D]={...C,key:j.target.value},c({envRows:M})}}),u.jsx("input",{type:"password",value:C.value,placeholder:C.configured?"•••••• (unchanged)":"value",onChange:j=>{const M=d.slice();M[D]={...C,value:j.target.value},c({envRows:M})}}),u.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:d.filter((j,M)=>M!==D)}),children:"×"})]},`${C.key}-${D}`)),u.jsx("button",{className:"nc-btn ghost",onClick:()=>c({envRows:[...d,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:i||!a.id||w||a.kind==="custom"&&!a.command||a.kind==="managed"&&(_==null?void 0:_.requiresModel)&&!a.managedModel||a.kind==="managed"&&(_==null?void 0:_.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:v("save")})]})]})}function aE({token:e,route:t,targets:i=[],location:s,setLocation:o,state:a,setState:c,engines:d,busy:m,onSave:p}){const[_,S]=P.useState(null),[y,k]=P.useState(""),w=a.form,x=j=>c({...a,form:{...w,...j}}),b=d.find(j=>j.id===w.engine),C=j=>{var Z,F,T;const M=d.find(X=>X.id===j);x({engine:j,model:((Z=w.models)==null?void 0:Z[j])||((F=M==null?void 0:M.managed)==null?void 0:F.model)||((T=M==null?void 0:M.model)==null?void 0:T.value)||""})},D=async j=>{try{const M=await Lv(e,j,t);S(M),x({cwd:M.path}),k("")}catch(M){k(String(M.message||M))}};return u.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[u.jsx("b",{children:a.mode==="new"?v("fleet-new-cell"):`${v("edit")} ${w.id}`}),a.mode==="new"&&u.jsxs("label",{className:"nc-field",children:[v("location"),u.jsx("span",{className:"nc-req",children:" *"}),u.jsxs("select",{value:s,onChange:j=>{o(j.target.value),x({engine:""})},children:[u.jsx("option",{value:"",children:v("local")}),i.map(j=>u.jsxs("option",{value:j.route.join("/"),disabled:j.status&&j.status!=="up",children:[j.label,j.status&&j.status!=="up"?` · ${v("node-offline")}`:""]},j.route.join("/")))]})]}),u.jsx("input",{value:w.id,disabled:a.mode!=="new",placeholder:"id",onChange:j=>x({id:j.target.value})}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:w.cwd,placeholder:v("cwd"),onChange:j=>x({cwd:j.target.value})}),u.jsx("button",{className:"nc-btn ghost",onClick:()=>_?S(null):D(w.cwd),children:v("browse")})]}),_&&u.jsxs("div",{className:"nc-fs",children:[u.jsx("div",{className:"nc-fs-path",children:_.path}),u.jsxs("div",{className:"nc-fs-list",children:[_.parent&&u.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>D(_.parent),children:["↑ ",v("fs-parent")]}),(_.dirs||[]).map(j=>u.jsxs("button",{className:"nc-fs-item",onClick:()=>D(`${_.path.replace(/\/$/,"")}/${j}`),children:["📁 ",j]},j))]})]}),y&&u.jsx("div",{className:"nc-err",children:y}),u.jsx("select",{value:w.engine,onChange:j=>C(j.target.value),children:d.map(j=>u.jsx("option",{value:j.id,children:j.label},j.id))}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:j=>x({boot:j.target.checked})})," boot"]}),u.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:v("fleet-model-override"),onChange:j=>x({model:j.target.value})}),u.jsx("datalist",{id:"nc-cell-models",children:((b==null?void 0:b.availableModels)||[]).map(j=>u.jsx("option",{value:j},j))}),u.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:j=>x({prompt:j.target.value})}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:m||!w.id||!w.cwd||!w.engine,onClick:p,children:v("save")})]})]})}function Sv({token:e,route:t=[],state:i,setState:s,busy:o,onSave:a}){const[c,d]=P.useState(null),[m,p]=P.useState([]),[_,S]=P.useState(""),y=Array.isArray(t)?t.join("/"):"";P.useEffect(()=>{let C=!0;return Wh(e,y?y.split("/"):[]).then(D=>{C&&(p(D.engines||[]),S(""))}).catch(D=>{C&&(p([]),S(String(D.message||D)))}),()=>{C=!1}},[e,y]);const k=i.form,w=C=>s({...i,form:{...k,...C}}),x=async C=>{try{const D=await Lv(e,C,t);d(D),w({cwd:D.path})}catch{}},b=!k.id&&k.tmuxSession?k.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):k.id;return u.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[u.jsxs("b",{children:[v("import-as-cell")," · ",k.tmuxSession]}),u.jsx("small",{children:v("import-help")}),u.jsx("input",{value:k.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),u.jsx("input",{value:k.id,placeholder:v("name"),onChange:C=>w({id:C.target.value})}),u.jsxs("div",{className:"nc-fleet-pair",children:[u.jsx("input",{value:k.cwd,placeholder:v("cwd"),onChange:C=>w({cwd:C.target.value})}),u.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?d(null):x(k.cwd),children:v("browse")})]}),c&&u.jsxs("div",{className:"nc-fs",children:[u.jsx("div",{className:"nc-fs-path",children:c.path}),u.jsxs("div",{className:"nc-fs-list",children:[c.parent&&u.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>x(c.parent),children:["↑ ",v("fs-parent")]}),(c.dirs||[]).map(C=>u.jsxs("button",{className:"nc-fs-item",onClick:()=>x(`${c.path.replace(/\/$/,"")}/${C}`),children:["📁 ",C]},C))]})]}),u.jsxs("select",{value:k.engine,onChange:C=>w({engine:C.target.value}),children:[u.jsx("option",{value:"",children:v("import-engine-required")}),m.map(C=>u.jsx("option",{value:C.id,children:C.label},C.id))]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:!!k.boot,onChange:C=>w({boot:C.target.checked})})," boot"]}),(i.err||_)&&u.jsx("div",{className:"nc-err",children:i.err||_}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:o||!k.tmuxSession||!k.engine||!m.length,onClick:a,children:v(b?"import-as-cell":"save")})]})]})}function lE({token:e,readonly:t,targets:i=[],startNewCell:s=!1,initialLocation:o=""}){const[a,c]=P.useState({engines:[],cells:[],managedCatalog:[]}),[d,m]=P.useState({available:!1,capabilities:[]}),[p,_]=P.useState(null),[S,y]=P.useState(null),[k,w]=P.useState(!1),[x,b]=P.useState(""),[C,D]=P.useState(""),[j,M]=P.useState(o),[Z,F]=P.useState(!1),[T,X]=P.useState(null),[K,G]=P.useState(null),[ee,A]=P.useState(!1),[N,R]=P.useState([]),[I,z]=P.useState(null),[$,H]=P.useState("manage"),re=P.useRef(!1),q=j?j.split("/"):[],L=P.useCallback(async()=>{try{const J=await mr(e,q);m(J);try{const B=await Kh(e,q);F(!!B.readonlyDefault)}catch{F(!1)}if(J.provider==="builtin"&&(J.capabilities||[]).includes("definitions")){const B=await Wh(e,q),fe=new Map((J.engines||[]).map(be=>[be.id,be]));if(B.engines=(B.engines||[]).map(be=>{var Se;return{...be,availableModels:((Se=fe.get(be.id))==null?void 0:Se.models)||[]}}),c(B),(J.capabilities||[]).includes("credentials"))try{R((await Iw(e,q)).credentials||[])}catch{R([])}else R([])}}catch(J){b(String(J.message||J))}},[e,j]);P.useEffect(()=>{L();const J=setInterval(L,5e3);return()=>clearInterval(J)},[L]);const W=new Set((d.cells||[]).filter(J=>J.active).map(J=>J.cell)),oe=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),me=(d.capabilities||[]).includes("restore");P.useEffect(()=>{!s||re.current||!oe||!a.engines.length||(re.current=!0,y({mode:"new",form:_v(a.engines[0].id)}))},[s,oe,a.engines]);const V=async J=>{w(!0),b(""),D("");try{await J(),await L()}catch(B){b(String(B.message||B))}w(!1)},Q=()=>V(async()=>{var $e;const J=p.mode==="new",B=p.form,fe=a.managedCatalog||[],be=B.kind==="managed"?co(fe,B):null,Se=typeof(be==null?void 0:be.credentialEnv)=="string"?be.credentialEnv:"",Ae=Se&&B.credentialValue||"",ce=rE(B,J,fe);!J&&p.form.kind==="custom"&&!p.form.modelFlag&&(ce.model=null),!J&&p.form.kind==="custom"&&p.form.promptMode!=="flag"&&(ce.promptFlag=null);let Me;if(J)Me=await Ow(e,ce,q);else{const he=p.original,Ee=new Set(p.form.envRows.filter(ue=>!ue.remove).map(ue=>ue.key)),Xe=(he.envKeys||[]).filter(ue=>!Ee.has(ue)),st=Object.fromEntries(p.form.envRows.filter(ue=>!ue.remove&&ue.key&&(!ue.configured||ue.value!=="")).map(ue=>[ue.key,ue.value]));Me=await zw(e,he.id,ce,p.form.kind==="custom"?{set:st,remove:Xe}:void 0,q)}let Pe=null;if(Se&&Ae)try{Pe=await lm(e,Se,Ae,q),R(Pe.credentials||[])}catch{throw await L(),J&&_({mode:"edit",original:{...ce,id:B.id},form:{...B,credentialReveal:!1}}),new Error(v(J?"fleet-key-partial-create":"fleet-key-partial-edit"))}await L(),_(null),D(v("fleet-saved"));const He=(($e=((Pe==null?void 0:Pe.credentials)||[]).find(he=>he.envKey===Se))==null?void 0:$e.activeCells)||[],Oe=[...new Set([...(Me==null?void 0:Me.activeCells)||[],...He])];if(Oe.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",Oe.join(", "))))for(const he of Oe)await Js(e,he,q)}),de=()=>V(async()=>{const J=S.mode==="new",B=S.form,fe={...J?{id:B.id}:{},cwd:B.cwd,engine:B.engine,boot:!!B.boot};J?(B.model&&(fe.model=B.model),B.prompt&&(fe.prompt=B.prompt)):(fe.model=B.model||null,fe.prompt=B.prompt||null);const be=J?await Hw(e,fe,q):await $w(e,S.original.id,fe,q),Se=J?B.id:S.original.id;y(null),D(v("fleet-saved")),!J&&(be!=null&&be.active)&&window.confirm(v("fleet-restart-confirm").replace("{cells}",Se))&&await Js(e,Se,q)}),ae=t||Z,ke=J=>N.find(B=>{var fe;return(fe=B.engines)==null?void 0:fe.includes(J.id)})||null,je=()=>V(async()=>{var fe;const J=await lm(e,I.envKey,I.value,q);R(J.credentials||[]),z(null),D(v("fleet-credential-saved"));const B=((fe=(J.credentials||[]).find(be=>be.envKey===I.envKey))==null?void 0:fe.activeCells)||[];if(B.length&&window.confirm(v("fleet-restart-confirm").replace("{cells}",B.join(", "))))for(const be of B)await Js(e,be,q)}),Ye=J=>V(async()=>{if(!window.confirm(v("fleet-credential-remove-confirm").replace("{key}",J.envKey)))return;const B=await Bw(e,J.envKey,q);R(B.credentials||[]),D(v("fleet-credential-removed"))}),qe=J=>X({...J,route:Array.isArray(J==null?void 0:J.route)?J.route:q}),Ce=async J=>{if(!T)return;const B=T.cell||T.id,fe=Array.isArray(T.route)?T.route:q;J.action==="up"?await $h(e,{cell:B,boot:!!J.boot,...J.engine?{engine:J.engine}:{},...J.model!==void 0?{model:J.model}:{},...J.permissionPolicy?{permissionPolicy:J.permissionPolicy}:{}},fe):await Ua(e,{cell:B,boot:!!J.boot},fe)},rt=(J,B)=>{b(""),G({mode:"new",route:Array.isArray(B)?B:q,form:{tmuxSession:J.name,id:"",engine:"",cwd:"",boot:!1},err:""})},St=()=>V(async()=>{const J=K.form;if(!J.engine){G({...K,err:v("import-engine-required")});return}await Ww(e,{tmuxSession:J.tmuxSession,id:J.id||void 0,engine:J.engine,cwd:J.cwd||void 0,boot:!!J.boot},J.route||q),G(null),D(v("fleet-saved"))}),ne=({engineRows:J=[],cellRows:B=[]})=>V(async()=>{const fe=J.filter($e=>$e.selected),be=fe.map($e=>by($e.engine));if(be.some($e=>!$e))throw new Error(v("fleet-backup-invalid-engine"));const Se=fe.filter($e=>$e.exists).map($e=>$e.engine.id);if(Se.length&&!window.confirm(v("fleet-backup-confirm-engine-overwrite").replace("{engines}",Se.join(", "))))return;const Ae=[...new Set([...a.engines.map($e=>$e.id),...be.map($e=>$e.id)])],ce=[];for(const $e of B.filter(he=>he.selected)){const he=eE($e.cell,$e.engine,Ae);if(!he)throw new Error(`${$e.cell.id}: ${v("fleet-backup-engine-missing")}`);ce.push(he)}const Me=B.filter($e=>$e.selected&&$e.exists).map($e=>$e.cell.id);if(Me.length&&!window.confirm(v("fleet-backup-confirm-overwrite").replace("{cells}",Me.join(", "))))return;const Pe=be.length?await Kw(e,be,Se.length>0,q):{needsRestart:[]},He=ce.length?await Uw(e,ce,q):{needsRestart:[]},Oe=[...new Set([...Pe.needsRestart||[],...He.needsRestart||[]])];A(!1),D(`${v("fleet-backup-restored").replace("{n}",String(ce.length))}${be.length?` · ${be.length} ${v("fleet-engines").toLowerCase()}`:""}${Oe.length?` · ${v("fleet-backup-needs-restart").replace("{cells}",Oe.join(", "))}`:""}`)}),le=u.jsxs("label",{className:"nc-field",children:[v("location"),u.jsxs("select",{value:j,onChange:J=>{M(J.target.value),_(null),y(null),b(""),D(""),F(!1),m({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),R([]),z(null)},children:[u.jsx("option",{value:"",children:v("local")}),i.map(J=>u.jsxs("option",{value:J.route.join("/"),disabled:J.status&&J.status!=="up",children:[J.label,J.status&&J.status!=="up"?` · ${v("node-offline")}`:""]},J.route.join("/")))]})]}),Be=u.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":v("tab-fleet"),children:[u.jsx("button",{type:"button",role:"tab","aria-selected":$==="manage",className:`nc-set-tabbtn${$==="manage"?" on":""}`,onClick:()=>H("manage"),children:v("fleet-manage-location")}),u.jsx("button",{type:"button",role:"tab","aria-selected":$==="overview",className:`nc-set-tabbtn${$==="overview"?" on":""}`,onClick:()=>H("overview"),children:v("fleet-network-overview")})]});return oe?u.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[Be,$==="overview"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),u.jsx(yv,{token:e,targets:i,readonly:t,onPower:qe,onImport:rt})]}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-manage-help")}),le,u.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[u.jsx("button",{className:"nc-btn ghost",disabled:ae||k,onClick:()=>{b(""),A(!0)},children:v("fleet-backup")}),u.jsx("small",{children:v("fleet-backup-help")})]}),u.jsxs("div",{className:"nc-fleet-section-head",children:[u.jsx("b",{children:v("fleet-cells")}),u.jsx("span",{className:"nc-fleet-head-actions",children:u.jsxs("button",{className:"nc-btn primary",disabled:ae||k||!a.engines.length,onClick:()=>{var J;b(""),y({mode:"new",form:_v((J=a.engines[0])==null?void 0:J.id)})},children:["+ ",v("add")]})})]}),a.cells.map(J=>{const B=W.has(J.id),fe=d.capabilities||[];return u.jsxs("div",{className:"nc-fleet-item",children:[u.jsxs("span",{children:[u.jsx("b",{children:J.id}),u.jsxs("small",{children:[J.engine," · ",J.cwd,B?` · ${v("service-active")}`:` · ${v("cell-off")}`]})]}),u.jsxs("span",{children:[B&&fe.includes("down")&&u.jsx("button",{className:"nc-btn ghost",disabled:ae||k,onClick:()=>V(()=>Ua(e,{cell:J.id},q)),children:v("stop")}),!B&&fe.includes("up")&&u.jsx("button",{className:"nc-btn primary",disabled:ae||k,onClick:()=>qe({cell:J.id,id:J.id,engine:J.engine,model:J.model,models:J.models,permissionPolicies:J.permissionPolicies,active:!1,boot:J.boot}),children:v("start")}),B&&fe.includes("restart")&&u.jsx("button",{className:"nc-btn ghost",disabled:ae||k,onClick:()=>V(()=>Js(e,J.id,q)),children:v("restart")}),u.jsx("button",{className:"nc-btn ghost",disabled:ae||k,onClick:()=>{b(""),y({mode:"edit",original:J,form:{...J}})},children:v("edit")}),u.jsx("button",{className:"nc-btn danger",disabled:ae||k,onClick:()=>V(async()=>{window.confirm(v("fleet-remove-cell").replace("{id}",J.id))&&await Dv(e,J.id,!0,q)}),children:"×"})]})]},J.id)}),u.jsxs("div",{className:"nc-fleet-section-head",children:[u.jsx("b",{children:v("fleet-engines")}),u.jsxs("button",{className:"nc-btn primary",disabled:ae||k,onClick:()=>{b(""),_({mode:"new",form:tE()})},children:["+ ",v("add")]})]}),a.engines.map(J=>{var fe,be;const B=ke(J);return u.jsxs("div",{className:"nc-fleet-item",children:[u.jsxs("span",{children:[u.jsx("b",{children:J.label}),u.jsx("small",{children:J.managed?`${J.id} · ${J.managed.client} / ${J.managed.provider} · ${(fe=J.managedInfo)!=null&&fe.configured?v("fleet-ready"):((be=J.managedInfo)==null?void 0:be.reason)||v("fleet-not-ready")}`:`${J.id} · ${J.command}`}),B&&u.jsxs("small",{children:[B.envKey," · ",v(`fleet-credential-source-${B.source||"missing"}`)]})]}),u.jsxs("span",{children:[B&&u.jsx("button",{className:"nc-btn ghost",disabled:ae||k,onClick:()=>{b(""),z({envKey:B.envKey,value:""})},children:B.configured?v("fleet-credential-change"):v("fleet-credential-set")}),(B==null?void 0:B.source)==="local"&&u.jsx("button",{className:"nc-btn danger",disabled:ae||k,onClick:()=>Ye(B),children:v("fleet-credential-forget")}),u.jsx("button",{className:"nc-btn ghost",disabled:ae||k,onClick:()=>{b(""),_({mode:"edit",original:J,form:nE(J)})},children:v("edit")}),u.jsx("button",{className:"nc-btn danger",disabled:ae||k,onClick:()=>V(async()=>{window.confirm(v("fleet-remove-engine").replace("{id}",J.id))&&await Fw(e,J.id,q)}),children:"×"})]})]},J.id)})]}),p&&u.jsx(qr,{onClose:()=>_(null),label:v("fleet-new-engine"),error:x,children:u.jsx(oE,{state:p,setState:_,busy:k,onSave:Q,catalog:a.managedCatalog||[]})}),S&&u.jsx(qr,{onClose:()=>y(null),label:v("fleet-new-cell"),error:x,children:u.jsx(aE,{token:e,route:q,targets:i,location:j,setLocation:M,state:S,setState:y,engines:a.engines,busy:k,onSave:de})}),C&&u.jsx("div",{className:"nc-set-note",children:C}),x&&u.jsx("div",{className:"nc-err",children:x}),ee&&u.jsx(qr,{onClose:()=>A(!1),label:v("fleet-backup"),error:x,children:u.jsx(sE,{cells:a.cells,engines:a.engines,busy:k,canRestore:me,onRestore:ne,onClose:()=>A(!1)})}),I&&u.jsx(qr,{onClose:()=>z(null),label:v("fleet-credential-title"),error:x,children:u.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[u.jsx("b",{children:v("fleet-credential-title")}),u.jsx("small",{children:v("fleet-credential-help")}),u.jsxs("label",{className:"nc-field",children:[I.envKey,u.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:I.value,onChange:J=>z({...I,value:J.target.value})})]}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",onClick:()=>z(null),children:v("cancel")}),u.jsx("button",{className:"nc-btn primary",disabled:k||!I.value,onClick:je,children:v("save")})]})]})}),K&&u.jsx(qr,{onClose:()=>G(null),label:v("import-as-cell"),error:x,children:u.jsx(Sv,{token:e,route:K.route||q,state:K,setState:G,busy:k,onSave:St})}),T&&u.jsx(Ka,{cell:T,token:e,route:Array.isArray(T.route)?T.route:q,onConfirm:async J=>{try{await Ce(J)}finally{await L()}},onClose:()=>X(null)})]}):u.jsxs("div",{className:"nc-set-tab",children:[Be,$==="overview"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"nc-set-info",children:v("fleet-overview-help")}),u.jsx(yv,{token:e,targets:i,readonly:t,onPower:qe,onImport:rt})]}):u.jsxs(u.Fragment,{children:[le,u.jsx("div",{className:"nc-set-info",children:v("fleet-editor-unavailable")})]}),x&&u.jsx("div",{className:"nc-err",children:x}),K&&u.jsx(qr,{onClose:()=>G(null),label:v("import-as-cell"),error:x,children:u.jsx(Sv,{token:e,route:K.route||q,state:K,setState:G,busy:k,onSave:St})}),T&&u.jsx(Ka,{cell:T,token:e,route:Array.isArray(T.route)?T.route:q,onConfirm:async J=>{try{await Ce(J)}finally{await L()}},onClose:()=>X(null)})]})}function cE({text:e}){const[t,i]=P.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}};return u.jsxs("div",{className:"nc-set-copyline",children:[u.jsx("code",{children:e}),u.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[u.jsx(tt,{name:"copy",size:14})," ",v(t?"copied":"copy")]})]})}function uE({value:e}){const[t,i]=P.useState("");return P.useEffect(()=>{let s=!0;return xx.toDataURL(e,{margin:1,width:220}).then(o=>{s&&i(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?u.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function hE({token:e,nodes:t,settings:i,readonly:s,refresh:o}){const[a,c]=P.useState(null),[d,m]=P.useState(null),[p,_]=P.useState({}),[S,y]=P.useState(null),[k,w]=P.useState({ssh:"",sshPort:"",name:""}),[x,b]=P.useState(""),[C,D]=P.useState(""),[j,M]=P.useState(""),[Z,F]=P.useState(!1),[T,X]=P.useState(null),[K,G]=P.useState(null),ee=Date.now(),A=i&&i.deviceName||"",N=(t||[]).filter(V=>V&&V.direction==="outbound"&&V.name&&V.ssh),R=N.find(V=>V.name===x)||N[0]||null,I=N.find(V=>V.name===C)||N[0]||null,z=I?xm(I.tunnel,ee):null,$=I!=null&&I.shared?z!=null&&z.up?"share-local-active":"share-local-pending":z!=null&&z.up?"share-local-private":"share-local-private-down",H=[{key:"peer-group-hubs",rows:(t||[]).filter(V=>V.kind!=="transitive"&&V.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(V=>V.kind!=="transitive"&&V.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(V=>V.kind==="transitive")}],re=async(V,Q)=>{c(null),m(`${V}:${Q}`);try{const de=await qh(e,V,Q);Q==="test"&&_(ae=>({...ae,[V]:de})),await o()}catch(de){c(`${V}: ${String(de.message||de)}`)}m(null)},q=async V=>{c(null),m(`${V}:remove`);try{await Jw(e,V),G(null),await o()}catch(Q){c(`${V}: ${String(Q.message||Q)}`)}m(null)},L=V=>X({name:V.name,direction:V.direction,label:V.label||V.name,ssh:V.ssh||"",sshPort:V.sshPort?String(V.sshPort):"",autostart:V.autostart===!0,visibility:V.visibility||"network",selected:[...V.selected||[]]}),W=async()=>{if(!T||!so(T.label)){c(v("err-label"));return}const V=T.direction==="inbound"?{label:T.label,visibility:T.visibility,selected:T.visibility==="selected"?T.selected:[]}:{label:T.label,ssh:T.ssh,autostart:T.autostart,...T.sshPort?{sshPort:Number(T.sshPort)}:{}};c(null),m(`${T.name}:edit`);try{await Qw(e,T.name,V),X(null),await o()}catch(Q){c(`${T.name}: ${String(Q.message||Q)}`)}m(null)},oe=async V=>{if(I){c(null),m(`${I.name}:share`);try{await Zw(e,I.name,V),await o()}catch(Q){const de=Q!=null&&Q.data&&typeof Q.data.hint=="string"?Q.data.hint:"";c(`${I.name}: ${String(Q.message||Q)}${de?` — ${de}`:""}`)}m(null)}},me=async()=>{if(c(null),R){const de=Cm({name:R.name,ssh:R.ssh,sshPort:R.sshPort||""});if(!de.ok){c(v(de.error));return}m("invite");try{y(await um(e,{ssh:de.value.ssh,...de.value.sshPort?{sshPort:de.value.sshPort}:{}},[R.name]))}catch(ae){c(String(ae.message||ae))}m(null);return}const V=Gr(k.name||j||A||"NexusCrew"),Q=Cm({name:V,ssh:k.ssh,sshPort:k.sshPort});if(!Q.ok){c(v(Q.error));return}m("invite");try{y(await um(e,{...j||A?{label:j||A}:{},name:V,ssh:Q.value.ssh,...Q.value.sshPort?{sshPort:Q.value.sshPort}:{}}))}catch(de){c(String(de.message||de))}m(null)};return u.jsxs("div",{className:"nc-set-tab",children:[u.jsx("div",{className:"nc-sheet-label",children:v("peer-inventory-title")}),(t||[]).length===0&&u.jsx("div",{className:"nc-empty",children:v("no-nodes")}),H.map(V=>V.rows.length>0&&u.jsxs("div",{className:"nc-peer-group",children:[u.jsxs("div",{className:"nc-peer-group-title",children:[v(V.key)," ",u.jsx("span",{children:V.rows.length})]}),V.rows.map(Q=>{var Ye,qe;const de=Q.kind==="transitive",ae=de?{up:Q.stale!==!0,label:Q.stale===!0?"peer-routed-stale":"peer-routed"}:xm(Q.tunnel,ee),ke=p[Q.name],je=Q.actions||{};return u.jsxs("div",{className:`nc-set-node${de?" routed":""}`,children:[u.jsxs("div",{className:"nc-set-node-head",children:[u.jsx("span",{className:`nc-dot ${ae.up?"on":""}`}),u.jsx("b",{children:Q.label||Q.name}),u.jsxs("small",{children:[Q.name,de?` · ${Q.route.join(" → ")}`:Q.direction==="outbound"?` · SSH ${Q.ssh||""}`:` · ${v("node-connected-client")}`,(Ye=Q.tunnel)!=null&&Ye.transport?` · ${Q.tunnel.transport} ${v("transport-used")}`:""]}),u.jsxs("span",{className:`nc-set-tunnel${ae.up?" up":""}`,children:[v(ae.label),ae.since?` · ${ae.since}`:""]})]}),!de&&Q.direction==="inbound"&&u.jsx("div",{className:"nc-set-info",children:v(Q.shared?"peer-shared":"peer-private")}),je.visibility&&Q.shared&&u.jsxs(u.Fragment,{children:[u.jsxs("select",{value:Q.visibility||"network",disabled:s||!!d,onChange:async Ce=>{m(`${Q.name}:visibility`);try{await hm(e,Q.name,Ce.target.value),await o()}catch(rt){c(String(rt.message||rt))}m(null)},children:[u.jsx("option",{value:"network",children:v("visibility-network")}),u.jsx("option",{value:"relay-only",children:v("visibility-relay")}),u.jsx("option",{value:"selected",children:v("visibility-selected")})]}),Q.visibility==="selected"&&u.jsx("div",{className:"nc-set-row",children:(t||[]).filter(Ce=>Ce.name!==Q.name&&Ce.nodeId).map(Ce=>{const rt=(Q.selected||[]).includes(Ce.nodeId);return u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:rt,disabled:s||!!d,onChange:async St=>{const ne=St.target.checked?[...Q.selected||[],Ce.nodeId]:(Q.selected||[]).filter(le=>le!==Ce.nodeId);m(`${Q.name}:visibility`);try{await hm(e,Q.name,"selected",ne),await o()}catch(le){c(String(le.message||le))}m(null)}})," ",Ce.label||Ce.name]},Ce.nodeId)})})]}),u.jsxs("div",{className:"nc-set-node-actions",children:[je.edit&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:()=>L(Q),children:v("edit")}),je.test&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>re(Q.name,"test"),children:v("node-test")}),je.disconnect&&ae.up&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:()=>re(Q.name,"down"),children:v("tunnel-stop")}),je.connect&&!ae.up&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:()=>re(Q.name,"up"),children:v("tunnel-start")}),je.restart&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:()=>re(Q.name,"restart"),children:v("tunnel-restart")}),je.remove&&u.jsxs("button",{type:"button",className:"nc-btn danger",disabled:s||!!d,title:v(s?"settings-readonly":"delete"),onClick:()=>G(Q.name),children:[u.jsx(tt,{name:"trash",size:14})," ",v("delete")]})]}),(T==null?void 0:T.name)===Q.name&&u.jsxs("div",{className:"nc-set-form nc-node-editor",children:[u.jsxs("label",{className:"nc-field",children:[v("node-display-label"),u.jsx("input",{value:T.label,disabled:!!d,onChange:Ce=>X({...T,label:Ce.target.value})})]}),T.direction==="outbound"?u.jsxs(u.Fragment,{children:[u.jsxs("label",{className:"nc-field",children:[v("node-ssh-label"),u.jsx("input",{value:T.ssh,disabled:!!d,onChange:Ce=>X({...T,ssh:Ce.target.value})})]}),u.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),u.jsx("input",{inputMode:"numeric",value:T.sshPort,disabled:!!d,onChange:Ce=>X({...T,sshPort:Ce.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:T.autostart,disabled:!!d,onChange:Ce=>X({...T,autostart:Ce.target.checked})})," ",v("boot-persist")]})]}):u.jsxs("label",{className:"nc-field",children:[v("peer-visibility"),u.jsxs("select",{value:T.visibility,disabled:!!d,onChange:Ce=>X({...T,visibility:Ce.target.value}),children:[u.jsx("option",{value:"network",children:v("visibility-network")}),u.jsx("option",{value:"relay-only",children:v("visibility-relay")}),u.jsx("option",{value:"selected",children:v("visibility-selected")})]})]}),u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!d,onClick:W,children:v("save")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>X(null),children:v("cancel")})]})]}),K===Q.name&&u.jsxs("div",{className:"nc-set-confirm",children:[u.jsx("b",{children:v("node-remove-confirm").replace("{name}",Q.label||Q.name)}),u.jsx("small",{children:v("node-remove-warning")}),u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!d,onClick:()=>q(Q.name),children:v("delete")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>G(null),children:v("cancel")})]})]}),((qe=Q.health)==null?void 0:qe.detail)&&u.jsx("div",{className:`nc-set-test${Q.health.status==="healthy"?" ok":Q.health.status==="passive"?"":" ko"}`,children:Q.health.detail}),ke&&u.jsxs("div",{className:`nc-set-test${ke.ok?" ok":" ko"}`,children:[ke.result,ke.detail?` — ${ke.detail}`:""]})]},`${Q.kind||"direct"}:${Q.nodeId||Q.name}`)})]},V.key)),I&&u.jsxs("div",{className:"nc-set-form nc-local-share",children:[u.jsx("div",{className:"nc-sheet-label",children:v("share-local-heading")}),N.length>1&&u.jsxs("label",{className:"nc-field",children:[v("share-local-hub"),u.jsx("select",{value:I.name,disabled:s||!!d,onChange:V=>D(V.target.value),children:N.map(V=>u.jsx("option",{value:V.name,children:V.label||V.name},V.name))})]}),u.jsxs("label",{className:"nc-check nc-node-share",children:[u.jsx("input",{type:"checkbox",checked:I.shared===!0,disabled:s||!!d,onChange:V=>oe(V.target.checked)}),u.jsxs("span",{children:[u.jsx("b",{children:v("share-local-through").replace("{device}",A||v("local")).replace("{hub}",I.label||I.name)}),u.jsx("small",{children:v(I.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),u.jsx("div",{className:`nc-set-test${I.shared&&(z!=null&&z.up)?" ok":z!=null&&z.up?"":" ko"}`,children:v($)}),!(z!=null&&z.up)&&u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:()=>oe(I.shared===!0),children:v("share-local-reconnect")})]}),u.jsx(my,{token:e,deviceDefault:A,readonly:s,onSuccess:o}),u.jsxs("div",{className:"nc-set-form",children:[u.jsx("div",{className:"nc-sheet-label",children:v("invite-node")}),u.jsx("small",{className:"nc-set-hint",children:v(R?"invite-network-hint":"invite-v2-hint")}),R?u.jsxs(u.Fragment,{children:[N.length>1&&u.jsxs("label",{className:"nc-field",children:[v("invite-network-label"),u.jsx("select",{value:R.name,disabled:s||!!d,onChange:V=>{b(V.target.value),y(null)},children:N.map(V=>u.jsx("option",{value:V.name,children:V.label||V.name},V.name))})]}),u.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[v("invite-network-via"),": ",u.jsx("b",{children:R.label||R.name})," · ",R.ssh,R.sshPort?`:${R.sshPort}`:""]}),u.jsx("small",{className:"nc-set-hint",children:v("invite-network-route")})]}):u.jsxs("label",{className:"nc-field",children:[v("invite-endpoint-label"),u.jsx("input",{placeholder:"user@host",value:k.ssh,disabled:s,onChange:V=>w({...k,ssh:V.target.value})}),u.jsx("small",{className:"nc-set-hint",children:v("invite-endpoint-needed")})]}),!R&&Z&&u.jsxs("div",{className:"nc-invite-advanced",children:[u.jsxs("label",{className:"nc-field",children:[v("node-ssh-port-label"),u.jsx("input",{inputMode:"numeric",placeholder:"22",value:k.sshPort,disabled:s,onChange:V=>w({...k,sshPort:V.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),u.jsxs("label",{className:"nc-field",children:[v("device-name-label"),u.jsx("input",{placeholder:A||"NexusCrew",value:j,disabled:s,onChange:V=>M(V.target.value)}),u.jsx("small",{className:"nc-set-hint",children:v("device-name-hint")})]}),u.jsxs("label",{className:"nc-field",children:[v("node-name-label"),u.jsx("input",{placeholder:Gr(j||A||v("node-name-ph")),value:k.name,disabled:s,onChange:V=>w({...k,name:V.target.value?Gr(V.target.value):""})})]})]}),u.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[u.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!d||!R&&!k.ssh.trim(),onClick:me,children:v("create-pairing-link")}),!R&&u.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>F(V=>!V),children:[Z?"▾":"▸"," ",v("pair-advanced")]})]}),S&&u.jsxs(u.Fragment,{children:[u.jsx(uE,{value:S.pairingUrl}),u.jsx(cE,{text:S.pairingUrl}),u.jsx("div",{className:"nc-set-info",children:v("invite-next-steps")})]})]}),a&&u.jsx("div",{className:"nc-err",children:a})]})}function dE({token:e,readonly:t}){const[i,s]=P.useState("idle"),[o,a]=P.useState(!1),[c,d]=P.useState(null);P.useEffect(()=>{let p=!1;return Bx().then(_=>{p||s(_)}),()=>{p=!0}},[]);const m=async()=>{d(null),a(!0);try{i==="subscribed"?(await zx(e),s("idle")):(await Ox(e),s("subscribed"))}catch(p){const _=String(p.message||p);_==="push-denied"?(s("denied"),d(v("push-denied"))):_==="push-unsupported"?(s("unsupported"),d(v("push-unsupported"))):d(_)}a(!1)};return i==="unsupported"?u.jsx("div",{className:"nc-set-info",children:v("push-unsupported")}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||i==="denied",title:t?v("settings-readonly"):"",onClick:m,children:v(i==="subscribed"?"push-disable":"push-enable")}),u.jsx("span",{className:"nc-set-info",children:v(i==="subscribed"?"push-on":i==="denied"?"push-denied":"push-off")})]}),c&&u.jsx("div",{className:"nc-err",children:c})]})}function fE({token:e,settings:t,readonly:i,refresh:s}){const[o,a]=P.useState(null),[c,d]=P.useState(null),[m,p]=P.useState(!1),[_,S]=P.useState(!1),[y,k]=P.useState(null),[w,x]=P.useState(!0);P.useEffect(()=>{k(t&&t.update||null),x(!t||t.autoUpdate!==!1)},[t]);const b=async()=>{a(null),d(null),S(!0);try{const T=await Xw(e);d(T.note||"ok"),p(!1)}catch(T){a(String(T.message||T))}S(!1)},C=async()=>{a(null),d(null),S(!0);try{const T=await e0(e);d(`${T.note||"ok"}${T.target?` (${T.target})`:""}`)}catch(T){a(String(T.message||T))}S(!1)},D=async T=>{a(null),d(null),S(!0);try{await Av(e,{autoUpdate:T}),x(T),s&&await s()}catch(X){a(String(X.message||X))}S(!1)},j=async()=>{a(null),d(null),S(!0);try{k(await t0(e))}catch(T){a(String(T.message||T))}S(!1)},M=async()=>{a(null),d(null),S(!0);try{const T=await i0(e);k(T),d(v("npm-update-restarting"))}catch(T){a(String(T.message||T))}S(!1)},Z=()=>{window.confirm(v("composer-clear-confirm"))&&(a(null),LC()?(window.dispatchEvent(new Event(Mh)),d(v("composer-clear-done"))):a(v("composer-clear-failed")))},F=t&&t.service;return u.jsxs("div",{className:"nc-set-tab",children:[t&&u.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,u.jsx("br",{}),F&&F.installed?v("service-installed"):v("service-missing"),F&&F.installed?` · ${F.active?v("service-active"):v("service-inactive")}`:"",F?` · boot ${F.boot?"on":"off"}`:""]}),u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_,title:i?v("settings-readonly"):"",onClick:()=>{a(null),d(null),p(!0)},children:v("token-rotate")}),u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_,title:i?v("settings-readonly"):"",onClick:C,children:v("service-regenerate")})]}),u.jsxs("div",{className:"nc-set-form nc-update-settings",children:[u.jsxs("label",{className:"nc-check",children:[u.jsx("input",{type:"checkbox",checked:w,disabled:i||_||y&&!y.supported,onChange:T=>D(T.target.checked)}),u.jsxs("span",{children:[u.jsx("b",{children:v("npm-auto-update")}),u.jsx("small",{children:v("npm-auto-update-help")})]})]}),y&&u.jsxs("div",{className:"nc-set-info",children:[v("npm-update-current")," v",y.current,y.latest?` · ${v("npm-update-latest")} v${y.latest}`:""," · ",v(`npm-update-${y.supported?y.phase:"unsupported"}`)]}),u.jsxs("div",{className:"nc-set-row",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_||!y||!y.supported,onClick:j,children:v("npm-update-check")}),y&&y.available&&u.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||_||y.phase==="installing",onClick:M,children:v("npm-update-install")})]}),y&&y.lastError&&u.jsx("div",{className:"nc-err",children:y.lastError})]}),u.jsx(dE,{token:e,readonly:i}),u.jsxs("div",{className:"nc-set-form",children:[u.jsx("div",{className:"nc-sheet-label",children:v("composer-clear-data")}),u.jsx("small",{className:"nc-set-hint",children:v("composer-clear-data-help")}),u.jsx("div",{className:"nc-set-row",children:u.jsx("button",{type:"button",className:"nc-btn ghost",onClick:Z,children:v("composer-clear-data")})})]}),m&&u.jsxs("div",{className:"nc-set-confirm",children:[u.jsx("div",{children:v("token-rotate-explain")}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>p(!1),children:v("cancel")}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:_,onClick:b,children:v("confirm")})]})]}),c&&u.jsx("div",{className:"nc-set-note",children:c}),o&&u.jsx("div",{className:"nc-err",children:o})]})}function pE({token:e,onClose:t,initialTab:i="nodes",initialLocation:s="",startNewCell:o=!1}){wi();const[a,c]=P.useState(i),[d,m]=P.useState(null),[p,_]=P.useState([]),[S,y]=P.useState(!1),[k,w]=P.useState(null),x=Yh(e),b=P.useCallback(async()=>{try{const C=await jv(e);m(C),w(null)}catch(C){w(String(C.message||C))}try{const C=await Vw(e);_(C.peers||[])}catch(C){w(String(C.message||C))}},[e]);return P.useEffect(()=>{b();const C=setInterval(b,5e3);return()=>clearInterval(C)},[b]),P.useEffect(()=>{let C=!1;return zt("/api/config",e).then(D=>D.json()).then(D=>{C||y(!!D.readonlyDefault)}).catch(()=>{}),()=>{C=!0}},[e]),u.jsx("div",{className:"nc-set-overlay",onClick:t,children:u.jsxs("div",{className:"nc-set-panel",onClick:C=>C.stopPropagation(),children:[u.jsxs("div",{className:"nc-set-head",children:[u.jsx(tt,{name:"gear",size:18}),u.jsx("b",{children:v("settings")}),u.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:v("close"),children:u.jsx(tt,{name:"x",size:18})})]}),S&&u.jsx("div",{className:"nc-set-readonly",children:v("settings-readonly")}),k&&u.jsx("div",{className:"nc-err",children:k}),u.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(C=>u.jsx("button",{type:"button",className:`nc-set-tabbtn${a===C?" on":""}`,onClick:()=>c(C),children:v(`tab-${C}`)},C))}),u.jsxs("div",{className:"nc-set-body",children:[a==="nodes"&&u.jsx(hE,{token:e,nodes:p,settings:d,readonly:S,refresh:b}),a==="fleet"&&u.jsx(lE,{token:e,readonly:S,startNewCell:o,initialLocation:s,targets:x.map(C=>({route:C.route,label:C.label||C.name,status:C.status}))}),a==="system"&&u.jsx(fE,{token:e,settings:d,readonly:S,refresh:b})]})]})})}function mE({token:e,initialPair:t,onPairDone:i,onDone:s}){wi();const[o,a]=P.useState(t?"pair":"welcome"),[c,d]=P.useState(!1),[m,p]=P.useState(null),_=async()=>{d(!0),p(null);try{await Av(e,{wizardDone:!0}),i&&i(),s()}catch(S){p(String(S.message||S)),d(!1)}};return u.jsx("div",{className:"nc-wiz-overlay",children:u.jsxs("div",{className:"nc-wiz",children:[u.jsxs("div",{className:"nc-wiz-head",children:[u.jsx("b",{children:v("wizard-title")}),u.jsx("small",{children:v("hydra-simple")})]}),o==="welcome"&&u.jsxs("div",{className:"nc-wiz-body",children:[u.jsx("div",{className:"nc-wiz-done",children:v("local-ready")}),u.jsxs("div",{className:"nc-sheet-actions",children:[u.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:_,children:v("local-only")}),u.jsx("button",{className:"nc-btn primary",disabled:c,onClick:()=>a("pair"),children:v("add-node")})]})]}),o==="pair"&&u.jsxs("div",{className:"nc-wiz-body",children:[u.jsx(my,{token:e,initial:t||"",autoStart:!!t,onBusyChange:d,onSuccess:async()=>{i&&i(),a("done")}}),u.jsx("div",{className:"nc-sheet-actions",children:u.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:()=>{i&&i(),a("welcome")},children:v("back")})})]}),o==="done"&&u.jsxs("div",{className:"nc-wiz-body",children:[u.jsx("div",{className:"nc-wiz-done",children:v("node-connected")}),u.jsx("div",{className:"nc-sheet-actions",children:u.jsx("button",{className:"nc-btn primary",disabled:c,onClick:_,children:v("finish")})})]}),m&&u.jsx("div",{className:"nc-err",children:m})]})})}function gE(e,t){if(typeof EventSource>"u"||!e)return()=>{};const i=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return i.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{i.close()}catch{}}}const vE=6e3,_E=12e3;function yE({n:e,onClose:t}){return u.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[u.jsxs("div",{className:"nc-ntf-toast-txt",children:[u.jsx("b",{children:e.title}),e.body&&u.jsx("small",{children:e.body}),e.session&&u.jsx("span",{className:"nc-ntf-from",children:e.session})]}),u.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:v("close"),children:u.jsx(tt,{name:"x",size:14})})]})}function SE({ask:e,token:t,onAnswered:i}){const[s,o]=P.useState(""),[a,c]=P.useState(!1),[d,m]=P.useState(null),p=async _=>{const S=String(_||"").trim();if(!(!S||a)){m(null),c(!0);try{await r0(t,e.id,S),i(e.id)}catch(y){m(String(y.message||y))}c(!1)}};return u.jsxs("div",{className:"nc-ask-card",children:[u.jsxs("div",{className:"nc-ask-head",children:[u.jsx("span",{className:"nc-ntf-from",children:e.session}),u.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),u.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&u.jsx("div",{className:"nc-ask-opts",children:e.options.map(_=>u.jsx("button",{type:"button",className:"nc-btn ghost",disabled:a,onClick:()=>p(_),children:_},_))}),u.jsxs("div",{className:"nc-ask-reply",children:[u.jsx("textarea",{rows:2,placeholder:v("ask-reply-ph"),value:s,disabled:a,onChange:_=>o(_.target.value)}),u.jsx("button",{type:"button",className:"nc-btn primary",disabled:a||!s.trim(),onClick:()=>p(s),children:v("send")})]}),d&&u.jsx("div",{className:"nc-err",children:d})]})}function wE({token:e}){wi();const[t,i]=P.useState([]),[s,o]=P.useState([]),[a,c]=P.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),d=P.useRef(0),m=P.useCallback(S=>{i(y=>y.filter(k=>k.key!==S))},[]),p=P.useCallback(S=>{const y=`t${d.current+=1}`;i(k=>[...k.slice(-3),{...S,key:y}]),setTimeout(()=>m(y),S.urgency==="high"?_E:vE)},[m]);P.useEffect(()=>{if(!e)return;let S=!1;n0(e).then(k=>{S||o(k.asks||[])}).catch(()=>{});const y=gE(e,k=>{k.type==="notify"?p(k):k.type==="ask"&&k.ask&&k.ask.id?o(w=>w.some(x=>x.id===k.ask.id)?w:[...w,k.ask]):k.type==="ask-answered"&&k.id&&o(w=>w.filter(x=>x.id!==k.id))});return()=>{S=!0,y()}},[e,p]);const _=S=>o(y=>y.filter(k=>k.id!==S));return u.jsxs(u.Fragment,{children:[t.length>0&&u.jsx("div",{className:"nc-ntf-toasts",children:t.map(S=>u.jsx(yE,{n:S,onClose:()=>m(S.key)},S.key))}),s.length>0&&!a&&u.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>c(!0),title:v("asks-title"),children:["? ",u.jsx("span",{className:"nc-ask-count",children:s.length})]}),s.length>0&&a&&u.jsxs("div",{className:"nc-ask-panel",children:[u.jsxs("div",{className:"nc-ask-panel-head",children:[u.jsx("b",{children:v("asks-title")}),u.jsx("span",{className:"nc-ask-count",children:s.length}),u.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>c(!1),title:v("close"),children:u.jsx(tt,{name:"x",size:16})})]}),u.jsx("div",{className:"nc-ask-panel-body",children:s.map(S=>u.jsx(SE,{ask:S,token:e,onAnswered:_},S.id))})]})]})}const $u=e=>Qi(hr(e)).length===0,Wu=e=>Array.isArray(e)?e.join("/"):"";function bE(e){const t=new Set,i=[];for(const s of Array.isArray(e)?e:[])!s||!Li.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),i.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return i.sort((s,o)=>s.label.localeCompare(o.label))}function Qs(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function rr(e,t,i,s=!1,o=!0){const a=t.instanceId;return{...e,id:Qr(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(i)?i:[],layout:jh(e.layout,a,i)}}function kE(e,t,i,s,o=[]){const[a,c]=P.useState([]),[d,m]=P.useState(!1),[p,_]=P.useState("idle"),[S,y]=P.useState(""),[k,w]=P.useState(""),x=P.useRef([]),b=P.useRef([]),C=P.useRef(""),D=P.useRef(t),j=P.useRef(i),M=P.useRef(!1),Z=P.useRef(!0),F=P.useRef(""),T=P.useMemo(()=>bE(o),[o]),X=T.map(q=>`${q.instanceId}:${Wu(q.route)}:${q.status}:${q.label}`).join("|");b.current=T,j.current=i,D.current=t,x.current=a;const K=P.useCallback(q=>Th(q.layout,C.current,b.current),[]),G=P.useCallback((q,L=!0,W=D.current)=>{const oe=Ag(q,Aa()),me=x.current.some(Q=>Q.id===W);x.current=oe,c(oe);const V=oe.find(Q=>Q.id===W);if(L&&V){Z.current=!0;const Q=K(V);s(Q),V.local&&ex(V.name,Q)}else me&&!V&&(Z.current=!0,s(Xr()),y("deck non più condiviso dal nodo owner"));GC(oe.filter(Q=>Q.local).map(Q=>Q.name))},[s,K]),ee=P.useCallback(async q=>{let L=await Ea(e);const W=L.decks.find(oe=>oe.name==="main");if(L.decks.length===1&&W&&W.revision===0&&$u(W.layout)){const oe=XC(),me=hr(Ah("main")||Xr());if(!$u(me)){const V=jh(me,q,[]);L.decks[0]=await Na(e,"main",V,0,[])}for(const V of oe.filter(Q=>Q!=="main"))try{let Q=await dm(e,V,[]);const de=hr(Ah(V)||Xr());$u(de)||(Q=await Na(e,V,jh(de,q,[]),Q.revision,[]))}catch{}L=await Ea(e)}return L},[e]),A=P.useCallback(async({migrate:q=!1}={})=>{const L=await Kh(e,[]),W=Li.test(String(L.instanceId||""))?L.instanceId:"";if(!W)throw new Error("instanceId locale non disponibile");C.current=W,w(W);const[oe,me]=await Promise.all([q?ee(W):Ea(e),cm(e,[]).catch(()=>({nodes:[]}))]),V={instanceId:W,route:[],label:"Local"},Q=oe.decks.map(ae=>rr(ae,V,me.nodes,!0,!0)),de=x.current;return await Promise.all(b.current.map(async ae=>{if(ae.status!=="up"){Q.push(...de.filter(ke=>!ke.local&&ke.ownerId===ae.instanceId).map(ke=>({...ke,ownerRoute:[...ae.route],ownerLabel:ae.label,available:!1})));return}try{const[ke,je]=await Promise.all([Ea(e,ae.route),cm(e,ae.route).catch(()=>({nodes:[]}))]);Q.push(...ke.decks.map(Ye=>rr(Ye,ae,je.nodes,!1,!0)))}catch{Q.push(...de.filter(je=>!je.local&&je.ownerId===ae.instanceId).map(je=>({...je,ownerRoute:[...ae.route],ownerLabel:ae.label,available:!1})))}})),Q.sort((ae,ke)=>ae.local===ke.local?ae.ownerLabel.localeCompare(ke.ownerLabel)||(ae.name==="main"?-1:ke.name==="main"?1:ae.name.localeCompare(ke.name)):ae.local?-1:1),Q},[e,ee,X]);P.useEffect(()=>{if(!e)return;let q=!1;const L=F.current!==e;return F.current=e,A({migrate:L}).then(W=>{if(q)return;const oe=x.current.find(Q=>Q.id===D.current),me=W.find(Q=>Q.id===D.current),V=me&&(!oe||me.revision>oe.revision||oe.available!==me.available||Wu(oe.ownerRoute)!==Wu(me.ownerRoute));G(W,L||!!V&&!M.current),m(!0),me&&y("")}).catch(W=>{q||(m(!0),y(String(W.message||W)))}),()=>{q=!0}},[G,A,X,e]);const N=P.useCallback(async(q=D.current)=>{if(!d||!M.current)return!0;const L=x.current.find(W=>W.id===q);if(!L)return y(`deck inesistente: ${q}`),!1;if(L.available===!1)return y(`nodo owner offline: ${L.ownerLabel}`),!1;_("saving");try{const W=jg(hr(j.current),L.ownerId,L.ownerTopology),oe=await Na(e,L.name,W,L.revision,L.ownerRoute),me=rr(oe,Qs(L),L.ownerTopology,L.local,!0);return G(x.current.map(V=>V.id===q?me:V),!1),M.current=!1,_("saved"),y(""),setTimeout(()=>_("idle"),1500),!0}catch(W){if(_("error"),y(String(W.message||W)),W.status===409&&W.data&&W.data.current){const oe=x.current.find(V=>V.id===q),me=rr(W.data.current,Qs(oe),oe.ownerTopology,oe.local,!0);G(x.current.map(V=>V.id===q?me:V),!1)}return!1}},[d,e,G]);return P.useEffect(()=>{if(!d)return;if(Z.current){Z.current=!1;return}M.current=!0,_("saving");const q=setTimeout(N,650);return()=>clearTimeout(q)},[i,d,N]),P.useEffect(()=>{if(!d)return;const q=setInterval(async()=>{try{const L=await A(),W=x.current.find(V=>V.id===D.current),oe=L.find(V=>V.id===D.current),me=oe&&(!W||oe.revision>W.revision||W.available!==oe.available);G(L,me&&!M.current)}catch{}},5e3);return()=>clearInterval(q)},[d,A,G]),{decks:a,records:a,localNodeId:k,ready:d,saveState:p,error:S,setError:y,saveNow:N,select:async q=>{if(M.current&&!await N(D.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const L=x.current.find(W=>W.id===q);if(!L)throw new Error(`deck inesistente: ${q}`);return M.current=!1,Z.current=!0,K(L)},add:async(q,L=null)=>{const W=L===hn?x.current.find(V=>V.local):L?x.current.find(V=>V.ownerId===L):null;if(!W||W.available===!1)throw new Error("nodo owner non disponibile");const oe=await dm(e,q,W.ownerRoute),me=rr(oe,Qs(W),W.ownerTopology,W.local,!0);return G([...x.current,me],!1),me},rename:async(q,L)=>{const W=x.current.find(de=>de.id===q);if(!W)throw new Error("deck inesistente");if(q===D.current&&M.current&&!await N(q))throw new Error(`salvataggio di "${W.name}" fallito: rinomina annullata`);const oe=x.current.find(de=>de.id===q);if(!oe)throw new Error("deck inesistente");const me=await s0(e,oe.name,L,oe.revision,oe.ownerRoute),V=rr(me,Qs(oe),oe.ownerTopology,oe.local,!0),Q=oe.local?hn:oe.ownerId;return _u(JC(Aa(),Q,q,V.id)),G(x.current.map(de=>de.id===q?V:de),!1),V},remove:async q=>{const L=x.current.find(oe=>oe.id===q);if(!L)throw new Error("deck inesistente");q===D.current&&(M.current=!1),await o0(e,L.name,L.revision,L.ownerRoute);const W=L.local?hn:L.ownerId;_u(ZC(Aa(),W,q)),G(x.current.filter(oe=>oe.id!==q),!1)},reorder:(q,L)=>{const W=x.current.find(ae=>ae.id===q),oe=x.current.find(ae=>ae.id===L);if(!W||!oe)return!1;const me=W.local?hn:W.ownerId,V=oe.local?hn:oe.ownerId;if(me!==V)return!1;const Q=x.current.filter(ae=>(ae.local?hn:ae.ownerId)===me).map(ae=>ae.id),de=_u(QC(Aa(),me,q,L,Q));return G(Ag(x.current,de),!1),!0},addTileTo:async(q,L)=>{const W=x.current.find(ae=>ae.id===q);if(!W)throw new Error("deck inesistente");if(W.available===!1)throw new Error(`nodo owner offline: ${W.ownerLabel}`);const oe=sy(L,C.current,b.current);if(!oe)throw new Error("riferimento sessione non valido");const me=K(W),V=jg(Zv(me,oe),W.ownerId,W.ownerTopology),Q=await Na(e,W.name,V,W.revision,W.ownerRoute),de=rr(Q,Qs(W),W.ownerTopology,W.local,!0);return G(x.current.map(ae=>ae.id===q?de:ae),!1),de},localMainId:Qr(null,"main"),parseDeckId:cd}}const CE="/sw.js",Ih="nc-sw-update";let Bh=null,Oh=!1,zh=null,Cy=Object.freeze({needed:!1,kind:null,version:""}),xy=!1;function Ey(){typeof window<"u"&&window.dispatchEvent(new Event(Ih))}function Ny(){const e=zh||(Oh?{kind:"reload",version:""}:null);Cy=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function wv(){return Cy}function xE(e){return typeof window>"u"?()=>{}:(window.addEventListener(Ih,e),()=>window.removeEventListener(Ih,e))}function pd(e){Oh!==e&&(Oh=e,Ny(),Ey())}function EE(e,t,i){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&i&&t!==i&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(zh);zh=s,Ny(),o||Ey()}function NE(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&pd(!0)})}function RE(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{xy&&location.reload()}),navigator.serviceWorker.register(CE).then(e=>{Bh=e,e.waiting&&pd(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&NE(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function PE(){xy=!0,pd(!1);const e=Bh&&Bh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function DE({hash:e="",origin:t="",pathname:i="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${i||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const c=new URLSearchParams(o),d=c.get("token")||"",m=c.get("pair")||"",p=m?`${t||""}${i||""}#pair=${m}`:"";return{token:d,pair:p,nextUrl:a}}const Ry=9,Py=24,Dy="nc_side_w",bv="nc_side_min",ME=240,kv="(min-width:1024px) and (pointer:fine)";function LE(){const e=Number(localStorage.getItem(Dy));return e>=180&&e<=480?e:ME}function jE(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=Ry&&e<=Py?e:13}function TE(){const e={token:"",pair:""};try{const{token:t,pair:i,nextUrl:s}=DE({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(i){e.pair=i;try{sessionStorage.setItem("nc_pair",i)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function AE(e){try{return hr(Ah(e))}catch{return Xr()}}function Cv(e){if(!e)return"";const t=Math.floor(Date.now()/1e3)-e;return t<0||t<60?"ora":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}g`}function IE(){const[e,t]=P.useState(()=>window.matchMedia(kv).matches);return P.useEffect(()=>{const i=window.matchMedia(kv),s=o=>t(o.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),e}function xv({session:e,node:t,ownerId:i,token:s,readonly:o=!1,onBack:a}){wi();const[c,d]=P.useState(!1),[m,p]=P.useState(()=>window.matchMedia("(pointer: coarse)").matches),[_,S]=P.useState(null),[y,k]=P.useState(jE),[w,x]=P.useState(""),b=G=>k(ee=>{const A=Math.max(Ry,Math.min(Py,ee+G));return localStorage.setItem("nc_fontsize",String(A)),A}),C=P.useRef(()=>{}),D=P.useRef(()=>!1),j=P.useRef(()=>{}),M=P.useRef(!1),[Z,F]=P.useState(!1),[T,X]=P.useState(!1),K=()=>{M.current=!M.current,F(M.current)};return P.useEffect(()=>{let G=!0;const ee=t?t.split("/"):[],A=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function N(){let I=null,z=null;try{const re=await(await zt(`${A}/sessions`,s)).json();Array.isArray(re.sessions)&&(I=re.sessions.find(q=>q.name===e))}catch{}try{const H=await mr(s,ee);H.available&&Array.isArray(H.cells)&&(z=H.cells.find(re=>re.tmuxSession===e))}catch{}if(!G)return;let $="";z?$=`${z.engine}${z.key?`·${z.key}`:""}`:I&&($=I.attached?`attached · ${Cv(I.activity)}`:I.activity?Cv(I.activity):""),x($)}N();const R=setInterval(N,4e3);return()=>{G=!1,clearInterval(R)}},[e,t,s]),u.jsxs("div",{className:"nc-app",children:[u.jsxs("header",{className:"nc-bar nc-bar-single",children:[u.jsxs("button",{onClick:a,title:v("sessions"),children:[u.jsx(tt,{name:"chevronLeft",size:18}),u.jsx("span",{className:"nc-bar-label",children:v("sessions")})]}),u.jsxs("span",{className:"nc-bar-center",children:[u.jsx("b",{children:t?`${t}:${e}`:e}),w&&u.jsx("small",{className:"nc-bar-sub",children:w})]}),u.jsxs("span",{className:"nc-bar-right",children:[u.jsx("button",{onClick:()=>b(-1),title:v("zoom-out"),children:u.jsx(tt,{name:"zoomOut",size:18})}),u.jsx("button",{onClick:()=>b(1),title:v("zoom-in"),children:u.jsx(tt,{name:"zoomIn",size:18})}),u.jsx("button",{onClick:()=>p(G=>!G),title:v("composer"),children:u.jsx(tt,{name:"keyboard",size:20})}),u.jsx("button",{onClick:()=>d(G=>!G),title:v("files"),children:u.jsx(tt,{name:"folder",size:20})})]})]}),u.jsx("div",{className:"nc-termwrap",children:u.jsx(V_,{session:e,node:t,token:s,readonly:o,takeSize:!0,sendRef:C,composerRef:D,actionRef:j,ctrlRef:M,setCtrlArmed:F,onFiles:S,fontSize:y,selectionMode:T,onSelectionModeChange:X})}),u.jsx(wC,{onKeyboard:()=>p(G=>!G),send:G=>C.current(G),action:G=>j.current(G),ctrlArmed:Z,onCtrl:K,selectionMode:T,onSelectionMode:X}),m&&u.jsx(ny,{submitText:G=>D.current(G),token:s,session:e,node:t,ownerId:i}),c&&u.jsx(Y_,{session:e,node:t,token:s,filesEvent:_,onClose:()=>d(!1)})]})}function BE(){wi();const[e]=P.useState(TE),[t,i]=P.useState(e.token),[s,o]=P.useState(e.pair||""),a=P.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[c,d]=P.useState(!1),m=IE(),[p]=P.useState(()=>YC(typeof location<"u"?location.pathname:"/")),[_,S]=P.useState(p.id),y=_===Qr(null,Si),[k,w]=P.useState(null),x=ue=>w(Wn(ue)),[b,C]=P.useState([]),[D,j]=P.useState([]),[M,Z]=P.useState(()=>p.ownerId?Xr():AE(p.name)),[F,T]=P.useState(null),[X,K]=P.useState(null),G=ue=>K(Wn(ue)),ee=Yh(t,m),A=P.useMemo(()=>(ee||[]).filter(ue=>ue.instanceId).map(ue=>({instanceId:ue.instanceId,route:ue.route,label:ue.label,status:ue.status})),[ee]),N=kE(t,_,M,Z,A),R=N.decks;P.useEffect(()=>{const ue=new Map;for(const Ne of ee||[]){const Ve=(Ne.route||[Ne.name]).join("/"),qt=new Set((Ne.sessions||[]).map(di=>di.name));for(const di of Ne.cells||[])!di.cell||!di.tmuxSession||di.cell===di.tmuxSession||qt.has(di.cell)||ue.set(`${Ve}:${di.cell}`,`${Ve}:${di.tmuxSession}`)}Z(Ne=>T0(Ne,ue))},[ee]),P.useEffect(()=>{N.localNodeId&&Z(ue=>{const Ne=Th(ue,N.localNodeId,A);return JSON.stringify(Ne)===JSON.stringify(ue)?ue:Ne})},[A,N.localNodeId]);const[I,z]=P.useState(null),[$,H]=P.useState(!1),[re,q]=P.useState(LE),[L,W]=P.useState(!y),[oe,me]=P.useState(()=>y?localStorage.getItem(bv)==="1":!0),[V,Q]=P.useState(!1),[de,ae]=P.useState("nodes"),[ke,je]=P.useState(!1),[Ye,qe]=P.useState(""),Ce=(ue="nodes",Ne=!1,Ve="")=>{ae(ue),je(Ne),qe(Ve),Q(!0)},[rt,St]=P.useState(!1),[ne,le]=P.useState(!1);P.useEffect(()=>{try{localStorage.setItem(Dy,String(re))}catch{}},[re]),P.useEffect(()=>{try{localStorage.setItem(bv,oe?"1":"")}catch{}},[oe]),P.useEffect(()=>{if(!t)return;let ue=!1;return Promise.all([jv(t),zt("/api/config",t).then(Ne=>Ne.json())]).then(([Ne,Ve])=>{ue||(le(!!Ve.readonlyDefault),(Ne.firstRun===!0&&!Ve.readonlyDefault||s)&&St(!0))}).catch(()=>{}),()=>{ue=!0}},[t,s]);const Be=P.useCallback(async()=>{try{const Ne=await(await zt("/api/sessions",t)).json();Ne.error||C(Ne.sessions||[])}catch{}try{const ue=await mr(t);j(ue.available?ue.cells||[]:[])}catch{j([])}},[t]);P.useEffect(()=>{if(!m)return;Be();const ue=setInterval(Be,4e3);return()=>clearInterval(ue)},[m,Be]),P.useEffect(()=>{let ue=!1;return zt("/api/config",t).then(Ne=>Ne.json()).then(Ne=>{ue||EE(Ne.version,Ne.uiVersion,"0.8.22")}).catch(()=>{}),()=>{ue=!0}},[t]);const J=new Set([...b.map(ue=>ue.name),...ee.flatMap(ue=>ue.sessions.map(Ne=>Ne.key))]),B=Qi(M),fe=ue=>Z(Ne=>{const Ve=sy(ue,N.localNodeId,A)||ue,qt=Zv(Ne,Ve);return qt===Ne&&Qi(Ne).length>=9&&N.setError(v("grid-full")),qt}),be=async(ue,Ne=[])=>{try{await Uh(t,ue,Ne)}catch{return}const Ve=Ne.length?`${Ne.join("/")}:${ue}`:ue;Z(qt=>Ga(qt,Ve)),Be()},Se=async(ue,Ne,Ve=[])=>{try{await Mv(t,ue,Ne,Ve)}catch{return}Be()},Ae=async ue=>{if(!I)return;const{cell:Ne}=I,Ve=Array.isArray(I.route)?I.route:[];ue.action==="up"?await $h(t,{cell:Ne,boot:!!ue.boot,...ue.engine?{engine:ue.engine}:{},...ue.model!==void 0?{model:ue.model}:{},...ue.permissionPolicy?{permissionPolicy:ue.permissionPolicy}:{}},Ve):await Ua(t,{cell:Ne,boot:!!ue.boot},Ve),Be()},ce=async ue=>{if(!(!(ue!=null&&ue.direct)||$)){H(!0);try{await qh(t,ue.name,ue.tunnelStatus==="up"?"down":"up")}finally{H(!1)}}},Me=async(ue,Ne)=>{const Ve=String(Ne||"").trim();return!(ue!=null&&ue.direct)||!so(Ve)?!1:(await Iv(t,ue.name,Ve),!0)},Pe=ue=>{const Ne=R.find(Ve=>Ve.id===ue);if(!Ne)return!1;try{const Ve=window.open(vu(Ne,t),"_blank");return Ve&&(Ve.opener=null),!!Ve}catch{return!1}},He=async ue=>{if(!ue||ue===_)return;const Ne=await N.select(ue),Ve=N.records.find(qt=>qt.id===ue);S(ue),Z(Ne),T(null),K(null);try{history.replaceState(null,"",vu(Ve||ue,null))}catch{}},Oe=async(ue,Ne)=>{const Ve=await N.add(ue,Ne);await He(Ve.id)},$e=async(ue,Ne)=>{const Ve=await N.rename(ue,Ne);if(ue===_){S(Ve.id),Z(Th(Ve.layout,N.localNodeId,A)),T(null),K(null);try{history.replaceState(null,"",vu(Ve,null))}catch{}}},he=async ue=>{await N.remove(ue),ue===_&&await He(N.localMainId)},Ee=async(ue,Ne)=>{!Ne||Ne===_||(await N.addTileTo(Ne,ue),Z(Ve=>Ga(Ve,ue)))};if(!t)return u.jsxs("div",{className:"nc-auth",children:[u.jsx("p",{children:v("auth-prompt")}),u.jsx("input",{onChange:ue=>i(ue.target.value.trim()),placeholder:"token"}),u.jsxs("label",{children:[u.jsx("input",{type:"checkbox",checked:c,onChange:ue=>d(ue.target.checked)})," ",v("remember-device")]}),u.jsx("button",{onClick:()=>{(c?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Xe=u.jsxs(u.Fragment,{children:[V&&u.jsx(pE,{token:t,initialTab:de,initialLocation:Ye,startNewCell:ke,onClose:()=>{Q(!1),je(!1),qe("")}}),rt&&u.jsx(mE,{token:t,initialPair:s,onPairDone:a,onDone:()=>St(!1)}),u.jsx(wE,{token:t})]});if(!m)return k?u.jsxs(u.Fragment,{children:[u.jsx(xv,{session:k.session,node:k.node,ownerId:k.ownerId,token:t,readonly:ne,onBack:()=>w(null)}),Xe]}):u.jsxs(u.Fragment,{children:[u.jsx(G0,{onPick:x,token:t,onSettings:Ce}),Xe]});const st=y||!L;return u.jsxs("div",{className:"nc-workspace",children:[st&&u.jsx(OC,{sessions:b,cells:D,activeSessions:B,nodeGroups:ee,localNodeId:N.localNodeId,onPick:G,onAddTile:fe,onPower:z,onNodePower:ce,onNodeRename:Me,onKill:be,onVisibility:Se,onNew:()=>Ce("fleet",!0),onSettings:Ce,width:re,collapsed:oe,onResize:q,onToggleCollapse:()=>me(ue=>!ue)}),u.jsxs("div",{className:"nc-workspace-main",children:[u.jsx(ix,{decks:R,currentDeck:_,onCreate:Oe,onRename:$e,onDelete:he,onReorder:N.reorder,onOpenWindow:Pe,onNavigate:He,saveState:N.saveState,error:N.error,sidebarVisible:st,onToggleSidebar:y?null:()=>W(ue=>!ue)}),u.jsx(WC,{layout:M,onLayoutChange:Z,token:t,readonly:ne,sessionsAlive:J,focusSession:F,onFocus:T,onOpenSingle:G,decks:R,currentDeck:_,onSendToDeck:Ee})]}),X&&u.jsx("div",{className:"nc-single-overlay",children:u.jsx(xv,{session:X.session,node:X.node,ownerId:X.ownerId,token:t,readonly:ne,onBack:()=>K(null)})}),I&&u.jsx(Ka,{cell:I,token:t,route:Array.isArray(I.route)?I.route:[],onConfirm:Ae,onClose:()=>z(null)}),Xe]})}function OE(){wi();const e=P.useSyncExternalStore(xE,wv,wv);if(!e.needed)return null;const t=e.kind==="install"?v("install-version-mismatch").replace("{v}",e.version):v("update-available").replace("{v}",e.version).replace(" "," ").trim();return u.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[u.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&u.jsx("button",{className:"nc-update-btn",onClick:PE,children:v("reload")})]})}RE();Aw.createRoot(document.getElementById("root")).render(u.jsxs(Rw.StrictMode,{children:[u.jsx(BE,{}),u.jsx(OE,{})]}));