@mmmbuto/nexuscrew 0.8.16 → 0.8.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +280 -407
- package/frontend/dist/assets/index-CffPTRyq.js +91 -0
- package/frontend/dist/index.html +1 -1
- package/frontend/dist/version.json +1 -1
- package/lib/cli/commands.js +11 -269
- package/lib/cli/fleet-service.js +4 -0
- package/lib/cli/runtime-lifecycle.js +299 -0
- package/lib/cli/service.js +4 -1
- package/lib/fleet/builtin.js +56 -434
- package/lib/fleet/launch.js +227 -0
- package/lib/fleet/runtime.js +269 -0
- package/lib/mcp/cells.js +154 -0
- package/lib/mcp/server.js +11 -422
- package/lib/mcp/tools.js +300 -0
- package/lib/runtime/env.js +38 -1
- package/lib/settings/pairing-coordinator.js +325 -0
- package/lib/settings/public-peering-routes.js +126 -0
- package/lib/settings/routes.js +16 -396
- package/package.json +1 -1
- package/frontend/dist/assets/index-B9RXe5E4.js +0 -91
|
@@ -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 l of o)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function Dh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wc={exports:{}},zs={},Uc={exports:{}},We={};/**
|
|
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 $p;function GS(){if($p)return We;$p=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),b=Symbol.iterator;function _(M){return M===null||typeof M!="object"?null:(M=b&&M[b]||M["@@iterator"],typeof M=="function"?M:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,C={};function k(M,K,Q){this.props=M,this.context=K,this.refs=C,this.updater=Q||v}k.prototype.isReactComponent={},k.prototype.setState=function(M,K){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,K,"setState")},k.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function N(){}N.prototype=k.prototype;function D(M,K,Q){this.props=M,this.context=K,this.refs=C,this.updater=Q||v}var B=D.prototype=new N;B.constructor=D,w(B,k.prototype),B.isPureReactComponent=!0;var A=Array.isArray,J=Object.prototype.hasOwnProperty,O={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function Z(M,K,Q){var re,oe={},le=null,V=null;if(K!=null)for(re in K.ref!==void 0&&(V=K.ref),K.key!==void 0&&(le=""+K.key),K)J.call(K,re)&&!F.hasOwnProperty(re)&&(oe[re]=K[re]);var z=arguments.length-2;if(z===1)oe.children=Q;else if(1<z){for(var pe=Array(z),ye=0;ye<z;ye++)pe[ye]=arguments[ye+2];oe.children=pe}if(M&&M.defaultProps)for(re in z=M.defaultProps,z)oe[re]===void 0&&(oe[re]=z[re]);return{$$typeof:e,type:M,key:le,ref:V,props:oe,_owner:O.current}}function W(M,K){return{$$typeof:e,type:M.type,key:K,ref:M.ref,props:M.props,_owner:M._owner}}function G(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function X(M){var K={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(Q){return K[Q]})}var j=/\/+/g;function E(M,K){return typeof M=="object"&&M!==null&&M.key!=null?X(""+M.key):K.toString(36)}function P(M,K,Q,re,oe){var le=typeof M;(le==="undefined"||le==="boolean")&&(M=null);var V=!1;if(M===null)V=!0;else switch(le){case"string":case"number":V=!0;break;case"object":switch(M.$$typeof){case e:case t:V=!0}}if(V)return V=M,oe=oe(V),M=re===""?"."+E(V,0):re,A(oe)?(Q="",M!=null&&(Q=M.replace(j,"$&/")+"/"),P(oe,K,Q,"",function(ye){return ye})):oe!=null&&(G(oe)&&(oe=W(oe,Q+(!oe.key||V&&V.key===oe.key?"":(""+oe.key).replace(j,"$&/")+"/")+M)),K.push(oe)),1;if(V=0,re=re===""?".":re+":",A(M))for(var z=0;z<M.length;z++){le=M[z];var pe=re+E(le,z);V+=P(le,K,Q,pe,oe)}else if(pe=_(M),typeof pe=="function")for(M=pe.call(M),z=0;!(le=M.next()).done;)le=le.value,pe=re+E(le,z++),V+=P(le,K,Q,pe,oe);else if(le==="object")throw K=String(M),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.");return V}function U(M,K,Q){if(M==null)return M;var re=[],oe=0;return P(M,re,"","",function(le){return K.call(Q,le,oe++)}),re}function R(M){if(M._status===-1){var K=M._result;K=K(),K.then(function(Q){(M._status===0||M._status===-1)&&(M._status=1,M._result=Q)},function(Q){(M._status===0||M._status===-1)&&(M._status=2,M._result=Q)}),M._status===-1&&(M._status=0,M._result=K)}if(M._status===1)return M._result.default;throw M._result}var H={current:null},I={transition:null},se={ReactCurrentDispatcher:H,ReactCurrentBatchConfig:I,ReactCurrentOwner:O};function q(){throw Error("act(...) is not supported in production builds of React.")}return We.Children={map:U,forEach:function(M,K,Q){U(M,function(){K.apply(this,arguments)},Q)},count:function(M){var K=0;return U(M,function(){K++}),K},toArray:function(M){return U(M,function(K){return K})||[]},only:function(M){if(!G(M))throw Error("React.Children.only expected to receive a single React element child.");return M}},We.Component=k,We.Fragment=n,We.Profiler=o,We.PureComponent=D,We.StrictMode=s,We.Suspense=p,We.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=se,We.act=q,We.cloneElement=function(M,K,Q){if(M==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+M+".");var re=w({},M.props),oe=M.key,le=M.ref,V=M._owner;if(K!=null){if(K.ref!==void 0&&(le=K.ref,V=O.current),K.key!==void 0&&(oe=""+K.key),M.type&&M.type.defaultProps)var z=M.type.defaultProps;for(pe in K)J.call(K,pe)&&!F.hasOwnProperty(pe)&&(re[pe]=K[pe]===void 0&&z!==void 0?z[pe]:K[pe])}var pe=arguments.length-2;if(pe===1)re.children=Q;else if(1<pe){z=Array(pe);for(var ye=0;ye<pe;ye++)z[ye]=arguments[ye+2];re.children=z}return{$$typeof:e,type:M.type,key:oe,ref:le,props:re,_owner:V}},We.createContext=function(M){return M={$$typeof:c,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},M.Provider={$$typeof:l,_context:M},M.Consumer=M},We.createElement=Z,We.createFactory=function(M){var K=Z.bind(null,M);return K.type=M,K},We.createRef=function(){return{current:null}},We.forwardRef=function(M){return{$$typeof:d,render:M}},We.isValidElement=G,We.lazy=function(M){return{$$typeof:S,_payload:{_status:-1,_result:M},_init:R}},We.memo=function(M,K){return{$$typeof:m,type:M,compare:K===void 0?null:K}},We.startTransition=function(M){var K=I.transition;I.transition={};try{M()}finally{I.transition=K}},We.unstable_act=q,We.useCallback=function(M,K){return H.current.useCallback(M,K)},We.useContext=function(M){return H.current.useContext(M)},We.useDebugValue=function(){},We.useDeferredValue=function(M){return H.current.useDeferredValue(M)},We.useEffect=function(M,K){return H.current.useEffect(M,K)},We.useId=function(){return H.current.useId()},We.useImperativeHandle=function(M,K,Q){return H.current.useImperativeHandle(M,K,Q)},We.useInsertionEffect=function(M,K){return H.current.useInsertionEffect(M,K)},We.useLayoutEffect=function(M,K){return H.current.useLayoutEffect(M,K)},We.useMemo=function(M,K){return H.current.useMemo(M,K)},We.useReducer=function(M,K,Q){return H.current.useReducer(M,K,Q)},We.useRef=function(M){return H.current.useRef(M)},We.useState=function(M){return H.current.useState(M)},We.useSyncExternalStore=function(M,K,Q){return H.current.useSyncExternalStore(M,K,Q)},We.useTransition=function(){return H.current.useTransition()},We.version="18.3.1",We}var Wp;function Lh(){return Wp||(Wp=1,Uc.exports=GS()),Uc.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 Up;function QS(){if(Up)return zs;Up=1;var e=Lh(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(d,p,m){var S,b={},_=null,v=null;m!==void 0&&(_=""+m),p.key!==void 0&&(_=""+p.key),p.ref!==void 0&&(v=p.ref);for(S in p)s.call(p,S)&&!l.hasOwnProperty(S)&&(b[S]=p[S]);if(d&&d.defaultProps)for(S in p=d.defaultProps,p)b[S]===void 0&&(b[S]=p[S]);return{$$typeof:t,type:d,key:_,ref:v,props:b,_owner:o.current}}return zs.Fragment=n,zs.jsx=c,zs.jsxs=c,zs}var Kp;function JS(){return Kp||(Kp=1,Wc.exports=QS()),Wc.exports}var h=JS(),L=Lh();const ZS=Dh(L);var _a={},Kc={exports:{}},si={},qc={exports:{}},Vc={};/**
|
|
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 qp;function ew(){return qp||(qp=1,(function(e){function t(I,se){var q=I.length;I.push(se);e:for(;0<q;){var M=q-1>>>1,K=I[M];if(0<o(K,se))I[M]=se,I[q]=K,q=M;else break e}}function n(I){return I.length===0?null:I[0]}function s(I){if(I.length===0)return null;var se=I[0],q=I.pop();if(q!==se){I[0]=q;e:for(var M=0,K=I.length,Q=K>>>1;M<Q;){var re=2*(M+1)-1,oe=I[re],le=re+1,V=I[le];if(0>o(oe,q))le<K&&0>o(V,oe)?(I[M]=V,I[le]=q,M=le):(I[M]=oe,I[re]=q,M=re);else if(le<K&&0>o(V,q))I[M]=V,I[le]=q,M=le;else break e}}return se}function o(I,se){var q=I.sortIndex-se.sortIndex;return q!==0?q:I.id-se.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var p=[],m=[],S=1,b=null,_=3,v=!1,w=!1,C=!1,k=typeof setTimeout=="function"?setTimeout:null,N=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 B(I){for(var se=n(m);se!==null;){if(se.callback===null)s(m);else if(se.startTime<=I)s(m),se.sortIndex=se.expirationTime,t(p,se);else break;se=n(m)}}function A(I){if(C=!1,B(I),!w)if(n(p)!==null)w=!0,R(J);else{var se=n(m);se!==null&&H(A,se.startTime-I)}}function J(I,se){w=!1,C&&(C=!1,N(Z),Z=-1),v=!0;var q=_;try{for(B(se),b=n(p);b!==null&&(!(b.expirationTime>se)||I&&!X());){var M=b.callback;if(typeof M=="function"){b.callback=null,_=b.priorityLevel;var K=M(b.expirationTime<=se);se=e.unstable_now(),typeof K=="function"?b.callback=K:b===n(p)&&s(p),B(se)}else s(p);b=n(p)}if(b!==null)var Q=!0;else{var re=n(m);re!==null&&H(A,re.startTime-se),Q=!1}return Q}finally{b=null,_=q,v=!1}}var O=!1,F=null,Z=-1,W=5,G=-1;function X(){return!(e.unstable_now()-G<W)}function j(){if(F!==null){var I=e.unstable_now();G=I;var se=!0;try{se=F(!0,I)}finally{se?E():(O=!1,F=null)}}else O=!1}var E;if(typeof D=="function")E=function(){D(j)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,U=P.port2;P.port1.onmessage=j,E=function(){U.postMessage(null)}}else E=function(){k(j,0)};function R(I){F=I,O||(O=!0,E())}function H(I,se){Z=k(function(){I(e.unstable_now())},se)}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(I){I.callback=null},e.unstable_continueExecution=function(){w||v||(w=!0,R(J))},e.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_getFirstCallbackNode=function(){return n(p)},e.unstable_next=function(I){switch(_){case 1:case 2:case 3:var se=3;break;default:se=_}var q=_;_=se;try{return I()}finally{_=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,se){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var q=_;_=I;try{return se()}finally{_=q}},e.unstable_scheduleCallback=function(I,se,q){var M=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?M+q:M):q=M,I){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=q+K,I={id:S++,callback:se,priorityLevel:I,startTime:q,expirationTime:K,sortIndex:-1},q>M?(I.sortIndex=q,t(m,I),n(p)===null&&I===n(m)&&(C?(N(Z),Z=-1):C=!0,H(A,q-M))):(I.sortIndex=K,t(p,I),w||v||(w=!0,R(J))),I},e.unstable_shouldYield=X,e.unstable_wrapCallback=function(I){var se=_;return function(){var q=_;_=se;try{return I.apply(this,arguments)}finally{_=q}}}})(Vc)),Vc}var Vp;function tw(){return Vp||(Vp=1,qc.exports=ew()),qc.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 Yp;function iw(){if(Yp)return si;Yp=1;var e=Lh(),t=tw();function n(i){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+i,a=1;a<arguments.length;a++)r+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+i+"; 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 l(i,r){c(i,r),c(i+"Capture",r)}function c(i,r){for(o[i]=r,i=0;i<r.length;i++)s.add(r[i])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,m=/^[: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={},b={};function _(i){return p.call(b,i)?!0:p.call(S,i)?!1:m.test(i)?b[i]=!0:(S[i]=!0,!1)}function v(i,r,a,u){if(a!==null&&a.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return u?!1:a!==null?!a.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function w(i,r,a,u){if(r===null||typeof r>"u"||v(i,r,a,u))return!0;if(u)return!1;if(a!==null)switch(a.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 C(i,r,a,u,f,g,x){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=u,this.attributeNamespace=f,this.mustUseProperty=a,this.propertyName=i,this.type=r,this.sanitizeURL=g,this.removeEmptyString=x}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){k[i]=new C(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];k[r]=new C(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){k[i]=new C(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){k[i]=new C(i,2,!1,i,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(i){k[i]=new C(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){k[i]=new C(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){k[i]=new C(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){k[i]=new C(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){k[i]=new C(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function D(i){return i[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(i){var r=i.replace(N,D);k[r]=new C(r,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var r=i.replace(N,D);k[r]=new C(r,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var r=i.replace(N,D);k[r]=new C(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){k[i]=new C(i,1,!1,i.toLowerCase(),null,!1,!1)}),k.xlinkHref=new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){k[i]=new C(i,1,!1,i.toLowerCase(),null,!0,!0)});function B(i,r,a,u){var f=k.hasOwnProperty(r)?k[r]:null;(f!==null?f.type!==0:u||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(w(r,a,f,u)&&(a=null),u||f===null?_(r)&&(a===null?i.removeAttribute(r):i.setAttribute(r,""+a)):f.mustUseProperty?i[f.propertyName]=a===null?f.type===3?!1:"":a:(r=f.attributeName,u=f.attributeNamespace,a===null?i.removeAttribute(r):(f=f.type,a=f===3||f===4&&a===!0?"":""+a,u?i.setAttributeNS(u,r,a):i.setAttribute(r,a))))}var A=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,J=Symbol.for("react.element"),O=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),G=Symbol.for("react.provider"),X=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),I=Symbol.iterator;function se(i){return i===null||typeof i!="object"?null:(i=I&&i[I]||i["@@iterator"],typeof i=="function"?i:null)}var q=Object.assign,M;function K(i){if(M===void 0)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);M=r&&r[1]||""}return`
|
|
34
|
+
`+M+i}var Q=!1;function re(i,r){if(!i||Q)return"";Q=!0;var a=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(ae){var u=ae}Reflect.construct(i,[],r)}else{try{r.call()}catch(ae){u=ae}i.call(r.prototype)}else{try{throw Error()}catch(ae){u=ae}i()}}catch(ae){if(ae&&u&&typeof ae.stack=="string"){for(var f=ae.stack.split(`
|
|
35
|
+
`),g=u.stack.split(`
|
|
36
|
+
`),x=f.length-1,T=g.length-1;1<=x&&0<=T&&f[x]!==g[T];)T--;for(;1<=x&&0<=T;x--,T--)if(f[x]!==g[T]){if(x!==1||T!==1)do if(x--,T--,0>T||f[x]!==g[T]){var $=`
|
|
37
|
+
`+f[x].replace(" at new "," at ");return i.displayName&&$.includes("<anonymous>")&&($=$.replace("<anonymous>",i.displayName)),$}while(1<=x&&0<=T);break}}}finally{Q=!1,Error.prepareStackTrace=a}return(i=i?i.displayName||i.name:"")?K(i):""}function oe(i){switch(i.tag){case 5:return K(i.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return i=re(i.type,!1),i;case 11:return i=re(i.type.render,!1),i;case 1:return i=re(i.type,!0),i;default:return""}}function le(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case F:return"Fragment";case O:return"Portal";case W:return"Profiler";case Z:return"StrictMode";case E:return"Suspense";case P:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case X:return(i.displayName||"Context")+".Consumer";case G:return(i._context.displayName||"Context")+".Provider";case j:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case U:return r=i.displayName||null,r!==null?r:le(i.type)||"Memo";case R:r=i._payload,i=i._init;try{return le(i(r))}catch{}}return null}function V(i){var r=i.type;switch(i.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 i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(r);case 8:return r===Z?"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 z(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function pe(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function ye(i){var r=pe(i)?"checked":"value",a=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),u=""+i[r];if(!i.hasOwnProperty(r)&&typeof a<"u"&&typeof a.get=="function"&&typeof a.set=="function"){var f=a.get,g=a.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return f.call(this)},set:function(x){u=""+x,g.call(this,x)}}),Object.defineProperty(i,r,{enumerable:a.enumerable}),{getValue:function(){return u},setValue:function(x){u=""+x},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function xe(i){i._valueTracker||(i._valueTracker=ye(i))}function te(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var a=r.getValue(),u="";return i&&(u=pe(i)?i.checked?"true":"false":i.value),i=u,i!==a?(r.setValue(i),!0):!1}function de(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function Ne(i,r){var a=r.checked;return q({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:a??i._wrapperState.initialChecked})}function ke(i,r){var a=r.defaultValue==null?"":r.defaultValue,u=r.checked!=null?r.checked:r.defaultChecked;a=z(r.value!=null?r.value:a),i._wrapperState={initialChecked:u,initialValue:a,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function Ve(i,r){r=r.checked,r!=null&&B(i,"checked",r,!1)}function Qe(i,r){Ve(i,r);var a=z(r.value),u=r.type;if(a!=null)u==="number"?(a===0&&i.value===""||i.value!=a)&&(i.value=""+a):i.value!==""+a&&(i.value=""+a);else if(u==="submit"||u==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?ie(i,r.type,a):r.hasOwnProperty("defaultValue")&&ie(i,r.type,z(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function Ke(i,r,a){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var u=r.type;if(!(u!=="submit"&&u!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+i._wrapperState.initialValue,a||r===i.value||(i.value=r),i.defaultValue=r}a=i.name,a!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,a!==""&&(i.name=a)}function ie(i,r,a){(r!=="number"||de(i.ownerDocument)!==i)&&(a==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+a&&(i.defaultValue=""+a))}var we=Array.isArray;function Te(i,r,a,u){if(i=i.options,r){r={};for(var f=0;f<a.length;f++)r["$"+a[f]]=!0;for(a=0;a<i.length;a++)f=r.hasOwnProperty("$"+i[a].value),i[a].selected!==f&&(i[a].selected=f),f&&u&&(i[a].defaultSelected=!0)}else{for(a=""+z(a),r=null,f=0;f<i.length;f++){if(i[f].value===a){i[f].selected=!0,u&&(i[f].defaultSelected=!0);return}r!==null||i[f].disabled||(r=i[f])}r!==null&&(r.selected=!0)}}function Se(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return q({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Xe(i,r){var a=r.value;if(a==null){if(a=r.children,r=r.defaultValue,a!=null){if(r!=null)throw Error(n(92));if(we(a)){if(1<a.length)throw Error(n(93));a=a[0]}r=a}r==null&&(r=""),a=r}i._wrapperState={initialValue:z(a)}}function ci(i,r){var a=z(r.value),u=z(r.defaultValue);a!=null&&(a=""+a,a!==i.value&&(i.value=a),r.defaultValue==null&&i.defaultValue!==a&&(i.defaultValue=a)),u!=null&&(i.defaultValue=""+u)}function $t(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function Zt(i){switch(i){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 Ue(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?Zt(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Bt,Si=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,a,u,f){MSApp.execUnsafeLocalFunction(function(){return i(r,a,u,f)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(Bt=Bt||document.createElement("div"),Bt.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=Bt.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function qe(i,r){if(r){var a=i.firstChild;if(a&&a===i.lastChild&&a.nodeType===3){a.nodeValue=r;return}}i.textContent=r}var me={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},$e=["Webkit","ms","Moz","O"];Object.keys(me).forEach(function(i){$e.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),me[r]=me[i]})});function Je(i,r,a){return r==null||typeof r=="boolean"||r===""?"":a||typeof r!="number"||r===0||me.hasOwnProperty(i)&&me[i]?(""+r).trim():r+"px"}function ce(i,r){i=i.style;for(var a in r)if(r.hasOwnProperty(a)){var u=a.indexOf("--")===0,f=Je(a,r[a],u);a==="float"&&(a="cssFloat"),u?i.setProperty(a,f):i[a]=f}}var Pe=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 Oe(i,r){if(r){if(Pe[i]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(n(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(n(61))}if(r.style!=null&&typeof r.style!="object")throw Error(n(62))}}function Et(i,r){if(i.indexOf("-")===-1)return typeof r.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ui=null;function rl(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var sl=null,gr=null,vr=null;function rd(i){if(i=ks(i)){if(typeof sl!="function")throw Error(n(280));var r=i.stateNode;r&&(r=jo(r),sl(i.stateNode,i.type,r))}}function sd(i){gr?vr?vr.push(i):vr=[i]:gr=i}function od(){if(gr){var i=gr,r=vr;if(vr=gr=null,rd(i),r)for(i=0;i<r.length;i++)rd(r[i])}}function ad(i,r){return i(r)}function ld(){}var ol=!1;function cd(i,r,a){if(ol)return i(r,a);ol=!0;try{return ad(i,r,a)}finally{ol=!1,(gr!==null||vr!==null)&&(ld(),od())}}function ns(i,r){var a=i.stateNode;if(a===null)return null;var u=jo(a);if(u===null)return null;a=u[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":(u=!u.disabled)||(i=i.type,u=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!u;break e;default:i=!1}if(i)return null;if(a&&typeof a!="function")throw Error(n(231,r,typeof a));return a}var al=!1;if(d)try{var rs={};Object.defineProperty(rs,"passive",{get:function(){al=!0}}),window.addEventListener("test",rs,rs),window.removeEventListener("test",rs,rs)}catch{al=!1}function iy(i,r,a,u,f,g,x,T,$){var ae=Array.prototype.slice.call(arguments,3);try{r.apply(a,ae)}catch(fe){this.onError(fe)}}var ss=!1,uo=null,ho=!1,ll=null,ny={onError:function(i){ss=!0,uo=i}};function ry(i,r,a,u,f,g,x,T,$){ss=!1,uo=null,iy.apply(ny,arguments)}function sy(i,r,a,u,f,g,x,T,$){if(ry.apply(this,arguments),ss){if(ss){var ae=uo;ss=!1,uo=null}else throw Error(n(198));ho||(ho=!0,ll=ae)}}function $n(i){var r=i,a=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(a=r.return),i=r.return;while(i)}return r.tag===3?a:null}function ud(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function hd(i){if($n(i)!==i)throw Error(n(188))}function oy(i){var r=i.alternate;if(!r){if(r=$n(i),r===null)throw Error(n(188));return r!==i?null:i}for(var a=i,u=r;;){var f=a.return;if(f===null)break;var g=f.alternate;if(g===null){if(u=f.return,u!==null){a=u;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===a)return hd(f),i;if(g===u)return hd(f),r;g=g.sibling}throw Error(n(188))}if(a.return!==u.return)a=f,u=g;else{for(var x=!1,T=f.child;T;){if(T===a){x=!0,a=f,u=g;break}if(T===u){x=!0,u=f,a=g;break}T=T.sibling}if(!x){for(T=g.child;T;){if(T===a){x=!0,a=g,u=f;break}if(T===u){x=!0,u=g,a=f;break}T=T.sibling}if(!x)throw Error(n(189))}}if(a.alternate!==u)throw Error(n(190))}if(a.tag!==3)throw Error(n(188));return a.stateNode.current===a?i:r}function dd(i){return i=oy(i),i!==null?fd(i):null}function fd(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=fd(i);if(r!==null)return r;i=i.sibling}return null}var pd=t.unstable_scheduleCallback,md=t.unstable_cancelCallback,ay=t.unstable_shouldYield,ly=t.unstable_requestPaint,mt=t.unstable_now,cy=t.unstable_getCurrentPriorityLevel,cl=t.unstable_ImmediatePriority,gd=t.unstable_UserBlockingPriority,fo=t.unstable_NormalPriority,uy=t.unstable_LowPriority,vd=t.unstable_IdlePriority,po=null,Fi=null;function hy(i){if(Fi&&typeof Fi.onCommitFiberRoot=="function")try{Fi.onCommitFiberRoot(po,i,void 0,(i.current.flags&128)===128)}catch{}}var Mi=Math.clz32?Math.clz32:py,dy=Math.log,fy=Math.LN2;function py(i){return i>>>=0,i===0?32:31-(dy(i)/fy|0)|0}var mo=64,go=4194304;function os(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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 i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function vo(i,r){var a=i.pendingLanes;if(a===0)return 0;var u=0,f=i.suspendedLanes,g=i.pingedLanes,x=a&268435455;if(x!==0){var T=x&~f;T!==0?u=os(T):(g&=x,g!==0&&(u=os(g)))}else x=a&~f,x!==0?u=os(x):g!==0&&(u=os(g));if(u===0)return 0;if(r!==0&&r!==u&&(r&f)===0&&(f=u&-u,g=r&-r,f>=g||f===16&&(g&4194240)!==0))return r;if((u&4)!==0&&(u|=a&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=u;0<r;)a=31-Mi(r),f=1<<a,u|=i[a],r&=~f;return u}function my(i,r){switch(i){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 gy(i,r){for(var a=i.suspendedLanes,u=i.pingedLanes,f=i.expirationTimes,g=i.pendingLanes;0<g;){var x=31-Mi(g),T=1<<x,$=f[x];$===-1?((T&a)===0||(T&u)!==0)&&(f[x]=my(T,r)):$<=r&&(i.expiredLanes|=T),g&=~T}}function ul(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function _d(){var i=mo;return mo<<=1,(mo&4194240)===0&&(mo=64),i}function hl(i){for(var r=[],a=0;31>a;a++)r.push(i);return r}function as(i,r,a){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Mi(r),i[r]=a}function vy(i,r){var a=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var u=i.eventTimes;for(i=i.expirationTimes;0<a;){var f=31-Mi(a),g=1<<f;r[f]=0,u[f]=-1,i[f]=-1,a&=~g}}function dl(i,r){var a=i.entangledLanes|=r;for(i=i.entanglements;a;){var u=31-Mi(a),f=1<<u;f&r|i[u]&r&&(i[u]|=r),a&=~f}}var et=0;function yd(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Sd,fl,wd,bd,Cd,pl=!1,_o=[],pn=null,mn=null,gn=null,ls=new Map,cs=new Map,vn=[],_y="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 kd(i,r){switch(i){case"focusin":case"focusout":pn=null;break;case"dragenter":case"dragleave":mn=null;break;case"mouseover":case"mouseout":gn=null;break;case"pointerover":case"pointerout":ls.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":cs.delete(r.pointerId)}}function us(i,r,a,u,f,g){return i===null||i.nativeEvent!==g?(i={blockedOn:r,domEventName:a,eventSystemFlags:u,nativeEvent:g,targetContainers:[f]},r!==null&&(r=ks(r),r!==null&&fl(r)),i):(i.eventSystemFlags|=u,r=i.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),i)}function yy(i,r,a,u,f){switch(r){case"focusin":return pn=us(pn,i,r,a,u,f),!0;case"dragenter":return mn=us(mn,i,r,a,u,f),!0;case"mouseover":return gn=us(gn,i,r,a,u,f),!0;case"pointerover":var g=f.pointerId;return ls.set(g,us(ls.get(g)||null,i,r,a,u,f)),!0;case"gotpointercapture":return g=f.pointerId,cs.set(g,us(cs.get(g)||null,i,r,a,u,f)),!0}return!1}function xd(i){var r=Wn(i.target);if(r!==null){var a=$n(r);if(a!==null){if(r=a.tag,r===13){if(r=ud(a),r!==null){i.blockedOn=r,Cd(i.priority,function(){wd(a)});return}}else if(r===3&&a.stateNode.current.memoizedState.isDehydrated){i.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}i.blockedOn=null}function yo(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var a=gl(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(a===null){a=i.nativeEvent;var u=new a.constructor(a.type,a);ui=u,a.target.dispatchEvent(u),ui=null}else return r=ks(a),r!==null&&fl(r),i.blockedOn=a,!1;r.shift()}return!0}function Ed(i,r,a){yo(i)&&a.delete(r)}function Sy(){pl=!1,pn!==null&&yo(pn)&&(pn=null),mn!==null&&yo(mn)&&(mn=null),gn!==null&&yo(gn)&&(gn=null),ls.forEach(Ed),cs.forEach(Ed)}function hs(i,r){i.blockedOn===r&&(i.blockedOn=null,pl||(pl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Sy)))}function ds(i){function r(f){return hs(f,i)}if(0<_o.length){hs(_o[0],i);for(var a=1;a<_o.length;a++){var u=_o[a];u.blockedOn===i&&(u.blockedOn=null)}}for(pn!==null&&hs(pn,i),mn!==null&&hs(mn,i),gn!==null&&hs(gn,i),ls.forEach(r),cs.forEach(r),a=0;a<vn.length;a++)u=vn[a],u.blockedOn===i&&(u.blockedOn=null);for(;0<vn.length&&(a=vn[0],a.blockedOn===null);)xd(a),a.blockedOn===null&&vn.shift()}var _r=A.ReactCurrentBatchConfig,So=!0;function wy(i,r,a,u){var f=et,g=_r.transition;_r.transition=null;try{et=1,ml(i,r,a,u)}finally{et=f,_r.transition=g}}function by(i,r,a,u){var f=et,g=_r.transition;_r.transition=null;try{et=4,ml(i,r,a,u)}finally{et=f,_r.transition=g}}function ml(i,r,a,u){if(So){var f=gl(i,r,a,u);if(f===null)jl(i,r,u,wo,a),kd(i,u);else if(yy(f,i,r,a,u))u.stopPropagation();else if(kd(i,u),r&4&&-1<_y.indexOf(i)){for(;f!==null;){var g=ks(f);if(g!==null&&Sd(g),g=gl(i,r,a,u),g===null&&jl(i,r,u,wo,a),g===f)break;f=g}f!==null&&u.stopPropagation()}else jl(i,r,u,null,a)}}var wo=null;function gl(i,r,a,u){if(wo=null,i=rl(u),i=Wn(i),i!==null)if(r=$n(i),r===null)i=null;else if(a=r.tag,a===13){if(i=ud(r),i!==null)return i;i=null}else if(a===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return wo=i,null}function Nd(i){switch(i){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(cy()){case cl:return 1;case gd:return 4;case fo:case uy:return 16;case vd:return 536870912;default:return 16}default:return 16}}var _n=null,vl=null,bo=null;function Rd(){if(bo)return bo;var i,r=vl,a=r.length,u,f="value"in _n?_n.value:_n.textContent,g=f.length;for(i=0;i<a&&r[i]===f[i];i++);var x=a-i;for(u=1;u<=x&&r[a-u]===f[g-u];u++);return bo=f.slice(i,1<u?1-u:void 0)}function Co(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function ko(){return!0}function Pd(){return!1}function hi(i){function r(a,u,f,g,x){this._reactName=a,this._targetInst=f,this.type=u,this.nativeEvent=g,this.target=x,this.currentTarget=null;for(var T in i)i.hasOwnProperty(T)&&(a=i[T],this[T]=a?a(g):g[T]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?ko:Pd,this.isPropagationStopped=Pd,this}return q(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=ko)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=ko)},persist:function(){},isPersistent:ko}),r}var yr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},_l=hi(yr),fs=q({},yr,{view:0,detail:0}),Cy=hi(fs),yl,Sl,ps,xo=q({},fs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bl,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ps&&(ps&&i.type==="mousemove"?(yl=i.screenX-ps.screenX,Sl=i.screenY-ps.screenY):Sl=yl=0,ps=i),yl)},movementY:function(i){return"movementY"in i?i.movementY:Sl}}),Dd=hi(xo),ky=q({},xo,{dataTransfer:0}),xy=hi(ky),Ey=q({},fs,{relatedTarget:0}),wl=hi(Ey),Ny=q({},yr,{animationName:0,elapsedTime:0,pseudoElement:0}),Ry=hi(Ny),Py=q({},yr,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),Dy=hi(Py),Ly=q({},yr,{data:0}),Ld=hi(Ly),My={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jy={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"},Ty={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ay(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=Ty[i])?!!r[i]:!1}function bl(){return Ay}var By=q({},fs,{key:function(i){if(i.key){var r=My[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=Co(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?jy[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bl,charCode:function(i){return i.type==="keypress"?Co(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Co(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),Iy=hi(By),Oy=q({},xo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Md=hi(Oy),zy=q({},fs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bl}),Fy=hi(zy),Hy=q({},yr,{propertyName:0,elapsedTime:0,pseudoElement:0}),$y=hi(Hy),Wy=q({},xo,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),Uy=hi(Wy),Ky=[9,13,27,32],Cl=d&&"CompositionEvent"in window,ms=null;d&&"documentMode"in document&&(ms=document.documentMode);var qy=d&&"TextEvent"in window&&!ms,jd=d&&(!Cl||ms&&8<ms&&11>=ms),Td=" ",Ad=!1;function Bd(i,r){switch(i){case"keyup":return Ky.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Id(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Sr=!1;function Vy(i,r){switch(i){case"compositionend":return Id(r);case"keypress":return r.which!==32?null:(Ad=!0,Td);case"textInput":return i=r.data,i===Td&&Ad?null:i;default:return null}}function Yy(i,r){if(Sr)return i==="compositionend"||!Cl&&Bd(i,r)?(i=Rd(),bo=vl=_n=null,Sr=!1,i):null;switch(i){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 jd&&r.locale!=="ko"?null:r.data;default:return null}}var Xy={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 Od(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!Xy[i.type]:r==="textarea"}function zd(i,r,a,u){sd(u),r=Do(r,"onChange"),0<r.length&&(a=new _l("onChange","change",null,a,u),i.push({event:a,listeners:r}))}var gs=null,vs=null;function Gy(i){rf(i,0)}function Eo(i){var r=xr(i);if(te(r))return i}function Qy(i,r){if(i==="change")return r}var Fd=!1;if(d){var kl;if(d){var xl="oninput"in document;if(!xl){var Hd=document.createElement("div");Hd.setAttribute("oninput","return;"),xl=typeof Hd.oninput=="function"}kl=xl}else kl=!1;Fd=kl&&(!document.documentMode||9<document.documentMode)}function $d(){gs&&(gs.detachEvent("onpropertychange",Wd),vs=gs=null)}function Wd(i){if(i.propertyName==="value"&&Eo(vs)){var r=[];zd(r,vs,i,rl(i)),cd(Gy,r)}}function Jy(i,r,a){i==="focusin"?($d(),gs=r,vs=a,gs.attachEvent("onpropertychange",Wd)):i==="focusout"&&$d()}function Zy(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Eo(vs)}function eS(i,r){if(i==="click")return Eo(r)}function tS(i,r){if(i==="input"||i==="change")return Eo(r)}function iS(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var ji=typeof Object.is=="function"?Object.is:iS;function _s(i,r){if(ji(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var a=Object.keys(i),u=Object.keys(r);if(a.length!==u.length)return!1;for(u=0;u<a.length;u++){var f=a[u];if(!p.call(r,f)||!ji(i[f],r[f]))return!1}return!0}function Ud(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function Kd(i,r){var a=Ud(i);i=0;for(var u;a;){if(a.nodeType===3){if(u=i+a.textContent.length,i<=r&&u>=r)return{node:a,offset:r-i};i=u}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Ud(a)}}function qd(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?qd(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Vd(){for(var i=window,r=de();r instanceof i.HTMLIFrameElement;){try{var a=typeof r.contentWindow.location.href=="string"}catch{a=!1}if(a)i=r.contentWindow;else break;r=de(i.document)}return r}function El(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}function nS(i){var r=Vd(),a=i.focusedElem,u=i.selectionRange;if(r!==a&&a&&a.ownerDocument&&qd(a.ownerDocument.documentElement,a)){if(u!==null&&El(a)){if(r=u.start,i=u.end,i===void 0&&(i=r),"selectionStart"in a)a.selectionStart=r,a.selectionEnd=Math.min(i,a.value.length);else if(i=(r=a.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var f=a.textContent.length,g=Math.min(u.start,f);u=u.end===void 0?g:Math.min(u.end,f),!i.extend&&g>u&&(f=u,u=g,g=f),f=Kd(a,g);var x=Kd(a,u);f&&x&&(i.rangeCount!==1||i.anchorNode!==f.node||i.anchorOffset!==f.offset||i.focusNode!==x.node||i.focusOffset!==x.offset)&&(r=r.createRange(),r.setStart(f.node,f.offset),i.removeAllRanges(),g>u?(i.addRange(r),i.extend(x.node,x.offset)):(r.setEnd(x.node,x.offset),i.addRange(r)))}}for(r=[],i=a;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<r.length;a++)i=r[a],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var rS=d&&"documentMode"in document&&11>=document.documentMode,wr=null,Nl=null,ys=null,Rl=!1;function Yd(i,r,a){var u=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;Rl||wr==null||wr!==de(u)||(u=wr,"selectionStart"in u&&El(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ys&&_s(ys,u)||(ys=u,u=Do(Nl,"onSelect"),0<u.length&&(r=new _l("onSelect","select",null,r,a),i.push({event:r,listeners:u}),r.target=wr)))}function No(i,r){var a={};return a[i.toLowerCase()]=r.toLowerCase(),a["Webkit"+i]="webkit"+r,a["Moz"+i]="moz"+r,a}var br={animationend:No("Animation","AnimationEnd"),animationiteration:No("Animation","AnimationIteration"),animationstart:No("Animation","AnimationStart"),transitionend:No("Transition","TransitionEnd")},Pl={},Xd={};d&&(Xd=document.createElement("div").style,"AnimationEvent"in window||(delete br.animationend.animation,delete br.animationiteration.animation,delete br.animationstart.animation),"TransitionEvent"in window||delete br.transitionend.transition);function Ro(i){if(Pl[i])return Pl[i];if(!br[i])return i;var r=br[i],a;for(a in r)if(r.hasOwnProperty(a)&&a in Xd)return Pl[i]=r[a];return i}var Gd=Ro("animationend"),Qd=Ro("animationiteration"),Jd=Ro("animationstart"),Zd=Ro("transitionend"),ef=new Map,tf="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 yn(i,r){ef.set(i,r),l(r,[i])}for(var Dl=0;Dl<tf.length;Dl++){var Ll=tf[Dl],sS=Ll.toLowerCase(),oS=Ll[0].toUpperCase()+Ll.slice(1);yn(sS,"on"+oS)}yn(Gd,"onAnimationEnd"),yn(Qd,"onAnimationIteration"),yn(Jd,"onAnimationStart"),yn("dblclick","onDoubleClick"),yn("focusin","onFocus"),yn("focusout","onBlur"),yn(Zd,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ss="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(" "),aS=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ss));function nf(i,r,a){var u=i.type||"unknown-event";i.currentTarget=a,sy(u,r,void 0,i),i.currentTarget=null}function rf(i,r){r=(r&4)!==0;for(var a=0;a<i.length;a++){var u=i[a],f=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var x=u.length-1;0<=x;x--){var T=u[x],$=T.instance,ae=T.currentTarget;if(T=T.listener,$!==g&&f.isPropagationStopped())break e;nf(f,T,ae),g=$}else for(x=0;x<u.length;x++){if(T=u[x],$=T.instance,ae=T.currentTarget,T=T.listener,$!==g&&f.isPropagationStopped())break e;nf(f,T,ae),g=$}}}if(ho)throw i=ll,ho=!1,ll=null,i}function nt(i,r){var a=r[zl];a===void 0&&(a=r[zl]=new Set);var u=i+"__bubble";a.has(u)||(sf(r,i,2,!1),a.add(u))}function Ml(i,r,a){var u=0;r&&(u|=4),sf(a,i,u,r)}var Po="_reactListening"+Math.random().toString(36).slice(2);function ws(i){if(!i[Po]){i[Po]=!0,s.forEach(function(a){a!=="selectionchange"&&(aS.has(a)||Ml(a,!1,i),Ml(a,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Po]||(r[Po]=!0,Ml("selectionchange",!1,r))}}function sf(i,r,a,u){switch(Nd(r)){case 1:var f=wy;break;case 4:f=by;break;default:f=ml}a=f.bind(null,r,a,i),f=void 0,!al||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),u?f!==void 0?i.addEventListener(r,a,{capture:!0,passive:f}):i.addEventListener(r,a,!0):f!==void 0?i.addEventListener(r,a,{passive:f}):i.addEventListener(r,a,!1)}function jl(i,r,a,u,f){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var x=u.tag;if(x===3||x===4){var T=u.stateNode.containerInfo;if(T===f||T.nodeType===8&&T.parentNode===f)break;if(x===4)for(x=u.return;x!==null;){var $=x.tag;if(($===3||$===4)&&($=x.stateNode.containerInfo,$===f||$.nodeType===8&&$.parentNode===f))return;x=x.return}for(;T!==null;){if(x=Wn(T),x===null)return;if($=x.tag,$===5||$===6){u=g=x;continue e}T=T.parentNode}}u=u.return}cd(function(){var ae=g,fe=rl(a),ge=[];e:{var he=ef.get(i);if(he!==void 0){var Ce=_l,Re=i;switch(i){case"keypress":if(Co(a)===0)break e;case"keydown":case"keyup":Ce=Iy;break;case"focusin":Re="focus",Ce=wl;break;case"focusout":Re="blur",Ce=wl;break;case"beforeblur":case"afterblur":Ce=wl;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ce=Dd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ce=xy;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ce=Fy;break;case Gd:case Qd:case Jd:Ce=Ry;break;case Zd:Ce=$y;break;case"scroll":Ce=Cy;break;case"wheel":Ce=Uy;break;case"copy":case"cut":case"paste":Ce=Dy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ce=Md}var De=(r&4)!==0,gt=!De&&i==="scroll",ee=De?he!==null?he+"Capture":null:he;De=[];for(var Y=ae,ne;Y!==null;){ne=Y;var ve=ne.stateNode;if(ne.tag===5&&ve!==null&&(ne=ve,ee!==null&&(ve=ns(Y,ee),ve!=null&&De.push(bs(Y,ve,ne)))),gt)break;Y=Y.return}0<De.length&&(he=new Ce(he,Re,null,a,fe),ge.push({event:he,listeners:De}))}}if((r&7)===0){e:{if(he=i==="mouseover"||i==="pointerover",Ce=i==="mouseout"||i==="pointerout",he&&a!==ui&&(Re=a.relatedTarget||a.fromElement)&&(Wn(Re)||Re[en]))break e;if((Ce||he)&&(he=fe.window===fe?fe:(he=fe.ownerDocument)?he.defaultView||he.parentWindow:window,Ce?(Re=a.relatedTarget||a.toElement,Ce=ae,Re=Re?Wn(Re):null,Re!==null&&(gt=$n(Re),Re!==gt||Re.tag!==5&&Re.tag!==6)&&(Re=null)):(Ce=null,Re=ae),Ce!==Re)){if(De=Dd,ve="onMouseLeave",ee="onMouseEnter",Y="mouse",(i==="pointerout"||i==="pointerover")&&(De=Md,ve="onPointerLeave",ee="onPointerEnter",Y="pointer"),gt=Ce==null?he:xr(Ce),ne=Re==null?he:xr(Re),he=new De(ve,Y+"leave",Ce,a,fe),he.target=gt,he.relatedTarget=ne,ve=null,Wn(fe)===ae&&(De=new De(ee,Y+"enter",Re,a,fe),De.target=ne,De.relatedTarget=gt,ve=De),gt=ve,Ce&&Re)t:{for(De=Ce,ee=Re,Y=0,ne=De;ne;ne=Cr(ne))Y++;for(ne=0,ve=ee;ve;ve=Cr(ve))ne++;for(;0<Y-ne;)De=Cr(De),Y--;for(;0<ne-Y;)ee=Cr(ee),ne--;for(;Y--;){if(De===ee||ee!==null&&De===ee.alternate)break t;De=Cr(De),ee=Cr(ee)}De=null}else De=null;Ce!==null&&of(ge,he,Ce,De,!1),Re!==null&>!==null&&of(ge,gt,Re,De,!0)}}e:{if(he=ae?xr(ae):window,Ce=he.nodeName&&he.nodeName.toLowerCase(),Ce==="select"||Ce==="input"&&he.type==="file")var Le=Qy;else if(Od(he))if(Fd)Le=tS;else{Le=Zy;var Me=Jy}else(Ce=he.nodeName)&&Ce.toLowerCase()==="input"&&(he.type==="checkbox"||he.type==="radio")&&(Le=eS);if(Le&&(Le=Le(i,ae))){zd(ge,Le,a,fe);break e}Me&&Me(i,he,ae),i==="focusout"&&(Me=he._wrapperState)&&Me.controlled&&he.type==="number"&&ie(he,"number",he.value)}switch(Me=ae?xr(ae):window,i){case"focusin":(Od(Me)||Me.contentEditable==="true")&&(wr=Me,Nl=ae,ys=null);break;case"focusout":ys=Nl=wr=null;break;case"mousedown":Rl=!0;break;case"contextmenu":case"mouseup":case"dragend":Rl=!1,Yd(ge,a,fe);break;case"selectionchange":if(rS)break;case"keydown":case"keyup":Yd(ge,a,fe)}var je;if(Cl)e:{switch(i){case"compositionstart":var Ae="onCompositionStart";break e;case"compositionend":Ae="onCompositionEnd";break e;case"compositionupdate":Ae="onCompositionUpdate";break e}Ae=void 0}else Sr?Bd(i,a)&&(Ae="onCompositionEnd"):i==="keydown"&&a.keyCode===229&&(Ae="onCompositionStart");Ae&&(jd&&a.locale!=="ko"&&(Sr||Ae!=="onCompositionStart"?Ae==="onCompositionEnd"&&Sr&&(je=Rd()):(_n=fe,vl="value"in _n?_n.value:_n.textContent,Sr=!0)),Me=Do(ae,Ae),0<Me.length&&(Ae=new Ld(Ae,i,null,a,fe),ge.push({event:Ae,listeners:Me}),je?Ae.data=je:(je=Id(a),je!==null&&(Ae.data=je)))),(je=qy?Vy(i,a):Yy(i,a))&&(ae=Do(ae,"onBeforeInput"),0<ae.length&&(fe=new Ld("onBeforeInput","beforeinput",null,a,fe),ge.push({event:fe,listeners:ae}),fe.data=je))}rf(ge,r)})}function bs(i,r,a){return{instance:i,listener:r,currentTarget:a}}function Do(i,r){for(var a=r+"Capture",u=[];i!==null;){var f=i,g=f.stateNode;f.tag===5&&g!==null&&(f=g,g=ns(i,a),g!=null&&u.unshift(bs(i,g,f)),g=ns(i,r),g!=null&&u.push(bs(i,g,f))),i=i.return}return u}function Cr(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function of(i,r,a,u,f){for(var g=r._reactName,x=[];a!==null&&a!==u;){var T=a,$=T.alternate,ae=T.stateNode;if($!==null&&$===u)break;T.tag===5&&ae!==null&&(T=ae,f?($=ns(a,g),$!=null&&x.unshift(bs(a,$,T))):f||($=ns(a,g),$!=null&&x.push(bs(a,$,T)))),a=a.return}x.length!==0&&i.push({event:r,listeners:x})}var lS=/\r\n?/g,cS=/\u0000|\uFFFD/g;function af(i){return(typeof i=="string"?i:""+i).replace(lS,`
|
|
38
|
+
`).replace(cS,"")}function Lo(i,r,a){if(r=af(r),af(i)!==r&&a)throw Error(n(425))}function Mo(){}var Tl=null,Al=null;function Bl(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Il=typeof setTimeout=="function"?setTimeout:void 0,uS=typeof clearTimeout=="function"?clearTimeout:void 0,lf=typeof Promise=="function"?Promise:void 0,hS=typeof queueMicrotask=="function"?queueMicrotask:typeof lf<"u"?function(i){return lf.resolve(null).then(i).catch(dS)}:Il;function dS(i){setTimeout(function(){throw i})}function Ol(i,r){var a=r,u=0;do{var f=a.nextSibling;if(i.removeChild(a),f&&f.nodeType===8)if(a=f.data,a==="/$"){if(u===0){i.removeChild(f),ds(r);return}u--}else a!=="$"&&a!=="$?"&&a!=="$!"||u++;a=f}while(a);ds(r)}function Sn(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return i}function cf(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="$"||a==="$!"||a==="$?"){if(r===0)return i;r--}else a==="/$"&&r++}i=i.previousSibling}return null}var kr=Math.random().toString(36).slice(2),Hi="__reactFiber$"+kr,Cs="__reactProps$"+kr,en="__reactContainer$"+kr,zl="__reactEvents$"+kr,fS="__reactListeners$"+kr,pS="__reactHandles$"+kr;function Wn(i){var r=i[Hi];if(r)return r;for(var a=i.parentNode;a;){if(r=a[en]||a[Hi]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(i=cf(i);i!==null;){if(a=i[Hi])return a;i=cf(i)}return r}i=a,a=i.parentNode}return null}function ks(i){return i=i[Hi]||i[en],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function xr(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function jo(i){return i[Cs]||null}var Fl=[],Er=-1;function wn(i){return{current:i}}function rt(i){0>Er||(i.current=Fl[Er],Fl[Er]=null,Er--)}function it(i,r){Er++,Fl[Er]=i.current,i.current=r}var bn={},Wt=wn(bn),ei=wn(!1),Un=bn;function Nr(i,r){var a=i.type.contextTypes;if(!a)return bn;var u=i.stateNode;if(u&&u.__reactInternalMemoizedUnmaskedChildContext===r)return u.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in a)f[g]=r[g];return u&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=f),f}function ti(i){return i=i.childContextTypes,i!=null}function To(){rt(ei),rt(Wt)}function uf(i,r,a){if(Wt.current!==bn)throw Error(n(168));it(Wt,r),it(ei,a)}function hf(i,r,a){var u=i.stateNode;if(r=r.childContextTypes,typeof u.getChildContext!="function")return a;u=u.getChildContext();for(var f in u)if(!(f in r))throw Error(n(108,V(i)||"Unknown",f));return q({},a,u)}function Ao(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||bn,Un=Wt.current,it(Wt,i),it(ei,ei.current),!0}function df(i,r,a){var u=i.stateNode;if(!u)throw Error(n(169));a?(i=hf(i,r,Un),u.__reactInternalMemoizedMergedChildContext=i,rt(ei),rt(Wt),it(Wt,i)):rt(ei),it(ei,a)}var tn=null,Bo=!1,Hl=!1;function ff(i){tn===null?tn=[i]:tn.push(i)}function mS(i){Bo=!0,ff(i)}function Cn(){if(!Hl&&tn!==null){Hl=!0;var i=0,r=et;try{var a=tn;for(et=1;i<a.length;i++){var u=a[i];do u=u(!0);while(u!==null)}tn=null,Bo=!1}catch(f){throw tn!==null&&(tn=tn.slice(i+1)),pd(cl,Cn),f}finally{et=r,Hl=!1}}return null}var Rr=[],Pr=0,Io=null,Oo=0,wi=[],bi=0,Kn=null,nn=1,rn="";function qn(i,r){Rr[Pr++]=Oo,Rr[Pr++]=Io,Io=i,Oo=r}function pf(i,r,a){wi[bi++]=nn,wi[bi++]=rn,wi[bi++]=Kn,Kn=i;var u=nn;i=rn;var f=32-Mi(u)-1;u&=~(1<<f),a+=1;var g=32-Mi(r)+f;if(30<g){var x=f-f%5;g=(u&(1<<x)-1).toString(32),u>>=x,f-=x,nn=1<<32-Mi(r)+f|a<<f|u,rn=g+i}else nn=1<<g|a<<f|u,rn=i}function $l(i){i.return!==null&&(qn(i,1),pf(i,1,0))}function Wl(i){for(;i===Io;)Io=Rr[--Pr],Rr[Pr]=null,Oo=Rr[--Pr],Rr[Pr]=null;for(;i===Kn;)Kn=wi[--bi],wi[bi]=null,rn=wi[--bi],wi[bi]=null,nn=wi[--bi],wi[bi]=null}var di=null,fi=null,ot=!1,Ti=null;function mf(i,r){var a=Ei(5,null,null,0);a.elementType="DELETED",a.stateNode=r,a.return=i,r=i.deletions,r===null?(i.deletions=[a],i.flags|=16):r.push(a)}function gf(i,r){switch(i.tag){case 5:var a=i.type;return r=r.nodeType!==1||a.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,di=i,fi=Sn(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,di=i,fi=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(a=Kn!==null?{id:nn,overflow:rn}:null,i.memoizedState={dehydrated:r,treeContext:a,retryLane:1073741824},a=Ei(18,null,null,0),a.stateNode=r,a.return=i,i.child=a,di=i,fi=null,!0):!1;default:return!1}}function Ul(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Kl(i){if(ot){var r=fi;if(r){var a=r;if(!gf(i,r)){if(Ul(i))throw Error(n(418));r=Sn(a.nextSibling);var u=di;r&&gf(i,r)?mf(u,a):(i.flags=i.flags&-4097|2,ot=!1,di=i)}}else{if(Ul(i))throw Error(n(418));i.flags=i.flags&-4097|2,ot=!1,di=i}}}function vf(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;di=i}function zo(i){if(i!==di)return!1;if(!ot)return vf(i),ot=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!Bl(i.type,i.memoizedProps)),r&&(r=fi)){if(Ul(i))throw _f(),Error(n(418));for(;r;)mf(i,r),r=Sn(r.nextSibling)}if(vf(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var a=i.data;if(a==="/$"){if(r===0){fi=Sn(i.nextSibling);break e}r--}else a!=="$"&&a!=="$!"&&a!=="$?"||r++}i=i.nextSibling}fi=null}}else fi=di?Sn(i.stateNode.nextSibling):null;return!0}function _f(){for(var i=fi;i;)i=Sn(i.nextSibling)}function Dr(){fi=di=null,ot=!1}function ql(i){Ti===null?Ti=[i]:Ti.push(i)}var gS=A.ReactCurrentBatchConfig;function xs(i,r,a){if(i=a.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(a._owner){if(a=a._owner,a){if(a.tag!==1)throw Error(n(309));var u=a.stateNode}if(!u)throw Error(n(147,i));var f=u,g=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===g?r.ref:(r=function(x){var T=f.refs;x===null?delete T[g]:T[g]=x},r._stringRef=g,r)}if(typeof i!="string")throw Error(n(284));if(!a._owner)throw Error(n(290,i))}return i}function Fo(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function yf(i){var r=i._init;return r(i._payload)}function Sf(i){function r(ee,Y){if(i){var ne=ee.deletions;ne===null?(ee.deletions=[Y],ee.flags|=16):ne.push(Y)}}function a(ee,Y){if(!i)return null;for(;Y!==null;)r(ee,Y),Y=Y.sibling;return null}function u(ee,Y){for(ee=new Map;Y!==null;)Y.key!==null?ee.set(Y.key,Y):ee.set(Y.index,Y),Y=Y.sibling;return ee}function f(ee,Y){return ee=Ln(ee,Y),ee.index=0,ee.sibling=null,ee}function g(ee,Y,ne){return ee.index=ne,i?(ne=ee.alternate,ne!==null?(ne=ne.index,ne<Y?(ee.flags|=2,Y):ne):(ee.flags|=2,Y)):(ee.flags|=1048576,Y)}function x(ee){return i&&ee.alternate===null&&(ee.flags|=2),ee}function T(ee,Y,ne,ve){return Y===null||Y.tag!==6?(Y=Ic(ne,ee.mode,ve),Y.return=ee,Y):(Y=f(Y,ne),Y.return=ee,Y)}function $(ee,Y,ne,ve){var Le=ne.type;return Le===F?fe(ee,Y,ne.props.children,ve,ne.key):Y!==null&&(Y.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===R&&yf(Le)===Y.type)?(ve=f(Y,ne.props),ve.ref=xs(ee,Y,ne),ve.return=ee,ve):(ve=ua(ne.type,ne.key,ne.props,null,ee.mode,ve),ve.ref=xs(ee,Y,ne),ve.return=ee,ve)}function ae(ee,Y,ne,ve){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==ne.containerInfo||Y.stateNode.implementation!==ne.implementation?(Y=Oc(ne,ee.mode,ve),Y.return=ee,Y):(Y=f(Y,ne.children||[]),Y.return=ee,Y)}function fe(ee,Y,ne,ve,Le){return Y===null||Y.tag!==7?(Y=er(ne,ee.mode,ve,Le),Y.return=ee,Y):(Y=f(Y,ne),Y.return=ee,Y)}function ge(ee,Y,ne){if(typeof Y=="string"&&Y!==""||typeof Y=="number")return Y=Ic(""+Y,ee.mode,ne),Y.return=ee,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case J:return ne=ua(Y.type,Y.key,Y.props,null,ee.mode,ne),ne.ref=xs(ee,null,Y),ne.return=ee,ne;case O:return Y=Oc(Y,ee.mode,ne),Y.return=ee,Y;case R:var ve=Y._init;return ge(ee,ve(Y._payload),ne)}if(we(Y)||se(Y))return Y=er(Y,ee.mode,ne,null),Y.return=ee,Y;Fo(ee,Y)}return null}function he(ee,Y,ne,ve){var Le=Y!==null?Y.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number")return Le!==null?null:T(ee,Y,""+ne,ve);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case J:return ne.key===Le?$(ee,Y,ne,ve):null;case O:return ne.key===Le?ae(ee,Y,ne,ve):null;case R:return Le=ne._init,he(ee,Y,Le(ne._payload),ve)}if(we(ne)||se(ne))return Le!==null?null:fe(ee,Y,ne,ve,null);Fo(ee,ne)}return null}function Ce(ee,Y,ne,ve,Le){if(typeof ve=="string"&&ve!==""||typeof ve=="number")return ee=ee.get(ne)||null,T(Y,ee,""+ve,Le);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case J:return ee=ee.get(ve.key===null?ne:ve.key)||null,$(Y,ee,ve,Le);case O:return ee=ee.get(ve.key===null?ne:ve.key)||null,ae(Y,ee,ve,Le);case R:var Me=ve._init;return Ce(ee,Y,ne,Me(ve._payload),Le)}if(we(ve)||se(ve))return ee=ee.get(ne)||null,fe(Y,ee,ve,Le,null);Fo(Y,ve)}return null}function Re(ee,Y,ne,ve){for(var Le=null,Me=null,je=Y,Ae=Y=0,Pt=null;je!==null&&Ae<ne.length;Ae++){je.index>Ae?(Pt=je,je=null):Pt=je.sibling;var Ge=he(ee,je,ne[Ae],ve);if(Ge===null){je===null&&(je=Pt);break}i&&je&&Ge.alternate===null&&r(ee,je),Y=g(Ge,Y,Ae),Me===null?Le=Ge:Me.sibling=Ge,Me=Ge,je=Pt}if(Ae===ne.length)return a(ee,je),ot&&qn(ee,Ae),Le;if(je===null){for(;Ae<ne.length;Ae++)je=ge(ee,ne[Ae],ve),je!==null&&(Y=g(je,Y,Ae),Me===null?Le=je:Me.sibling=je,Me=je);return ot&&qn(ee,Ae),Le}for(je=u(ee,je);Ae<ne.length;Ae++)Pt=Ce(je,ee,Ae,ne[Ae],ve),Pt!==null&&(i&&Pt.alternate!==null&&je.delete(Pt.key===null?Ae:Pt.key),Y=g(Pt,Y,Ae),Me===null?Le=Pt:Me.sibling=Pt,Me=Pt);return i&&je.forEach(function(Mn){return r(ee,Mn)}),ot&&qn(ee,Ae),Le}function De(ee,Y,ne,ve){var Le=se(ne);if(typeof Le!="function")throw Error(n(150));if(ne=Le.call(ne),ne==null)throw Error(n(151));for(var Me=Le=null,je=Y,Ae=Y=0,Pt=null,Ge=ne.next();je!==null&&!Ge.done;Ae++,Ge=ne.next()){je.index>Ae?(Pt=je,je=null):Pt=je.sibling;var Mn=he(ee,je,Ge.value,ve);if(Mn===null){je===null&&(je=Pt);break}i&&je&&Mn.alternate===null&&r(ee,je),Y=g(Mn,Y,Ae),Me===null?Le=Mn:Me.sibling=Mn,Me=Mn,je=Pt}if(Ge.done)return a(ee,je),ot&&qn(ee,Ae),Le;if(je===null){for(;!Ge.done;Ae++,Ge=ne.next())Ge=ge(ee,Ge.value,ve),Ge!==null&&(Y=g(Ge,Y,Ae),Me===null?Le=Ge:Me.sibling=Ge,Me=Ge);return ot&&qn(ee,Ae),Le}for(je=u(ee,je);!Ge.done;Ae++,Ge=ne.next())Ge=Ce(je,ee,Ae,Ge.value,ve),Ge!==null&&(i&&Ge.alternate!==null&&je.delete(Ge.key===null?Ae:Ge.key),Y=g(Ge,Y,Ae),Me===null?Le=Ge:Me.sibling=Ge,Me=Ge);return i&&je.forEach(function(XS){return r(ee,XS)}),ot&&qn(ee,Ae),Le}function gt(ee,Y,ne,ve){if(typeof ne=="object"&&ne!==null&&ne.type===F&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case J:e:{for(var Le=ne.key,Me=Y;Me!==null;){if(Me.key===Le){if(Le=ne.type,Le===F){if(Me.tag===7){a(ee,Me.sibling),Y=f(Me,ne.props.children),Y.return=ee,ee=Y;break e}}else if(Me.elementType===Le||typeof Le=="object"&&Le!==null&&Le.$$typeof===R&&yf(Le)===Me.type){a(ee,Me.sibling),Y=f(Me,ne.props),Y.ref=xs(ee,Me,ne),Y.return=ee,ee=Y;break e}a(ee,Me);break}else r(ee,Me);Me=Me.sibling}ne.type===F?(Y=er(ne.props.children,ee.mode,ve,ne.key),Y.return=ee,ee=Y):(ve=ua(ne.type,ne.key,ne.props,null,ee.mode,ve),ve.ref=xs(ee,Y,ne),ve.return=ee,ee=ve)}return x(ee);case O:e:{for(Me=ne.key;Y!==null;){if(Y.key===Me)if(Y.tag===4&&Y.stateNode.containerInfo===ne.containerInfo&&Y.stateNode.implementation===ne.implementation){a(ee,Y.sibling),Y=f(Y,ne.children||[]),Y.return=ee,ee=Y;break e}else{a(ee,Y);break}else r(ee,Y);Y=Y.sibling}Y=Oc(ne,ee.mode,ve),Y.return=ee,ee=Y}return x(ee);case R:return Me=ne._init,gt(ee,Y,Me(ne._payload),ve)}if(we(ne))return Re(ee,Y,ne,ve);if(se(ne))return De(ee,Y,ne,ve);Fo(ee,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"?(ne=""+ne,Y!==null&&Y.tag===6?(a(ee,Y.sibling),Y=f(Y,ne),Y.return=ee,ee=Y):(a(ee,Y),Y=Ic(ne,ee.mode,ve),Y.return=ee,ee=Y),x(ee)):a(ee,Y)}return gt}var Lr=Sf(!0),wf=Sf(!1),Ho=wn(null),$o=null,Mr=null,Vl=null;function Yl(){Vl=Mr=$o=null}function Xl(i){var r=Ho.current;rt(Ho),i._currentValue=r}function Gl(i,r,a){for(;i!==null;){var u=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),i===a)break;i=i.return}}function jr(i,r){$o=i,Vl=Mr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(ii=!0),i.firstContext=null)}function Ci(i){var r=i._currentValue;if(Vl!==i)if(i={context:i,memoizedValue:r,next:null},Mr===null){if($o===null)throw Error(n(308));Mr=i,$o.dependencies={lanes:0,firstContext:i}}else Mr=Mr.next=i;return r}var Vn=null;function Ql(i){Vn===null?Vn=[i]:Vn.push(i)}function bf(i,r,a,u){var f=r.interleaved;return f===null?(a.next=a,Ql(r)):(a.next=f.next,f.next=a),r.interleaved=a,sn(i,u)}function sn(i,r){i.lanes|=r;var a=i.alternate;for(a!==null&&(a.lanes|=r),a=i,i=i.return;i!==null;)i.childLanes|=r,a=i.alternate,a!==null&&(a.childLanes|=r),a=i,i=i.return;return a.tag===3?a.stateNode:null}var kn=!1;function Jl(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Cf(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function on(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function xn(i,r,a){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(Ye&2)!==0){var f=u.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),u.pending=r,sn(i,a)}return f=u.interleaved,f===null?(r.next=r,Ql(u)):(r.next=f.next,f.next=r),u.interleaved=r,sn(i,a)}function Wo(i,r,a){if(r=r.updateQueue,r!==null&&(r=r.shared,(a&4194240)!==0)){var u=r.lanes;u&=i.pendingLanes,a|=u,r.lanes=a,dl(i,a)}}function kf(i,r){var a=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,a===u)){var f=null,g=null;if(a=a.firstBaseUpdate,a!==null){do{var x={eventTime:a.eventTime,lane:a.lane,tag:a.tag,payload:a.payload,callback:a.callback,next:null};g===null?f=g=x:g=g.next=x,a=a.next}while(a!==null);g===null?f=g=r:g=g.next=r}else f=g=r;a={baseState:u.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:u.shared,effects:u.effects},i.updateQueue=a;return}i=a.lastBaseUpdate,i===null?a.firstBaseUpdate=r:i.next=r,a.lastBaseUpdate=r}function Uo(i,r,a,u){var f=i.updateQueue;kn=!1;var g=f.firstBaseUpdate,x=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var $=T,ae=$.next;$.next=null,x===null?g=ae:x.next=ae,x=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,T=fe.lastBaseUpdate,T!==x&&(T===null?fe.firstBaseUpdate=ae:T.next=ae,fe.lastBaseUpdate=$))}if(g!==null){var ge=f.baseState;x=0,fe=ae=$=null,T=g;do{var he=T.lane,Ce=T.eventTime;if((u&he)===he){fe!==null&&(fe=fe.next={eventTime:Ce,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var Re=i,De=T;switch(he=r,Ce=a,De.tag){case 1:if(Re=De.payload,typeof Re=="function"){ge=Re.call(Ce,ge,he);break e}ge=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=De.payload,he=typeof Re=="function"?Re.call(Ce,ge,he):Re,he==null)break e;ge=q({},ge,he);break e;case 2:kn=!0}}T.callback!==null&&T.lane!==0&&(i.flags|=64,he=f.effects,he===null?f.effects=[T]:he.push(T))}else Ce={eventTime:Ce,lane:he,tag:T.tag,payload:T.payload,callback:T.callback,next:null},fe===null?(ae=fe=Ce,$=ge):fe=fe.next=Ce,x|=he;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;he=T,T=he.next,he.next=null,f.lastBaseUpdate=he,f.shared.pending=null}}while(!0);if(fe===null&&($=ge),f.baseState=$,f.firstBaseUpdate=ae,f.lastBaseUpdate=fe,r=f.shared.interleaved,r!==null){f=r;do x|=f.lane,f=f.next;while(f!==r)}else g===null&&(f.shared.lanes=0);Gn|=x,i.lanes=x,i.memoizedState=ge}}function xf(i,r,a){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var u=i[r],f=u.callback;if(f!==null){if(u.callback=null,u=a,typeof f!="function")throw Error(n(191,f));f.call(u)}}}var Es={},$i=wn(Es),Ns=wn(Es),Rs=wn(Es);function Yn(i){if(i===Es)throw Error(n(174));return i}function Zl(i,r){switch(it(Rs,r),it(Ns,i),it($i,Es),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Ue(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=Ue(r,i)}rt($i),it($i,r)}function Tr(){rt($i),rt(Ns),rt(Rs)}function Ef(i){Yn(Rs.current);var r=Yn($i.current),a=Ue(r,i.type);r!==a&&(it(Ns,i),it($i,a))}function ec(i){Ns.current===i&&(rt($i),rt(Ns))}var lt=wn(0);function Ko(i){for(var r=i;r!==null;){if(r.tag===13){var a=r.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||a.data==="$?"||a.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===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var tc=[];function ic(){for(var i=0;i<tc.length;i++)tc[i]._workInProgressVersionPrimary=null;tc.length=0}var qo=A.ReactCurrentDispatcher,nc=A.ReactCurrentBatchConfig,Xn=0,ct=null,wt=null,Nt=null,Vo=!1,Ps=!1,Ds=0,vS=0;function Ut(){throw Error(n(321))}function rc(i,r){if(r===null)return!1;for(var a=0;a<r.length&&a<i.length;a++)if(!ji(i[a],r[a]))return!1;return!0}function sc(i,r,a,u,f,g){if(Xn=g,ct=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,qo.current=i===null||i.memoizedState===null?wS:bS,i=a(u,f),Ps){g=0;do{if(Ps=!1,Ds=0,25<=g)throw Error(n(301));g+=1,Nt=wt=null,r.updateQueue=null,qo.current=CS,i=a(u,f)}while(Ps)}if(qo.current=Go,r=wt!==null&&wt.next!==null,Xn=0,Nt=wt=ct=null,Vo=!1,r)throw Error(n(300));return i}function oc(){var i=Ds!==0;return Ds=0,i}function Wi(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Nt===null?ct.memoizedState=Nt=i:Nt=Nt.next=i,Nt}function ki(){if(wt===null){var i=ct.alternate;i=i!==null?i.memoizedState:null}else i=wt.next;var r=Nt===null?ct.memoizedState:Nt.next;if(r!==null)Nt=r,wt=i;else{if(i===null)throw Error(n(310));wt=i,i={memoizedState:wt.memoizedState,baseState:wt.baseState,baseQueue:wt.baseQueue,queue:wt.queue,next:null},Nt===null?ct.memoizedState=Nt=i:Nt=Nt.next=i}return Nt}function Ls(i,r){return typeof r=="function"?r(i):r}function ac(i){var r=ki(),a=r.queue;if(a===null)throw Error(n(311));a.lastRenderedReducer=i;var u=wt,f=u.baseQueue,g=a.pending;if(g!==null){if(f!==null){var x=f.next;f.next=g.next,g.next=x}u.baseQueue=f=g,a.pending=null}if(f!==null){g=f.next,u=u.baseState;var T=x=null,$=null,ae=g;do{var fe=ae.lane;if((Xn&fe)===fe)$!==null&&($=$.next={lane:0,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null}),u=ae.hasEagerState?ae.eagerState:i(u,ae.action);else{var ge={lane:fe,action:ae.action,hasEagerState:ae.hasEagerState,eagerState:ae.eagerState,next:null};$===null?(T=$=ge,x=u):$=$.next=ge,ct.lanes|=fe,Gn|=fe}ae=ae.next}while(ae!==null&&ae!==g);$===null?x=u:$.next=T,ji(u,r.memoizedState)||(ii=!0),r.memoizedState=u,r.baseState=x,r.baseQueue=$,a.lastRenderedState=u}if(i=a.interleaved,i!==null){f=i;do g=f.lane,ct.lanes|=g,Gn|=g,f=f.next;while(f!==i)}else f===null&&(a.lanes=0);return[r.memoizedState,a.dispatch]}function lc(i){var r=ki(),a=r.queue;if(a===null)throw Error(n(311));a.lastRenderedReducer=i;var u=a.dispatch,f=a.pending,g=r.memoizedState;if(f!==null){a.pending=null;var x=f=f.next;do g=i(g,x.action),x=x.next;while(x!==f);ji(g,r.memoizedState)||(ii=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),a.lastRenderedState=g}return[g,u]}function Nf(){}function Rf(i,r){var a=ct,u=ki(),f=r(),g=!ji(u.memoizedState,f);if(g&&(u.memoizedState=f,ii=!0),u=u.queue,cc(Lf.bind(null,a,u,i),[i]),u.getSnapshot!==r||g||Nt!==null&&Nt.memoizedState.tag&1){if(a.flags|=2048,Ms(9,Df.bind(null,a,u,f,r),void 0,null),Rt===null)throw Error(n(349));(Xn&30)!==0||Pf(a,r,f)}return f}function Pf(i,r,a){i.flags|=16384,i={getSnapshot:r,value:a},r=ct.updateQueue,r===null?(r={lastEffect:null,stores:null},ct.updateQueue=r,r.stores=[i]):(a=r.stores,a===null?r.stores=[i]:a.push(i))}function Df(i,r,a,u){r.value=a,r.getSnapshot=u,Mf(r)&&jf(i)}function Lf(i,r,a){return a(function(){Mf(r)&&jf(i)})}function Mf(i){var r=i.getSnapshot;i=i.value;try{var a=r();return!ji(i,a)}catch{return!0}}function jf(i){var r=sn(i,1);r!==null&&Oi(r,i,1,-1)}function Tf(i){var r=Wi();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ls,lastRenderedState:i},r.queue=i,i=i.dispatch=SS.bind(null,ct,i),[r.memoizedState,i]}function Ms(i,r,a,u){return i={tag:i,create:r,destroy:a,deps:u,next:null},r=ct.updateQueue,r===null?(r={lastEffect:null,stores:null},ct.updateQueue=r,r.lastEffect=i.next=i):(a=r.lastEffect,a===null?r.lastEffect=i.next=i:(u=a.next,a.next=i,i.next=u,r.lastEffect=i)),i}function Af(){return ki().memoizedState}function Yo(i,r,a,u){var f=Wi();ct.flags|=i,f.memoizedState=Ms(1|r,a,void 0,u===void 0?null:u)}function Xo(i,r,a,u){var f=ki();u=u===void 0?null:u;var g=void 0;if(wt!==null){var x=wt.memoizedState;if(g=x.destroy,u!==null&&rc(u,x.deps)){f.memoizedState=Ms(r,a,g,u);return}}ct.flags|=i,f.memoizedState=Ms(1|r,a,g,u)}function Bf(i,r){return Yo(8390656,8,i,r)}function cc(i,r){return Xo(2048,8,i,r)}function If(i,r){return Xo(4,2,i,r)}function Of(i,r){return Xo(4,4,i,r)}function zf(i,r){if(typeof r=="function")return i=i(),r(i),function(){r(null)};if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function Ff(i,r,a){return a=a!=null?a.concat([i]):null,Xo(4,4,zf.bind(null,r,i),a)}function uc(){}function Hf(i,r){var a=ki();r=r===void 0?null:r;var u=a.memoizedState;return u!==null&&r!==null&&rc(r,u[1])?u[0]:(a.memoizedState=[i,r],i)}function $f(i,r){var a=ki();r=r===void 0?null:r;var u=a.memoizedState;return u!==null&&r!==null&&rc(r,u[1])?u[0]:(i=i(),a.memoizedState=[i,r],i)}function Wf(i,r,a){return(Xn&21)===0?(i.baseState&&(i.baseState=!1,ii=!0),i.memoizedState=a):(ji(a,r)||(a=_d(),ct.lanes|=a,Gn|=a,i.baseState=!0),r)}function _S(i,r){var a=et;et=a!==0&&4>a?a:4,i(!0);var u=nc.transition;nc.transition={};try{i(!1),r()}finally{et=a,nc.transition=u}}function Uf(){return ki().memoizedState}function yS(i,r,a){var u=Pn(i);if(a={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null},Kf(i))qf(r,a);else if(a=bf(i,r,a,u),a!==null){var f=Xt();Oi(a,i,u,f),Vf(a,r,u)}}function SS(i,r,a){var u=Pn(i),f={lane:u,action:a,hasEagerState:!1,eagerState:null,next:null};if(Kf(i))qf(r,f);else{var g=i.alternate;if(i.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var x=r.lastRenderedState,T=g(x,a);if(f.hasEagerState=!0,f.eagerState=T,ji(T,x)){var $=r.interleaved;$===null?(f.next=f,Ql(r)):(f.next=$.next,$.next=f),r.interleaved=f;return}}catch{}finally{}a=bf(i,r,f,u),a!==null&&(f=Xt(),Oi(a,i,u,f),Vf(a,r,u))}}function Kf(i){var r=i.alternate;return i===ct||r!==null&&r===ct}function qf(i,r){Ps=Vo=!0;var a=i.pending;a===null?r.next=r:(r.next=a.next,a.next=r),i.pending=r}function Vf(i,r,a){if((a&4194240)!==0){var u=r.lanes;u&=i.pendingLanes,a|=u,r.lanes=a,dl(i,a)}}var Go={readContext:Ci,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useInsertionEffect:Ut,useLayoutEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useMutableSource:Ut,useSyncExternalStore:Ut,useId:Ut,unstable_isNewReconciler:!1},wS={readContext:Ci,useCallback:function(i,r){return Wi().memoizedState=[i,r===void 0?null:r],i},useContext:Ci,useEffect:Bf,useImperativeHandle:function(i,r,a){return a=a!=null?a.concat([i]):null,Yo(4194308,4,zf.bind(null,r,i),a)},useLayoutEffect:function(i,r){return Yo(4194308,4,i,r)},useInsertionEffect:function(i,r){return Yo(4,2,i,r)},useMemo:function(i,r){var a=Wi();return r=r===void 0?null:r,i=i(),a.memoizedState=[i,r],i},useReducer:function(i,r,a){var u=Wi();return r=a!==void 0?a(r):r,u.memoizedState=u.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},u.queue=i,i=i.dispatch=yS.bind(null,ct,i),[u.memoizedState,i]},useRef:function(i){var r=Wi();return i={current:i},r.memoizedState=i},useState:Tf,useDebugValue:uc,useDeferredValue:function(i){return Wi().memoizedState=i},useTransition:function(){var i=Tf(!1),r=i[0];return i=_S.bind(null,i[1]),Wi().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,a){var u=ct,f=Wi();if(ot){if(a===void 0)throw Error(n(407));a=a()}else{if(a=r(),Rt===null)throw Error(n(349));(Xn&30)!==0||Pf(u,r,a)}f.memoizedState=a;var g={value:a,getSnapshot:r};return f.queue=g,Bf(Lf.bind(null,u,g,i),[i]),u.flags|=2048,Ms(9,Df.bind(null,u,g,a,r),void 0,null),a},useId:function(){var i=Wi(),r=Rt.identifierPrefix;if(ot){var a=rn,u=nn;a=(u&~(1<<32-Mi(u)-1)).toString(32)+a,r=":"+r+"R"+a,a=Ds++,0<a&&(r+="H"+a.toString(32)),r+=":"}else a=vS++,r=":"+r+"r"+a.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},bS={readContext:Ci,useCallback:Hf,useContext:Ci,useEffect:cc,useImperativeHandle:Ff,useInsertionEffect:If,useLayoutEffect:Of,useMemo:$f,useReducer:ac,useRef:Af,useState:function(){return ac(Ls)},useDebugValue:uc,useDeferredValue:function(i){var r=ki();return Wf(r,wt.memoizedState,i)},useTransition:function(){var i=ac(Ls)[0],r=ki().memoizedState;return[i,r]},useMutableSource:Nf,useSyncExternalStore:Rf,useId:Uf,unstable_isNewReconciler:!1},CS={readContext:Ci,useCallback:Hf,useContext:Ci,useEffect:cc,useImperativeHandle:Ff,useInsertionEffect:If,useLayoutEffect:Of,useMemo:$f,useReducer:lc,useRef:Af,useState:function(){return lc(Ls)},useDebugValue:uc,useDeferredValue:function(i){var r=ki();return wt===null?r.memoizedState=i:Wf(r,wt.memoizedState,i)},useTransition:function(){var i=lc(Ls)[0],r=ki().memoizedState;return[i,r]},useMutableSource:Nf,useSyncExternalStore:Rf,useId:Uf,unstable_isNewReconciler:!1};function Ai(i,r){if(i&&i.defaultProps){r=q({},r),i=i.defaultProps;for(var a in i)r[a]===void 0&&(r[a]=i[a]);return r}return r}function hc(i,r,a,u){r=i.memoizedState,a=a(u,r),a=a==null?r:q({},r,a),i.memoizedState=a,i.lanes===0&&(i.updateQueue.baseState=a)}var Qo={isMounted:function(i){return(i=i._reactInternals)?$n(i)===i:!1},enqueueSetState:function(i,r,a){i=i._reactInternals;var u=Xt(),f=Pn(i),g=on(u,f);g.payload=r,a!=null&&(g.callback=a),r=xn(i,g,f),r!==null&&(Oi(r,i,f,u),Wo(r,i,f))},enqueueReplaceState:function(i,r,a){i=i._reactInternals;var u=Xt(),f=Pn(i),g=on(u,f);g.tag=1,g.payload=r,a!=null&&(g.callback=a),r=xn(i,g,f),r!==null&&(Oi(r,i,f,u),Wo(r,i,f))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var a=Xt(),u=Pn(i),f=on(a,u);f.tag=2,r!=null&&(f.callback=r),r=xn(i,f,u),r!==null&&(Oi(r,i,u,a),Wo(r,i,u))}};function Yf(i,r,a,u,f,g,x){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(u,g,x):r.prototype&&r.prototype.isPureReactComponent?!_s(a,u)||!_s(f,g):!0}function Xf(i,r,a){var u=!1,f=bn,g=r.contextType;return typeof g=="object"&&g!==null?g=Ci(g):(f=ti(r)?Un:Wt.current,u=r.contextTypes,g=(u=u!=null)?Nr(i,f):bn),r=new r(a,g),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=Qo,i.stateNode=r,r._reactInternals=i,u&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=f,i.__reactInternalMemoizedMaskedChildContext=g),r}function Gf(i,r,a,u){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(a,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(a,u),r.state!==i&&Qo.enqueueReplaceState(r,r.state,null)}function dc(i,r,a,u){var f=i.stateNode;f.props=a,f.state=i.memoizedState,f.refs={},Jl(i);var g=r.contextType;typeof g=="object"&&g!==null?f.context=Ci(g):(g=ti(r)?Un:Wt.current,f.context=Nr(i,g)),f.state=i.memoizedState,g=r.getDerivedStateFromProps,typeof g=="function"&&(hc(i,r,g,a),f.state=i.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&&Qo.enqueueReplaceState(f,f.state,null),Uo(i,a,f,u),f.state=i.memoizedState),typeof f.componentDidMount=="function"&&(i.flags|=4194308)}function Ar(i,r){try{var a="",u=r;do a+=oe(u),u=u.return;while(u);var f=a}catch(g){f=`
|
|
39
|
+
Error generating stack: `+g.message+`
|
|
40
|
+
`+g.stack}return{value:i,source:r,stack:f,digest:null}}function fc(i,r,a){return{value:i,source:null,stack:a??null,digest:r??null}}function pc(i,r){try{console.error(r.value)}catch(a){setTimeout(function(){throw a})}}var kS=typeof WeakMap=="function"?WeakMap:Map;function Qf(i,r,a){a=on(-1,a),a.tag=3,a.payload={element:null};var u=r.value;return a.callback=function(){ra||(ra=!0,Pc=u),pc(i,r)},a}function Jf(i,r,a){a=on(-1,a),a.tag=3;var u=i.type.getDerivedStateFromError;if(typeof u=="function"){var f=r.value;a.payload=function(){return u(f)},a.callback=function(){pc(i,r)}}var g=i.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(a.callback=function(){pc(i,r),typeof u!="function"&&(Nn===null?Nn=new Set([this]):Nn.add(this));var x=r.stack;this.componentDidCatch(r.value,{componentStack:x!==null?x:""})}),a}function Zf(i,r,a){var u=i.pingCache;if(u===null){u=i.pingCache=new kS;var f=new Set;u.set(r,f)}else f=u.get(r),f===void 0&&(f=new Set,u.set(r,f));f.has(a)||(f.add(a),i=OS.bind(null,i,r,a),r.then(i,i))}function ep(i){do{var r;if((r=i.tag===13)&&(r=i.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return i;i=i.return}while(i!==null);return null}function tp(i,r,a,u,f){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,a.flags|=131072,a.flags&=-52805,a.tag===1&&(a.alternate===null?a.tag=17:(r=on(-1,1),r.tag=2,xn(a,r,1))),a.lanes|=1),i):(i.flags|=65536,i.lanes=f,i)}var xS=A.ReactCurrentOwner,ii=!1;function Yt(i,r,a,u){r.child=i===null?wf(r,null,a,u):Lr(r,i.child,a,u)}function ip(i,r,a,u,f){a=a.render;var g=r.ref;return jr(r,f),u=sc(i,r,a,u,g,f),a=oc(),i!==null&&!ii?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~f,an(i,r,f)):(ot&&a&&$l(r),r.flags|=1,Yt(i,r,u,f),r.child)}function np(i,r,a,u,f){if(i===null){var g=a.type;return typeof g=="function"&&!Bc(g)&&g.defaultProps===void 0&&a.compare===null&&a.defaultProps===void 0?(r.tag=15,r.type=g,rp(i,r,g,u,f)):(i=ua(a.type,null,u,r,r.mode,f),i.ref=r.ref,i.return=r,r.child=i)}if(g=i.child,(i.lanes&f)===0){var x=g.memoizedProps;if(a=a.compare,a=a!==null?a:_s,a(x,u)&&i.ref===r.ref)return an(i,r,f)}return r.flags|=1,i=Ln(g,u),i.ref=r.ref,i.return=r,r.child=i}function rp(i,r,a,u,f){if(i!==null){var g=i.memoizedProps;if(_s(g,u)&&i.ref===r.ref)if(ii=!1,r.pendingProps=u=g,(i.lanes&f)!==0)(i.flags&131072)!==0&&(ii=!0);else return r.lanes=i.lanes,an(i,r,f)}return mc(i,r,a,u,f)}function sp(i,r,a){var u=r.pendingProps,f=u.children,g=i!==null?i.memoizedState:null;if(u.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},it(Ir,pi),pi|=a;else{if((a&1073741824)===0)return i=g!==null?g.baseLanes|a:a,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,it(Ir,pi),pi|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},u=g!==null?g.baseLanes:a,it(Ir,pi),pi|=u}else g!==null?(u=g.baseLanes|a,r.memoizedState=null):u=a,it(Ir,pi),pi|=u;return Yt(i,r,f,a),r.child}function op(i,r){var a=r.ref;(i===null&&a!==null||i!==null&&i.ref!==a)&&(r.flags|=512,r.flags|=2097152)}function mc(i,r,a,u,f){var g=ti(a)?Un:Wt.current;return g=Nr(r,g),jr(r,f),a=sc(i,r,a,u,g,f),u=oc(),i!==null&&!ii?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~f,an(i,r,f)):(ot&&u&&$l(r),r.flags|=1,Yt(i,r,a,f),r.child)}function ap(i,r,a,u,f){if(ti(a)){var g=!0;Ao(r)}else g=!1;if(jr(r,f),r.stateNode===null)Zo(i,r),Xf(r,a,u),dc(r,a,u,f),u=!0;else if(i===null){var x=r.stateNode,T=r.memoizedProps;x.props=T;var $=x.context,ae=a.contextType;typeof ae=="object"&&ae!==null?ae=Ci(ae):(ae=ti(a)?Un:Wt.current,ae=Nr(r,ae));var fe=a.getDerivedStateFromProps,ge=typeof fe=="function"||typeof x.getSnapshotBeforeUpdate=="function";ge||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T!==u||$!==ae)&&Gf(r,x,u,ae),kn=!1;var he=r.memoizedState;x.state=he,Uo(r,u,x,f),$=r.memoizedState,T!==u||he!==$||ei.current||kn?(typeof fe=="function"&&(hc(r,a,fe,u),$=r.memoizedState),(T=kn||Yf(r,a,T,u,he,$,ae))?(ge||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(r.flags|=4194308)):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=$),x.props=u,x.state=$,x.context=ae,u=T):(typeof x.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{x=r.stateNode,Cf(i,r),T=r.memoizedProps,ae=r.type===r.elementType?T:Ai(r.type,T),x.props=ae,ge=r.pendingProps,he=x.context,$=a.contextType,typeof $=="object"&&$!==null?$=Ci($):($=ti(a)?Un:Wt.current,$=Nr(r,$));var Ce=a.getDerivedStateFromProps;(fe=typeof Ce=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(T!==ge||he!==$)&&Gf(r,x,u,$),kn=!1,he=r.memoizedState,x.state=he,Uo(r,u,x,f);var Re=r.memoizedState;T!==ge||he!==Re||ei.current||kn?(typeof Ce=="function"&&(hc(r,a,Ce,u),Re=r.memoizedState),(ae=kn||Yf(r,a,ae,u,he,Re,$)||!1)?(fe||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(u,Re,$),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(u,Re,$)),typeof x.componentDidUpdate=="function"&&(r.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof x.componentDidUpdate!="function"||T===i.memoizedProps&&he===i.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||T===i.memoizedProps&&he===i.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=Re),x.props=u,x.state=Re,x.context=$,u=ae):(typeof x.componentDidUpdate!="function"||T===i.memoizedProps&&he===i.memoizedState||(r.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||T===i.memoizedProps&&he===i.memoizedState||(r.flags|=1024),u=!1)}return gc(i,r,a,u,g,f)}function gc(i,r,a,u,f,g){op(i,r);var x=(r.flags&128)!==0;if(!u&&!x)return f&&df(r,a,!1),an(i,r,g);u=r.stateNode,xS.current=r;var T=x&&typeof a.getDerivedStateFromError!="function"?null:u.render();return r.flags|=1,i!==null&&x?(r.child=Lr(r,i.child,null,g),r.child=Lr(r,null,T,g)):Yt(i,r,T,g),r.memoizedState=u.state,f&&df(r,a,!0),r.child}function lp(i){var r=i.stateNode;r.pendingContext?uf(i,r.pendingContext,r.pendingContext!==r.context):r.context&&uf(i,r.context,!1),Zl(i,r.containerInfo)}function cp(i,r,a,u,f){return Dr(),ql(f),r.flags|=256,Yt(i,r,a,u),r.child}var vc={dehydrated:null,treeContext:null,retryLane:0};function _c(i){return{baseLanes:i,cachePool:null,transitions:null}}function up(i,r,a){var u=r.pendingProps,f=lt.current,g=!1,x=(r.flags&128)!==0,T;if((T=x)||(T=i!==null&&i.memoizedState===null?!1:(f&2)!==0),T?(g=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(f|=1),it(lt,f&1),i===null)return Kl(r),i=r.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((r.mode&1)===0?r.lanes=1:i.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(x=u.children,i=u.fallback,g?(u=r.mode,g=r.child,x={mode:"hidden",children:x},(u&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=x):g=ha(x,u,0,null),i=er(i,u,a,null),g.return=r,i.return=r,g.sibling=i,r.child=g,r.child.memoizedState=_c(a),r.memoizedState=vc,i):yc(r,x));if(f=i.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return ES(i,r,x,u,T,f,a);if(g){g=u.fallback,x=r.mode,f=i.child,T=f.sibling;var $={mode:"hidden",children:u.children};return(x&1)===0&&r.child!==f?(u=r.child,u.childLanes=0,u.pendingProps=$,r.deletions=null):(u=Ln(f,$),u.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=Ln(T,g):(g=er(g,x,a,null),g.flags|=2),g.return=r,u.return=r,u.sibling=g,r.child=u,u=g,g=r.child,x=i.child.memoizedState,x=x===null?_c(a):{baseLanes:x.baseLanes|a,cachePool:null,transitions:x.transitions},g.memoizedState=x,g.childLanes=i.childLanes&~a,r.memoizedState=vc,u}return g=i.child,i=g.sibling,u=Ln(g,{mode:"visible",children:u.children}),(r.mode&1)===0&&(u.lanes=a),u.return=r,u.sibling=null,i!==null&&(a=r.deletions,a===null?(r.deletions=[i],r.flags|=16):a.push(i)),r.child=u,r.memoizedState=null,u}function yc(i,r){return r=ha({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function Jo(i,r,a,u){return u!==null&&ql(u),Lr(r,i.child,null,a),i=yc(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function ES(i,r,a,u,f,g,x){if(a)return r.flags&256?(r.flags&=-257,u=fc(Error(n(422))),Jo(i,r,x,u)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(g=u.fallback,f=r.mode,u=ha({mode:"visible",children:u.children},f,0,null),g=er(g,f,x,null),g.flags|=2,u.return=r,g.return=r,u.sibling=g,r.child=u,(r.mode&1)!==0&&Lr(r,i.child,null,x),r.child.memoizedState=_c(x),r.memoizedState=vc,g);if((r.mode&1)===0)return Jo(i,r,x,null);if(f.data==="$!"){if(u=f.nextSibling&&f.nextSibling.dataset,u)var T=u.dgst;return u=T,g=Error(n(419)),u=fc(g,u,void 0),Jo(i,r,x,u)}if(T=(x&i.childLanes)!==0,ii||T){if(u=Rt,u!==null){switch(x&-x){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&(u.suspendedLanes|x))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,sn(i,f),Oi(u,i,f,-1))}return Ac(),u=fc(Error(n(421))),Jo(i,r,x,u)}return f.data==="$?"?(r.flags|=128,r.child=i.child,r=zS.bind(null,i),f._reactRetry=r,null):(i=g.treeContext,fi=Sn(f.nextSibling),di=r,ot=!0,Ti=null,i!==null&&(wi[bi++]=nn,wi[bi++]=rn,wi[bi++]=Kn,nn=i.id,rn=i.overflow,Kn=r),r=yc(r,u.children),r.flags|=4096,r)}function hp(i,r,a){i.lanes|=r;var u=i.alternate;u!==null&&(u.lanes|=r),Gl(i.return,r,a)}function Sc(i,r,a,u,f){var g=i.memoizedState;g===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:a,tailMode:f}:(g.isBackwards=r,g.rendering=null,g.renderingStartTime=0,g.last=u,g.tail=a,g.tailMode=f)}function dp(i,r,a){var u=r.pendingProps,f=u.revealOrder,g=u.tail;if(Yt(i,r,u.children,a),u=lt.current,(u&2)!==0)u=u&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&hp(i,a,r);else if(i.tag===19)hp(i,a,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}u&=1}if(it(lt,u),(r.mode&1)===0)r.memoizedState=null;else switch(f){case"forwards":for(a=r.child,f=null;a!==null;)i=a.alternate,i!==null&&Ko(i)===null&&(f=a),a=a.sibling;a=f,a===null?(f=r.child,r.child=null):(f=a.sibling,a.sibling=null),Sc(r,!1,f,a,g);break;case"backwards":for(a=null,f=r.child,r.child=null;f!==null;){if(i=f.alternate,i!==null&&Ko(i)===null){r.child=f;break}i=f.sibling,f.sibling=a,a=f,f=i}Sc(r,!0,a,null,g);break;case"together":Sc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Zo(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function an(i,r,a){if(i!==null&&(r.dependencies=i.dependencies),Gn|=r.lanes,(a&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,a=Ln(i,i.pendingProps),r.child=a,a.return=r;i.sibling!==null;)i=i.sibling,a=a.sibling=Ln(i,i.pendingProps),a.return=r;a.sibling=null}return r.child}function NS(i,r,a){switch(r.tag){case 3:lp(r),Dr();break;case 5:Ef(r);break;case 1:ti(r.type)&&Ao(r);break;case 4:Zl(r,r.stateNode.containerInfo);break;case 10:var u=r.type._context,f=r.memoizedProps.value;it(Ho,u._currentValue),u._currentValue=f;break;case 13:if(u=r.memoizedState,u!==null)return u.dehydrated!==null?(it(lt,lt.current&1),r.flags|=128,null):(a&r.child.childLanes)!==0?up(i,r,a):(it(lt,lt.current&1),i=an(i,r,a),i!==null?i.sibling:null);it(lt,lt.current&1);break;case 19:if(u=(a&r.childLanes)!==0,(i.flags&128)!==0){if(u)return dp(i,r,a);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),it(lt,lt.current),u)break;return null;case 22:case 23:return r.lanes=0,sp(i,r,a)}return an(i,r,a)}var fp,wc,pp,mp;fp=function(i,r){for(var a=r.child;a!==null;){if(a.tag===5||a.tag===6)i.appendChild(a.stateNode);else if(a.tag!==4&&a.child!==null){a.child.return=a,a=a.child;continue}if(a===r)break;for(;a.sibling===null;){if(a.return===null||a.return===r)return;a=a.return}a.sibling.return=a.return,a=a.sibling}},wc=function(){},pp=function(i,r,a,u){var f=i.memoizedProps;if(f!==u){i=r.stateNode,Yn($i.current);var g=null;switch(a){case"input":f=Ne(i,f),u=Ne(i,u),g=[];break;case"select":f=q({},f,{value:void 0}),u=q({},u,{value:void 0}),g=[];break;case"textarea":f=Se(i,f),u=Se(i,u),g=[];break;default:typeof f.onClick!="function"&&typeof u.onClick=="function"&&(i.onclick=Mo)}Oe(a,u);var x;a=null;for(ae in f)if(!u.hasOwnProperty(ae)&&f.hasOwnProperty(ae)&&f[ae]!=null)if(ae==="style"){var T=f[ae];for(x in T)T.hasOwnProperty(x)&&(a||(a={}),a[x]="")}else ae!=="dangerouslySetInnerHTML"&&ae!=="children"&&ae!=="suppressContentEditableWarning"&&ae!=="suppressHydrationWarning"&&ae!=="autoFocus"&&(o.hasOwnProperty(ae)?g||(g=[]):(g=g||[]).push(ae,null));for(ae in u){var $=u[ae];if(T=f!=null?f[ae]:void 0,u.hasOwnProperty(ae)&&$!==T&&($!=null||T!=null))if(ae==="style")if(T){for(x in T)!T.hasOwnProperty(x)||$&&$.hasOwnProperty(x)||(a||(a={}),a[x]="");for(x in $)$.hasOwnProperty(x)&&T[x]!==$[x]&&(a||(a={}),a[x]=$[x])}else a||(g||(g=[]),g.push(ae,a)),a=$;else ae==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,T=T?T.__html:void 0,$!=null&&T!==$&&(g=g||[]).push(ae,$)):ae==="children"?typeof $!="string"&&typeof $!="number"||(g=g||[]).push(ae,""+$):ae!=="suppressContentEditableWarning"&&ae!=="suppressHydrationWarning"&&(o.hasOwnProperty(ae)?($!=null&&ae==="onScroll"&&nt("scroll",i),g||T===$||(g=[])):(g=g||[]).push(ae,$))}a&&(g=g||[]).push("style",a);var ae=g;(r.updateQueue=ae)&&(r.flags|=4)}},mp=function(i,r,a,u){a!==u&&(r.flags|=4)};function js(i,r){if(!ot)switch(i.tailMode){case"hidden":r=i.tail;for(var a=null;r!==null;)r.alternate!==null&&(a=r),r=r.sibling;a===null?i.tail=null:a.sibling=null;break;case"collapsed":a=i.tail;for(var u=null;a!==null;)a.alternate!==null&&(u=a),a=a.sibling;u===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:u.sibling=null}}function Kt(i){var r=i.alternate!==null&&i.alternate.child===i.child,a=0,u=0;if(r)for(var f=i.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags&14680064,u|=f.flags&14680064,f.return=i,f=f.sibling;else for(f=i.child;f!==null;)a|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=i,f=f.sibling;return i.subtreeFlags|=u,i.childLanes=a,r}function RS(i,r,a){var u=r.pendingProps;switch(Wl(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kt(r),null;case 1:return ti(r.type)&&To(),Kt(r),null;case 3:return u=r.stateNode,Tr(),rt(ei),rt(Wt),ic(),u.pendingContext&&(u.context=u.pendingContext,u.pendingContext=null),(i===null||i.child===null)&&(zo(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ti!==null&&(Mc(Ti),Ti=null))),wc(i,r),Kt(r),null;case 5:ec(r);var f=Yn(Rs.current);if(a=r.type,i!==null&&r.stateNode!=null)pp(i,r,a,u,f),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!u){if(r.stateNode===null)throw Error(n(166));return Kt(r),null}if(i=Yn($i.current),zo(r)){u=r.stateNode,a=r.type;var g=r.memoizedProps;switch(u[Hi]=r,u[Cs]=g,i=(r.mode&1)!==0,a){case"dialog":nt("cancel",u),nt("close",u);break;case"iframe":case"object":case"embed":nt("load",u);break;case"video":case"audio":for(f=0;f<Ss.length;f++)nt(Ss[f],u);break;case"source":nt("error",u);break;case"img":case"image":case"link":nt("error",u),nt("load",u);break;case"details":nt("toggle",u);break;case"input":ke(u,g),nt("invalid",u);break;case"select":u._wrapperState={wasMultiple:!!g.multiple},nt("invalid",u);break;case"textarea":Xe(u,g),nt("invalid",u)}Oe(a,g),f=null;for(var x in g)if(g.hasOwnProperty(x)){var T=g[x];x==="children"?typeof T=="string"?u.textContent!==T&&(g.suppressHydrationWarning!==!0&&Lo(u.textContent,T,i),f=["children",T]):typeof T=="number"&&u.textContent!==""+T&&(g.suppressHydrationWarning!==!0&&Lo(u.textContent,T,i),f=["children",""+T]):o.hasOwnProperty(x)&&T!=null&&x==="onScroll"&&nt("scroll",u)}switch(a){case"input":xe(u),Ke(u,g,!0);break;case"textarea":xe(u),$t(u);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(u.onclick=Mo)}u=f,r.updateQueue=u,u!==null&&(r.flags|=4)}else{x=f.nodeType===9?f:f.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Zt(a)),i==="http://www.w3.org/1999/xhtml"?a==="script"?(i=x.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof u.is=="string"?i=x.createElement(a,{is:u.is}):(i=x.createElement(a),a==="select"&&(x=i,u.multiple?x.multiple=!0:u.size&&(x.size=u.size))):i=x.createElementNS(i,a),i[Hi]=r,i[Cs]=u,fp(i,r,!1,!1),r.stateNode=i;e:{switch(x=Et(a,u),a){case"dialog":nt("cancel",i),nt("close",i),f=u;break;case"iframe":case"object":case"embed":nt("load",i),f=u;break;case"video":case"audio":for(f=0;f<Ss.length;f++)nt(Ss[f],i);f=u;break;case"source":nt("error",i),f=u;break;case"img":case"image":case"link":nt("error",i),nt("load",i),f=u;break;case"details":nt("toggle",i),f=u;break;case"input":ke(i,u),f=Ne(i,u),nt("invalid",i);break;case"option":f=u;break;case"select":i._wrapperState={wasMultiple:!!u.multiple},f=q({},u,{value:void 0}),nt("invalid",i);break;case"textarea":Xe(i,u),f=Se(i,u),nt("invalid",i);break;default:f=u}Oe(a,f),T=f;for(g in T)if(T.hasOwnProperty(g)){var $=T[g];g==="style"?ce(i,$):g==="dangerouslySetInnerHTML"?($=$?$.__html:void 0,$!=null&&Si(i,$)):g==="children"?typeof $=="string"?(a!=="textarea"||$!=="")&&qe(i,$):typeof $=="number"&&qe(i,""+$):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(o.hasOwnProperty(g)?$!=null&&g==="onScroll"&&nt("scroll",i):$!=null&&B(i,g,$,x))}switch(a){case"input":xe(i),Ke(i,u,!1);break;case"textarea":xe(i),$t(i);break;case"option":u.value!=null&&i.setAttribute("value",""+z(u.value));break;case"select":i.multiple=!!u.multiple,g=u.value,g!=null?Te(i,!!u.multiple,g,!1):u.defaultValue!=null&&Te(i,!!u.multiple,u.defaultValue,!0);break;default:typeof f.onClick=="function"&&(i.onclick=Mo)}switch(a){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}}u&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return Kt(r),null;case 6:if(i&&r.stateNode!=null)mp(i,r,i.memoizedProps,u);else{if(typeof u!="string"&&r.stateNode===null)throw Error(n(166));if(a=Yn(Rs.current),Yn($i.current),zo(r)){if(u=r.stateNode,a=r.memoizedProps,u[Hi]=r,(g=u.nodeValue!==a)&&(i=di,i!==null))switch(i.tag){case 3:Lo(u.nodeValue,a,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Lo(u.nodeValue,a,(i.mode&1)!==0)}g&&(r.flags|=4)}else u=(a.nodeType===9?a:a.ownerDocument).createTextNode(u),u[Hi]=r,r.stateNode=u}return Kt(r),null;case 13:if(rt(lt),u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(ot&&fi!==null&&(r.mode&1)!==0&&(r.flags&128)===0)_f(),Dr(),r.flags|=98560,g=!1;else if(g=zo(r),u!==null&&u.dehydrated!==null){if(i===null){if(!g)throw Error(n(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(n(317));g[Hi]=r}else Dr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Kt(r),g=!1}else Ti!==null&&(Mc(Ti),Ti=null),g=!0;if(!g)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=a,r):(u=u!==null,u!==(i!==null&&i.memoizedState!==null)&&u&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(lt.current&1)!==0?bt===0&&(bt=3):Ac())),r.updateQueue!==null&&(r.flags|=4),Kt(r),null);case 4:return Tr(),wc(i,r),i===null&&ws(r.stateNode.containerInfo),Kt(r),null;case 10:return Xl(r.type._context),Kt(r),null;case 17:return ti(r.type)&&To(),Kt(r),null;case 19:if(rt(lt),g=r.memoizedState,g===null)return Kt(r),null;if(u=(r.flags&128)!==0,x=g.rendering,x===null)if(u)js(g,!1);else{if(bt!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(x=Ko(i),x!==null){for(r.flags|=128,js(g,!1),u=x.updateQueue,u!==null&&(r.updateQueue=u,r.flags|=4),r.subtreeFlags=0,u=a,a=r.child;a!==null;)g=a,i=u,g.flags&=14680066,x=g.alternate,x===null?(g.childLanes=0,g.lanes=i,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=x.childLanes,g.lanes=x.lanes,g.child=x.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=x.memoizedProps,g.memoizedState=x.memoizedState,g.updateQueue=x.updateQueue,g.type=x.type,i=x.dependencies,g.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),a=a.sibling;return it(lt,lt.current&1|2),r.child}i=i.sibling}g.tail!==null&&mt()>Or&&(r.flags|=128,u=!0,js(g,!1),r.lanes=4194304)}else{if(!u)if(i=Ko(x),i!==null){if(r.flags|=128,u=!0,a=i.updateQueue,a!==null&&(r.updateQueue=a,r.flags|=4),js(g,!0),g.tail===null&&g.tailMode==="hidden"&&!x.alternate&&!ot)return Kt(r),null}else 2*mt()-g.renderingStartTime>Or&&a!==1073741824&&(r.flags|=128,u=!0,js(g,!1),r.lanes=4194304);g.isBackwards?(x.sibling=r.child,r.child=x):(a=g.last,a!==null?a.sibling=x:r.child=x,g.last=x)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=mt(),r.sibling=null,a=lt.current,it(lt,u?a&1|2:a&1),r):(Kt(r),null);case 22:case 23:return Tc(),u=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==u&&(r.flags|=8192),u&&(r.mode&1)!==0?(pi&1073741824)!==0&&(Kt(r),r.subtreeFlags&6&&(r.flags|=8192)):Kt(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function PS(i,r){switch(Wl(r),r.tag){case 1:return ti(r.type)&&To(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Tr(),rt(ei),rt(Wt),ic(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return ec(r),null;case 13:if(rt(lt),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));Dr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return rt(lt),null;case 4:return Tr(),null;case 10:return Xl(r.type._context),null;case 22:case 23:return Tc(),null;case 24:return null;default:return null}}var ea=!1,qt=!1,DS=typeof WeakSet=="function"?WeakSet:Set,Ee=null;function Br(i,r){var a=i.ref;if(a!==null)if(typeof a=="function")try{a(null)}catch(u){dt(i,r,u)}else a.current=null}function bc(i,r,a){try{a()}catch(u){dt(i,r,u)}}var gp=!1;function LS(i,r){if(Tl=So,i=Vd(),El(i)){if("selectionStart"in i)var a={start:i.selectionStart,end:i.selectionEnd};else e:{a=(a=i.ownerDocument)&&a.defaultView||window;var u=a.getSelection&&a.getSelection();if(u&&u.rangeCount!==0){a=u.anchorNode;var f=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{a.nodeType,g.nodeType}catch{a=null;break e}var x=0,T=-1,$=-1,ae=0,fe=0,ge=i,he=null;t:for(;;){for(var Ce;ge!==a||f!==0&&ge.nodeType!==3||(T=x+f),ge!==g||u!==0&&ge.nodeType!==3||($=x+u),ge.nodeType===3&&(x+=ge.nodeValue.length),(Ce=ge.firstChild)!==null;)he=ge,ge=Ce;for(;;){if(ge===i)break t;if(he===a&&++ae===f&&(T=x),he===g&&++fe===u&&($=x),(Ce=ge.nextSibling)!==null)break;ge=he,he=ge.parentNode}ge=Ce}a=T===-1||$===-1?null:{start:T,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(Al={focusedElem:i,selectionRange:a},So=!1,Ee=r;Ee!==null;)if(r=Ee,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Ee=i;else for(;Ee!==null;){r=Ee;try{var Re=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Re!==null){var De=Re.memoizedProps,gt=Re.memoizedState,ee=r.stateNode,Y=ee.getSnapshotBeforeUpdate(r.elementType===r.type?De:Ai(r.type,De),gt);ee.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var ne=r.stateNode.containerInfo;ne.nodeType===1?ne.textContent="":ne.nodeType===9&&ne.documentElement&&ne.removeChild(ne.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ve){dt(r,r.return,ve)}if(i=r.sibling,i!==null){i.return=r.return,Ee=i;break}Ee=r.return}return Re=gp,gp=!1,Re}function Ts(i,r,a){var u=r.updateQueue;if(u=u!==null?u.lastEffect:null,u!==null){var f=u=u.next;do{if((f.tag&i)===i){var g=f.destroy;f.destroy=void 0,g!==void 0&&bc(r,a,g)}f=f.next}while(f!==u)}}function ta(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&i)===i){var u=a.create;a.destroy=u()}a=a.next}while(a!==r)}}function Cc(i){var r=i.ref;if(r!==null){var a=i.stateNode;switch(i.tag){case 5:i=a;break;default:i=a}typeof r=="function"?r(i):r.current=i}}function vp(i){var r=i.alternate;r!==null&&(i.alternate=null,vp(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[Hi],delete r[Cs],delete r[zl],delete r[fS],delete r[pS])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function _p(i){return i.tag===5||i.tag===3||i.tag===4}function yp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||_p(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function kc(i,r,a){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?a.nodeType===8?a.parentNode.insertBefore(i,r):a.insertBefore(i,r):(a.nodeType===8?(r=a.parentNode,r.insertBefore(i,a)):(r=a,r.appendChild(i)),a=a._reactRootContainer,a!=null||r.onclick!==null||(r.onclick=Mo));else if(u!==4&&(i=i.child,i!==null))for(kc(i,r,a),i=i.sibling;i!==null;)kc(i,r,a),i=i.sibling}function xc(i,r,a){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?a.insertBefore(i,r):a.appendChild(i);else if(u!==4&&(i=i.child,i!==null))for(xc(i,r,a),i=i.sibling;i!==null;)xc(i,r,a),i=i.sibling}var It=null,Bi=!1;function En(i,r,a){for(a=a.child;a!==null;)Sp(i,r,a),a=a.sibling}function Sp(i,r,a){if(Fi&&typeof Fi.onCommitFiberUnmount=="function")try{Fi.onCommitFiberUnmount(po,a)}catch{}switch(a.tag){case 5:qt||Br(a,r);case 6:var u=It,f=Bi;It=null,En(i,r,a),It=u,Bi=f,It!==null&&(Bi?(i=It,a=a.stateNode,i.nodeType===8?i.parentNode.removeChild(a):i.removeChild(a)):It.removeChild(a.stateNode));break;case 18:It!==null&&(Bi?(i=It,a=a.stateNode,i.nodeType===8?Ol(i.parentNode,a):i.nodeType===1&&Ol(i,a),ds(i)):Ol(It,a.stateNode));break;case 4:u=It,f=Bi,It=a.stateNode.containerInfo,Bi=!0,En(i,r,a),It=u,Bi=f;break;case 0:case 11:case 14:case 15:if(!qt&&(u=a.updateQueue,u!==null&&(u=u.lastEffect,u!==null))){f=u=u.next;do{var g=f,x=g.destroy;g=g.tag,x!==void 0&&((g&2)!==0||(g&4)!==0)&&bc(a,r,x),f=f.next}while(f!==u)}En(i,r,a);break;case 1:if(!qt&&(Br(a,r),u=a.stateNode,typeof u.componentWillUnmount=="function"))try{u.props=a.memoizedProps,u.state=a.memoizedState,u.componentWillUnmount()}catch(T){dt(a,r,T)}En(i,r,a);break;case 21:En(i,r,a);break;case 22:a.mode&1?(qt=(u=qt)||a.memoizedState!==null,En(i,r,a),qt=u):En(i,r,a);break;default:En(i,r,a)}}function wp(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var a=i.stateNode;a===null&&(a=i.stateNode=new DS),r.forEach(function(u){var f=FS.bind(null,i,u);a.has(u)||(a.add(u),u.then(f,f))})}}function Ii(i,r){var a=r.deletions;if(a!==null)for(var u=0;u<a.length;u++){var f=a[u];try{var g=i,x=r,T=x;e:for(;T!==null;){switch(T.tag){case 5:It=T.stateNode,Bi=!1;break e;case 3:It=T.stateNode.containerInfo,Bi=!0;break e;case 4:It=T.stateNode.containerInfo,Bi=!0;break e}T=T.return}if(It===null)throw Error(n(160));Sp(g,x,f),It=null,Bi=!1;var $=f.alternate;$!==null&&($.return=null),f.return=null}catch(ae){dt(f,r,ae)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)bp(r,i),r=r.sibling}function bp(i,r){var a=i.alternate,u=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(Ii(r,i),Ui(i),u&4){try{Ts(3,i,i.return),ta(3,i)}catch(De){dt(i,i.return,De)}try{Ts(5,i,i.return)}catch(De){dt(i,i.return,De)}}break;case 1:Ii(r,i),Ui(i),u&512&&a!==null&&Br(a,a.return);break;case 5:if(Ii(r,i),Ui(i),u&512&&a!==null&&Br(a,a.return),i.flags&32){var f=i.stateNode;try{qe(f,"")}catch(De){dt(i,i.return,De)}}if(u&4&&(f=i.stateNode,f!=null)){var g=i.memoizedProps,x=a!==null?a.memoizedProps:g,T=i.type,$=i.updateQueue;if(i.updateQueue=null,$!==null)try{T==="input"&&g.type==="radio"&&g.name!=null&&Ve(f,g),Et(T,x);var ae=Et(T,g);for(x=0;x<$.length;x+=2){var fe=$[x],ge=$[x+1];fe==="style"?ce(f,ge):fe==="dangerouslySetInnerHTML"?Si(f,ge):fe==="children"?qe(f,ge):B(f,fe,ge,ae)}switch(T){case"input":Qe(f,g);break;case"textarea":ci(f,g);break;case"select":var he=f._wrapperState.wasMultiple;f._wrapperState.wasMultiple=!!g.multiple;var Ce=g.value;Ce!=null?Te(f,!!g.multiple,Ce,!1):he!==!!g.multiple&&(g.defaultValue!=null?Te(f,!!g.multiple,g.defaultValue,!0):Te(f,!!g.multiple,g.multiple?[]:"",!1))}f[Cs]=g}catch(De){dt(i,i.return,De)}}break;case 6:if(Ii(r,i),Ui(i),u&4){if(i.stateNode===null)throw Error(n(162));f=i.stateNode,g=i.memoizedProps;try{f.nodeValue=g}catch(De){dt(i,i.return,De)}}break;case 3:if(Ii(r,i),Ui(i),u&4&&a!==null&&a.memoizedState.isDehydrated)try{ds(r.containerInfo)}catch(De){dt(i,i.return,De)}break;case 4:Ii(r,i),Ui(i);break;case 13:Ii(r,i),Ui(i),f=i.child,f.flags&8192&&(g=f.memoizedState!==null,f.stateNode.isHidden=g,!g||f.alternate!==null&&f.alternate.memoizedState!==null||(Rc=mt())),u&4&&wp(i);break;case 22:if(fe=a!==null&&a.memoizedState!==null,i.mode&1?(qt=(ae=qt)||fe,Ii(r,i),qt=ae):Ii(r,i),Ui(i),u&8192){if(ae=i.memoizedState!==null,(i.stateNode.isHidden=ae)&&!fe&&(i.mode&1)!==0)for(Ee=i,fe=i.child;fe!==null;){for(ge=Ee=fe;Ee!==null;){switch(he=Ee,Ce=he.child,he.tag){case 0:case 11:case 14:case 15:Ts(4,he,he.return);break;case 1:Br(he,he.return);var Re=he.stateNode;if(typeof Re.componentWillUnmount=="function"){u=he,a=he.return;try{r=u,Re.props=r.memoizedProps,Re.state=r.memoizedState,Re.componentWillUnmount()}catch(De){dt(u,a,De)}}break;case 5:Br(he,he.return);break;case 22:if(he.memoizedState!==null){xp(ge);continue}}Ce!==null?(Ce.return=he,Ee=Ce):xp(ge)}fe=fe.sibling}e:for(fe=null,ge=i;;){if(ge.tag===5){if(fe===null){fe=ge;try{f=ge.stateNode,ae?(g=f.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(T=ge.stateNode,$=ge.memoizedProps.style,x=$!=null&&$.hasOwnProperty("display")?$.display:null,T.style.display=Je("display",x))}catch(De){dt(i,i.return,De)}}}else if(ge.tag===6){if(fe===null)try{ge.stateNode.nodeValue=ae?"":ge.memoizedProps}catch(De){dt(i,i.return,De)}}else if((ge.tag!==22&&ge.tag!==23||ge.memoizedState===null||ge===i)&&ge.child!==null){ge.child.return=ge,ge=ge.child;continue}if(ge===i)break e;for(;ge.sibling===null;){if(ge.return===null||ge.return===i)break e;fe===ge&&(fe=null),ge=ge.return}fe===ge&&(fe=null),ge.sibling.return=ge.return,ge=ge.sibling}}break;case 19:Ii(r,i),Ui(i),u&4&&wp(i);break;case 21:break;default:Ii(r,i),Ui(i)}}function Ui(i){var r=i.flags;if(r&2){try{e:{for(var a=i.return;a!==null;){if(_p(a)){var u=a;break e}a=a.return}throw Error(n(160))}switch(u.tag){case 5:var f=u.stateNode;u.flags&32&&(qe(f,""),u.flags&=-33);var g=yp(i);xc(i,g,f);break;case 3:case 4:var x=u.stateNode.containerInfo,T=yp(i);kc(i,T,x);break;default:throw Error(n(161))}}catch($){dt(i,i.return,$)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function MS(i,r,a){Ee=i,Cp(i)}function Cp(i,r,a){for(var u=(i.mode&1)!==0;Ee!==null;){var f=Ee,g=f.child;if(f.tag===22&&u){var x=f.memoizedState!==null||ea;if(!x){var T=f.alternate,$=T!==null&&T.memoizedState!==null||qt;T=ea;var ae=qt;if(ea=x,(qt=$)&&!ae)for(Ee=f;Ee!==null;)x=Ee,$=x.child,x.tag===22&&x.memoizedState!==null?Ep(f):$!==null?($.return=x,Ee=$):Ep(f);for(;g!==null;)Ee=g,Cp(g),g=g.sibling;Ee=f,ea=T,qt=ae}kp(i)}else(f.subtreeFlags&8772)!==0&&g!==null?(g.return=f,Ee=g):kp(i)}}function kp(i){for(;Ee!==null;){var r=Ee;if((r.flags&8772)!==0){var a=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:qt||ta(5,r);break;case 1:var u=r.stateNode;if(r.flags&4&&!qt)if(a===null)u.componentDidMount();else{var f=r.elementType===r.type?a.memoizedProps:Ai(r.type,a.memoizedProps);u.componentDidUpdate(f,a.memoizedState,u.__reactInternalSnapshotBeforeUpdate)}var g=r.updateQueue;g!==null&&xf(r,g,u);break;case 3:var x=r.updateQueue;if(x!==null){if(a=null,r.child!==null)switch(r.child.tag){case 5:a=r.child.stateNode;break;case 1:a=r.child.stateNode}xf(r,x,a)}break;case 5:var T=r.stateNode;if(a===null&&r.flags&4){a=T;var $=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":$.autoFocus&&a.focus();break;case"img":$.src&&(a.src=$.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var ae=r.alternate;if(ae!==null){var fe=ae.memoizedState;if(fe!==null){var ge=fe.dehydrated;ge!==null&&ds(ge)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}qt||r.flags&512&&Cc(r)}catch(he){dt(r,r.return,he)}}if(r===i){Ee=null;break}if(a=r.sibling,a!==null){a.return=r.return,Ee=a;break}Ee=r.return}}function xp(i){for(;Ee!==null;){var r=Ee;if(r===i){Ee=null;break}var a=r.sibling;if(a!==null){a.return=r.return,Ee=a;break}Ee=r.return}}function Ep(i){for(;Ee!==null;){var r=Ee;try{switch(r.tag){case 0:case 11:case 15:var a=r.return;try{ta(4,r)}catch($){dt(r,a,$)}break;case 1:var u=r.stateNode;if(typeof u.componentDidMount=="function"){var f=r.return;try{u.componentDidMount()}catch($){dt(r,f,$)}}var g=r.return;try{Cc(r)}catch($){dt(r,g,$)}break;case 5:var x=r.return;try{Cc(r)}catch($){dt(r,x,$)}}}catch($){dt(r,r.return,$)}if(r===i){Ee=null;break}var T=r.sibling;if(T!==null){T.return=r.return,Ee=T;break}Ee=r.return}}var jS=Math.ceil,ia=A.ReactCurrentDispatcher,Ec=A.ReactCurrentOwner,xi=A.ReactCurrentBatchConfig,Ye=0,Rt=null,_t=null,Ot=0,pi=0,Ir=wn(0),bt=0,As=null,Gn=0,na=0,Nc=0,Bs=null,ni=null,Rc=0,Or=1/0,ln=null,ra=!1,Pc=null,Nn=null,sa=!1,Rn=null,oa=0,Is=0,Dc=null,aa=-1,la=0;function Xt(){return(Ye&6)!==0?mt():aa!==-1?aa:aa=mt()}function Pn(i){return(i.mode&1)===0?1:(Ye&2)!==0&&Ot!==0?Ot&-Ot:gS.transition!==null?(la===0&&(la=_d()),la):(i=et,i!==0||(i=window.event,i=i===void 0?16:Nd(i.type)),i)}function Oi(i,r,a,u){if(50<Is)throw Is=0,Dc=null,Error(n(185));as(i,a,u),((Ye&2)===0||i!==Rt)&&(i===Rt&&((Ye&2)===0&&(na|=a),bt===4&&Dn(i,Ot)),ri(i,u),a===1&&Ye===0&&(r.mode&1)===0&&(Or=mt()+500,Bo&&Cn()))}function ri(i,r){var a=i.callbackNode;gy(i,r);var u=vo(i,i===Rt?Ot:0);if(u===0)a!==null&&md(a),i.callbackNode=null,i.callbackPriority=0;else if(r=u&-u,i.callbackPriority!==r){if(a!=null&&md(a),r===1)i.tag===0?mS(Rp.bind(null,i)):ff(Rp.bind(null,i)),hS(function(){(Ye&6)===0&&Cn()}),a=null;else{switch(yd(u)){case 1:a=cl;break;case 4:a=gd;break;case 16:a=fo;break;case 536870912:a=vd;break;default:a=fo}a=Bp(a,Np.bind(null,i))}i.callbackPriority=r,i.callbackNode=a}}function Np(i,r){if(aa=-1,la=0,(Ye&6)!==0)throw Error(n(327));var a=i.callbackNode;if(zr()&&i.callbackNode!==a)return null;var u=vo(i,i===Rt?Ot:0);if(u===0)return null;if((u&30)!==0||(u&i.expiredLanes)!==0||r)r=ca(i,u);else{r=u;var f=Ye;Ye|=2;var g=Dp();(Rt!==i||Ot!==r)&&(ln=null,Or=mt()+500,Jn(i,r));do try{BS();break}catch(T){Pp(i,T)}while(!0);Yl(),ia.current=g,Ye=f,_t!==null?r=0:(Rt=null,Ot=0,r=bt)}if(r!==0){if(r===2&&(f=ul(i),f!==0&&(u=f,r=Lc(i,f))),r===1)throw a=As,Jn(i,0),Dn(i,u),ri(i,mt()),a;if(r===6)Dn(i,u);else{if(f=i.current.alternate,(u&30)===0&&!TS(f)&&(r=ca(i,u),r===2&&(g=ul(i),g!==0&&(u=g,r=Lc(i,g))),r===1))throw a=As,Jn(i,0),Dn(i,u),ri(i,mt()),a;switch(i.finishedWork=f,i.finishedLanes=u,r){case 0:case 1:throw Error(n(345));case 2:Zn(i,ni,ln);break;case 3:if(Dn(i,u),(u&130023424)===u&&(r=Rc+500-mt(),10<r)){if(vo(i,0)!==0)break;if(f=i.suspendedLanes,(f&u)!==u){Xt(),i.pingedLanes|=i.suspendedLanes&f;break}i.timeoutHandle=Il(Zn.bind(null,i,ni,ln),r);break}Zn(i,ni,ln);break;case 4:if(Dn(i,u),(u&4194240)===u)break;for(r=i.eventTimes,f=-1;0<u;){var x=31-Mi(u);g=1<<x,x=r[x],x>f&&(f=x),u&=~g}if(u=f,u=mt()-u,u=(120>u?120:480>u?480:1080>u?1080:1920>u?1920:3e3>u?3e3:4320>u?4320:1960*jS(u/1960))-u,10<u){i.timeoutHandle=Il(Zn.bind(null,i,ni,ln),u);break}Zn(i,ni,ln);break;case 5:Zn(i,ni,ln);break;default:throw Error(n(329))}}}return ri(i,mt()),i.callbackNode===a?Np.bind(null,i):null}function Lc(i,r){var a=Bs;return i.current.memoizedState.isDehydrated&&(Jn(i,r).flags|=256),i=ca(i,r),i!==2&&(r=ni,ni=a,r!==null&&Mc(r)),i}function Mc(i){ni===null?ni=i:ni.push.apply(ni,i)}function TS(i){for(var r=i;;){if(r.flags&16384){var a=r.updateQueue;if(a!==null&&(a=a.stores,a!==null))for(var u=0;u<a.length;u++){var f=a[u],g=f.getSnapshot;f=f.value;try{if(!ji(g(),f))return!1}catch{return!1}}}if(a=r.child,r.subtreeFlags&16384&&a!==null)a.return=r,r=a;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Dn(i,r){for(r&=~Nc,r&=~na,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var a=31-Mi(r),u=1<<a;i[a]=-1,r&=~u}}function Rp(i){if((Ye&6)!==0)throw Error(n(327));zr();var r=vo(i,0);if((r&1)===0)return ri(i,mt()),null;var a=ca(i,r);if(i.tag!==0&&a===2){var u=ul(i);u!==0&&(r=u,a=Lc(i,u))}if(a===1)throw a=As,Jn(i,0),Dn(i,r),ri(i,mt()),a;if(a===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,Zn(i,ni,ln),ri(i,mt()),null}function jc(i,r){var a=Ye;Ye|=1;try{return i(r)}finally{Ye=a,Ye===0&&(Or=mt()+500,Bo&&Cn())}}function Qn(i){Rn!==null&&Rn.tag===0&&(Ye&6)===0&&zr();var r=Ye;Ye|=1;var a=xi.transition,u=et;try{if(xi.transition=null,et=1,i)return i()}finally{et=u,xi.transition=a,Ye=r,(Ye&6)===0&&Cn()}}function Tc(){pi=Ir.current,rt(Ir)}function Jn(i,r){i.finishedWork=null,i.finishedLanes=0;var a=i.timeoutHandle;if(a!==-1&&(i.timeoutHandle=-1,uS(a)),_t!==null)for(a=_t.return;a!==null;){var u=a;switch(Wl(u),u.tag){case 1:u=u.type.childContextTypes,u!=null&&To();break;case 3:Tr(),rt(ei),rt(Wt),ic();break;case 5:ec(u);break;case 4:Tr();break;case 13:rt(lt);break;case 19:rt(lt);break;case 10:Xl(u.type._context);break;case 22:case 23:Tc()}a=a.return}if(Rt=i,_t=i=Ln(i.current,null),Ot=pi=r,bt=0,As=null,Nc=na=Gn=0,ni=Bs=null,Vn!==null){for(r=0;r<Vn.length;r++)if(a=Vn[r],u=a.interleaved,u!==null){a.interleaved=null;var f=u.next,g=a.pending;if(g!==null){var x=g.next;g.next=f,u.next=x}a.pending=u}Vn=null}return i}function Pp(i,r){do{var a=_t;try{if(Yl(),qo.current=Go,Vo){for(var u=ct.memoizedState;u!==null;){var f=u.queue;f!==null&&(f.pending=null),u=u.next}Vo=!1}if(Xn=0,Nt=wt=ct=null,Ps=!1,Ds=0,Ec.current=null,a===null||a.return===null){bt=1,As=r,_t=null;break}e:{var g=i,x=a.return,T=a,$=r;if(r=Ot,T.flags|=32768,$!==null&&typeof $=="object"&&typeof $.then=="function"){var ae=$,fe=T,ge=fe.tag;if((fe.mode&1)===0&&(ge===0||ge===11||ge===15)){var he=fe.alternate;he?(fe.updateQueue=he.updateQueue,fe.memoizedState=he.memoizedState,fe.lanes=he.lanes):(fe.updateQueue=null,fe.memoizedState=null)}var Ce=ep(x);if(Ce!==null){Ce.flags&=-257,tp(Ce,x,T,g,r),Ce.mode&1&&Zf(g,ae,r),r=Ce,$=ae;var Re=r.updateQueue;if(Re===null){var De=new Set;De.add($),r.updateQueue=De}else Re.add($);break e}else{if((r&1)===0){Zf(g,ae,r),Ac();break e}$=Error(n(426))}}else if(ot&&T.mode&1){var gt=ep(x);if(gt!==null){(gt.flags&65536)===0&&(gt.flags|=256),tp(gt,x,T,g,r),ql(Ar($,T));break e}}g=$=Ar($,T),bt!==4&&(bt=2),Bs===null?Bs=[g]:Bs.push(g),g=x;do{switch(g.tag){case 3:g.flags|=65536,r&=-r,g.lanes|=r;var ee=Qf(g,$,r);kf(g,ee);break e;case 1:T=$;var Y=g.type,ne=g.stateNode;if((g.flags&128)===0&&(typeof Y.getDerivedStateFromError=="function"||ne!==null&&typeof ne.componentDidCatch=="function"&&(Nn===null||!Nn.has(ne)))){g.flags|=65536,r&=-r,g.lanes|=r;var ve=Jf(g,T,r);kf(g,ve);break e}}g=g.return}while(g!==null)}Mp(a)}catch(Le){r=Le,_t===a&&a!==null&&(_t=a=a.return);continue}break}while(!0)}function Dp(){var i=ia.current;return ia.current=Go,i===null?Go:i}function Ac(){(bt===0||bt===3||bt===2)&&(bt=4),Rt===null||(Gn&268435455)===0&&(na&268435455)===0||Dn(Rt,Ot)}function ca(i,r){var a=Ye;Ye|=2;var u=Dp();(Rt!==i||Ot!==r)&&(ln=null,Jn(i,r));do try{AS();break}catch(f){Pp(i,f)}while(!0);if(Yl(),Ye=a,ia.current=u,_t!==null)throw Error(n(261));return Rt=null,Ot=0,bt}function AS(){for(;_t!==null;)Lp(_t)}function BS(){for(;_t!==null&&!ay();)Lp(_t)}function Lp(i){var r=Ap(i.alternate,i,pi);i.memoizedProps=i.pendingProps,r===null?Mp(i):_t=r,Ec.current=null}function Mp(i){var r=i;do{var a=r.alternate;if(i=r.return,(r.flags&32768)===0){if(a=RS(a,r,pi),a!==null){_t=a;return}}else{if(a=PS(a,r),a!==null){a.flags&=32767,_t=a;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{bt=6,_t=null;return}}if(r=r.sibling,r!==null){_t=r;return}_t=r=i}while(r!==null);bt===0&&(bt=5)}function Zn(i,r,a){var u=et,f=xi.transition;try{xi.transition=null,et=1,IS(i,r,a,u)}finally{xi.transition=f,et=u}return null}function IS(i,r,a,u){do zr();while(Rn!==null);if((Ye&6)!==0)throw Error(n(327));a=i.finishedWork;var f=i.finishedLanes;if(a===null)return null;if(i.finishedWork=null,i.finishedLanes=0,a===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var g=a.lanes|a.childLanes;if(vy(i,g),i===Rt&&(_t=Rt=null,Ot=0),(a.subtreeFlags&2064)===0&&(a.flags&2064)===0||sa||(sa=!0,Bp(fo,function(){return zr(),null})),g=(a.flags&15990)!==0,(a.subtreeFlags&15990)!==0||g){g=xi.transition,xi.transition=null;var x=et;et=1;var T=Ye;Ye|=4,Ec.current=null,LS(i,a),bp(a,i),nS(Al),So=!!Tl,Al=Tl=null,i.current=a,MS(a),ly(),Ye=T,et=x,xi.transition=g}else i.current=a;if(sa&&(sa=!1,Rn=i,oa=f),g=i.pendingLanes,g===0&&(Nn=null),hy(a.stateNode),ri(i,mt()),r!==null)for(u=i.onRecoverableError,a=0;a<r.length;a++)f=r[a],u(f.value,{componentStack:f.stack,digest:f.digest});if(ra)throw ra=!1,i=Pc,Pc=null,i;return(oa&1)!==0&&i.tag!==0&&zr(),g=i.pendingLanes,(g&1)!==0?i===Dc?Is++:(Is=0,Dc=i):Is=0,Cn(),null}function zr(){if(Rn!==null){var i=yd(oa),r=xi.transition,a=et;try{if(xi.transition=null,et=16>i?16:i,Rn===null)var u=!1;else{if(i=Rn,Rn=null,oa=0,(Ye&6)!==0)throw Error(n(331));var f=Ye;for(Ye|=4,Ee=i.current;Ee!==null;){var g=Ee,x=g.child;if((Ee.flags&16)!==0){var T=g.deletions;if(T!==null){for(var $=0;$<T.length;$++){var ae=T[$];for(Ee=ae;Ee!==null;){var fe=Ee;switch(fe.tag){case 0:case 11:case 15:Ts(8,fe,g)}var ge=fe.child;if(ge!==null)ge.return=fe,Ee=ge;else for(;Ee!==null;){fe=Ee;var he=fe.sibling,Ce=fe.return;if(vp(fe),fe===ae){Ee=null;break}if(he!==null){he.return=Ce,Ee=he;break}Ee=Ce}}}var Re=g.alternate;if(Re!==null){var De=Re.child;if(De!==null){Re.child=null;do{var gt=De.sibling;De.sibling=null,De=gt}while(De!==null)}}Ee=g}}if((g.subtreeFlags&2064)!==0&&x!==null)x.return=g,Ee=x;else e:for(;Ee!==null;){if(g=Ee,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:Ts(9,g,g.return)}var ee=g.sibling;if(ee!==null){ee.return=g.return,Ee=ee;break e}Ee=g.return}}var Y=i.current;for(Ee=Y;Ee!==null;){x=Ee;var ne=x.child;if((x.subtreeFlags&2064)!==0&&ne!==null)ne.return=x,Ee=ne;else e:for(x=Y;Ee!==null;){if(T=Ee,(T.flags&2048)!==0)try{switch(T.tag){case 0:case 11:case 15:ta(9,T)}}catch(Le){dt(T,T.return,Le)}if(T===x){Ee=null;break e}var ve=T.sibling;if(ve!==null){ve.return=T.return,Ee=ve;break e}Ee=T.return}}if(Ye=f,Cn(),Fi&&typeof Fi.onPostCommitFiberRoot=="function")try{Fi.onPostCommitFiberRoot(po,i)}catch{}u=!0}return u}finally{et=a,xi.transition=r}}return!1}function jp(i,r,a){r=Ar(a,r),r=Qf(i,r,1),i=xn(i,r,1),r=Xt(),i!==null&&(as(i,1,r),ri(i,r))}function dt(i,r,a){if(i.tag===3)jp(i,i,a);else for(;r!==null;){if(r.tag===3){jp(r,i,a);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Nn===null||!Nn.has(u))){i=Ar(a,i),i=Jf(r,i,1),r=xn(r,i,1),i=Xt(),r!==null&&(as(r,1,i),ri(r,i));break}}r=r.return}}function OS(i,r,a){var u=i.pingCache;u!==null&&u.delete(r),r=Xt(),i.pingedLanes|=i.suspendedLanes&a,Rt===i&&(Ot&a)===a&&(bt===4||bt===3&&(Ot&130023424)===Ot&&500>mt()-Rc?Jn(i,0):Nc|=a),ri(i,r)}function Tp(i,r){r===0&&((i.mode&1)===0?r=1:(r=go,go<<=1,(go&130023424)===0&&(go=4194304)));var a=Xt();i=sn(i,r),i!==null&&(as(i,r,a),ri(i,a))}function zS(i){var r=i.memoizedState,a=0;r!==null&&(a=r.retryLane),Tp(i,a)}function FS(i,r){var a=0;switch(i.tag){case 13:var u=i.stateNode,f=i.memoizedState;f!==null&&(a=f.retryLane);break;case 19:u=i.stateNode;break;default:throw Error(n(314))}u!==null&&u.delete(r),Tp(i,a)}var Ap;Ap=function(i,r,a){if(i!==null)if(i.memoizedProps!==r.pendingProps||ei.current)ii=!0;else{if((i.lanes&a)===0&&(r.flags&128)===0)return ii=!1,NS(i,r,a);ii=(i.flags&131072)!==0}else ii=!1,ot&&(r.flags&1048576)!==0&&pf(r,Oo,r.index);switch(r.lanes=0,r.tag){case 2:var u=r.type;Zo(i,r),i=r.pendingProps;var f=Nr(r,Wt.current);jr(r,a),f=sc(null,r,u,i,f,a);var g=oc();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,ti(u)?(g=!0,Ao(r)):g=!1,r.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Jl(r),f.updater=Qo,r.stateNode=f,f._reactInternals=r,dc(r,u,i,a),r=gc(null,r,u,!0,g,a)):(r.tag=0,ot&&g&&$l(r),Yt(null,r,f,a),r=r.child),r;case 16:u=r.elementType;e:{switch(Zo(i,r),i=r.pendingProps,f=u._init,u=f(u._payload),r.type=u,f=r.tag=$S(u),i=Ai(u,i),f){case 0:r=mc(null,r,u,i,a);break e;case 1:r=ap(null,r,u,i,a);break e;case 11:r=ip(null,r,u,i,a);break e;case 14:r=np(null,r,u,Ai(u.type,i),a);break e}throw Error(n(306,u,""))}return r;case 0:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),mc(i,r,u,f,a);case 1:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),ap(i,r,u,f,a);case 3:e:{if(lp(r),i===null)throw Error(n(387));u=r.pendingProps,g=r.memoizedState,f=g.element,Cf(i,r),Uo(r,u,null,a);var x=r.memoizedState;if(u=x.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){f=Ar(Error(n(423)),r),r=cp(i,r,u,a,f);break e}else if(u!==f){f=Ar(Error(n(424)),r),r=cp(i,r,u,a,f);break e}else for(fi=Sn(r.stateNode.containerInfo.firstChild),di=r,ot=!0,Ti=null,a=wf(r,null,u,a),r.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling;else{if(Dr(),u===f){r=an(i,r,a);break e}Yt(i,r,u,a)}r=r.child}return r;case 5:return Ef(r),i===null&&Kl(r),u=r.type,f=r.pendingProps,g=i!==null?i.memoizedProps:null,x=f.children,Bl(u,f)?x=null:g!==null&&Bl(u,g)&&(r.flags|=32),op(i,r),Yt(i,r,x,a),r.child;case 6:return i===null&&Kl(r),null;case 13:return up(i,r,a);case 4:return Zl(r,r.stateNode.containerInfo),u=r.pendingProps,i===null?r.child=Lr(r,null,u,a):Yt(i,r,u,a),r.child;case 11:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),ip(i,r,u,f,a);case 7:return Yt(i,r,r.pendingProps,a),r.child;case 8:return Yt(i,r,r.pendingProps.children,a),r.child;case 12:return Yt(i,r,r.pendingProps.children,a),r.child;case 10:e:{if(u=r.type._context,f=r.pendingProps,g=r.memoizedProps,x=f.value,it(Ho,u._currentValue),u._currentValue=x,g!==null)if(ji(g.value,x)){if(g.children===f.children&&!ei.current){r=an(i,r,a);break e}}else for(g=r.child,g!==null&&(g.return=r);g!==null;){var T=g.dependencies;if(T!==null){x=g.child;for(var $=T.firstContext;$!==null;){if($.context===u){if(g.tag===1){$=on(-1,a&-a),$.tag=2;var ae=g.updateQueue;if(ae!==null){ae=ae.shared;var fe=ae.pending;fe===null?$.next=$:($.next=fe.next,fe.next=$),ae.pending=$}}g.lanes|=a,$=g.alternate,$!==null&&($.lanes|=a),Gl(g.return,a,r),T.lanes|=a;break}$=$.next}}else if(g.tag===10)x=g.type===r.type?null:g.child;else if(g.tag===18){if(x=g.return,x===null)throw Error(n(341));x.lanes|=a,T=x.alternate,T!==null&&(T.lanes|=a),Gl(x,a,r),x=g.sibling}else x=g.child;if(x!==null)x.return=g;else for(x=g;x!==null;){if(x===r){x=null;break}if(g=x.sibling,g!==null){g.return=x.return,x=g;break}x=x.return}g=x}Yt(i,r,f.children,a),r=r.child}return r;case 9:return f=r.type,u=r.pendingProps.children,jr(r,a),f=Ci(f),u=u(f),r.flags|=1,Yt(i,r,u,a),r.child;case 14:return u=r.type,f=Ai(u,r.pendingProps),f=Ai(u.type,f),np(i,r,u,f,a);case 15:return rp(i,r,r.type,r.pendingProps,a);case 17:return u=r.type,f=r.pendingProps,f=r.elementType===u?f:Ai(u,f),Zo(i,r),r.tag=1,ti(u)?(i=!0,Ao(r)):i=!1,jr(r,a),Xf(r,u,f),dc(r,u,f,a),gc(null,r,u,!0,i,a);case 19:return dp(i,r,a);case 22:return sp(i,r,a)}throw Error(n(156,r.tag))};function Bp(i,r){return pd(i,r)}function HS(i,r,a,u){this.tag=i,this.key=a,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=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ei(i,r,a,u){return new HS(i,r,a,u)}function Bc(i){return i=i.prototype,!(!i||!i.isReactComponent)}function $S(i){if(typeof i=="function")return Bc(i)?1:0;if(i!=null){if(i=i.$$typeof,i===j)return 11;if(i===U)return 14}return 2}function Ln(i,r){var a=i.alternate;return a===null?(a=Ei(i.tag,r,i.key,i.mode),a.elementType=i.elementType,a.type=i.type,a.stateNode=i.stateNode,a.alternate=i,i.alternate=a):(a.pendingProps=r,a.type=i.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=i.flags&14680064,a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,r=i.dependencies,a.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},a.sibling=i.sibling,a.index=i.index,a.ref=i.ref,a}function ua(i,r,a,u,f,g){var x=2;if(u=i,typeof i=="function")Bc(i)&&(x=1);else if(typeof i=="string")x=5;else e:switch(i){case F:return er(a.children,f,g,r);case Z:x=8,f|=8;break;case W:return i=Ei(12,a,r,f|2),i.elementType=W,i.lanes=g,i;case E:return i=Ei(13,a,r,f),i.elementType=E,i.lanes=g,i;case P:return i=Ei(19,a,r,f),i.elementType=P,i.lanes=g,i;case H:return ha(a,f,g,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case G:x=10;break e;case X:x=9;break e;case j:x=11;break e;case U:x=14;break e;case R:x=16,u=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=Ei(x,a,r,f),r.elementType=i,r.type=u,r.lanes=g,r}function er(i,r,a,u){return i=Ei(7,i,u,r),i.lanes=a,i}function ha(i,r,a,u){return i=Ei(22,i,u,r),i.elementType=H,i.lanes=a,i.stateNode={isHidden:!1},i}function Ic(i,r,a){return i=Ei(6,i,null,r),i.lanes=a,i}function Oc(i,r,a){return r=Ei(4,i.children!==null?i.children:[],i.key,r),r.lanes=a,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function WS(i,r,a,u,f){this.tag=r,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=hl(0),this.expirationTimes=hl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hl(0),this.identifierPrefix=u,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function zc(i,r,a,u,f,g,x,T,$){return i=new WS(i,r,a,T,$),r===1?(r=1,g===!0&&(r|=8)):r=0,g=Ei(3,null,null,r),i.current=g,g.stateNode=i,g.memoizedState={element:u,isDehydrated:a,cache:null,transitions:null,pendingSuspenseBoundaries:null},Jl(g),i}function US(i,r,a){var u=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:u==null?null:""+u,children:i,containerInfo:r,implementation:a}}function Ip(i){if(!i)return bn;i=i._reactInternals;e:{if($n(i)!==i||i.tag!==1)throw Error(n(170));var r=i;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(ti(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var a=i.type;if(ti(a))return hf(i,a,r)}return r}function Op(i,r,a,u,f,g,x,T,$){return i=zc(a,u,!0,i,f,g,x,T,$),i.context=Ip(null),a=i.current,u=Xt(),f=Pn(a),g=on(u,f),g.callback=r??null,xn(a,g,f),i.current.lanes=f,as(i,f,u),ri(i,u),i}function da(i,r,a,u){var f=r.current,g=Xt(),x=Pn(f);return a=Ip(a),r.context===null?r.context=a:r.pendingContext=a,r=on(g,x),r.payload={element:i},u=u===void 0?null:u,u!==null&&(r.callback=u),i=xn(f,r,x),i!==null&&(Oi(i,f,x,g),Wo(i,f,x)),x}function fa(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function zp(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var a=i.retryLane;i.retryLane=a!==0&&a<r?a:r}}function Fc(i,r){zp(i,r),(i=i.alternate)&&zp(i,r)}function KS(){return null}var Fp=typeof reportError=="function"?reportError:function(i){console.error(i)};function Hc(i){this._internalRoot=i}pa.prototype.render=Hc.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));da(i,r,null,null)},pa.prototype.unmount=Hc.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Qn(function(){da(null,i,null,null)}),r[en]=null}};function pa(i){this._internalRoot=i}pa.prototype.unstable_scheduleHydration=function(i){if(i){var r=bd();i={blockedOn:null,target:i,priority:r};for(var a=0;a<vn.length&&r!==0&&r<vn[a].priority;a++);vn.splice(a,0,i),a===0&&xd(i)}};function $c(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function ma(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function Hp(){}function qS(i,r,a,u,f){if(f){if(typeof u=="function"){var g=u;u=function(){var ae=fa(x);g.call(ae)}}var x=Op(r,u,i,0,null,!1,!1,"",Hp);return i._reactRootContainer=x,i[en]=x.current,ws(i.nodeType===8?i.parentNode:i),Qn(),x}for(;f=i.lastChild;)i.removeChild(f);if(typeof u=="function"){var T=u;u=function(){var ae=fa($);T.call(ae)}}var $=zc(i,0,!1,null,null,!1,!1,"",Hp);return i._reactRootContainer=$,i[en]=$.current,ws(i.nodeType===8?i.parentNode:i),Qn(function(){da(r,$,a,u)}),$}function ga(i,r,a,u,f){var g=a._reactRootContainer;if(g){var x=g;if(typeof f=="function"){var T=f;f=function(){var $=fa(x);T.call($)}}da(r,x,i,f)}else x=qS(a,r,i,f,u);return fa(x)}Sd=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var a=os(r.pendingLanes);a!==0&&(dl(r,a|1),ri(r,mt()),(Ye&6)===0&&(Or=mt()+500,Cn()))}break;case 13:Qn(function(){var u=sn(i,1);if(u!==null){var f=Xt();Oi(u,i,1,f)}}),Fc(i,1)}},fl=function(i){if(i.tag===13){var r=sn(i,134217728);if(r!==null){var a=Xt();Oi(r,i,134217728,a)}Fc(i,134217728)}},wd=function(i){if(i.tag===13){var r=Pn(i),a=sn(i,r);if(a!==null){var u=Xt();Oi(a,i,r,u)}Fc(i,r)}},bd=function(){return et},Cd=function(i,r){var a=et;try{return et=i,r()}finally{et=a}},sl=function(i,r,a){switch(r){case"input":if(Qe(i,a),r=a.name,a.type==="radio"&&r!=null){for(a=i;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<a.length;r++){var u=a[r];if(u!==i&&u.form===i.form){var f=jo(u);if(!f)throw Error(n(90));te(u),Qe(u,f)}}}break;case"textarea":ci(i,a);break;case"select":r=a.value,r!=null&&Te(i,!!a.multiple,r,!1)}},ad=jc,ld=Qn;var VS={usingClientEntryPoint:!1,Events:[ks,xr,jo,sd,od,jc]},Os={findFiberByHostInstance:Wn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},YS={bundleType:Os.bundleType,version:Os.version,rendererPackageName:Os.rendererPackageName,rendererConfig:Os.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:A.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=dd(i),i===null?null:i.stateNode},findFiberByHostInstance:Os.findFiberByHostInstance||KS,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 va=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!va.isDisabled&&va.supportsFiber)try{po=va.inject(YS),Fi=va}catch{}}return si.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=VS,si.createPortal=function(i,r){var a=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!$c(r))throw Error(n(200));return US(i,r,null,a)},si.createRoot=function(i,r){if(!$c(i))throw Error(n(299));var a=!1,u="",f=Fp;return r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onRecoverableError!==void 0&&(f=r.onRecoverableError)),r=zc(i,1,!1,null,null,a,!1,u,f),i[en]=r.current,ws(i.nodeType===8?i.parentNode:i),new Hc(r)},si.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=dd(r),i=i===null?null:i.stateNode,i},si.flushSync=function(i){return Qn(i)},si.hydrate=function(i,r,a){if(!ma(r))throw Error(n(200));return ga(null,i,r,!0,a)},si.hydrateRoot=function(i,r,a){if(!$c(i))throw Error(n(405));var u=a!=null&&a.hydratedSources||null,f=!1,g="",x=Fp;if(a!=null&&(a.unstable_strictMode===!0&&(f=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),r=Op(r,null,i,1,a??null,f,!1,g,x),i[en]=r.current,ws(i),u)for(i=0;i<u.length;i++)a=u[i],f=a._getVersion,f=f(a._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[a,f]:r.mutableSourceEagerHydrationData.push(a,f);return new pa(r)},si.render=function(i,r,a){if(!ma(r))throw Error(n(200));return ga(null,i,r,!1,a)},si.unmountComponentAtNode=function(i){if(!ma(i))throw Error(n(40));return i._reactRootContainer?(Qn(function(){ga(null,null,i,!1,function(){i._reactRootContainer=null,i[en]=null})}),!0):!1},si.unstable_batchedUpdates=jc,si.unstable_renderSubtreeIntoContainer=function(i,r,a,u){if(!ma(a))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return ga(i,r,a,!1,u)},si.version="18.3.1-next-f1338f8080-20240426",si}var Xp;function nw(){if(Xp)return Kc.exports;Xp=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(),Kc.exports=iw(),Kc.exports}var Gp;function rw(){if(Gp)return _a;Gp=1;var e=nw();return _a.createRoot=e.createRoot,_a.hydrateRoot=e.hydrateRoot,_a}var sw=rw();const ow=Dh(sw);function Tt(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const hv=e=>`nc_seen_${e}`;async function Ie(e,t,n={}){const s=await Tt(e,t,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const l=new Error(o.error||`HTTP ${s.status}`);throw l.status=s.status,l.data=o,l}return o}const li=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Ht=(e,t)=>`${li(e)}/fleet/${t}`,dr=(e,t)=>Ie(Ht(t,"status"),e),Mh=(e,t,n)=>Ie(Ht(n,"up"),e,{method:"POST",body:t}),Ia=(e,t,n)=>Ie(Ht(n,"down"),e,{method:"POST",body:t}),Ys=(e,t,n)=>Ie(Ht(n,"restart"),e,{method:"POST",body:{cell:t}}),jh=(e,t)=>Ie(Ht(t,"definitions"),e),aw=(e,t)=>Ie(Ht(t,"credentials/status"),e),lw=(e,t,n,s)=>Ie(Ht(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),cw=(e,t,n)=>Ie(Ht(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),uw=(e,t,n)=>Ie(Ht(n,"define-engine"),e,{method:"POST",body:{def:t}}),hw=(e,t,n,s,o)=>Ie(Ht(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),dw=(e,t,n)=>Ie(Ht(n,"remove-engine"),e,{method:"POST",body:{id:t}}),fw=(e,t,n)=>Ie(Ht(n,"define-cell"),e,{method:"POST",body:{def:t}}),pw=(e,t,n,s)=>Ie(Ht(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),dv=(e,t,n=!1,s)=>Ie(Ht(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),mw=(e,t,n)=>Ie(Ht(n,"import-cell"),e,{method:"POST",body:t}),gw=(e,t,n)=>Ie(Ht(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),vw=(e,t,n,s)=>Ie(Ht(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n}}),Th=(e,t,n)=>Ie(`${li(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),fv=(e,t,n,s)=>Ie(`${li(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),pv=(e,t,n)=>Ie(`${li(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),mv=e=>Ie("/api/settings",e),gv=e=>Ie("/api/nodes",e),_w=e=>Ie("/api/topology",e),vv=(e,t)=>Ie(`${li(t)}/sessions`,e),Ah=(e,t)=>Ie(`${li(t)}/config`,e),Qp=(e,t)=>Ie(`${li(t)}/topology`,e),_v=(e,t)=>Ie("/api/settings/config",e,{method:"POST",body:t}),yw=e=>Ie("/api/settings/token/rotate",e,{method:"POST"}),Sw=(e,t)=>Ie("/api/settings/nodes/pair",e,{method:"POST",body:t}),Jp=(e,t,n=[])=>Ie(`${li(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),ww=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),bw=(e,t)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Bh=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),Cw=(e,t,n)=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),Zp=(e,t,n,s=[])=>Ie(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),kw=e=>Ie("/api/settings/service/regenerate",e,{method:"POST"}),xw=e=>Ie("/api/settings/update/check",e,{method:"POST"}),Ew=e=>Ie("/api/settings/update/apply",e,{method:"POST"}),Nw=(e,t=!0)=>Ie(`/api/asks${t?"?open=1":""}`,e),Rw=(e,t,n)=>Ie(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),ya=(e,t=[])=>Ie(`${li(t)}/decks`,e),em=(e,t,n=[])=>Ie(`${li(n)}/decks`,e,{method:"POST",body:{name:t}}),Sa=(e,t,n,s,o=[])=>Ie(`${li(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),Pw=(e,t,n,s,o=[])=>Ie(`${li(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),Dw=(e,t,n,s=[])=>Ie(`${li(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),Lw={power:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 3v8"}),h.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:h.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:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),h.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),h.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),h.jsx("path",{d:"M12 18v3"})]}),enter:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),h.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),h.jsx("path",{d:"M22 2 11 13"})]}),trash:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M4 7h16"}),h.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),h.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),h.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:h.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),h.jsx("polyline",{points:"21 3 21 8 16 8"})]}),upload:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M12 16V5"}),h.jsx("polyline",{points:"8 9 12 5 16 9"}),h.jsx("path",{d:"M5 20h14"})]}),chevronLeft:h.jsx("polyline",{points:"14 6 8 12 14 18"}),attach:h.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:h.jsxs(h.Fragment,{children:[h.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),h.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:h.jsxs(h.Fragment,{children:[h.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"}),h.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),h.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),h.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"11",cy:"11",r:"7"}),h.jsx("path",{d:"M21 21l-4.35-4.35"}),h.jsx("path",{d:"M8 11h6"})]}),gear:h.jsxs(h.Fragment,{children:[h.jsx("circle",{cx:"12",cy:"12",r:"3"}),h.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:h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),h.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function Ze({name:e,size:t=20}){return h.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:Lw[e]||null})}const Mw=["all","pinned","active","off","technical"],yv="nc_sidebar_views_v1",Sv="nc_sidebar_order_v1";function wv(e){return Mw.includes(e)?e:"all"}function jw(e,t=[],n="all"){const s=wv(n);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 Tw(e,t,n=[],s=[]){const o=n.indexOf(e.key),l=n.indexOf(t.key),c=o===-1?Number.MAX_SAFE_INTEGER:o,d=l===-1?Number.MAX_SAFE_INTEGER:l,p=s.indexOf(e.key),m=s.indexOf(t.key),S=p===-1?Number.MAX_SAFE_INTEGER:p,b=m===-1?Number.MAX_SAFE_INTEGER:m;return c-d||S-b||+!!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 Aw(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Sv));if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const l=[...new Set(o.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);l.length&&(n[s]=l)}return n}catch{return{}}}function zn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function Bw(e,t=globalThis.localStorage){try{t.setItem(Sv,JSON.stringify(e))}catch{}return e}function Iw(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const l=[...new Set(o.filter(_=>typeof _=="string"&&_))];if(!l.includes(n)||!l.includes(s))return e;const c=zn(e,t).filter(_=>l.includes(_)),d=[...c,...l.filter(_=>!c.includes(_))],p=d.indexOf(n),m=d.indexOf(s);d.splice(p,1);const S=d.indexOf(s),b=p<m?S+1:S;return d.splice(b,0,n),{...e,[t]:d}}function Ow(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(yv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function tm(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:wv((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function zw(e,t=globalThis.localStorage){try{t.setItem(yv,JSON.stringify(e))}catch{}return e}function im(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function ar(e=[],t=[],n="all",s=[]){return[...e].filter(o=>jw(o,t,n)).sort((o,l)=>Tw(o,l,t,s))}const Ih=["it","en","es"];function Fw(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return Ih.includes(t)?t:"en"}catch{return"en"}}const Da=Fw(),bv="nc_lang",Bu="nc-lang";function Cv(){return typeof localStorage<"u"?localStorage:null}const wa={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","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-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…",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-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-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-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","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-external-hint":"Provider esterno: engine/modello si configurano nel fleet esterno.","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","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-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…",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-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-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-private":"Private: only this device can use its hub connection.","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-external-hint":"External provider: engine/model are configured in the external fleet.","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","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-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…",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-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-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-private":"Privado: solo este dispositivo puede usar la conexión al hub.","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-external-hint":"Proveedor externo: motor/modelo se configuran en el fleet externo.","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 Iu(){const e=Cv(),t=e?e.getItem(bv):null;return Ih.includes(t)?t:Da}function Hw(e){const t=Cv();if(t)try{t.setItem(bv,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Bu))}function y(e){const t=Iu(),n=wa[t]||wa[Da];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(wa[Da],e)?wa[Da][e]:e}function $w(e){return typeof window>"u"?()=>{}:(window.addEventListener(Bu,e),()=>window.removeEventListener(Bu,e))}const kv=Ih;function yi(){return[L.useSyncExternalStore($w,Iu,Iu),Hw]}function Oa({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var U,R;yi();const l=!!(e&&e.active),c=Array.isArray(n)?n.join("/"):"",[d,p]=L.useState([]),[m,S]=L.useState(!1);L.useEffect(()=>{let H=!0;return(async()=>{if(t)try{const I=await dr(t,c?c.split("/"):[]);if(!H)return;if(S(I.provider==="builtin"&&(I.capabilities||[]).includes("edit")),I.provider==="builtin"&&(I.capabilities||[]).includes("definitions")){const se=await jh(t,c?c.split("/"):[]);if(!H)return;const q=new Map((I.engines||[]).map(M=>[M.id,M]));p((se.engines||[]).map(M=>{var K,Q,re,oe,le,V,z;return{id:M.id,label:M.label||M.id,client:((K=M.managed)==null?void 0:K.client)||"",models:[...new Set([...((Q=q.get(M.id))==null?void 0:Q.models)||[],...((re=M.managedInfo)==null?void 0:re.models)||[]])].filter(Boolean),defaultModel:((oe=M.managed)==null?void 0:oe.model)||((le=M.managedInfo)==null?void 0:le.defaultModel)||"",policyDefault:((V=M.managed)==null?void 0:V.permissionPolicy)||((z=M.managed)!=null&&z.client&&M.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{H=!1}},[t,c]);const b=(e==null?void 0:e.engine)||((U=d[0])==null?void 0:U.id)||"",_=H=>(e==null?void 0:e.models)&&e.models[H]||"",v=H=>{const I=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[H];if(I==="standard"||I==="unsafe")return I;const se=d.find(q=>q.id===H);return se?se.policyDefault:"standard"},[w,C]=L.useState(b),[k,N]=L.useState((e==null?void 0:e.model)||""),D=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((R=e==null?void 0:e.permissionPolicies)==null?void 0:R[e==null?void 0:e.engine])||"",[B,A]=L.useState(D),[J,O]=L.useState((e==null?void 0:e.boot)??!0),[F,Z]=L.useState(!1),[W,G]=L.useState(null);L.useEffect(()=>{d.length&&(C(H=>H||b),N(H=>H||_((e==null?void 0:e.engine)||b)||""),A(H=>H==="standard"||H==="unsafe"?H:v((e==null?void 0:e.engine)||b)))},[d.length]);const X=L.useMemo(()=>d.find(H=>H.id===w)||null,[d,w]),j=!!(X&&["claude","codex","codex-vl"].includes(X.client));function E(H){C(H);const I=d.find(se=>se.id===H);N(_(H)||(I==null?void 0:I.defaultModel)||""),A(v(H))}async function P(H){H.preventDefault(),Z(!0),G(null);try{if(l)await s({action:"down",boot:J});else{const I=B==="standard"||B==="unsafe"?B:(X==null?void 0:X.policyDefault)||"standard";await s({action:"up",...m?{engine:w,model:k||"",...j?{permissionPolicy:I}:(X==null?void 0:X.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:J})}o()}catch(I){G(String(I&&I.message||I)),Z(!1)}}return h.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:h.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:H=>H.stopPropagation(),onSubmit:P,children:[h.jsxs("div",{className:"nc-sheet-head",children:[h.jsx("b",{children:e==null?void 0:e.cell}),h.jsx("span",{className:"nc-sheet-state",children:y(l?"state-on":"state-off")})]}),l?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:y("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[y("model"),": ",e.model]}),h.jsx("small",{children:y("power-on-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:J,onChange:H=>O(H.target.checked)}),y("remove-boot")]})]}):h.jsxs(h.Fragment,{children:[m&&d.length>0?h.jsxs("div",{className:"nc-launch-fields",children:[h.jsxs("label",{className:"nc-field",children:[y("engine"),h.jsx("select",{value:w,onChange:H=>E(H.target.value),children:d.map(H=>h.jsx("option",{value:H.id,children:H.label},H.id))})]}),h.jsxs("label",{className:"nc-field",children:[y("model"),h.jsx("input",{value:k,list:"nc-launch-models",placeholder:y("model-default"),onChange:H=>N(H.target.value)}),h.jsx("datalist",{id:"nc-launch-models",children:((X==null?void 0:X.models)||[]).map(H=>h.jsx("option",{value:H},H))})]}),j?h.jsxs("label",{className:"nc-field",children:[y("permissions"),h.jsxs("select",{value:B,onChange:H=>A(H.target.value),children:[h.jsx("option",{value:"standard",children:y("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:y("fleet-unsafe-permissions")})]})]}):h.jsx("small",{className:"nc-note",children:y("fleet-standard-permissions")}),j&&B==="unsafe"&&h.jsx("small",{className:"nc-err",children:y("fleet-unsafe-warning")}),h.jsx("small",{className:"nc-note",children:y("launch-engine-help")})]}):h.jsxs("div",{className:"nc-power-config",children:[h.jsx("span",{children:y("engine")}),h.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&h.jsxs("small",{children:[y("model"),": ",e.model]}),h.jsx("small",{children:y("launch-external-hint")})]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:J,onChange:H=>O(H.target.checked)}),y("boot-persist")]})]}),W&&h.jsx("div",{className:"nc-err",children:W}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:F,children:y("cancel")}),h.jsx("button",{type:"submit",className:"nc-btn primary",disabled:F,children:y(l?"power-off":"save-and-start")})]})]})})}const nm=/^[a-z0-9-]{1,32}$/;function za(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function Ww(e,t,n){const s={};for(const o of Array.isArray(t)?t:[]){const l=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!l.length)continue;const c=l.join("/"),d=o.status==="up"||o.tunnel&&o.tunnel.status==="up",p=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!d&&!p&&(s[c]=e&&e[c]||n)}return s}function rm(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function sm({nodes:e,topology:t,remote:n,down:s,fleet:o}={}){var p,m,S,b;const l=[],c=new Set,d=new Set;for(const _ of Array.isArray(e)?e:[]){if(!_||typeof _.name!="string"||!nm.test(_.name)||_.direction==="inbound"&&_.shared!==!0)continue;const v=[_.name],w=_.name;c.add(w);const C=((p=_.tunnel)==null?void 0:p.status)||"unknown",k=C==="up",N={name:_.name,label:_.label||_.name,route:v,direct:!0,instanceId:_.nodeId||null,shared:_.shared===!0,tunnelStatus:C,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:_.health||null,direction:_.direction||"outbound",roles:_.roles||null,rolesKnown:_.rolesKnown===!0};if(_.nodeId&&d.add(_.nodeId),!_.nodeId&&_.paired===!1){l.push({...N,status:"needs-repair",downSince:s&&s[w]||null});continue}if(((m=_.health)==null?void 0:m.auth)==="failed"||C==="degraded"&&((S=_.health)==null?void 0:S.status)==="degraded"){l.push({...N,status:"needs-repair",downSince:s&&s[w]||null});continue}if(C==="passive"||((b=_.health)==null?void 0:b.status)==="passive"){l.push({...N,status:"passive",downSince:null});continue}if(!k){l.push({...N,status:"down",downSince:s&&s[w]||null});continue}const D=n&&(n[w]||n[_.name])||null;if(!D||D.error||!Array.isArray(D.sessions)){l.push({...N,status:"unreachable"});continue}const B=D.sessions.filter(F=>F&&typeof F.name=="string"&&F.name).map(F=>({...F,node:w,route:v,key:`${w}:${F.name}`})),A=o&&(o[w]||o[_.name]),J=rm(A,v,w),O=new Set(J.map(F=>F.tmuxSession).filter(Boolean));l.push({...N,status:"up",sessions:B,cells:J,unmanaged:B.filter(F=>!O.has(F.name)),fleetAvailable:!!(A&&A.available),capabilities:A&&A.capabilities||[],engines:A&&A.engines||[],fleetProvider:A&&A.provider||null})}for(const _ of Array.isArray(t)?t:[]){if(!_||!Array.isArray(_.route)||_.route.length<1||_.route.some(A=>!nm.test(A)))continue;const v=_.route.join("/");if(c.has(v)||_.instanceId&&d.has(_.instanceId))continue;_.instanceId&&d.add(_.instanceId);const w={name:_.name,label:_.label||_.route.join(" › "),route:[..._.route],direct:!1,instanceId:_.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:_.health||null,lastSeen:_.lastSeen||null};if(_.stale){l.push({...w,status:"offline",downSince:s&&s[v]||_.lastSeen||null});continue}const C=n&&n[v]||null;if(!C||C.error||!Array.isArray(C.sessions)){l.push({...w,status:"unreachable",downSince:s&&s[v]||null});continue}const k=C.sessions.filter(A=>A&&typeof A.name=="string"&&A.name).map(A=>({...A,node:v,route:_.route,key:`${v}:${A.name}`})),N=o&&o[v],D=rm(N,_.route,v),B=new Set(D.map(A=>A.tmuxSession).filter(Boolean));l.push({...w,status:"up",sessions:k,cells:D,unmanaged:k.filter(A=>!B.has(A.name)),fleetAvailable:!!(N&&N.available),capabilities:N&&N.capabilities||[],engines:N&&N.engines||[],fleetProvider:N&&N.provider||null,lastSeen:_.lastSeen||null})}return l.sort((_,v)=>_.label.localeCompare(v.label))}const Uw=4e3;function Oh(e,t=!0){const[n,s]=L.useState([]),o=L.useRef({});return L.useEffect(()=>{if(!t||!e){s([]);return}let l=!0;async function c(){var C;let p=[],m=[];if(await Promise.all([gv(e).then(k=>{p=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{}),_w(e).then(k=>{m=Array.isArray(k.nodes)?k.nodes:[]}).catch(()=>{})]),!l)return;const S={},b={},_=new Set(p.map(k=>k.name)),v=[];for(const k of p)((C=k.tunnel)==null?void 0:C.status)==="up"&&(k.nodeId||k.paired!==!1)&&(k.direction!=="inbound"||k.shared===!0)&&v.push([k.name]);for(const k of m)!k.stale&&Array.isArray(k.route)&&!(k.route.length===1&&_.has(k.route[0]))&&v.push(k.route);if(await Promise.all(v.map(async k=>{const N=k.join("/");try{S[N]=await vv(e,k)}catch{S[N]={error:"unreachable"}}try{b[N]=await dr(e,k)}catch{b[N]={available:!1}}})),!l)return;const w=sm({nodes:p,topology:m,remote:S,fleet:b,down:o.current});o.current=Ww(o.current,w,Math.floor(Date.now()/1e3)),s(sm({nodes:p,topology:m,remote:S,fleet:b,down:o.current}))}c();const d=setInterval(c,Uw);return()=>{l=!1,clearInterval(d)}},[e,t]),n}const om=52,am=14;function Ur({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:l=()=>!0}){const c=L.useRef(null),d=L.useRef(0),[p,m]=L.useState(!1),S=()=>{var k,N,D,B;const C=c.current;(N=(k=C==null?void 0:C.over)==null?void 0:k.classList)==null||N.remove("nc-roster-over"),(B=(D=C==null?void 0:C.source)==null?void 0:D.classList)==null||B.remove("nc-roster-dragging"),d.current&&cancelAnimationFrame(d.current),d.current=0},b=(C=!1)=>{const k=c.current;if(!k)return;const N=k.target;S(),c.current=null,m(!1);try{k.handle.releasePointerCapture(k.pointerId)}catch{}C&&N&&N!==t&&l(t,N)&&s(t,N)},_=(C,k)=>{var J,O,F,Z,W,G,X,j;const N=c.current;if(!N)return;N.x=C,N.y=k;const D=(O=(J=document.elementFromPoint(C,k))==null?void 0:J.closest)==null?void 0:O.call(J,"[data-roster-key][data-position]"),B=(F=D==null?void 0:D.dataset)==null?void 0:F.rosterKey,A=((Z=D==null?void 0:D.dataset)==null?void 0:Z.position)===e&&B&&B!==t&&l(t,B);N.over!==(A?D:null)&&((G=(W=N.over)==null?void 0:W.classList)==null||G.remove("nc-roster-over"),N.over=A?D:null,(j=(X=N.over)==null?void 0:X.classList)==null||j.add("nc-roster-over")),N.target=A?B:null},v=()=>{const C=c.current;if(!C){d.current=0;return}const k=C.container;if(k){const N=k.getBoundingClientRect(),D=C.y<N.top+om?-am:C.y>N.bottom-om?am:0;D&&(k.scrollTop+=D,_(C.x,C.y))}d.current=requestAnimationFrame(v)};L.useEffect(()=>{const C=N=>{N.key==="Escape"&&c.current&&(N.preventDefault(),b(!1))},k=()=>b(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",k),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",k),S(),c.current=null}},[t,e]);const w=C=>{var D;if(C.pointerType==="mouse"&&C.button!==0)return;C.preventDefault(),C.stopPropagation(),C.currentTarget.focus({preventScroll:!0});const k=C.currentTarget.closest("[data-roster-key][data-position]"),N=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");c.current={pointerId:C.pointerId,handle:C.currentTarget,source:k,container:N,target:null,over:null,x:C.clientX,y:C.clientY},(D=k==null?void 0:k.classList)==null||D.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}m(!0),d.current=requestAnimationFrame(v)};return h.jsx("button",{type:"button",className:`nc-roster-handle${p?" active":""}`,"aria-label":`${y("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:y("reorder-help"),onClick:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),o(C.key==="ArrowUp"?-1:1))},onPointerDown:w,onPointerMove:C=>{!c.current||C.pointerId!==c.current.pointerId||(C.preventDefault(),C.stopPropagation(),_(C.clientX,C.clientY))},onPointerUp:C=>{!c.current||C.pointerId!==c.current.pointerId||(C.preventDefault(),C.stopPropagation(),b(!0))},onPointerCancel:()=>b(!1),onLostPointerCapture:()=>{c.current&&b(!1)},children:"↕"})}const zh="nc_pins";function Kw(){try{const e=JSON.parse(localStorage.getItem(zh));return Array.isArray(e)?e:[]}catch{return[]}}function qw(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(zh,JSON.stringify(n))}catch{}return n}function Vw(e,t,n){if(!e.includes(t)||!e.includes(n)||t===n)return e;const s=[...e],o=s.indexOf(t),l=s.indexOf(n);s.splice(o,1);const c=s.indexOf(n);s.splice(o<l?c+1:c,0,t);try{localStorage.setItem(zh,JSON.stringify(s))}catch{}return s}function Yw(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function Xw(e,t){return e[0]-t[0]||e[1]-t[1]}function xv(){const[e,t]=L.useState(Kw),[n,s]=L.useState(Ow),[o,l]=L.useState(Aw),c=_=>t(v=>qw(v,_)),d=_=>tm(n,_),p=(_,v)=>s(w=>{const C={...w,[_]:{...tm(w,_),...v}};return zw(C)}),m=(_,v)=>e.includes(_)===e.includes(v);function S(_,v,w,C){const k=e.includes(v),N=e.includes(w);if(k===N){if(k){t(D=>Vw(D,v,w));return}l(D=>{var J;const B=((J=C.find(O=>O.key===v))==null?void 0:J.technical)===!0,A=ar(C,e,B?"technical":"all",zn(D,_)).map(O=>O.key);return Bw(Iw(D,_,v,w,A))})}}function b(_,v,w,C){var J;const k=((J=C.find(O=>O.key===v))==null?void 0:J.technical)===!0,N=e.includes(v),D=ar(C,e,k?"technical":"all",zn(o,_)).map(O=>O.key).filter(O=>e.includes(O)===N),B=D.indexOf(v),A=D[B+w];B>=0&&A&&S(_,v,A,C)}return{pins:e,views:n,orders:o,togglePin:c,viewFor:d,updateView:p,canMoveRoster:m,moveRoster:S,stepRoster:b}}function Gr(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const n=t-e;return n<0||n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function qr(e){return e.status==="passive"?y("node-passive"):e.status==="down"?e.downSince?y("tunnel-down-since").replace("{t}",Gr(e.downSince)):y("tunnel-down"):e.status==="unreachable"?y("node-unreachable"):e.status==="offline"?e.lastSeen?y("node-offline-seen").replace("{t}",Gr(e.lastSeen)):y("node-offline"):e.status==="needs-repair"?y("node-needs-repair"):""}function Ev(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function Fa(e){return e&&(e.detail||e.status)||""}function Ha(e,t,n=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(n.getItem(hv(t))||0);return e.outbox.latest>s}function Nv(e,t,n,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const l=n.get(o.tmuxSession)||{},c=za([],o.tmuxSession);return{type:"cell",value:o,key:c,label:o.cell,live:!!o.tmux,fresh:Ha(l,c,s),activity:l.activity||0,searchText:`${o.engine||""} ${o.key||""} ${l.preview||""}`}}),...(Array.isArray(t)?t:[]).map(o=>{const l=za([],o.name);return{type:"session",value:o,key:l,label:o.name,live:!0,technical:o.technical===!0,fresh:Ha(o,l,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function Rv(e,t=globalThis.localStorage){const n=e||{},s=Array.isArray(n.route)?n.route:[],o=new Map((n.sessions||[]).map(c=>[c.name,c])),l=[...(n.cells||[]).map(c=>{const d=o.get(c.tmuxSession)||{},p=za(s,c.tmuxSession||c.cell);return{type:"cell",value:c,key:p,label:c.cell,live:!!c.tmux,fresh:Ha(d,p,t),activity:d.activity||c.activity||0,searchText:`${c.engine||""} ${c.key||""} ${d.preview||c.preview||""}`}}),...(n.unmanaged||[]).map(c=>{const d=za(s,c.name);return{type:"session",value:c,key:d,label:c.name,live:!0,technical:c.technical===!0,fresh:Ha(c,d,t),activity:c.activity||0,searchText:`${c.preview||""} ${c.cmd||""}`}})];return{route:s,rawItems:l}}function Gw({onPick:e,token:t,onSettings:n}){const[s,o]=yi(),l=Oh(t),[c,d]=L.useState(null),[p,m]=L.useState(null),[S,b]=L.useState(""),[_,v]=L.useState(""),[w,C]=L.useState({bind:"127.0.0.1",port:""}),[k,N]=L.useState([]),[D,B]=L.useState(null),[A,J]=L.useState(null),{pins:O,orders:F,togglePin:Z,viewFor:W,updateView:G,canMoveRoster:X,moveRoster:j,stepRoster:E}=xv();async function P(){try{const de=await(await Tt("/api/sessions",t)).json();de.error?(m(de.error),d([])):(m(null),d(de.sessions||[]))}catch(te){m(String(te)),d([])}try{const te=await dr(t);N(te.available?te.cells||[]:[])}catch{N([])}}L.useEffect(()=>{P(),Tt("/api/config",t).then(de=>de.json()).then(de=>{v(de.version||""),C({bind:de.bind||"127.0.0.1",port:de.port||""})}).catch(()=>{});const te=setInterval(P,4e3);return()=>clearInterval(te)},[]);async function U(){if(!w.port)return;const te=`http://${w.bind}:${w.port}/#token=${t}`;try{await navigator.clipboard.writeText(te)}catch{}}async function R(te){if(!D)return;const{cell:de}=D,Ne=Array.isArray(D.route)?D.route:[];te.action==="up"?await Mh(t,{cell:de,boot:!!te.boot,...te.engine?{engine:te.engine}:{},...te.model!==void 0?{model:te.model}:{},...te.permissionPolicy?{permissionPolicy:te.permissionPolicy}:{}},Ne):await Ia(t,{cell:de,boot:!!te.boot},Ne),P()}async function H(te,de=[]){try{await Th(t,te,de)}catch{return}P()}async function I(te,de,Ne=[]){try{await fv(t,te,de,Ne)}catch{return}P()}async function se(te){if(!(!(te!=null&&te.direct)||A)){J(te.name);try{await Bh(t,te.name,te.tunnelStatus==="up"?"down":"up")}catch{}J(null)}}const q=L.useMemo(()=>new Map((c||[]).map(te=>[te.name,te])),[c]),M=L.useMemo(()=>new Set(k.map(te=>te.tmuxSession)),[k]),K=L.useMemo(()=>(c||[]).filter(te=>!M.has(te.name)),[c,M]),Q=L.useMemo(()=>Nv(k,K,q),[k,K,q]),re=W("local"),oe=L.useMemo(()=>ar(Q,O,re.filter,zn(F,"local")).filter(te=>im(te,S)),[Q,O,re.filter,S,F]),le=l.reduce((te,de)=>te+(de.cells||[]).length+(de.unmanaged||[]).filter(Ne=>!Ne.technical).length,0),V=ar(Q,O,"all",zn(F,"local")).length+le,z=c?c.length:0,pe=(c||[]).filter(te=>te.attached).length,ye=w.port?`${w.bind}:${w.port}`:w.bind;function xe(te,de=null,Ne=Q){var we,Te;const ke=Array.isArray(de==null?void 0:de.route)?de.route:[],Ve=ke.join("/"),Qe=Ve||"local",Ke=X;if(te.type==="cell"){const Se=te.value,Xe=ke.length?((de==null?void 0:de.sessions)||[]).find(Ue=>Ue.name===Se.tmuxSession):q.get(Se.tmuxSession),ci=(Xe==null?void 0:Xe.preview)||Se.preview||"",$t=[`${Se.engine}${Se.key?`·${Se.key}`:""}`,ci,Se.active?"":y("cell-off")].filter(Boolean).join(" · "),Zt=ke.length===0||((de==null?void 0:de.capabilities)||[]).includes(Se.active?"down":"up");return h.jsxs("div",{className:"nc-mcard","data-roster-key":te.key,"data-position":Qe,children:[h.jsx(Ur,{position:Qe,itemKey:te.key,label:Se.cell,canMove:Ke,onMove:(Ue,Bt)=>j(Qe,Ue,Bt,Ne),onStep:Ue=>E(Qe,te.key,Ue,Ne)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>Se.tmux&&e(ke.length?{session:Se.tmuxSession,node:Ve}:Se.tmuxSession),title:Se.degraded?y("cell-degraded"):Se.tmux?y("cell-on"):y("cell-off"),children:[h.jsx("span",{className:`dot ${Se.degraded?"warn":Se.tmux?"on":""}`}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:Se.cell}),h.jsx("small",{children:$t})]})]}),te.activity?h.jsx("span",{className:"nc-rel",children:Gr(te.activity)}):null,te.fresh&&((we=Xe==null?void 0:Xe.outbox)==null?void 0:we.count)>0&&h.jsx("span",{className:"nc-badge",title:y("new-files-outbox"),children:Xe.outbox.count}),h.jsx("button",{className:`nc-act pin${O.includes(te.key)?" on":""}`,"aria-label":`${y("pin")} ${Se.cell}`,title:y("pin"),onClick:()=>Z(te.key),children:O.includes(te.key)?"★":"☆"}),Zt&&h.jsx("button",{className:`nc-act power${Se.tmux?" on":""}${Se.degraded?" warn":""}`,onClick:()=>B(ke.length?{...Se,route:ke,availableEngines:(de==null?void 0:de.engines)||[]}:Se),title:Se.active?y("power-off"):y("power-on"),"aria-label":`${Se.active?y("power-off"):y("power-on")} ${Se.cell}`,children:h.jsx(Ze,{name:"power",size:16})})]},te.key)}const ie=te.value;return h.jsxs("div",{className:"nc-mcard","data-roster-key":te.key,"data-position":Qe,children:[h.jsx(Ur,{position:Qe,itemKey:te.key,label:ie.name,canMove:Ke,onMove:(Se,Xe)=>j(Qe,Se,Xe,Ne),onStep:Se=>E(Qe,te.key,Se,Ne)}),h.jsxs("button",{className:"nc-mcard-main",onClick:()=>e(ke.length?{session:ie.name,node:Ve}:ie.name),children:[h.jsx("span",{className:ie.attached?"dot on":"dot"}),h.jsxs("span",{className:"nc-mcard-text",children:[h.jsx("b",{children:ie.name}),h.jsx("small",{children:ie.preview?ie.preview:ie.cmd?ie.cmd:y("windows").replace("{n}",String(ie.windows||0))})]})]}),te.activity?h.jsx("span",{className:"nc-rel",children:Gr(te.activity)}):null,te.fresh&&((Te=ie.outbox)==null?void 0:Te.count)>0&&h.jsx("span",{className:"nc-badge",title:y("new-files-outbox"),children:ie.outbox.count}),h.jsx("button",{className:`nc-act pin${O.includes(te.key)?" on":""}`,"aria-label":`${y("pin")} ${ie.name}`,title:y("pin"),onClick:()=>Z(te.key),children:O.includes(te.key)?"★":"☆"}),h.jsx("button",{className:`nc-act technical${ie.technical?" on":""}`,title:ie.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${ie.technical?y("mark-normal"):y("mark-technical")} ${ie.name}`,onClick:()=>I(ie.name,!ie.technical,ke),children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),"aria-label":`${y("terminate")} ${ie.name}`,onClick:()=>{window.confirm(y("terminate-confirm").replace("{name}",ie.name))&&H(ie.name,ke)},children:"⋯"})]},te.key)}return h.jsxs("div",{className:"nc-home",children:[h.jsxs("header",{className:"nc-home-head",children:[h.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",h.jsx("span",{className:"nc-cursor"})]}),h.jsxs("div",{className:"nc-home-sub",children:[y("fleet-tmux")," · ",z," ",y("sessions"),pe>0&&` · ${pe} attached`]}),h.jsxs("span",{className:"nc-head-actions",children:[h.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:y("settings"),children:h.jsx(Ze,{name:"gear",size:18})}),h.jsx("button",{className:"nc-refresh",onClick:P,title:y("refresh"),children:h.jsx(Ze,{name:"refresh",size:18})})]})]}),h.jsxs("main",{className:"nc-home-scroll",children:[V>8&&h.jsx("input",{className:"nc-filter",type:"search",placeholder:y("filter-placeholder"),"aria-label":y("filter-placeholder"),value:S,onChange:te=>b(te.target.value)}),p&&h.jsx("div",{className:"nc-err",children:p}),h.jsxs("section",{className:"nc-group","data-position":"local",children:[h.jsx(lm,{label:y("position-local"),count:oe.length,state:re,dotClass:"on",onToggle:()=>G("local",{open:!re.open}),onFilter:te=>G("local",{filter:te})}),re.open&&oe.map(te=>xe(te,null,Q)),re.open&&c===null&&h.jsx("div",{className:"nc-empty",children:y("loading-fleet")}),re.open&&c!==null&&oe.length===0&&!p&&h.jsx("div",{className:"nc-empty",children:S?y("no-match").replace("{q}",S):y("no-sessions-short")})]}),l.map(te=>{const Ne=Ev(te.health,{passive:"warn"})||(te.status==="up"?"on":te.status==="passive"?"":"warn"),ke=te.health?Fa(te.health):te.status==="up"?"":qr(te),Qe=(te.route||[te.name]).join("/"),Ke=W(Qe),{rawItems:ie}=Rv(te),we=ar(ie,O,Ke.filter,zn(F,Qe)).filter(Se=>im(Se,S)),Te=te.direct&&te.health&&te.health.managed!==!1?h.jsx("button",{type:"button",className:`nc-act power${te.tunnelStatus==="up"?" on":""}`,disabled:A===te.name,title:te.tunnelStatus==="up"?y("power-off"):y("power-on"),"aria-label":`${te.tunnelStatus==="up"?y("power-off"):y("power-on")} ${te.label||te.name}`,onClick:()=>se(te),children:h.jsx(Ze,{name:"power",size:15})}):null;return h.jsxs("section",{className:"nc-group","data-position":Qe,children:[h.jsx(lm,{label:te.label||te.name,count:we.length,state:Ke,dotClass:Ne,dotTitle:ke,detail:te.status==="up"?"":te.health&&Fa(te.health)||qr(te),onToggle:()=>G(Qe,{open:!Ke.open}),onFilter:Se=>G(Qe,{filter:Se}),action:Te}),te.status==="up"&&Ke.open&&we.map(Se=>xe(Se,te,ie)),te.status==="up"&&Ke.open&&we.length===0&&h.jsx("div",{className:"nc-empty",children:S?y("no-match").replace("{q}",S):y("no-sessions-short")})]},`nodo-${Qe}`)}),h.jsxs("footer",{className:"nc-home-foot",onClick:U,title:y("copy-url"),children:[h.jsxs("span",{className:"nc-home-meta",children:[_&&h.jsxs("span",{className:"nc-home-version",children:["v",_]}),h.jsxs("span",{className:"nc-home-endpoint",children:[ye," · ",y("ssh-only")]})]}),h.jsx("span",{className:"nc-lang",onClick:te=>te.stopPropagation(),children:kv.map((te,de)=>h.jsxs("span",{children:[de>0&&" · ",h.jsx("button",{className:`nc-lang-btn${s===te?" on":""}`,onClick:()=>o(te),title:te,children:te.toUpperCase()})]},te))})]})]}),h.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:y("fleet-new-cell"),"aria-label":y("fleet-new-cell"),children:"+"}),D&&h.jsx(Oa,{cell:D,token:t,route:Array.isArray(D.route)?D.route:[],onConfirm:R,onClose:()=>B(null)})]})}function lm({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:l="",onToggle:c,onFilter:d,action:p=null}){return h.jsxs("div",{className:"nc-mobile-position-head",children:[h.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":n.open,"aria-label":`${e} · ${y("node-sessions").replace("{n}",String(t))}`,children:[h.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),h.jsx("span",{className:`dot ${s}`,title:o}),h.jsxs("span",{className:"nc-mobile-position-copy",children:[h.jsx("b",{children:e}),h.jsx("small",{children:l||y("node-sessions").replace("{n}",String(t))})]})]}),h.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${y("filter-placeholder")}`,title:y(`view-${n.filter}`),onChange:m=>d(m.target.value),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("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 Pv=Object.defineProperty,Qw=Object.getOwnPropertyDescriptor,Jw=(e,t)=>{for(var n in t)Pv(e,n,{get:t[n],enumerable:!0})},pt=(e,t,n,s)=>{for(var o=s>1?void 0:s?Qw(t,n):t,l=e.length-1,c;l>=0;l--)(c=e[l])&&(o=(s?c(t,n,o):c(o))||o);return s&&o&&Pv(t,n,o),o},be=(e,t)=>(n,s)=>t(n,s,e),cm="Terminal input",Ou={get:()=>cm,set:e=>cm=e},um="Too much output to announce, navigate to rows manually to read",zu={get:()=>um,set:e=>um=e};function Zw(e){return e.replace(/\r?\n/g,"\r")}function e0(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function t0(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function i0(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Dv(o,t,n,s)}}function Dv(e,t,n,s){e=Zw(e),e=e0(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Lv(e,t,n){let s=n.getBoundingClientRect(),o=e.clientX-s.left-10,l=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${l}px`,t.style.zIndex="1000",t.focus()}function hm(e,t,n,s,o){Lv(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function In(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Qa(e,t=0,n=e.length){let s="";for(let o=t;o<n;++o){let l=e[o];l>65535?(l-=65536,s+=String.fromCharCode((l>>10)+55296)+String.fromCharCode(l%1024+56320)):s+=String.fromCharCode(l)}return s}var n0=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o=0;if(this._interim){let l=e.charCodeAt(o++);56320<=l&&l<=57343?t[s++]=(this._interim-55296)*1024+l-56320+65536:(t[s++]=this._interim,t[s++]=l),this._interim=0}for(let l=o;l<n;++l){let c=e.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=n)return this._interim=c,s;let d=e.charCodeAt(l);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}},r0=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o,l,c,d,p=0,m=0;if(this.interim[0]){let _=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let w=0,C;for(;(C=this.interim[++w]&63)&&w<4;)v<<=6,v|=C;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,N=k-w;for(;m<N;){if(m>=n)return 0;if(C=e[m++],(C&192)!==128){m--,_=!0;break}else this.interim[w++]=C,v<<=6,v|=C&63}_||(k===2?v<128?m--:t[s++]=v:k===3?v<2048||v>=55296&&v<=57343||v===65279||(t[s++]=v):v<65536||v>1114111||(t[s++]=v)),this.interim.fill(0)}let S=n-4,b=m;for(;b<n;){for(;b<S&&!((o=e[b])&128)&&!((l=e[b+1])&128)&&!((c=e[b+2])&128)&&!((d=e[b+3])&128);)t[s++]=o,t[s++]=l,t[s++]=c,t[s++]=d,b+=4;if(o=e[b++],o<128)t[s++]=o;else if((o&224)===192){if(b>=n)return this.interim[0]=o,s;if(l=e[b++],(l&192)!==128){b--;continue}if(p=(o&31)<<6|l&63,p<128){b--;continue}t[s++]=p}else if((o&240)===224){if(b>=n)return this.interim[0]=o,s;if(l=e[b++],(l&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(p=(o&15)<<12|(l&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((o&248)===240){if(b>=n)return this.interim[0]=o,s;if(l=e[b++],(l&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=l,s;if(c=e[b++],(c&192)!==128){b--;continue}if(b>=n)return this.interim[0]=o,this.interim[1]=l,this.interim[2]=c,s;if(d=e[b++],(d&192)!==128){b--;continue}if(p=(o&7)<<18|(l&63)<<12|(c&63)<<6|d&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},Mv="",On=" ",ro=class jv{constructor(){this.fg=0,this.bg=0,this.extended=new $a}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 jv;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}},$a=class Tv{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Tv(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Di=class Av extends ro{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new $a,this.combinedData=""}static fromCharData(t){let n=new Av;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?In(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let 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:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},dm="di$target",Fu="di$dependencies",Yc=new Map;function s0(e){return e[Fu]||[]}function At(e){if(Yc.has(e))return Yc.get(e);let t=function(n,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");o0(t,n,o)};return t._id=e,Yc.set(e,t),t}function o0(e,t,n){t[dm]===t?t[Fu].push({id:e,index:n}):(t[Fu]=[{id:e,index:n}],t[dm]=t)}var Qt=At("BufferService"),Bv=At("CoreMouseService"),fr=At("CoreService"),a0=At("CharsetService"),Fh=At("InstantiationService"),Iv=At("LogService"),Jt=At("OptionsService"),Ov=At("OscLinkService"),l0=At("UnicodeService"),so=At("DecorationService"),Hu=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var S;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,l=new Di,c=n.getTrimmedLength(),d=-1,p=-1,m=!1;for(let b=0;b<c;b++)if(!(p===-1&&!n.hasContent(b))){if(n.loadCell(b,l),l.hasExtendedAttrs()&&l.extended.urlId)if(p===-1){p=b,d=l.extended.urlId;continue}else m=l.extended.urlId!==d;else p!==-1&&(m=!0);if(m||p!==-1&&b===c-1){let _=(S=this._oscLinkService.getLinkData(d))==null?void 0:S.uri;if(_){let v={start:{x:p+1,y:e},end:{x:b+(!m&&b===c-1?1:0),y:e}},w=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let C=new URL(_);["http:","https:"].includes(C.protocol)||(w=!0)}catch{w=!0}w||s.push({text:_,range:v,activate:(C,k)=>o?o.activate(C,k,v):c0(C,k),hover:(C,k)=>{var N;return(N=o==null?void 0:o.hover)==null?void 0:N.call(o,C,k,v)},leave:(C,k)=>{var N;return(N=o==null?void 0:o.leave)==null?void 0:N.call(o,C,k,v)}})}m=!1,l.hasExtendedAttrs()&&l.extended.urlId?(p=b,d=l.extended.urlId):(p=-1,d=-1)}}t(s)}};Hu=pt([be(0,Qt),be(1,Jt),be(2,Ov)],Hu);function c0(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
52
|
+
|
|
53
|
+
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Ja=At("CharSizeService"),dn=At("CoreBrowserService"),Hh=At("MouseService"),fn=At("RenderService"),u0=At("SelectionService"),zv=At("CharacterJoinerService"),Zr=At("ThemeService"),Fv=At("LinkProviderService"),h0=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?fm.isErrorNoTelemetry(e)?new fm(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)}},d0=new h0;function La(e){f0(e)||d0.onUnexpectedError(e)}var $u="Canceled";function f0(e){return e instanceof p0?!0:e instanceof Error&&e.name===$u&&e.message===$u}var p0=class extends Error{constructor(){super($u),this.name=this.message}};function m0(e){return new Error(`Illegal argument: ${e}`)}var fm=class Wu extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Wu)return t;let n=new Wu;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Uu=class Hv extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Hv.prototype)}};function mi(e,t=0){return e[e.length-(1+t)]}var g0;(e=>{function t(l){return l<0}e.isLessThan=t;function n(l){return l<=0}e.isLessThanOrEqual=n;function s(l){return l>0}e.isGreaterThan=s;function o(l){return l===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(g0||(g0={}));function v0(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var $v;(e=>{function t(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(A){yield A}e.single=o;function l(A){return t(A)?A:o(A)}e.wrap=l;function c(A){return A||n}e.from=c;function*d(A){for(let J=A.length-1;J>=0;J--)yield A[J]}e.reverse=d;function p(A){return!A||A[Symbol.iterator]().next().done===!0}e.isEmpty=p;function m(A){return A[Symbol.iterator]().next().value}e.first=m;function S(A,J){let O=0;for(let F of A)if(J(F,O++))return!0;return!1}e.some=S;function b(A,J){for(let O of A)if(J(O))return O}e.find=b;function*_(A,J){for(let O of A)J(O)&&(yield O)}e.filter=_;function*v(A,J){let O=0;for(let F of A)yield J(F,O++)}e.map=v;function*w(A,J){let O=0;for(let F of A)yield*J(F,O++)}e.flatMap=w;function*C(...A){for(let J of A)yield*J}e.concat=C;function k(A,J,O){let F=O;for(let Z of A)F=J(F,Z);return F}e.reduce=k;function*N(A,J,O=A.length){for(J<0&&(J+=A.length),O<0?O+=A.length:O>A.length&&(O=A.length);J<O;J++)yield A[J]}e.slice=N;function D(A,J=Number.POSITIVE_INFINITY){let O=[];if(J===0)return[O,A];let F=A[Symbol.iterator]();for(let Z=0;Z<J;Z++){let W=F.next();if(W.done)return[O,e.empty()];O.push(W.value)}return[O,{[Symbol.iterator](){return F}}]}e.consume=D;async function B(A){let J=[];for await(let O of A)J.push(O);return Promise.resolve(J)}e.asyncToArray=B})($v||($v={}));function ur(e){if($v.is(e)){let t=[];for(let n of e)if(n)try{n.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 _0(...e){return at(()=>ur(e))}function at(e){return{dispose:v0(()=>{e()})}}var Wv=class Uv{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{ur(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?Uv.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)}};Wv.DISABLE_DISPOSED_WARNING=!1;var Fn=Wv,He=class{constructor(){this._store=new Fn,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)}};He.None=Object.freeze({dispose(){}});var Qr=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}},hn=typeof window=="object"?window:globalThis,Ku=class qu{constructor(t){this.element=t,this.next=qu.Undefined,this.prev=qu.Undefined}};Ku.Undefined=new Ku(void 0);var ut=Ku,pm=class{constructor(){this._first=ut.Undefined,this._last=ut.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ut.Undefined}clear(){let e=this._first;for(;e!==ut.Undefined;){let t=e.next;e.prev=ut.Undefined,e.next=ut.Undefined,e=t}this._first=ut.Undefined,this._last=ut.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new ut(e);if(this._first===ut.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==ut.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ut.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ut.Undefined&&e.next!==ut.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ut.Undefined&&e.next===ut.Undefined?(this._first=ut.Undefined,this._last=ut.Undefined):e.next===ut.Undefined?(this._last=this._last.prev,this._last.next=ut.Undefined):e.prev===ut.Undefined&&(this._first=this._first.next,this._first.prev=ut.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ut.Undefined;)yield e.element,e=e.next}},y0=globalThis.performance&&typeof globalThis.performance.now=="function",S0=class Kv{static create(t){return new Kv(t)}constructor(t){this._now=y0&&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}},Ft;(e=>{e.None=()=>He.None;function t(j,E){return b(j,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function n(j){return(E,P=null,U)=>{let R=!1,H;return H=j(I=>{if(!R)return H?H.dispose():R=!0,E.call(P,I)},null,U),R&&H.dispose(),H}}e.once=n;function s(j,E,P){return m((U,R=null,H)=>j(I=>U.call(R,E(I)),null,H),P)}e.map=s;function o(j,E,P){return m((U,R=null,H)=>j(I=>{E(I),U.call(R,I)},null,H),P)}e.forEach=o;function l(j,E,P){return m((U,R=null,H)=>j(I=>E(I)&&U.call(R,I),null,H),P)}e.filter=l;function c(j){return j}e.signal=c;function d(...j){return(E,P=null,U)=>{let R=_0(...j.map(H=>H(I=>E.call(P,I))));return S(R,U)}}e.any=d;function p(j,E,P,U){let R=P;return s(j,H=>(R=E(R,H),R),U)}e.reduce=p;function m(j,E){let P,U={onWillAddFirstListener(){P=j(R.fire,R)},onDidRemoveLastListener(){P==null||P.dispose()}},R=new _e(U);return E==null||E.add(R),R.event}function S(j,E){return E instanceof Array?E.push(j):E&&E.add(j),j}function b(j,E,P=100,U=!1,R=!1,H,I){let se,q,M,K=0,Q,re={leakWarningThreshold:H,onWillAddFirstListener(){se=j(le=>{K++,q=E(q,le),U&&!M&&(oe.fire(q),q=void 0),Q=()=>{let V=q;q=void 0,M=void 0,(!U||K>1)&&oe.fire(V),K=0},typeof P=="number"?(clearTimeout(M),M=setTimeout(Q,P)):M===void 0&&(M=0,queueMicrotask(Q))})},onWillRemoveListener(){R&&K>0&&(Q==null||Q())},onDidRemoveLastListener(){Q=void 0,se.dispose()}},oe=new _e(re);return I==null||I.add(oe),oe.event}e.debounce=b;function _(j,E=0,P){return e.debounce(j,(U,R)=>U?(U.push(R),U):[R],E,void 0,!0,void 0,P)}e.accumulate=_;function v(j,E=(U,R)=>U===R,P){let U=!0,R;return l(j,H=>{let I=U||!E(H,R);return U=!1,R=H,I},P)}e.latch=v;function w(j,E,P){return[e.filter(j,E,P),e.filter(j,U=>!E(U),P)]}e.split=w;function C(j,E=!1,P=[],U){let R=P.slice(),H=j(q=>{R?R.push(q):se.fire(q)});U&&U.add(H);let I=()=>{R==null||R.forEach(q=>se.fire(q)),R=null},se=new _e({onWillAddFirstListener(){H||(H=j(q=>se.fire(q)),U&&U.add(H))},onDidAddFirstListener(){R&&(E?setTimeout(I):I())},onDidRemoveLastListener(){H&&H.dispose(),H=null}});return U&&U.add(se),se.event}e.buffer=C;function k(j,E){return(P,U,R)=>{let H=E(new D);return j(function(I){let se=H.evaluate(I);se!==N&&P.call(U,se)},void 0,R)}}e.chain=k;let N=Symbol("HaltChainable");class D{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(P=>(E(P),P)),this}filter(E){return this.steps.push(P=>E(P)?P:N),this}reduce(E,P){let U=P;return this.steps.push(R=>(U=E(U,R),U)),this}latch(E=(P,U)=>P===U){let P=!0,U;return this.steps.push(R=>{let H=P||!E(R,U);return P=!1,U=R,H?R:N}),this}evaluate(E){for(let P of this.steps)if(E=P(E),E===N)break;return E}}function B(j,E,P=U=>U){let U=(...se)=>I.fire(P(...se)),R=()=>j.on(E,U),H=()=>j.removeListener(E,U),I=new _e({onWillAddFirstListener:R,onDidRemoveLastListener:H});return I.event}e.fromNodeEventEmitter=B;function A(j,E,P=U=>U){let U=(...se)=>I.fire(P(...se)),R=()=>j.addEventListener(E,U),H=()=>j.removeEventListener(E,U),I=new _e({onWillAddFirstListener:R,onDidRemoveLastListener:H});return I.event}e.fromDOMEventEmitter=A;function J(j){return new Promise(E=>n(j)(E))}e.toPromise=J;function O(j){let E=new _e;return j.then(P=>{E.fire(P)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=O;function F(j,E){return j(P=>E.fire(P))}e.forward=F;function Z(j,E,P){return E(P),j(U=>E(U))}e.runAndSubscribe=Z;class W{constructor(E,P){this._observable=E,this._counter=0,this._hasChanged=!1;let U={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new _e(U),P&&P.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,P){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function G(j,E){return new W(j,E).emitter.event}e.fromObservable=G;function X(j){return(E,P,U)=>{let R=0,H=!1,I={beginUpdate(){R++},endUpdate(){R--,R===0&&(j.reportChanges(),H&&(H=!1,E.call(P)))},handlePossibleChange(){},handleChange(){H=!0}};j.addObserver(I),j.reportChanges();let se={dispose(){j.removeObserver(I)}};return U instanceof Fn?U.add(se):Array.isArray(U)&&U.push(se),se}}e.fromObservableLight=X})(Ft||(Ft={}));var Vu=class Yu{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Yu._idPool++}`,Yu.all.add(this)}start(t){this._stopWatch=new S0,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}}};Vu.all=new Set,Vu._idPool=0;var w0=Vu,b0=-1,qv=class Vv{constructor(t,n,s=(Vv._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n<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[l,c]=this.getMostFrequentStack(),d=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${c}):`;console.warn(d),console.warn(l);let p=new x0(d,l);this._errorHandler(p)}return()=>{let l=this._stacks.get(t.value)||0;this._stacks.set(t.value,l-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,n=0;for(let[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};qv._idPool=1;var C0=qv,k0=class Yv{constructor(t){this.value=t}static create(){let t=new Error;return new Yv(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
+
`).slice(2).join(`
|
|
59
|
+
`))}},x0=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},E0=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},N0=0,Xc=class{constructor(e){this.value=e,this.id=N0++}},R0=2,P0,_e=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new C0((e==null?void 0:e.onListenerError)??La,((n=this._options)==null?void 0:n.leakWarningThreshold)??b0):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new w0(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,n,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),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var c,d,p,m,S;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new E0(`${b}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||La)(v),He.None}if(this._disposed)return He.None;t&&(e=e.bind(t));let s=new Xc(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=k0.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Xc?(this._deliveryQueue??(this._deliveryQueue=new D0),this._listeners=[this._listeners,s]):this._listeners.push(s):((p=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||p.call(d,this),this._listeners=s,(S=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||S.call(m,this)),this._size++;let l=at(()=>{o==null||o(),this._removeListener(s)});return n instanceof Fn?n.add(l):Array.isArray(n)&&n.push(l),l}),this._event}_removeListener(e){var o,l,c,d;if((l=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||l.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,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*R0<=t.length){let p=0;for(let m=0;m<t.length;m++)t[m]?t[p++]=t[m]:s&&(this._deliveryQueue.end--,p<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=p}}_deliver(e,t){var s;if(!e)return;let n=((s=this._options)==null?void 0:s.onListenerError)||La;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(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,n,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Xc)this._deliver(this._listeners,e);else{let l=this._deliveryQueue;l.enqueue(this,e,this._listeners.length),this._deliverQueue(l)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},D0=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Xu=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new _e,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new _e,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Xu.INSTANCE=new Xu;var $h=Xu;function L0(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}$h.INSTANCE.onDidChangeZoomLevel;function M0(e){return $h.INSTANCE.getZoomFactor(e)}$h.INSTANCE.onDidChangeFullscreen;var es=typeof navigator=="object"?navigator.userAgent:"",Gu=es.indexOf("Firefox")>=0,j0=es.indexOf("AppleWebKit")>=0,Wh=es.indexOf("Chrome")>=0,T0=!Wh&&es.indexOf("Safari")>=0;es.indexOf("Electron/")>=0;es.indexOf("Android")>=0;var Gc=!1;if(typeof hn.matchMedia=="function"){let e=hn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=hn.matchMedia("(display-mode: fullscreen)");Gc=e.matches,L0(hn,e,({matches:n})=>{Gc&&t.matches||(Gc=n)})}var Kr="en",Qu=!1,Ju=!1,Ma=!1,Xv=!1,ba,ja=Kr,mm=Kr,A0,zi,lr=globalThis,zt,lv;typeof lr.vscode<"u"&&typeof lr.vscode.process<"u"?zt=lr.vscode.process:typeof process<"u"&&typeof((lv=process==null?void 0:process.versions)==null?void 0:lv.node)=="string"&&(zt=process);var cv,B0=typeof((cv=zt==null?void 0:zt.versions)==null?void 0:cv.electron)=="string",I0=B0&&(zt==null?void 0:zt.type)==="renderer",uv;if(typeof zt=="object"){Qu=zt.platform==="win32",Ju=zt.platform==="darwin",Ma=zt.platform==="linux",Ma&&zt.env.SNAP&&zt.env.SNAP_REVISION,zt.env.CI||zt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,ba=Kr,ja=Kr;let e=zt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);ba=t.userLocale,mm=t.osLocale,ja=t.resolvedLanguage||Kr,A0=(uv=t.languagePack)==null?void 0:uv.translationsConfigFile}catch{}Xv=!0}else typeof navigator=="object"&&!I0?(zi=navigator.userAgent,Qu=zi.indexOf("Windows")>=0,Ju=zi.indexOf("Macintosh")>=0,(zi.indexOf("Macintosh")>=0||zi.indexOf("iPad")>=0||zi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ma=zi.indexOf("Linux")>=0,(zi==null?void 0:zi.indexOf("Mobi"))>=0,ja=globalThis._VSCODE_NLS_LANGUAGE||Kr,ba=navigator.language.toLowerCase(),mm=ba):console.error("Unable to resolve platform.");var Gv=Qu,Gi=Ju,O0=Ma,gm=Xv,Zi=zi,jn=ja,z0;(e=>{function t(){return jn}e.value=t;function n(){return jn.length===2?jn==="en":jn.length>=3?jn[0]==="e"&&jn[1]==="n"&&jn[2]==="-":!1}e.isDefaultVariant=n;function s(){return jn==="en"}e.isDefault=s})(z0||(z0={}));var F0=typeof lr.postMessage=="function"&&!lr.importScripts;(()=>{if(F0){let e=[];lr.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let l=e[s];if(l.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),l.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),lr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var H0=!!(Zi&&Zi.indexOf("Chrome")>=0);Zi&&Zi.indexOf("Firefox")>=0;!H0&&Zi&&Zi.indexOf("Safari")>=0;Zi&&Zi.indexOf("Edg/")>=0;Zi&&Zi.indexOf("Android")>=0;var Fr=typeof navigator=="object"?navigator:{};gm||document.queryCommandSupported&&document.queryCommandSupported("copy")||Fr&&Fr.clipboard&&Fr.clipboard.writeText,gm||Fr&&Fr.clipboard&&Fr.clipboard.readText;var Uh=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}},Qc=new Uh,vm=new Uh,_m=new Uh,$0=new Array(230),Qv;(e=>{function t(d){return Qc.keyCodeToStr(d)}e.toString=t;function n(d){return Qc.strToKeyCode(d)}e.fromString=n;function s(d){return vm.keyCodeToStr(d)}e.toUserSettingsUS=s;function o(d){return _m.keyCodeToStr(d)}e.toUserSettingsGeneral=o;function l(d){return vm.strToKeyCode(d)||_m.strToKeyCode(d)}e.fromUserSettings=l;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 Qc.keyCodeToStr(d)}e.toElectronAccelerator=c})(Qv||(Qv={}));var W0=class Jv{constructor(t,n,s,o,l){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=l}equals(t){return t instanceof Jv&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new U0([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},U0=class{constructor(e){if(e.length===0)throw m0("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function K0(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return Qv.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(Gu)switch(t){case 59:return 85;case 60:if(O0)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Gi)return 57;break}else if(j0&&(Gi&&t===93||!Gi&&t===92))return 57;return $0[t]||0}var q0=Gi?256:2048,V0=512,Y0=1024,X0=Gi?2048:256,ym=class{constructor(e){var n;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=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=K0(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|=q0),this.altKey&&(t|=V0),this.shiftKey&&(t|=Y0),this.metaKey&&(t|=X0),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new W0(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Sm=new WeakMap;function G0(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var Q0=class{static getSameOriginWindowChain(e){let t=Sm.get(e);if(!t){t=[],Sm.set(e,t);let n=e,s;do s=G0(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let l of o){let c=l.window.deref();if(n+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===t||!l.iframeElement)break;let d=l.iframeElement.getBoundingClientRect();n+=d.top,s+=d.left}return{top:n,left:s}}},Ca=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=Q0.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},wm=class{constructor(e,t=0,n=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(Wh){let l=navigator.userAgent.match(/Chrome\/(\d+)/);s=(l?parseInt(l[1]):123)<=122}if(e){let l=e,c=e,d=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof l.wheelDeltaY<"u")s?this.deltaY=l.wheelDeltaY/(120*d):this.deltaY=l.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Gu&&!Gi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof l.wheelDeltaX<"u")T0&&Gv?this.deltaX=-(l.wheelDeltaX/120):s?this.deltaX=l.wheelDeltaX/(120*d):this.deltaX=l.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Gu&&!Gi?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()}},Zv=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),J0;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof Z0?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ft.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Zv})})(J0||(J0={}));var Z0=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?Zv:(this._emitter||(this._emitter=new _e),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Kh=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 Uu("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Uu("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},eb=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,n=globalThis){if(this.isDisposed)throw new Uu("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=at(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},tb;(e=>{async function t(s){let o,l=await Promise.all(s.map(c=>c.then(d=>d,d=>{o||(o=d)})));if(typeof o<"u")throw o;return l}e.settled=t;function n(s){return new Promise(async(o,l)=>{try{await s(o,l)}catch(c){l(c)}})}e.withAsyncBody=n})(tb||(tb={}));var bm=class Ri{static fromArray(t){return new Ri(n=>{n.emitMany(t)})}static fromPromise(t){return new Ri(async n=>{n.emitMany(await t)})}static fromPromises(t){return new Ri(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new Ri(async n=>{await Promise.all(t.map(async s=>{for await(let o of s)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new _e,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 Ft.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new Ri(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return Ri.map(this,t)}static filter(t,n){return new Ri(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return Ri.filter(this,t)}static coalesce(t){return Ri.filter(t,n=>!!n)}coalesce(){return Ri.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return Ri.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())}};bm.EMPTY=bm.fromArray([]);var{getWindow:Xi,getWindowId:ib,onDidRegisterWindow:nb}=(function(){let e=new Map,t={window:hn,disposables:new Fn};e.set(hn.vscodeWindowId,t);let n=new _e,s=new _e,o=new _e;function l(c,d){return(typeof c=="number"?e.get(c):void 0)??(d?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return He.None;let d=new Fn,p={window:c,disposables:d.add(new Fn)};return e.set(c.vscodeWindowId,p),d.add(at(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),d.add(Be(c,Dt.BEFORE_UNLOAD,()=>{o.fire(c)})),n.fire(p),d},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:l,getWindow(c){var m;let d=c;if((m=d==null?void 0:d.ownerDocument)!=null&&m.defaultView)return d.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:hn},getDocument(c){return Xi(c).document}}})(),rb=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,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 Be(e,t,n,s){return new rb(e,t,n,s)}var Cm=function(e,t,n,s){return Be(e,t,n,s)},qh,sb=class extends eb{constructor(e){super(),this.defaultTarget=e&&Xi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},km=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){La(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,o=l=>{n.set(l,!1);let c=e.get(l)??[];for(t.set(l,c),e.set(l,[]),s.set(l,!0);c.length>0;)c.sort(km.sort),c.shift().execute();s.set(l,!1)};qh=(l,c,d=0)=>{let p=ib(l),m=new km(c,d),S=e.get(p);return S||(S=[],e.set(p,S)),S.push(m),n.get(p)||(n.set(p,!0),l.requestAnimationFrame(()=>o(p))),m}})();function ob(e){let t=e.getBoundingClientRect(),n=Xi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var Dt={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"},ab=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 n=oi(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=oi(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=oi(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=oi(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=oi(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=oi(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=oi(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=oi(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=oi(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=oi(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=oi(t);this._paddingRight!==n&&(this._paddingRight=n,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 n=oi(t);this._fontSize!==n&&(this._fontSize=n,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 n=oi(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=oi(t);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,n){this.domNode.classList.toggle(t,n),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,n){this.domNode.setAttribute(t,n)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function oi(e){return typeof e=="number"?`${e}px`:e}function eo(e){return new ab(e)}var e_=class{constructor(){this._hooks=new Fn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let l=e;try{e.setPointerCapture(t),this._hooks.add(at(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{l=Xi(e)}this._hooks.add(Be(l,Dt.POINTER_MOVE,c=>{if(c.buttons!==n){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Be(l,Dt.POINTER_UP,c=>this.stopMonitoring(!0)))}};function lb(e,t,n){let s=null,o=null;if(typeof n.value=="function"?(s="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",o=n.get),!o)throw new Error("not supported");let l=`$memoize$${t}`;n[s]=function(...c){return this.hasOwnProperty(l)||Object.defineProperty(this,l,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,c)}),this[l]}}var Yi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Yi||(Yi={}));var Xs=class Vt extends He{constructor(){super(),this.dispatched=!1,this.targets=new pm,this.ignoreTargets=new pm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ft.runAndSubscribe(nb,({window:t,disposables:n})=>{n.add(Be(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Be(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(Be(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:hn,disposables:this._store}))}static addTarget(t){if(!Vt.isTouchDevice())return He.None;Vt.INSTANCE||(Vt.INSTANCE=new Vt);let n=Vt.INSTANCE.targets.push(t);return at(n)}static ignoreTarget(t){if(!Vt.isTouchDevice())return He.None;Vt.INSTANCE||(Vt.INSTANCE=new Vt);let n=Vt.INSTANCE.ignoreTargets.push(t);return at(n)}static isTouchDevice(){return"ontouchstart"in hn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let l=t.targetTouches.item(s);this.activeTouches[l.identifier]={id:l.identifier,initialTarget:l.target,initialTimeStamp:n,initialPageX:l.pageX,initialPageY:l.pageY,rollingTimestamps:[n],rollingPageX:[l.pageX],rollingPageY:[l.pageY]};let c=this.newGestureEvent(Yi.Start,l.target);c.pageX=l.pageX,c.pageY=l.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let l=0,c=n.changedTouches.length;l<c;l++){let d=n.changedTouches.item(l);if(!this.activeTouches.hasOwnProperty(String(d.identifier))){console.warn("move of an UNKNOWN touch",d);continue}let p=this.activeTouches[d.identifier],m=Date.now()-p.initialTimeStamp;if(m<Vt.HOLD_DELAY&&Math.abs(p.initialPageX-mi(p.rollingPageX))<30&&Math.abs(p.initialPageY-mi(p.rollingPageY))<30){let S=this.newGestureEvent(Yi.Tap,p.initialTarget);S.pageX=mi(p.rollingPageX),S.pageY=mi(p.rollingPageY),this.dispatchEvent(S)}else if(m>=Vt.HOLD_DELAY&&Math.abs(p.initialPageX-mi(p.rollingPageX))<30&&Math.abs(p.initialPageY-mi(p.rollingPageY))<30){let S=this.newGestureEvent(Yi.Contextmenu,p.initialTarget);S.pageX=mi(p.rollingPageX),S.pageY=mi(p.rollingPageY),this.dispatchEvent(S)}else if(o===1){let S=mi(p.rollingPageX),b=mi(p.rollingPageY),_=mi(p.rollingTimestamps)-p.rollingTimestamps[0],v=S-p.rollingPageX[0],w=b-p.rollingPageY[0],C=[...this.targets].filter(k=>p.initialTarget instanceof Node&&k.contains(p.initialTarget));this.inertia(t,C,s,Math.abs(v)/_,v>0?1:-1,S,Math.abs(w)/_,w>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(Yi.End,p.initialTarget)),delete this.activeTouches[d.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===Yi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Vt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Yi.Change||t.type===Yi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,l=t.initialTarget;for(;l&&l!==s;)o++,l=l.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,l,c,d,p,m){this.handle=qh(t,()=>{let S=Date.now(),b=S-s,_=0,v=0,w=!0;o+=Vt.SCROLL_FRICTION*b,d+=Vt.SCROLL_FRICTION*b,o>0&&(w=!1,_=l*o*b),d>0&&(w=!1,v=p*d*b);let C=this.newGestureEvent(Yi.Change);C.translationX=_,C.translationY=v,n.forEach(k=>k.dispatchEvent(C)),w||this.inertia(t,n,S,o,l,c+_,d,p,m+v)})}onTouchMove(t){let n=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let l=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("end of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],d=this.newGestureEvent(Yi.Change,c.initialTarget);d.translationX=l.pageX-mi(c.rollingPageX),d.translationY=l.pageY-mi(c.rollingPageY),d.pageX=l.pageX,d.pageY=l.pageY,this.dispatchEvent(d),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(l.pageX),c.rollingPageY.push(l.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Xs.SCROLL_FRICTION=-.005,Xs.HOLD_DELAY=700,Xs.CLEAR_TAP_COUNT_TIME=400,pt([lb],Xs,"isTouchDevice",1);var cb=Xs,Vh=class extends He{onclick(e,t){this._register(Be(e,Dt.CLICK,n=>t(new Ca(Xi(e),n))))}onmousedown(e,t){this._register(Be(e,Dt.MOUSE_DOWN,n=>t(new Ca(Xi(e),n))))}onmouseover(e,t){this._register(Be(e,Dt.MOUSE_OVER,n=>t(new Ca(Xi(e),n))))}onmouseleave(e,t){this._register(Be(e,Dt.MOUSE_LEAVE,n=>t(new Ca(Xi(e),n))))}onkeydown(e,t){this._register(Be(e,Dt.KEY_DOWN,n=>t(new ym(n))))}onkeyup(e,t){this._register(Be(e,Dt.KEY_UP,n=>t(new ym(n))))}oninput(e,t){this._register(Be(e,Dt.INPUT,t))}onblur(e,t){this._register(Be(e,Dt.BLUR,t))}onfocus(e,t){this._register(Be(e,Dt.FOCUS,t))}onchange(e,t){this._register(Be(e,Dt.CHANGE,t))}ignoreGesture(e){return cb.ignoreTarget(e)}},xm=11,ub=class extends Vh{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=xm+"px",this.domNode.style.height=xm+"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 e_),this._register(Cm(this.bgDomNode,Dt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Cm(this.domNode,Dt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new sb),this._pointerdownScheduleRepeatTimer=this._register(new Kh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Xi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},hb=class Zu{constructor(t,n,s,o,l,c,d){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,l=l|0,c=c|0,d=d|0),this.rawScrollLeft=o,this.rawScrollTop=d,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),l<0&&(l=0),d+l>c&&(d=c-l),d<0&&(d=0),this.width=n,this.scrollWidth=s,this.scrollLeft=o,this.height=l,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,n){return new Zu(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Zu(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,l=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,d=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:l,heightChanged:c,scrollHeightChanged:d,scrollTopChanged:p}}},db=class extends He{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new _e),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new hb(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 n=this._state.withScrollDimensions(e,t);this._setState(n,!!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 n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new Nm(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=Nm.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Em=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Jc(e,t){let n=t-e;return function(s){return e+n*mb(s)}}function fb(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var Nm=class eh{constructor(t,n,s,o){this.from=t,this.to=n,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,n,s){if(Math.abs(t-n)>2.5*s){let o,l;return t<n?(o=t+.75*s,l=n-.75*s):(o=t-.75*s,l=n+.75*s),fb(Jc(t,o),Jc(l,n),.33)}return Jc(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),o=this.scrollTop(n);return new Em(s,o,!1)}return new Em(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return eh.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new eh(t,n,o,s)}};function pb(e){return Math.pow(e,3)}function mb(e){return 1-pb(1-e)}var gb=class extends He{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Kh)}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":"")))}},vb=140,t_=class extends Vh{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 gb(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new e_),this._shouldRender=!0,this.domNode=eo(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(Be(this.domNode.domNode,Dt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new ub(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=eo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Be(this.slider.domNode,Dt.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=ob(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,n);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),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let l=this._sliderOrthogonalPointerPosition(o),c=Math.abs(l-n);if(Gv&&c>vb){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()}},i_=class th{constructor(t,n,s,o,l,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=l,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new th(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,l){let c=Math.max(0,s-t),d=Math.max(0,c-2*n),p=o>0&&o>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(d),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(s*d/o))),S=(d-m)/(o-s),b=l*S;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(m),computedSliderRatio:S,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=th._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},_b=class extends t_{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new i_(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}},yb=class extends t_{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new i_(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}},Sb=500,Rm=50,wb=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},ih=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,s=1,o=this._rear;do{let l=o===this._front?t:Math.pow(2,-s);if(t-=l,n+=this._memory[o].score*l,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(Wh){let n=Xi(t.browserEvent),s=M0(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let o=null,l=new wb(t,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=l,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]=l),l.score=this._computeScore(l,o)}_computeScore(t,n){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),n){let o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),c=Math.abs(n.deltaX),d=Math.abs(n.deltaY),p=Math.max(Math.min(o,c),1),m=Math.max(Math.min(l,d),1),S=Math.max(o,c),b=Math.max(l,d);S%p===0&&b%m===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};ih.INSTANCE=new ih;var bb=ih,Cb=class extends Vh{constructor(e,t,n){super(),this._onScroll=this._register(new _e),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new _e),this.onWillScroll=this._onWillScroll.event,this._options=xb(t),this._scrollable=n,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 yb(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new _b(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=eo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=eo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=eo(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 Kh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=ur(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,Gi&&(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 wm(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=ur(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new wm(n))};this._mouseWheelToDispose.push(Be(this._listenOnDomNode,Dt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=bb.INSTANCE;t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let l=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+l===0?c=l=0:Math.abs(l)>=Math.abs(c)?c=0:l=0),this._options.flipAxes&&([l,c]=[c,l]);let d=!Gi&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||d)&&!c&&(c=l,l=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,l=l*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),m={};if(l){let S=Rm*l,b=p.scrollTop-(S<0?Math.floor(S):Math.ceil(S));this._verticalScrollbar.writeScrollPosition(m,b)}if(c){let S=Rm*c,b=p.scrollLeft-(S<0?Math.floor(S):Math.ceil(S));this._horizontalScrollbar.writeScrollPosition(m,b)}m=this._scrollable.validateScrollPosition(m),(p.scrollLeft!==m.scrollLeft||p.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),n=!0)}let s=n;!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,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",l=n||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${l}${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(),Sb)}},kb=class extends Cb{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function xb(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,Gi&&(t.className+=" mac"),t}var nh=class extends He{constructor(e,t,n,s,o,l,c,d){super(),this._bufferService=n,this._optionsService=c,this._renderService=d,this._onRequestScrollLines=this._register(new _e),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new db({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>qh(s.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new kb(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(m=>{this._scrollableElement.updateOptions({handleMouseWheel:!(m&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ft.runAndSubscribe(l.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=l.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(at(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(at(()=>this._styleElement.remove())),this._register(Ft.runAndSubscribe(l.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${l.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${l.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${l.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(m=>this._handleScroll(m)))}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),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};nh=pt([be(2,Qt),be(3,dn),be(4,Bv),be(5,Zr),be(6,Jt),be(7,fn)],nh);var rh=class extends He{constructor(e,t,n,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,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(l=>this._removeDecoration(l))),this._register(at(()=>{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 n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};rh=pt([be(1,Qt),be(2,dn),be(3,so),be(4,fn)],rh);var Eb=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ki={full:0,left:0,center:0,right:0},Tn={full:0,left:0,center:0,right:0},Fs={full:0,left:0,center:0,right:0},Wa=class extends He{constructor(e,t,n,s,o,l,c,d){var m;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=l,this._themeService=c,this._coreBrowserService=d,this._colorZoneStore=new Eb,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(),(m=this._viewportElement.parentElement)==null||m.insertBefore(this._canvas,this._viewportElement),this._register(at(()=>{var S;return(S=this._canvas)==null?void 0:S.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;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);Tn.full=this._canvas.width,Tn.left=e,Tn.center=t,Tn.right=e,this._refreshDrawHeightConstants(),Fs.full=1,Fs.left=1,Fs.center=1+Tn.left,Fs.right=1+Tn.left+Tn.center}_refreshDrawHeightConstants(){Ki.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);Ki.left=t,Ki.center=t,Ki.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.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(Fs[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ki[e.position||"full"]/2),Tn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ki[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}))}};Wa=pt([be(2,Qt),be(3,so),be(4,fn),be(5,Jt),be(6,Zr),be(7,dn)],Wa);var ue;(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=""))(ue||(ue={}));var Ta;(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=""))(Ta||(Ta={}));var n_;(e=>e.ST=`${ue.ESC}\\`)(n_||(n_={}));var sh=class{constructor(e,t,n,s,o,l){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=s,this._coreService=o,this._renderService=l,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${ue.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,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=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let l=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(l.width,1)+"px",this._textarea.style.height=Math.max(l.height,1)+"px",this._textarea.style.lineHeight=l.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};sh=pt([be(2,Qt),be(3,Jt),be(4,fr),be(5,fn)],sh);var Lt=0,Mt=0,jt=0,ft=0,Pm={css:"#00000000",rgba:0},St;(e=>{function t(o,l,c,d){return d!==void 0?`#${tr(o)}${tr(l)}${tr(c)}${tr(d)}`:`#${tr(o)}${tr(l)}${tr(c)}`}e.toCss=t;function n(o,l,c,d=255){return(o<<24|l<<16|c<<8|d)>>>0}e.toRgba=n;function s(o,l,c,d){return{css:e.toCss(o,l,c,d),rgba:e.toRgba(o,l,c,d)}}e.toColor=s})(St||(St={}));var st;(e=>{function t(p,m){if(ft=(m.rgba&255)/255,ft===1)return{css:m.css,rgba:m.rgba};let S=m.rgba>>24&255,b=m.rgba>>16&255,_=m.rgba>>8&255,v=p.rgba>>24&255,w=p.rgba>>16&255,C=p.rgba>>8&255;Lt=v+Math.round((S-v)*ft),Mt=w+Math.round((b-w)*ft),jt=C+Math.round((_-C)*ft);let k=St.toCss(Lt,Mt,jt),N=St.toRgba(Lt,Mt,jt);return{css:k,rgba:N}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,m,S){let b=Aa.ensureContrastRatio(p.rgba,m.rgba,S);if(b)return St.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function o(p){let m=(p.rgba|255)>>>0;return[Lt,Mt,jt]=Aa.toChannels(m),{css:St.toCss(Lt,Mt,jt),rgba:m}}e.opaque=o;function l(p,m){return ft=Math.round(m*255),[Lt,Mt,jt]=Aa.toChannels(p.rgba),{css:St.toCss(Lt,Mt,jt,ft),rgba:St.toRgba(Lt,Mt,jt,ft)}}e.opacity=l;function c(p,m){return ft=p.rgba&255,l(p,ft*m/255)}e.multiplyOpacity=c;function d(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=d})(st||(st={}));var ht;(e=>{let t,n;try{let o=document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d",{willReadFrequently:!0});l&&(t=l,t.globalCompositeOperation="copy",n=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Lt=parseInt(o.slice(1,2).repeat(2),16),Mt=parseInt(o.slice(2,3).repeat(2),16),jt=parseInt(o.slice(3,4).repeat(2),16),St.toColor(Lt,Mt,jt);case 5:return Lt=parseInt(o.slice(1,2).repeat(2),16),Mt=parseInt(o.slice(2,3).repeat(2),16),jt=parseInt(o.slice(3,4).repeat(2),16),ft=parseInt(o.slice(4,5).repeat(2),16),St.toColor(Lt,Mt,jt,ft);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 l=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(l)return Lt=parseInt(l[1]),Mt=parseInt(l[2]),jt=parseInt(l[3]),ft=Math.round((l[5]===void 0?1:parseFloat(l[5]))*255),St.toColor(Lt,Mt,jt,ft);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Lt,Mt,jt,ft]=t.getImageData(0,0,1,1).data,ft!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:St.toRgba(Lt,Mt,jt,ft),css:o}}e.toColor=s})(ht||(ht={}));var Gt;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,l){let c=s/255,d=o/255,p=l/255,m=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),S=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4),b=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+S*.7152+b*.0722}e.relativeLuminance2=n})(Gt||(Gt={}));var Aa;(e=>{function t(c,d){if(ft=(d&255)/255,ft===1)return d;let p=d>>24&255,m=d>>16&255,S=d>>8&255,b=c>>24&255,_=c>>16&255,v=c>>8&255;return Lt=b+Math.round((p-b)*ft),Mt=_+Math.round((m-_)*ft),jt=v+Math.round((S-v)*ft),St.toRgba(Lt,Mt,jt)}e.blend=t;function n(c,d,p){let m=Gt.relativeLuminance(c>>8),S=Gt.relativeLuminance(d>>8);if(cn(m,S)<p){if(S<m){let v=s(c,d,p),w=cn(m,Gt.relativeLuminance(v>>8));if(w<p){let C=o(c,d,p),k=cn(m,Gt.relativeLuminance(C>>8));return w>k?v:C}return v}let b=o(c,d,p),_=cn(m,Gt.relativeLuminance(b>>8));if(_<p){let v=s(c,d,p),w=cn(m,Gt.relativeLuminance(v>>8));return _>w?b:v}return b}}e.ensureContrastRatio=n;function s(c,d,p){let m=c>>24&255,S=c>>16&255,b=c>>8&255,_=d>>24&255,v=d>>16&255,w=d>>8&255,C=cn(Gt.relativeLuminance2(_,v,w),Gt.relativeLuminance2(m,S,b));for(;C<p&&(_>0||v>0||w>0);)_-=Math.max(0,Math.ceil(_*.1)),v-=Math.max(0,Math.ceil(v*.1)),w-=Math.max(0,Math.ceil(w*.1)),C=cn(Gt.relativeLuminance2(_,v,w),Gt.relativeLuminance2(m,S,b));return(_<<24|v<<16|w<<8|255)>>>0}e.reduceLuminance=s;function o(c,d,p){let m=c>>24&255,S=c>>16&255,b=c>>8&255,_=d>>24&255,v=d>>16&255,w=d>>8&255,C=cn(Gt.relativeLuminance2(_,v,w),Gt.relativeLuminance2(m,S,b));for(;C<p&&(_<255||v<255||w<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),C=cn(Gt.relativeLuminance2(_,v,w),Gt.relativeLuminance2(m,S,b));return(_<<24|v<<16|w<<8|255)>>>0}e.increaseLuminance=o;function l(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=l})(Aa||(Aa={}));function tr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function cn(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Nb=class extends ro{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ua=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Di}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,l=0,c=0,d=t.getFg(0),p=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==d||this._workCell.bg!==p){if(m-o>1){let S=this._getJoinedRanges(s,c,l,t,o);for(let b=0;b<S.length;b++)n.push(S[b])}o=m,c=l,d=this._workCell.fg,p=this._workCell.bg}l+=this._workCell.getChars().length||On.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,c,l,t,o);for(let S=0;S<m.length;S++)n.push(m[S])}return n}_getJoinedRanges(e,t,n,s,o){let l=e.substring(t,n),c=[];try{c=this._characterJoiners[0].handler(l)}catch(d){console.error(d)}for(let d=1;d<this._characterJoiners.length;d++)try{let p=this._characterJoiners[d].handler(l);for(let m=0;m<p.length;m++)Ua._mergeRanges(c,p[m])}catch(p){console.error(p)}return this._stringRangesToCellRanges(c,s,o),c}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,l=0,c=e[s];if(c){for(let d=n;d<this._bufferService.cols;d++){let p=t.getWidth(d),m=t.getString(d).length||On.length;if(p!==0){if(!o&&c[0]<=l&&(c[0]=d,o=!0),c[1]<=l){if(c[1]=d,c=e[++s],!c)break;c[0]<=l?(c[0]=d,o=!0):o=!1}l+=m}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){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]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Ua=pt([be(0,Qt)],Ua);function Rb(e){return 57508<=e&&e<=57558}function Pb(e){return 9472<=e&&e<=9631}function Db(e){return Rb(e)||Pb(e)}function Lb(){return{css:{canvas:ka(),cell:ka()},device:{canvas:ka(),cell:ka(),char:{width:0,height:0,left:0,top:0}}}}function ka(){return{width:0,height:0}}var oh=class{constructor(e,t,n,s,o,l,c){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=l,this._themeService=c,this._workCell=new Di,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,l,c,d,p,m,S){let b=[],_=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,w=e.getNoBgTrimmedLength();n&&w<l+1&&(w=l+1);let C,k=0,N="",D=0,B=0,A=0,J=0,O=!1,F=0,Z=!1,W=0,G=0,X=[],j=m!==-1&&S!==-1;for(let E=0;E<w;E++){e.loadCell(E,this._workCell);let P=this._workCell.getWidth();if(P===0)continue;let U=!1,R=E>=G,H=E,I=this._workCell;if(_.length>0&&E===_[0][0]&&R){let de=_.shift(),Ne=this._isCellInSelection(de[0],t);for(D=de[0]+1;D<de[1];D++)R&&(R=Ne===this._isCellInSelection(D,t));R&&(R=!n||l<de[0]||l>=de[1]),R?(U=!0,I=new Nb(this._workCell,e.translateToString(!0,de[0],de[1]),de[1]-de[0]),H=de[1]-1,P=I.getWidth()):G=de[1]}let se=this._isCellInSelection(E,t),q=n&&E===l,M=j&&E>=m&&E<=S,K=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,de=>{K=!0});let Q=I.getChars()||On;if(Q===" "&&(I.isUnderline()||I.isOverline())&&(Q=" "),W=P*d-p.get(Q,I.isBold(),I.isItalic()),!C)C=this._document.createElement("span");else if(k&&(se&&Z||!se&&!Z&&I.bg===B)&&(se&&Z&&v.selectionForeground||I.fg===A)&&I.extended.ext===J&&M===O&&W===F&&!q&&!U&&!K&&R){I.isInvisible()?N+=On:N+=Q,k++;continue}else k&&(C.textContent=N),C=this._document.createElement("span"),k=0,N="";if(B=I.bg,A=I.fg,J=I.extended.ext,O=M,F=W,Z=se,U&&l>=E&&l<=H&&(l=E),!this._coreService.isCursorHidden&&q&&this._coreService.isCursorInitialized){if(X.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&X.push("xterm-cursor-blink"),X.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":X.push("xterm-cursor-outline");break;case"block":X.push("xterm-cursor-block");break;case"bar":X.push("xterm-cursor-bar");break;case"underline":X.push("xterm-cursor-underline");break}}if(I.isBold()&&X.push("xterm-bold"),I.isItalic()&&X.push("xterm-italic"),I.isDim()&&X.push("xterm-dim"),I.isInvisible()?N=On:N=I.getChars()||On,I.isUnderline()&&(X.push(`xterm-underline-${I.extended.underlineStyle}`),N===" "&&(N=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())C.style.textDecorationColor=`rgb(${ro.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let de=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&de<8&&(de+=8),C.style.textDecorationColor=v.ansi[de].css}I.isOverline()&&(X.push("xterm-overline"),N===" "&&(N=" ")),I.isStrikethrough()&&X.push("xterm-strikethrough"),M&&(C.style.textDecoration="underline");let re=I.getFgColor(),oe=I.getFgColorMode(),le=I.getBgColor(),V=I.getBgColorMode(),z=!!I.isInverse();if(z){let de=re;re=le,le=de;let Ne=oe;oe=V,V=Ne}let pe,ye,xe=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,de=>{de.options.layer!=="top"&&xe||(de.backgroundColorRGB&&(V=50331648,le=de.backgroundColorRGB.rgba>>8&16777215,pe=de.backgroundColorRGB),de.foregroundColorRGB&&(oe=50331648,re=de.foregroundColorRGB.rgba>>8&16777215,ye=de.foregroundColorRGB),xe=de.options.layer==="top")}),!xe&&se&&(pe=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,le=pe.rgba>>8&16777215,V=50331648,xe=!0,v.selectionForeground&&(oe=50331648,re=v.selectionForeground.rgba>>8&16777215,ye=v.selectionForeground)),xe&&X.push("xterm-decoration-top");let te;switch(V){case 16777216:case 33554432:te=v.ansi[le],X.push(`xterm-bg-${le}`);break;case 50331648:te=St.toColor(le>>16,le>>8&255,le&255),this._addStyle(C,`background-color:#${Dm((le>>>0).toString(16),"0",6)}`);break;case 0:default:z?(te=v.foreground,X.push("xterm-bg-257")):te=v.background}switch(pe||I.isDim()&&(pe=st.multiplyOpacity(te,.5)),oe){case 16777216:case 33554432:I.isBold()&&re<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(re+=8),this._applyMinimumContrast(C,te,v.ansi[re],I,pe,void 0)||X.push(`xterm-fg-${re}`);break;case 50331648:let de=St.toColor(re>>16&255,re>>8&255,re&255);this._applyMinimumContrast(C,te,de,I,pe,ye)||this._addStyle(C,`color:#${Dm(re.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(C,te,v.foreground,I,pe,ye)||z&&X.push("xterm-fg-257")}X.length&&(C.className=X.join(" "),X.length=0),!q&&!U&&!K&&R?k++:C.textContent=N,W!==this.defaultSpacing&&(C.style.letterSpacing=`${W}px`),b.push(C),E=H}return C&&k&&(C.textContent=N),b}_applyMinimumContrast(e,t,n,s,o,l){if(this._optionsService.rawOptions.minimumContrastRatio===1||Db(s.getCode()))return!1;let c=this._getContrastCache(s),d;if(!o&&!l&&(d=c.getColor(t.rgba,n.rgba)),d===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);d=st.ensureContrastRatio(o||t,l||n,p),c.setColor((o||t).rgba,(l||n).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 n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};oh=pt([be(1,zv),be(2,Jt),be(3,dn),be(4,fr),be(5,so),be(6,Zr)],oh);function Dm(e,t,n){for(;e.length<n;)e=t+e;return e}var Mb=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let 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 l=e.createElement("span");l.classList.add("xterm-char-measure-element"),l.style.fontWeight="bold",l.style.fontStyle="italic",this._measureElements=[n,s,o,l],this._container.appendChild(n),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(l),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&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"),n&&(o+="I");let l=this._holey.get(o);if(l===void 0){let c=0;t&&(c|=1),n&&(c|=2),l=this._measure(e,c),l>0&&this._holey.set(o,l)}return l}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},jb=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,l=t[1]-o,c=n[1]-o,d=Math.max(l,0),p=Math.min(c,e.rows-1);if(d>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=l,this.viewportEndRow=c,this.viewportCappedStartRow=d,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function Tb(){return new jb}var Zc="xterm-dom-renderer-owner-",Ni="xterm-rows",xa="xterm-fg-",Lm="xterm-bg-",Hs="xterm-focus",Ea="xterm-selection",Ab=1,ah=class extends He{constructor(e,t,n,s,o,l,c,d,p,m,S,b,_,v){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=l,this._linkifier2=c,this._charSizeService=p,this._optionsService=m,this._bufferService=S,this._coreService=b,this._coreBrowserService=_,this._themeService=v,this._terminalClass=Ab++,this._rowElements=[],this._selectionRenderModel=Tb(),this.onRequestRedraw=this._register(new _e).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ni),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(Ea),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Lb(),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(oh,document),this._element.classList.add(Zc+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(at(()=>{this._element.classList.remove(Zc+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Mb(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ni} 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} .${Ni} { 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} .${Ni} .xterm-dim { color: ${st.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 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} .${Ni}.${Hs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${Hs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ni}.${Hs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ni} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ea} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ea} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ea} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[l,c]of e.ansi.entries())t+=`${this._terminalSelector} .${xa}${l} { color: ${c.css}; }${this._terminalSelector} .${xa}${l}.xterm-dim { color: ${st.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Lm}${l} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${xa}257 { color: ${st.opaque(e.background).css}; }${this._terminalSelector} .${xa}257.xterm-dim { color: ${st.multiplyOpacity(st.opaque(e.background),.5).css}; }${this._terminalSelector} .${Lm}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let 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(Hs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Hs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,l=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,d=this._document.createDocumentFragment();if(n){let p=e[0]>t[0];d.appendChild(this._createSelectionElement(l,p?t[0]:e[0],p?e[0]:t[0],c-l+1))}else{let p=s===l?e[0]:0,m=l===o?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(l,p,m));let S=c-l-1;if(d.appendChild(this._createSelectionElement(l+1,0,this._bufferService.cols,S)),l!==c){let b=o===c?t[0]:this._bufferService.cols;d.appendChild(this._createSelectionElement(c,0,b))}}this._selectionContainer.appendChild(d)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),l=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(n-t);return l+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-l),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${l}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 n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.x,this._bufferService.cols-1),l=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,d=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let m=p+n.ydisp,S=this._rowElements[p],b=n.lines.get(m);if(!S||!b)break;S.replaceChildren(...this._rowFactory.createRow(b,m,m===s,c,d,o,l,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Zc}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,o,l){n<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;n=Math.max(Math.min(n,c),0),s=Math.max(Math.min(s,c),0),o=Math.min(o,this._bufferService.cols);let d=this._bufferService.buffer,p=d.ybase+d.y,m=Math.min(d.x,o-1),S=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=n;v<=s;++v){let w=v+d.ydisp,C=this._rowElements[v],k=d.lines.get(w);if(!C||!k)break;C.replaceChildren(...this._rowFactory.createRow(k,w,w===p,b,_,m,S,this.dimensions.css.cell.width,this._widthCache,l?v===n?e:0:-1,l?(v===s?t:o)-1:-1))}}};ah=pt([be(7,Fh),be(8,Ja),be(9,Jt),be(10,Qt),be(11,fr),be(12,dn),be(13,Zr)],ah);var lh=class extends He{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new _e),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Ib(this._optionsService))}catch{this._measureStrategy=this._register(new Bb(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())}};lh=pt([be(2,Jt)],lh);var r_=class extends He{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)}},Bb=class extends r_{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Ib=class extends r_{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}},Ob=class extends He{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new zb(this._window)),this._onDprChange=this._register(new _e),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new _e),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Ft.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Be(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Be(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}},zb=class extends He{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Qr),this._onDprChange=this._register(new _e),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(at(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Be(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)}},Fb=class extends He{constructor(){super(),this.linkProviders=[],this._register(at(()=>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 Yh(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),l=parseInt(o.getPropertyValue("padding-left")),c=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-l,t.clientY-s.top-c]}function Hb(e,t,n,s,o,l,c,d,p){if(!l)return;let m=Yh(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(p?c/2:0))/c),m[1]=Math.ceil(m[1]/d),m[0]=Math.min(Math.max(m[0],1),s+(p?1:0)),m[1]=Math.min(Math.max(m[1],1),o),m}var ch=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return Hb(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=Yh(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};ch=pt([be(0,fn),be(1,Ja)],ch);var $b=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},s_={};Jw(s_,{getSafariVersion:()=>Ub,isChromeOS:()=>c_,isFirefox:()=>o_,isIpad:()=>Kb,isIphone:()=>qb,isLegacyEdge:()=>Wb,isLinux:()=>Xh,isMac:()=>Ka,isNode:()=>Za,isSafari:()=>a_,isWindows:()=>l_});var Za=typeof process<"u"&&"title"in process,oo=Za?"node":navigator.userAgent,ao=Za?"node":navigator.platform,o_=oo.includes("Firefox"),Wb=oo.includes("Edge"),a_=/^((?!chrome|android).)*safari/i.test(oo);function Ub(){if(!a_)return 0;let e=oo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Ka=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ao),Kb=ao==="iPad",qb=ao==="iPhone",l_=["Windows","Win16","Win32","WinCE"].includes(ao),Xh=ao.indexOf("Linux")>=0,c_=/\bCrOS\b/.test(oo),u_=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,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),n=Math.max(t,n),o=e.timeRemaining(),n*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()}},Vb=class extends u_{_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())}}},Yb=class extends u_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},qa=!Za&&"requestIdleCallback"in window?Yb:Vb,Xb=class{constructor(){this._queue=new qa}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},uh=class extends He{constructor(e,t,n,s,o,l,c,d,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=d,this._renderer=this._register(new Qr),this._pausedResizeTask=new Xb,this._observerDisposable=this._register(new Qr),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 _e),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new _e),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new _e),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new _e),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new $b((m,S)=>this._renderRows(m,S),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Gb(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(at(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var m;return(m=this._renderer.value)==null?void 0:m.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(l.onDecorationRegistered(()=>this._fullRefresh())),this._register(l.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(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=at(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){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 n;return(n=this._renderer.value)==null?void 0:n.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,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};uh=pt([be(2,Jt),be(3,Ja),be(4,fr),be(5,so),be(6,Qt),be(7,dn),be(8,Zr)],uh);var Gb=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Qb(e,t,n,s){let o=n.buffer.x,l=n.buffer.y;if(!n.buffer.hasScrollback)return e1(o,l,e,t,n,s)+el(l,t,n,s)+t1(o,l,e,t,n,s);let c;if(l===t)return c=o>e?"D":"C",io(Math.abs(o-e),to(c,s));c=l>t?"D":"C";let d=Math.abs(l-t),p=Zb(l>t?e:o,n)+(d-1)*n.cols+1+Jb(l>t?o:e);return io(p,to(c,s))}function Jb(e,t){return e-1}function Zb(e,t){return t.cols-e}function e1(e,t,n,s,o,l){return el(t,s,o,l).length===0?"":io(d_(e,t,e,t-hr(t,o),!1,o).length,to("D",l))}function el(e,t,n,s){let o=e-hr(e,n),l=t-hr(t,n),c=Math.abs(o-l)-i1(e,t,n);return io(c,to(h_(e,t),s))}function t1(e,t,n,s,o,l){let c;el(t,s,o,l).length>0?c=s-hr(s,o):c=t;let d=s,p=n1(e,t,n,s,o,l);return io(d_(e,c,n,d,p==="C",o).length,to(p,l))}function i1(e,t,n){var c;let s=0,o=e-hr(e,n),l=t-hr(t,n);for(let d=0;d<Math.abs(o-l);d++){let p=h_(e,t)==="A"?-1:1;(c=n.buffer.lines.get(o+p*d))!=null&&c.isWrapped&&s++}return s}function hr(e,t){let n=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return n}function n1(e,t,n,s,o,l){let c;return el(n,s,o,l).length>0?c=s-hr(s,o):c=t,e<n&&c<=s||e>=n&&c<s?"C":"D"}function h_(e,t){return e>t?"A":"B"}function d_(e,t,n,s,o,l){let c=e,d=t,p="";for(;(c!==n||d!==s)&&d>=0&&d<l.buffer.lines.length;)c+=o?1:-1,o&&c>l.cols-1?(p+=l.buffer.translateBufferLineToString(d,!1,e,c),c=0,e=0,d++):!o&&c<0&&(p+=l.buffer.translateBufferLineToString(d,!1,0,e+1),c=l.cols-1,e=c,d--);return p+l.buffer.translateBufferLineToString(d,!1,e,c)}function to(e,t){let n=t?"O":"[";return ue.ESC+n+e}function io(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var r1=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 Mm(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 eu=50,s1=15,o1=50,a1=500,l1=" ",c1=new RegExp(l1,"g"),hh=class extends He{constructor(e,t,n,s,o,l,c,d,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=s,this._coreService=o,this._mouseService=l,this._optionsService=c,this._renderService=d,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Di,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new _e),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new _e),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new _e),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new _e),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new r1(this._bufferService),this._activeSelectionMode=0,this._register(at(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],l=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let d=n.translateBufferLineToString(c,!0,o,l);s.push(d)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let l=e[1]+1;l<=t[1]-1;l++){let c=n.lines.get(l),d=n.translateBufferLineToString(l,!0);c!=null&&c.isWrapped?s[s.length-1]+=d:s.push(d)}if(e[1]!==t[1]){let l=n.lines.get(t[1]),c=n.translateBufferLineToString(t[1],!0,0,t[0]);l&&l.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(o=>o.replace(c1," ")).join(l_?`\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())),Xh&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,l;let n=(l=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:l.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Mm(n,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=Yh(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-eu),eu),t/=eu,t/Math.abs(t)+Math.round(t*(s1-1)))}shouldForceSelection(e){return Ka?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(),o1)}_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&&!(Ka&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.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<a1&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=Qb(n[0]-1,n[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,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,l=o.lines.get(e[1]);if(!l)return;let c=o.translateBufferLineToString(e[1],!1),d=this._convertViewportColToCharacterIndex(l,e[0]),p=d,m=e[0]-d,S=0,b=0,_=0,v=0;if(c.charAt(d)===" "){for(;d>0&&c.charAt(d-1)===" ";)d--;for(;p<c.length&&c.charAt(p+1)===" ";)p++}else{let k=e[0],N=e[0];l.getWidth(k)===0&&(S++,k--),l.getWidth(N)===2&&(b++,N++);let D=l.getString(N).length;for(D>1&&(v+=D-1,p+=D-1);k>0&&d>0&&!this._isCharWordSeparator(l.loadCell(k-1,this._workCell));){l.loadCell(k-1,this._workCell);let B=this._workCell.getChars().length;this._workCell.getWidth()===0?(S++,k--):B>1&&(_+=B-1,d-=B-1),d--,k--}for(;N<l.length&&p+1<c.length&&!this._isCharWordSeparator(l.loadCell(N+1,this._workCell));){l.loadCell(N+1,this._workCell);let B=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,N++):B>1&&(v+=B-1,p+=B-1),p++,N++}}p++;let w=d+m-S+_,C=Math.min(this._bufferService.cols,p-d+S+b-_-v);if(!(!t&&c.slice(d,p).trim()==="")){if(n&&w===0&&l.getCodePoint(0)!==32){let k=o.lines.get(e[1]-1);if(k&&l.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let N=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(N){let D=this._bufferService.cols-N.start;w-=D,C+=D}}}if(s&&w+C===this._bufferService.cols&&l.getCodePoint(this._bufferService.cols-1)!==32){let k=o.lines.get(e[1]+1);if(k!=null&&k.isWrapped&&k.getCodePoint(0)!==32){let N=this._getWordAt([0,e[1]+1],!1,!1,!0);N&&(C+=N.length)}}return{start:w,length:C}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Mm(n,this._bufferService.cols)}};hh=pt([be(3,Qt),be(4,fr),be(5,Hh),be(6,Jt),be(7,fn),be(8,dn)],hh);var jm=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Tm=class{constructor(){this._color=new jm,this._css=new jm}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ct=Object.freeze((()=>{let e=[ht.toColor("#2e3436"),ht.toColor("#cc0000"),ht.toColor("#4e9a06"),ht.toColor("#c4a000"),ht.toColor("#3465a4"),ht.toColor("#75507b"),ht.toColor("#06989a"),ht.toColor("#d3d7cf"),ht.toColor("#555753"),ht.toColor("#ef2929"),ht.toColor("#8ae234"),ht.toColor("#fce94f"),ht.toColor("#729fcf"),ht.toColor("#ad7fa8"),ht.toColor("#34e2e2"),ht.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],o=t[n/6%6|0],l=t[n%6];e.push({css:St.toCss(s,o,l),rgba:St.toRgba(s,o,l)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:St.toCss(s,s,s),rgba:St.toRgba(s,s,s)})}return e})()),nr=ht.toColor("#ffffff"),Gs=ht.toColor("#000000"),Am=ht.toColor("#ffffff"),Bm=Gs,$s={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},u1=nr,dh=class extends He{constructor(e){super(),this._optionsService=e,this._contrastCache=new Tm,this._halfContrastCache=new Tm,this._onChangeColors=this._register(new _e),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:nr,background:Gs,cursor:Am,cursorAccent:Bm,selectionForeground:void 0,selectionBackgroundTransparent:$s,selectionBackgroundOpaque:st.blend(Gs,$s),selectionInactiveBackgroundTransparent:$s,selectionInactiveBackgroundOpaque:st.blend(Gs,$s),scrollbarSliderBackground:st.opacity(nr,.2),scrollbarSliderHoverBackground:st.opacity(nr,.4),scrollbarSliderActiveBackground:st.opacity(nr,.5),overviewRulerBorder:nr,ansi:Ct.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=tt(e.foreground,nr),t.background=tt(e.background,Gs),t.cursor=st.blend(t.background,tt(e.cursor,Am)),t.cursorAccent=st.blend(t.background,tt(e.cursorAccent,Bm)),t.selectionBackgroundTransparent=tt(e.selectionBackground,$s),t.selectionBackgroundOpaque=st.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=tt(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=st.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?tt(e.selectionForeground,Pm):void 0,t.selectionForeground===Pm&&(t.selectionForeground=void 0),st.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=st.opacity(t.selectionBackgroundTransparent,.3)),st.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=st.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=tt(e.scrollbarSliderBackground,st.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=tt(e.scrollbarSliderHoverBackground,st.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=tt(e.scrollbarSliderActiveBackground,st.opacity(t.foreground,.5)),t.overviewRulerBorder=tt(e.overviewRulerBorder,u1),t.ansi=Ct.slice(),t.ansi[0]=tt(e.black,Ct[0]),t.ansi[1]=tt(e.red,Ct[1]),t.ansi[2]=tt(e.green,Ct[2]),t.ansi[3]=tt(e.yellow,Ct[3]),t.ansi[4]=tt(e.blue,Ct[4]),t.ansi[5]=tt(e.magenta,Ct[5]),t.ansi[6]=tt(e.cyan,Ct[6]),t.ansi[7]=tt(e.white,Ct[7]),t.ansi[8]=tt(e.brightBlack,Ct[8]),t.ansi[9]=tt(e.brightRed,Ct[9]),t.ansi[10]=tt(e.brightGreen,Ct[10]),t.ansi[11]=tt(e.brightYellow,Ct[11]),t.ansi[12]=tt(e.brightBlue,Ct[12]),t.ansi[13]=tt(e.brightMagenta,Ct[13]),t.ansi[14]=tt(e.brightCyan,Ct[14]),t.ansi[15]=tt(e.brightWhite,Ct[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=tt(e.extendedAnsi[s],Ct[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()}}};dh=pt([be(0,Jt)],dh);function tt(e,t){if(e!==void 0)try{return ht.toColor(e)}catch{}return t}var h1=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},d1=class{constructor(){this._services=new h1,this._services.set(Fh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=s0(e).sort((l,c)=>l.index-c.index),s=[];for(let l of n){let c=this._services.get(l.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${l.id._id}.`);s.push(c)}let o=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},f1={trace:0,debug:1,info:2,warn:3,error:4,off:5},p1="xterm.js: ",fh=class extends He{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=f1[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":p1)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};fh=pt([be(0,Jt)],fh);var Im=class extends He{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new _e),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new _e),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new _e),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let 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+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-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+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Fe=3,yt=Object.freeze(new ro),Na=0,tu=2,Qs=class f_{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Fe);let o=n||Di.fromCharData([0,Mv,1,0]);for(let l=0;l<t;++l)this.setCell(l,o);this.length=t}get(t){let n=this._data[t*Fe+0],s=n&2097151;return[this._data[t*Fe+1],n&2097152?this._combined[t]:s?In(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*Fe+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Fe+0]=t|2097152|n[2]<<22):this._data[t*Fe+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Fe+0]>>22}hasWidth(t){return this._data[t*Fe+0]&12582912}getFg(t){return this._data[t*Fe+1]}getBg(t){return this._data[t*Fe+2]}hasContent(t){return this._data[t*Fe+0]&4194303}getCodePoint(t){let n=this._data[t*Fe+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Fe+0]&2097152}getString(t){let n=this._data[t*Fe+0];return n&2097152?this._combined[t]:n&2097151?In(n&2097151):""}isProtected(t){return this._data[t*Fe+2]&536870912}loadCell(t,n){return Na=t*Fe,n.content=this._data[Na+0],n.fg=this._data[Na+1],n.bg=this._data[Na+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Fe+0]=n.content,this._data[t*Fe+1]=n.fg,this._data[t*Fe+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Fe+0]=n|s<<22,this._data[t*Fe+1]=o.fg,this._data[t*Fe+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*Fe+0];o&2097152?this._combined[t]+=In(n):o&2097151?(this._combined[t]=In(o&2097151)+In(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Fe+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new Di;for(let l=this.length-t-n-1;l>=0;--l)this.setCell(t+n+l,this.loadCell(t+l,o));for(let l=0;l<n;++l)this.setCell(t+l,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,n,s){if(t%=this.length,n<this.length-t){let o=new Di;for(let l=0;l<this.length-t-n;++l)this.setCell(t+l,this.loadCell(t+n+l,o));for(let l=this.length-n;l<this.length;++l)this.setCell(l,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,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&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),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*tu<this._data.buffer.byteLength;let s=t*Fe;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,n)}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 l=Object.keys(this._extendedAttrs);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=t&&delete this._extendedAttrs[d]}}return this.length=t,s*4*tu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*tu<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let 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 n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new f_(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Fe+0]&4194303)return t+(this._data[t*Fe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Fe+0]&4194303||this._data[t*Fe+2]&50331648)return t+(this._data[t*Fe+0]>>22);return 0}copyCellsFrom(t,n,s,o,l){let c=t._data;if(l)for(let p=o-1;p>=0;p--){for(let m=0;m<Fe;m++)this._data[(s+p)*Fe+m]=c[(n+p)*Fe+m];c[(n+p)*Fe+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}else for(let p=0;p<o;p++){for(let m=0;m<Fe;m++)this._data[(s+p)*Fe+m]=c[(n+p)*Fe+m];c[(n+p)*Fe+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}let d=Object.keys(t._combined);for(let p=0;p<d.length;p++){let m=parseInt(d[p],10);m>=n&&(this._combined[m-n+s]=t._combined[m])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let l="";for(;n<s;){let c=this._data[n*Fe+0],d=c&2097151,p=c&2097152?this._combined[n]:d?In(d):On;if(l+=p,o)for(let m=0;m<p.length;++m)o.push(n);n+=c>>22||1}return o&&o.push(n),l}};function m1(e,t,n,s,o,l){let c=[];for(let d=0;d<e.length-1;d++){let p=d,m=e.get(++p);if(!m.isWrapped)continue;let S=[e.get(d)];for(;p<e.length&&m.isWrapped;)S.push(m),m=e.get(++p);if(!l&&s>=d&&s<p){d+=S.length-1;continue}let b=0,_=no(S,b,t),v=1,w=0;for(;v<S.length;){let k=no(S,v,t),N=k-w,D=n-_,B=Math.min(N,D);S[b].copyCellsFrom(S[v],w,_,B,!1),_+=B,_===n&&(b++,_=0),w+=B,w===k&&(v++,w=0),_===0&&b!==0&&S[b-1].getWidth(n-1)===2&&(S[b].copyCellsFrom(S[b-1],n-1,_++,1,!1),S[b-1].setCell(n-1,o))}S[b].replaceCells(_,n,o);let C=0;for(let k=S.length-1;k>0&&(k>b||S[k].getTrimmedLength()===0);k--)C++;C>0&&(c.push(d+S.length-C),c.push(C)),d+=S.length-1}return c}function g1(e,t){let n=[],s=0,o=t[s],l=0;for(let c=0;c<e.length;c++)if(o===c){let d=t[++s];e.onDeleteEmitter.fire({index:c-l,amount:d}),c+=d-1,l+=d,o=t[++s]}else n.push(c);return{layout:n,countRemoved:l}}function v1(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function _1(e,t,n){let s=[],o=e.map((p,m)=>no(e,m,t)).reduce((p,m)=>p+m),l=0,c=0,d=0;for(;d<o;){if(o-d<n){s.push(o-d);break}l+=n;let p=no(e,c,t);l>p&&(l-=p,c++);let m=e[c].getWidth(l-1)===2;m&&l--;let S=m?n-1:n;s.push(S),d+=S}return s}function no(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var p_=class m_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=m_._nextId++,this._onDispose=this.register(new _e),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),ur(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};p_._nextId=1;var y1=p_,xt={},rr=xt.B;xt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};xt.A={"#":"£"};xt.B=void 0;xt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};xt.C=xt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};xt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};xt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};xt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};xt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};xt.E=xt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};xt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};xt.H=xt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};xt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Om=4294967295,zm=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=yt.clone(),this.savedCharset=rr,this.markers=[],this._nullCell=Di.fromCharData([0,Mv,1,0]),this._whitespaceCell=Di.fromCharData([0,On,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new qa,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Im(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 $a),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 $a),this._whitespaceCell}getBlankLine(e,t){return new Qs(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>Om?Om:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=yt);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 Im(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(yt),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,n);let l=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 Qs(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+l+1?(this.ybase--,l++,this.ydisp>0&&this.ydisp--):this.lines.push(new Qs(e,n)));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),l&&(this.y+=l),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 l=0;l<this.lines.length;l++)s+=+this.lines.get(l).resize(e,n);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 n=this._optionsService.rawOptions.reflowCursorLine,s=m1(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(yt),n);if(s.length>0){let o=g1(this.lines,s);v1(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(yt),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Qs(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(yt),o=[],l=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 p=[d];for(;d.isWrapped&&c>0;)d=this.lines.get(--c),p.unshift(d);if(!n){let B=this.ybase+this.y;if(B>=c&&B<c+p.length)continue}let m=p[p.length-1].getTrimmedLength(),S=_1(p,this._cols,e),b=S.length-p.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+b):_=Math.max(0,this.lines.length-this.lines.maxLength+b);let v=[];for(let B=0;B<b;B++){let A=this.getBlankLine(yt,!0);v.push(A)}v.length>0&&(o.push({start:c+p.length+l,newLines:v}),l+=v.length),p.push(...v);let w=S.length-1,C=S[w];C===0&&(w--,C=S[w]);let k=p.length-b-1,N=m;for(;k>=0;){let B=Math.min(N,C);if(p[w]===void 0)break;if(p[w].copyCellsFrom(p[k],N-B,C-B,B,!0),C-=B,C===0&&(w--,C=S[w]),N-=B,N===0){k--;let A=Math.max(k,0);N=no(p,A,this._cols)}}for(let B=0;B<p.length;B++)S[B]<e&&p[B].setCell(S[B],s);let D=b-_;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+l)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let c=[],d=[];for(let C=0;C<this.lines.length;C++)d.push(this.lines.get(C));let p=this.lines.length,m=p-1,S=0,b=o[S];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+l);let _=0;for(let C=Math.min(this.lines.maxLength-1,p+l-1);C>=0;C--)if(b&&b.start>m+_){for(let k=b.newLines.length-1;k>=0;k--)this.lines.set(C--,b.newLines[k]);C++,c.push({index:m+1,amount:b.newLines.length}),_+=b.newLines.length,b=o[++S]}else this.lines.set(C,d[m--]);let v=0;for(let C=c.length-1;C>=0;C--)c[C].index+=v,this.lines.onInsertEmitter.fire(c[C]),v+=c[C].amount;let w=Math.max(0,p+l-this.lines.maxLength);w>0&&this.lines.onTrimEmitter.fire(w)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new y1(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},S1=class extends He{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new _e),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 zm(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new zm(!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)}},g_=2,v_=1,ph=class extends He{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new _e),this.onResize=this._onResize.event,this._onScroll=this._register(new _e),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,g_),this.rows=Math.max(e.rawOptions.rows||0,v_),this.buffers=this._register(new S1(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,l=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;l===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(l+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=l-o+1;n.lines.shiftElements(o+1,c-1,-1),n.lines.set(l,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};ph=pt([be(0,Jt)],ph);var Hr={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:Ka,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},w1=["normal","bold","100","200","300","400","500","600","700","800","900"],b1=class extends He{constructor(e){super(),this._onOptionChange=this._register(new _e),this.onOptionChange=this._onOptionChange.event;let t={...Hr};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(at(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Hr))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Hr))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Hr[e]),!C1(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Hr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=w1.includes(t)?t:Hr[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 C1(e){return e==="block"||e==="underline"||e==="bar"}function Js(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&Js(e[s],t-1);return n}var Fm=Object.freeze({insertMode:!1}),Hm=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),mh=class extends He{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new _e),this.onData=this._onData.event,this._onUserInput=this._register(new _e),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new _e),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new _e),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Js(Fm),this.decPrivateModes=Js(Hm)}reset(){this.modes=Js(Fm),this.decPrivateModes=Js(Hm)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(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))}};mh=pt([be(0,Qt),be(1,Iv),be(2,Jt)],mh);var $m={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 iu(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var nu=String.fromCharCode,Wm={DEFAULT:e=>{let t=[iu(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${nu(t[0])}${nu(t[1])}${nu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${iu(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${iu(e,!0)};${e.x};${e.y}${t}`}},gh=class extends He{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new _e),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys($m))this.addProtocol(s,$m[s]);for(let s of Object.keys(Wm))this.addEncoding(s,Wm[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,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,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,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};gh=pt([be(0,Qt),be(1,fr),be(2,Jt)],gh);var ru=[[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]],k1=[[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]],kt;function x1(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var E1=class{constructor(){if(this.version="6",!kt){kt=new Uint8Array(65536),kt.fill(1),kt[0]=0,kt.fill(0,1,32),kt.fill(0,127,160),kt.fill(2,4352,4448),kt[9001]=2,kt[9002]=2,kt.fill(2,11904,42192),kt[12351]=1,kt.fill(2,44032,55204),kt.fill(2,63744,64256),kt.fill(2,65040,65050),kt.fill(2,65072,65136),kt.fill(2,65280,65377),kt.fill(2,65504,65511);for(let e=0;e<ru.length;++e)kt.fill(0,ru[e][0],ru[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?kt[e]:x1(e,k1)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=or.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return or.createPropertyValue(0,n,s)}},or=class Ba{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new _e,this.onChange=this._onChange.event;let t=new E1;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&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 n=0,s=0,o=t.length;for(let l=0;l<o;++l){let c=t.charCodeAt(l);if(55296<=c&&c<=56319){if(++l>=o)return n+this.wcwidth(c);let m=t.charCodeAt(l);56320<=m&&m<=57343?c=(c-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let d=this.charProperties(c,s),p=Ba.extractWidth(d);Ba.extractShouldJoin(d)&&(p-=Ba.extractWidth(s)),n+=p,s=d}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},N1=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 Um(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),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Ws=2147483647,R1=256,__=class vh{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>R1)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new vh;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let l=0;l<o.length;++l)n.addSubParam(o[l]);else n.addParam(o)}return n}clone(){let t=new vh(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&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>Ws?Ws: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>Ws?Ws:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,Ws):t}},Us=[],P1=class{constructor(){this._state=0,this._active=Us,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=Us}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=Us,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Us,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",Qa(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let 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&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Us,this._id=-1,this._state=0}}},gi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Qa(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Ks=[],D1=class{constructor(){this._handlers=Object.create(null),this._active=Ks,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ks}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.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=Ks,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ks,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",Qa(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Ks,this._ident=0}},Zs=new __;Zs.addParam(0);var Km=class{constructor(e){this._handler=e,this._data="",this._params=Zs,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Zs,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Qa(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=Zs,this._data="",this._hitLimit=!1,n));return this._params=Zs,this._data="",this._hitLimit=!1,t}},L1=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},Pi=160,M1=(function(){let e=new L1(4095),t=Array.apply(null,Array(256)).map((d,p)=>p),n=(d,p)=>t.slice(d,p),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let l=n(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in l)e.addMany([24,26,153,154],c,3,0),e.addMany(n(128,144),c,3,0),e.addMany(n(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(n(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(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Pi,0,2,0),e.add(Pi,8,5,8),e.add(Pi,6,0,6),e.add(Pi,11,0,11),e.add(Pi,13,13,13),e})(),j1=class extends He{constructor(e=M1){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 __,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(at(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new P1),this._dcsParser=this._register(new D1),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let l=e.intermediates.charCodeAt(o);if(32>l||l>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=l}}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 n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];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 n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];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,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,l=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,l=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let d=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&p>-1){for(;p>=0&&(c=d[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(n===!1&&p>-1){for(;p>=0&&(c=d[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,n),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,n),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,l=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let d=l;d<t;++d){switch(s=e[d],o=this._transitions.table[this.currentState<<8|(s<160?s:Pi)],o>>4){case 2:for(let _=d+1;;++_){if(_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-1;break}if(++_>=t||(s=e[_])<32||s>126&&s<Pi){this._printHandler(e,d,_),d=_-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 p=this._csiHandlers[this._collect<<8|s],m=p?p.length-1:-1;for(;m>=0&&(c=p[m](this._params),c!==!0);m--)if(c instanceof Promise)return this._preserveStack(3,p,m,o,d),c;m<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 S=this._escHandlers[this._collect<<8|s],b=S?S.length-1:-1;for(;b>=0&&(c=S[b](),c!==!0);b--)if(c instanceof Promise)return this._preserveStack(4,S,b,o,d),c;b<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 _=d+1;;++_)if(_>=t||(s=e[_])===24||s===26||s===27||s>127&&s<Pi){this._dcsParser.put(e,d,_),d=_-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 _=d+1;;_++)if(_>=t||(s=e[_])<32||s>127&&s<Pi){this._oscParser.put(e,d,_),d=_-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}}},T1=/^([\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})$/,A1=/^[\da-f]+$/;function qm(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=T1.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),A1.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let l=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?l<<4:n===2?l:n===3?l>>4:l>>8}return s}}function su(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function B1(e,t=16){let[n,s,o]=e;return`rgb:${su(n,t)}/${su(s,t)}/${su(o,t)}`}var I1={"(":0,")":1,"*":2,"+":3,"-":1,".":2},An=131072,Vm=10;function Ym(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 Xm=5e3,Gm=0,O1=class extends He{constructor(e,t,n,s,o,l,c,d,p=new j1){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=s,this._optionsService=o,this._oscLinkService=l,this._coreMouseService=c,this._unicodeService=d,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new n0,this._utf8Decoder=new r0,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=yt.clone(),this._eraseAttrDataInternal=yt.clone(),this._onRequestBell=this._register(new _e),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new _e),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new _e),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new _e),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new _e),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new _e),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new _e),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new _e),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new _e),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new _e),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new _e),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new _e),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new _e),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 _h(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,S)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:S.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,S,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:S,data:b})}),this._parser.setDcsHandlerFallback((m,S,b)=>{S==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:S,payload:b})}),this._parser.setPrintHandler((m,S,b)=>this.print(m,S,b)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(ue.BEL,()=>this.bell()),this._parser.setExecuteHandler(ue.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(ue.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(ue.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(ue.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(ue.BS,()=>this.backspace()),this._parser.setExecuteHandler(ue.HT,()=>this.tab()),this._parser.setExecuteHandler(ue.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(ue.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ta.IND,()=>this.index()),this._parser.setExecuteHandler(Ta.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ta.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new gi(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new gi(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new gi(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new gi(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new gi(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new gi(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new gi(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new gi(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new gi(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new gi(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new gi(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new gi(m=>this.restoreCursorColor(m))),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 m in xt)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Km((m,S)=>this.requestStatusString(m,S)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),Xm))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Xm} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,l=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>An&&(l=this._parseStack.position+An)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<An&&(this._parseBuffer=new Uint32Array(Math.min(e.length,An))),c||this._dirtyRowTracker.clearRange(),e.length>An)for(let m=l;m<e.length;m+=An){let S=m+An<e.length?m+An:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(m,S),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,S),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,b))return this._preserveStack(s,o,b,m),this._logSlowResolvingAsync(n),n}else if(!c){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let d=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),p=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);p<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(p,this._bufferService.rows-1),end:Math.min(d,this._bufferService.rows-1)})}print(e,t,n){let s,o,l=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,d=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,S=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,S);let _=this._parser.precedingJoinState;for(let v=t;v<n;++v){if(s=e[v],s<127&&l){let N=l[String.fromCharCode(s)];N&&(s=N.charCodeAt(0))}let w=this._unicodeService.charProperties(s,_);o=or.extractWidth(w);let C=or.extractShouldJoin(w),k=C?or.extractWidth(_):0;if(_=w,c&&this._onA11yChar.fire(In(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-k>d){if(p){let N=b,D=this._activeBuffer.x-k;for(this._activeBuffer.x=k,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),k>0&&b instanceof Qs&&b.copyCellsFrom(N,D,0,k,!1);D<d;)N.setCellFromCodepoint(D++,0,1,S)}else if(this._activeBuffer.x=d-1,o===2)continue}if(C&&this._activeBuffer.x){let N=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-N,s,o);for(let D=o-k;--D>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,S);continue}if(m&&(b.insertCells(this._activeBuffer.x,o-k,this._activeBuffer.getNullCell(S)),b.getWidth(d-1)===2&&b.setCellFromCodepoint(d-1,0,1,S)),b.setCellFromCodepoint(this._activeBuffer.x++,s,o,S),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,S)}this._parser.precedingJoinState=_,this._activeBuffer.x<d&&n-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,S),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>Ym(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Km(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new gi(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,n,s=!1,o=!1){let l=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);l.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(l.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let 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 n=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(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,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(yt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);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 n=e.params[0]||1,s=or.extractWidth(t),o=this._activeBuffer.x-s,l=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),c=new Uint32Array(l.length*n),d=0;for(let m=0;m<l.length;){let S=l.codePointAt(m)||0;c[d++]=S,m+=S>65535?2:1}let p=d;for(let m=1;m<n;++m)c.copyWithin(p,0,d),p+=d;return this.print(c,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(ue.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(ue.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(ue.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(ue.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(ue.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,rr),this._charsetService.setgCharset(1,rr),this._charsetService.setgCharset(2,rr),this._charsetService.setgCharset(3,rr);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){(C=>(C[C.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",C[C.SET=1]="SET",C[C.RESET=2]="RESET",C[C.PERMANENTLY_SET=3]="PERMANENTLY_SET",C[C.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:l}=this._coreMouseService,c=this._coreService,{buffers:d,cols:p}=this._bufferService,{active:m,alt:S}=d,b=this._optionsService.rawOptions,_=(C,k)=>(c.triggerDataEvent(`${ue.ESC}[${t?"":"?"}${C};${k}$y`),!0),v=C=>C?1:2,w=e.params[0];return t?w===2?_(w,4):w===4?_(w,v(c.modes.insertMode)):w===12?_(w,3):w===20?_(w,v(b.convertEol)):_(w,0):w===1?_(w,v(s.applicationCursorKeys)):w===3?_(w,b.windowOptions.setWinLines?p===80?2:p===132?1:0:0):w===6?_(w,v(s.origin)):w===7?_(w,v(s.wraparound)):w===8?_(w,3):w===9?_(w,v(o==="X10")):w===12?_(w,v(b.cursorBlink)):w===25?_(w,v(!c.isCursorHidden)):w===45?_(w,v(s.reverseWraparound)):w===66?_(w,v(s.applicationKeypad)):w===67?_(w,4):w===1e3?_(w,v(o==="VT200")):w===1002?_(w,v(o==="DRAG")):w===1003?_(w,v(o==="ANY")):w===1004?_(w,v(s.sendFocus)):w===1005?_(w,4):w===1006?_(w,v(l==="SGR")):w===1015?_(w,4):w===1016?_(w,v(l==="SGR_PIXELS")):w===1048?_(w,1):w===47||w===1047||w===1049?_(w,v(m===S)):w===2004?_(w,v(s.bracketedPasteMode)):w===2026?_(w,v(s.synchronizedOutput)):_(w,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=ro.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,l=0;do{if(s[l+o]=e.params[t+l],e.hasSubParams(t+l)){let c=e.getSubParams(t+l),d=0;do s[1]===5&&(o=1),s[l+d+1+o]=c[d];while(++d<c.length&&d+l+1+o<s.length);break}if(s[1]===5&&l+o>=2||s[1]===2&&l+o>=5)break;s[1]&&(o=1)}while(++l+t<e.length&&l+o<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return l}_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=yt.fg,e.bg=yt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=yt.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=yt.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=yt.fg&16777215,s.bg&=-67108864,s.bg|=yt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${ue.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ue.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${ue.ESC}[?${t};${n}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=yt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Ym(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(`${ue.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Vm&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Vm&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let l=parseInt(s);if(Qm(l))if(o==="?")t.push({type:0,index:l});else{let c=qm(o);c&&t.push({type:1,index:l,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(l=>l.startsWith("id="));return o!==-1&&(s=n[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 n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=qm(n[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=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);Qm(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,rr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(I1[e[0]],xt[e[1]]||rr),!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=yt.clone(),this._eraseAttrDataInternal=yt.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 Di;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=c=>(this._coreService.triggerDataEvent(`${ue.ESC}${c}${ue.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${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)}},_h=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&&(Gm=e,e=t,t=Gm),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};_h=pt([be(0,Qt)],_h);function Qm(e){return 0<=e&&e<256}var z1=5e7,Jm=12,F1=50,H1=class extends He{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 _e),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>z1)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let c=d=>performance.now()-n>=Jm?setTimeout(()=>this._innerWrite(0,d)):this._innerWrite(n,d);o.catch(d=>(queueMicrotask(()=>{throw d}),Promise.resolve(!1))).then(c);return}let l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-n>=Jm)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>F1&&(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()}},yh=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),p={data:e,id:this._nextId++,lines:[d]};return d.onDispose(()=>this._removeMarkerFromLink(p,d)),this._dataByLinkId.set(p.id,p),p.id}let n=e,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let l=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,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 n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};yh=pt([be(0,Qt)],yh);var Zm=!1,$1=class extends He{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Qr),this._onBinary=this._register(new _e),this.onBinary=this._onBinary.event,this._onData=this._register(new _e),this.onData=this._onData.event,this._onLineFeed=this._register(new _e),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new _e),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new _e),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new _e),this._instantiationService=new d1,this.optionsService=this._register(new b1(e)),this._instantiationService.setService(Jt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(ph)),this._instantiationService.setService(Qt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(fh)),this._instantiationService.setService(Iv,this._logService),this.coreService=this._register(this._instantiationService.createInstance(mh)),this._instantiationService.setService(fr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(gh)),this._instantiationService.setService(Bv,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(or)),this._instantiationService.setService(l0,this.unicodeService),this._charsetService=this._instantiationService.createInstance(N1),this._instantiationService.setService(a0,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(yh),this._instantiationService.setService(Ov,this._oscLinkService),this._inputHandler=this._register(new O1(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ft.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ft.forward(this._bufferService.onResize,this._onResize)),this._register(Ft.forward(this.coreService.onData,this._onData)),this._register(Ft.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 H1((t,n)=>this._inputHandler.parse(t,n))),this._register(Ft.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new _e),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&&!Zm&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Zm=!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,g_),t=Math.max(t,v_),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(Um.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Um(this._bufferService),!1))),this._windowsWrappingHeuristics.value=at(()=>{for(let t of e)t.dispose()})}}},W1={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 U1(e,t,n,s){var c;let o={type:0,cancel:!1,key:void 0},l=(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=ue.ESC+"OA":o.key=ue.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=ue.ESC+"OD":o.key=ue.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=ue.ESC+"OC":o.key=ue.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=ue.ESC+"OB":o.key=ue.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":ue.DEL,e.altKey&&(o.key=ue.ESC+o.key);break;case 9:if(e.shiftKey){o.key=ue.ESC+"[Z";break}o.key=ue.HT,o.cancel=!0;break;case 13:o.key=e.altKey?ue.ESC+ue.CR:ue.CR,o.cancel=!0;break;case 27:o.key=ue.ESC,e.altKey&&(o.key=ue.ESC+ue.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;l?o.key=ue.ESC+"[1;"+(l+1)+"D":t?o.key=ue.ESC+"OD":o.key=ue.ESC+"[D";break;case 39:if(e.metaKey)break;l?o.key=ue.ESC+"[1;"+(l+1)+"C":t?o.key=ue.ESC+"OC":o.key=ue.ESC+"[C";break;case 38:if(e.metaKey)break;l?o.key=ue.ESC+"[1;"+(l+1)+"A":t?o.key=ue.ESC+"OA":o.key=ue.ESC+"[A";break;case 40:if(e.metaKey)break;l?o.key=ue.ESC+"[1;"+(l+1)+"B":t?o.key=ue.ESC+"OB":o.key=ue.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=ue.ESC+"[2~");break;case 46:l?o.key=ue.ESC+"[3;"+(l+1)+"~":o.key=ue.ESC+"[3~";break;case 36:l?o.key=ue.ESC+"[1;"+(l+1)+"H":t?o.key=ue.ESC+"OH":o.key=ue.ESC+"[H";break;case 35:l?o.key=ue.ESC+"[1;"+(l+1)+"F":t?o.key=ue.ESC+"OF":o.key=ue.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=ue.ESC+"[5;"+(l+1)+"~":o.key=ue.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=ue.ESC+"[6;"+(l+1)+"~":o.key=ue.ESC+"[6~";break;case 112:l?o.key=ue.ESC+"[1;"+(l+1)+"P":o.key=ue.ESC+"OP";break;case 113:l?o.key=ue.ESC+"[1;"+(l+1)+"Q":o.key=ue.ESC+"OQ";break;case 114:l?o.key=ue.ESC+"[1;"+(l+1)+"R":o.key=ue.ESC+"OR";break;case 115:l?o.key=ue.ESC+"[1;"+(l+1)+"S":o.key=ue.ESC+"OS";break;case 116:l?o.key=ue.ESC+"[15;"+(l+1)+"~":o.key=ue.ESC+"[15~";break;case 117:l?o.key=ue.ESC+"[17;"+(l+1)+"~":o.key=ue.ESC+"[17~";break;case 118:l?o.key=ue.ESC+"[18;"+(l+1)+"~":o.key=ue.ESC+"[18~";break;case 119:l?o.key=ue.ESC+"[19;"+(l+1)+"~":o.key=ue.ESC+"[19~";break;case 120:l?o.key=ue.ESC+"[20;"+(l+1)+"~":o.key=ue.ESC+"[20~";break;case 121:l?o.key=ue.ESC+"[21;"+(l+1)+"~":o.key=ue.ESC+"[21~";break;case 122:l?o.key=ue.ESC+"[23;"+(l+1)+"~":o.key=ue.ESC+"[23~";break;case 123:l?o.key=ue.ESC+"[24;"+(l+1)+"~":o.key=ue.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=ue.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=ue.DEL:e.keyCode===219?o.key=ue.ESC:e.keyCode===220?o.key=ue.FS:e.keyCode===221&&(o.key=ue.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let d=(c=W1[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(d)o.key=ue.ESC+d;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(p);e.shiftKey&&(m=m.toUpperCase()),o.key=ue.ESC+m}else if(e.keyCode===32)o.key=ue.ESC+(e.ctrlKey?ue.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=ue.ESC+p,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=ue.US),e.key==="@"&&(o.key=ue.NUL));break}return o}var vt=0,K1=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new qa,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new qa,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,l)=>this._getKey(o)-this._getKey(l)),t=0,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];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||(vt=this._search(t),vt===-1)||this._getKey(this._array[vt])!==t)return!1;do if(this._array[vt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(vt),!0;while(++vt<this._array.length&&this._getKey(this._array[vt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,l)=>o-l),t=0,n=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(vt=this._search(e),!(vt<0||vt>=this._array.length)&&this._getKey(this._array[vt])===e))do yield this._array[vt];while(++vt<this._array.length&&this._getKey(this._array[vt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(vt=this._search(e),!(vt<0||vt>=this._array.length)&&this._getKey(this._array[vt])===e))do t(this._array[vt]);while(++vt<this._array.length&&this._getKey(this._array[vt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=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}},ou=0,eg=0,q1=class extends He{constructor(){super(),this._decorations=new K1(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new _e),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new _e),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(at(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new V1(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,o=0;for(let l of this._decorations.getKeyIterator(t))s=l.options.x??0,o=s+(l.options.width??1),e>=s&&e<o&&(!n||(l.options.layer??"bottom")===n)&&(yield l)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{ou=o.options.x??0,eg=ou+(o.options.width??1),e>=ou&&e<eg&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},V1=class extends Fn{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new _e),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new _e),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=ht.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ht.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Y1=1e3,X1=class{constructor(e,t=Y1){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,l=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},l)}}_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)}},tg=20,Va=class extends He{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,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 l=0;l<this._terminal.rows;l++)this._rowElements[l]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[l]);if(this._topBoundaryFocusListener=l=>this._handleBoundaryFocus(l,0),this._bottomBoundaryFocusListener=l=>this._handleBoundaryFocus(l,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 X1(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(l=>this._handleResize(l.rows))),this._register(this._terminal.onRender(l=>this._refreshRows(l.start,l.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(l=>this._handleChar(l))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
64
|
+
`))),this._register(this._terminal.onA11yTab(l=>this._handleTab(l))),this._register(this._terminal.onKey(l=>this._handleKey(l.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Be(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(at(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<tg+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===tg+1&&(this._liveRegion.textContent+=zu.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let l=n.lines.get(n.ydisp+o),c=[],d=(l==null?void 0:l.translateToString(!0,void 0,void 0,c))||"",p=(n.ydisp+o+1).toString(),m=this._rowElements[o];m&&(d.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=d,this._rowColumns.set(m,c)),m.setAttribute("aria-posinset",p),m.setAttribute("aria-setsize",s),this._alignRowWidth(m))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),l=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===l||e.relatedTarget!==s)return;let c,d;if(t===0?(c=n,d=this._rowElements.pop(),this._rowContainer.removeChild(d)):(c=this._rowElements.shift(),d=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),d.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}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},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((d=s.textContent)==null?void 0:d.length)??0}),!this._rowContainer.contains(n.node))return;let o=({node:p,offset:m})=>{let S=p instanceof Text?p.parentNode:p,b=parseInt(S==null?void 0:S.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(S);if(!_)return console.warn("columns is null. Race condition?"),null;let v=m<_.length?_[m]:_.slice(-1)[0]+1;return v>=this._terminal.cols&&(++b,v=0),{row:b,column:v}},l=o(t),c=o(n);if(!(!l||!c)){if(l.row>c.row||l.row===c.row&&l.column>=c.column)throw new Error("invalid range");this._terminal.select(l.column,l.row,(c.row-l.row)*this._terminal.cols-l.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,l;e.style.transform="";let t=e.getBoundingClientRect().width,n=(l=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:l[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Va=pt([be(1,Fh),be(2,dn),be(3,fn)],Va);var Sh=class extends He{constructor(e,t,n,s,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new _e),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new _e),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(at(()=>{var l;ur(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(l=this._activeProviderReplies)==null||l.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Be(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Be(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Be(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Be(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[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(l=>{l==null||l.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[l,c]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(l)&&(n=this._checkLinkProviderResult(l,e,n)):c.provideLinks(e.y,d=>{var m,S;if(this._isMouseOut)return;let p=d==null?void 0:d.map(b=>({link:b}));(m=this._activeProviderReplies)==null||m.set(l,p),n=this._checkLinkProviderResult(l,e,n),((S=this._activeProviderReplies)==null?void 0:S.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let l=0;l<o.length;l++){let c=o[l],d=c.link.range.start.y<e?0:c.link.range.start.x,p=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let m=d;m<=p;m++){if(n.has(m)){o.splice(l--,1);break}n.add(m)}}}}_checkLinkProviderResult(e,t,n){var l;if(!this._activeProviderReplies)return n;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&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let d=(l=this._activeProviderReplies.get(c))==null?void 0:l.find(p=>this._linkAtPosition(p.link,t));if(d){n=!0,this._handleNewLink(d);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&G1(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,ur(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 n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,o,l;(s=this._currentLink)!=null&&s.state&&((l=(o=this._currentLink)==null?void 0:o.state)==null?void 0:l.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let l=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);l&&this._askForLink(l,!1)}})))}_linkHover(e,t,n){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(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){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(n,t.text)}_linkAtPosition(e,t){let n=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 n<=o&&o<=s}_positionFromMouseEvent(e,t,n){let s=n.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,n,s,o){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:o}}};Sh=pt([be(1,Hh),be(2,fn),be(3,Qt),be(4,Fv)],Sh);function G1(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 Q1=class extends $1{constructor(e={}){super(e),this._linkifier=this._register(new Qr),this.browser=s_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Qr),this._onCursorMove=this._register(new _e),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new _e),this.onKey=this._onKey.event,this._onRender=this._register(new _e),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new _e),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new _e),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new _e),this.onBell=this._onBell.event,this._onFocus=this._register(new _e),this._onBlur=this._register(new _e),this._onA11yCharEmitter=this._register(new _e),this._onA11yTabEmitter=this._register(new _e),this._onWillOpen=this._register(new _e),this._setup(),this._decorationService=this._instantiationService.createInstance(q1),this._instantiationService.setService(so,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Fb),this._instantiationService.setService(Fv,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Hu)),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(Ft.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ft.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ft.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ft.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(at(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let o=st.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${ue.ESC}]${s};${B1(o)}${n_.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(l=>l.ansi[t.index]=St.toColor(...t.color));else{let l=n;this._themeService.modifyColors(c=>c[l]=St.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(Va,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(ue.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(ue.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),l=this._renderService.dimensions.css.cell.width*o,c=this.buffer.y*this._renderService.dimensions.css.cell.height,d=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=d+"px",this.textarea.style.top=c+"px",this.textarea.style.width=l+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Be(this.element,"copy",t=>{this.hasSelection()&&t0(t,this._selectionService)}));let e=t=>i0(t,this.textarea,this.coreService,this.optionsService);this._register(Be(this.textarea,"paste",e)),this._register(Be(this.element,"paste",e)),o_?this._register(Be(this.element,"mousedown",t=>{t.button===2&&hm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Be(this.element,"contextmenu",t=>{hm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Xh&&this._register(Be(this.element,"auxclick",t=>{t.button===1&&Lv(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Be(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Be(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Be(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Be(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Be(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Be(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Be(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(Be(this.screenElement,"mousemove",l=>this.updateCursorStyle(l))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ou.get()),c_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Ob,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(dn,this._coreBrowserService),this._register(Be(this.textarea,"focus",l=>this._handleTextAreaFocus(l))),this._register(Be(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(lh,this._document,this._helperContainer),this._instantiationService.setService(Ja,this._charSizeService),this._themeService=this._instantiationService.createInstance(dh),this._instantiationService.setService(Zr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ua),this._instantiationService.setService(zv,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(uh,this.rows,this.screenElement)),this._instantiationService.setService(fn,this._renderService),this._register(this._renderService.onRenderedViewportChange(l=>this._onRender.fire(l))),this.onResize(l=>this._renderService.resize(l.cols,l.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(sh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(ch),this._instantiationService.setService(Hh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Sh,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(nh,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(l=>{super.scrollLines(l,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(hh,this.element,this.screenElement,s)),this._instantiationService.setService(u0,this._selectionService),this._register(this._selectionService.onRequestScrollLines(l=>this.scrollLines(l.amount,l.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(l=>this._renderService.handleSelectionChanged(l.start,l.end,l.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(l=>{this.textarea.value=l,this.textarea.focus(),this.textarea.select()})),this._register(Ft.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var l;this._selectionService.refresh(),(l=this._viewport)==null||l.queueSync()})),this._register(this._instantiationService.createInstance(rh,this.screenElement)),this._register(Be(this.element,"mousedown",l=>this._selectionService.handleMouseDown(l))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Va,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",l=>this._handleScreenReaderModeOptionChange(l))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",l=>{!this._overviewRulerRenderer&&l&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Wa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ah,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(l){var m,S,b,_,v;let c=e._mouseService.getMouseReportCoords(l,e.screenElement);if(!c)return!1;let d,p;switch(l.overrideType||l.type){case"mousemove":p=32,l.buttons===void 0?(d=3,l.button!==void 0&&(d=l.button<3?l.button:3)):d=l.buttons&1?0:l.buttons&4?1:l.buttons&2?2:3;break;case"mouseup":p=0,d=l.button<3?l.button:3;break;case"mousedown":p=1,d=l.button<3?l.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(l)===!1)return!1;let w=l.deltaY;if(w===0||e.coreMouseService.consumeWheelEvent(l,(_=(b=(S=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:S.device)==null?void 0:b.cell)==null?void 0:_.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;p=w<0?0:1,d=4;break;default:return!1}return p===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:p,ctrl:l.ctrlKey,alt:l.altKey,shift:l.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:l=>(n(l),l.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(l)),wheel:l=>(n(l),this.cancel(l,!0)),mousedrag:l=>{l.buttons&&n(l)},mousemove:l=>{l.buttons||n(l)}};this._register(this.coreMouseService.onProtocolChange(l=>{l?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(l)),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()),l&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),l&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),l&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),l&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Be(t,"mousedown",l=>{if(l.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(l)))return n(l),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(l)})),this._register(Be(t,"wheel",l=>{var c,d,p,m,S;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(l)===!1)return!1;if(!this.buffer.hasScrollback){if(l.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(l,(m=(p=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:p.cell)==null?void 0:m.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return this.cancel(l,!0);let b=ue.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(l.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(b,!0),this.cancel(l,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.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){Dv(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=U1(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===ue.ETX||n.key===ue.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(J1(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 n;(n=this._charSizeService)==null||n.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(yt));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(ue.ESC+"[I"):this.coreService.triggerDataEvent(ue.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${ue.ESC}[4;${n};${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(`${ue.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function J1(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Z1=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},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 Di)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},ig=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 Di}},tC=class extends He{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new _e),this.onBufferChange=this._onBufferChange.event,this._normal=new ig(this._core.buffers.normal,"normal"),this._alternate=new ig(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,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,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"],qi=0,sC=class extends He{constructor(e){super(),this._core=this._register(new Q1(e)),this._addonManager=this._register(new Z1),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(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:n.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,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
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 Ou.get()},set promptLabel(e){Ou.set(e)},get tooMuchOutput(){return zu.get()},set tooMuchOutput(e){zu.set(e)}}}_verifyIntegers(...e){for(qi of e)if(qi===1/0||isNaN(qi)||qi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qi of e)if(qi&&(qi===1/0||isNaN(qi)||qi%1!==0||qi<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 b;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:((b=this._terminal.options.overviewRuler)==null?void 0:b.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),c={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},d=c.top+c.bottom,p=c.right+c.left,m=s-d,S=o-p-t;return{cols:Math.max(oC,Math.floor(S/e.css.cell.width)),rows:Math.max(aC,Math.floor(m/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:n,cols:s,rows:o,readonly:l=!1,takeSize:c,focused:d,onData:p,onExit:m,onFiles:S,retryBaseMs:b=250}){const _=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!_)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,n)}`;let C=null,k=!1,N=!1,D=null,B=0,A=d;const J=()=>{if(k||N||D)return;const F=Math.min(5e3,Math.max(0,b)*2**Math.min(B++,5));D=setTimeout(()=>{D=null,O()},F)},O=()=>{if(k||N)return;const F=new WebSocket(w);C=F,F.binaryType="arraybuffer",F.onopen=()=>{if(C!==F||k)return;B=0;const Z={type:"attach",session:e,token:n,cols:s,rows:o,readonly:l};c!==void 0&&(Z.takeSize=c),F.send(JSON.stringify(Z)),A!==void 0&&F.send(JSON.stringify({type:"focus",on:!!A}))},F.onmessage=Z=>{if(!(C!==F||k))if(typeof Z.data=="string"){let W;try{W=JSON.parse(Z.data)}catch{return}W.type==="exit"&&(N=!0,m&&m(W.code)),W.type==="files"&&S&&S(W)}else p&&p(new Uint8Array(Z.data))},F.onerror=()=>{if(C===F)try{F.close()}catch{}},F.onclose=Z=>{C!==F||k||N||[1e3,1002,4401,4404].includes(Z==null?void 0:Z.code)||J()}};return O(),{sendInput:F=>{if(!C||C.readyState!==1)return!1;try{return C.send(typeof F=="string"?new TextEncoder().encode(F):F),!0}catch{try{C.close()}catch{}return!1}},isReady:()=>!!C&&C.readyState===1,resize:(F,Z)=>{s=F,o=Z,(C==null?void 0:C.readyState)===1&&C.send(JSON.stringify({type:"resize",cols:F,rows:Z}))},action:F=>{(C==null?void 0:C.readyState)===1&&C.send(JSON.stringify({type:"action",name:F}))},focus:F=>{A=F,(C==null?void 0:C.readyState)===1&&C.send(JSON.stringify({type:"focus",on:!!F}))},close:()=>{if(k=!0,D&&clearTimeout(D),D=null,C)try{C.close()}catch{}},get raw(){return C}}}async function ng(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 n=document.createElement("textarea");n.value=t,n.readOnly=!0,n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select();const s=document.execCommand&&document.execCommand("copy");if(n.remove(),s)return!0}catch{}return!1}const hC="\r";function dC(e){const t=String(e||"");let n=t.length;for(;n>0;){const s=t.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return t.slice(0,n)}function fC({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n(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,rg=8;function vC(e,t,n,s){return Math.abs(Number(n)-Number(e))>rg||Math.abs(Number(s)-Number(t))>rg}const _C=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function au(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 sg(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function yC(e,t=0,n=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-${n}-${t+1}.${o}`}async function y_({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:l=Tt,onProgress:c=()=>{},now:d=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),m=[],S=[];if(!n||!p.length)return{paths:m,errors:S};const b=li(s?String(s).split("/"):[]);for(let _=0;_<p.length;_+=1){const v=p[_],w=yC(v,_,d);c({index:_,total:p.length,name:w,state:"uploading"});try{const C=new FormData;C.append("session",n),C.append("paste",o?"true":"false"),C.append("file",v,w);const k=await l(`${b}/files/upload`,t,{method:"POST",body:C}),N=await k.json().catch(()=>({}));if(!k.ok||N.error)throw new Error(N.error||`HTTP ${k.status}`);m.push(N.path),c({index:_,total:p.length,name:w,state:"done",path:N.path})}catch(C){const k=String((C==null?void 0:C.message)||C);S.push({name:w,message:k}),c({index:_,total:p.length,name:w,state:"error",error:k})}}return{paths:m,errors:S}}function S_({session:e,node:t,token:n,readonly:s,takeSize:o,focused:l,sendRef:c,composerRef:d,actionRef:p,ctrlRef:m,setCtrlArmed:S,onFiles:b,fontSize:_=13,selectionMode:v=!1,onSelectionModeChange:w}){const C=L.useRef(null),k=L.useRef(null),N=L.useRef(_);N.current=_;const D=L.useRef(l);D.current=l;const B=L.useRef(v);B.current=v;const[A,J]=L.useState(""),[O,F]=L.useState(""),[Z,W]=L.useState(null),G=async()=>{var P,U,R,H;const j=((U=(P=k.current)==null?void 0:P.term)==null?void 0:U.getSelection())||A;if(!j){F(y("copy-empty")),setTimeout(()=>F(""),1500);return}const E=await ng(j);F(y(E?"copied":"copy-manual")),E&&((H=(R=k.current)==null?void 0:R.term)==null||H.clearSelection(),w==null||w(!1)),setTimeout(()=>F(""),1800)},X=L.useRef(G);return X.current=G,L.useEffect(()=>{const j=k.current;j&&j.sock&&j.sock.focus&&j.sock.focus(!!l)},[l]),L.useEffect(()=>{const j=k.current;j&&(j.term.options.fontSize=_,j.fit.fit(),j.sock.resize(j.term.cols,j.term.rows))},[_]),L.useEffect(()=>{const j=new sC({cursorBlink:!0,fontSize:N.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),E=new lC;j.loadAddon(E),j.open(C.current),E.fit();const P=new TextDecoder;let U;try{U=uC({session:e,node:t,token:n,readonly:s,takeSize:o,focused:D.current,onFiles:b,cols:j.cols,rows:j.rows,onData:me=>j.write(P.decode(me)),onExit:()=>j.write(`\r
|
|
78
|
+
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
+
`)})}catch(me){return j.write(`\r
|
|
80
|
+
\x1B[31m${me.message}\x1B[0m\r
|
|
81
|
+
`),()=>j.dispose()}k.current={term:j,fit:E,sock:U};let R=null;const H=j.onData(me=>{if(s){R&&(R.ok=!1);return}if(!R&&m&&m.current&&me.length===1){const Je=me.charCodeAt(0);let ce=Je;Je>=97&&Je<=122?ce=Je-96:Je>=64&&Je<=95?ce=Je-64:Je===32&&(ce=0),me=String.fromCharCode(ce),m.current=!1,S&&S(!1)}const $e=U.sendInput(me);R&&(R.seen=!0,R.ok=R.ok&&$e)});c&&(c.current=me=>U.sendInput(me)),p&&(p.current=me=>U.action(me)),d&&(d.current=fC({isReady:()=>!s&&U.isReady(),paste:me=>{const $e={seen:!1,ok:!0};R=$e;try{j.paste(me)}catch{$e.ok=!1}finally{R=null}return $e.seen&&$e.ok},send:me=>U.sendInput(me)}));const I=j.onSelectionChange(()=>J(j.getSelection()));j.attachCustomKeyEventHandler(me=>(me.ctrlKey||me.metaKey)&&me.key.toLowerCase()==="c"&&j.getSelection()?(me.type==="keydown"&&ng(j.getSelection()),!1):!0);const se=C.current;let q=!1;const M=async me=>{if(!me.length||q)return;if(s){W({error:y("settings-readonly")});return}q=!0,W({current:0,total:me.length,name:""});const $e=await y_({files:me,token:n,session:e,node:t,paste:!0,onProgress:({index:Je,total:ce,name:Pe,state:Oe,error:Et})=>W({current:Je+1,total:ce,name:Pe,...Oe==="error"?{error:Et}:{}})});q=!1,$e.errors.length?W({error:$e.errors.map(Je=>`${Je.name}: ${Je.message}`).join(" · ")}):(W({done:!0,total:$e.paths.length}),setTimeout(()=>W(null),1600))},K=me=>{const $e=me.clipboardData;if(!au($e))return;const Je=sg($e);Je.length&&(me.preventDefault(),me.stopPropagation(),M(Je))},Q=me=>{au(me.dataTransfer)&&(me.preventDefault(),me.stopPropagation())},re=me=>{au(me.dataTransfer)&&(me.preventDefault(),me.stopPropagation(),M(sg(me.dataTransfer)))};se.addEventListener("paste",K,!0),se.addEventListener("dragenter",Q,!0),se.addEventListener("dragover",Q,!0),se.addEventListener("drop",re,!0);const oe=24;let le=null,V=null,z=0,pe=null,ye=null,xe=null,te=!1;const de=()=>{xe&&clearTimeout(xe),xe=null},Ne=(me,$e)=>{const ce=(se.querySelector(".xterm-screen")||se).getBoundingClientRect(),Pe=Math.max(0,Math.min(j.cols-1,Math.floor((me-ce.left)/Math.max(1,ce.width)*j.cols))),Oe=Math.max(0,Math.min(j.rows-1,Math.floor(($e-ce.top)/Math.max(1,ce.height)*j.rows)));return{col:Pe,row:j.buffer.active.viewportY+Oe}},ke=me=>Ne(me.clientX,me.clientY),Ve=me=>{if(de(),te=!1,me.touches.length!==1){le=null;return}if(B.current){me.preventDefault(),me.stopPropagation(),ye=ke(me.touches[0]),j.clearSelection();return}le=me.touches[0].clientY,V=me.touches[0].clientX,z=0,pe=null;const $e={x:V,y:le};xe=setTimeout(()=>{xe=null,te=!0,B.current=!0,w==null||w(!0),ye=Ne($e.x,$e.y),j.clearSelection(),j.select(ye.col,ye.row,1),le=null,V=null,pe=null,z=0},gC)},Qe=me=>{if((B.current||te)&&ye&&me.touches.length===1){me.preventDefault(),me.stopPropagation();const Je=ke(me.touches[0]),ce=ye.row*j.cols+ye.col,Pe=Je.row*j.cols+Je.col,Oe=ce<=Pe?ye:Je;j.select(Oe.col,Oe.row,Math.abs(Pe-ce)+1);return}if(le===null||me.touches.length!==1)return;me.preventDefault(),me.stopPropagation();const $e=me.touches[0];if(xe&&vC(V,le,$e.clientX,$e.clientY)&&de(),pe===null&&(Math.abs($e.clientY-le)>8||Math.abs($e.clientX-V)>8)&&(pe=Math.abs($e.clientY-le)>Math.abs($e.clientX-V)),!!pe){for(z+=$e.clientY-le,le=$e.clientY;z>=oe;)U.action("scroll-up"),z-=oe;for(;z<=-oe;)U.action("scroll-down"),z+=oe}},Ke=()=>{de(),le=null,V=null,ye=null,te=!1};let ie=0;const we=me=>{for(me.preventDefault(),me.stopPropagation(),ie+=me.deltaY;ie<=-oe;)U.action("scroll-up"),ie+=oe;for(;ie>=oe;)U.action("scroll-down"),ie-=oe};se.addEventListener("touchstart",Ve,{passive:!1}),se.addEventListener("touchmove",Qe,{passive:!1,capture:!0}),se.addEventListener("touchend",Ke,{passive:!0}),se.addEventListener("touchcancel",Ke,{passive:!0});const Te=me=>{(B.current||te)&&(me.preventDefault(),me.stopPropagation())};se.addEventListener("contextmenu",Te,!0),se.addEventListener("wheel",we,{passive:!1,capture:!0});let Se=null;const Xe=me=>{pC(me)&&(me.preventDefault(),me.stopPropagation(),Se=Ne(me.clientX,me.clientY),j.clearSelection())},ci=me=>{if(!Se)return;me.preventDefault(),me.stopPropagation();const $e=Ne(me.clientX,me.clientY),Je=Se.row*j.cols+Se.col,ce=$e.row*j.cols+$e.col,Pe=Je<=ce?Se:$e;j.select(Pe.col,Pe.row,Math.abs(ce-Je)+1)},$t=me=>{Se&&(me.stopPropagation(),Se=null)};se.addEventListener("mousedown",Xe,!0),se.addEventListener("mousemove",ci,!0),se.addEventListener("mouseup",$t,!0);const Zt=me=>{!mC(me)||!(k.current&&k.current.term&&k.current.term.getSelection())||(me.preventDefault(),me.stopPropagation(),X.current&&X.current())};se.addEventListener("keydown",Zt,!0);const Ue=()=>{E.fit(),U.resize(j.cols,j.rows)};window.addEventListener("resize",Ue);const Bt=window.visualViewport;Bt&&(Bt.addEventListener("resize",Ue),Bt.addEventListener("scroll",Ue));let Si=null,qe=0;return typeof ResizeObserver<"u"&&(Si=new ResizeObserver(()=>{qe&&cancelAnimationFrame(qe),qe=requestAnimationFrame(Ue)}),Si.observe(se)),()=>{k.current=null,c&&(c.current=()=>!1),d&&(d.current=()=>!1),p&&(p.current=()=>!1),H.dispose(),I.dispose(),se.removeEventListener("touchstart",Ve),se.removeEventListener("touchmove",Qe,{capture:!0}),se.removeEventListener("touchend",Ke),se.removeEventListener("touchcancel",Ke),se.removeEventListener("contextmenu",Te,!0),de(),se.removeEventListener("wheel",we,{capture:!0}),se.removeEventListener("mousedown",Xe,!0),se.removeEventListener("mousemove",ci,!0),se.removeEventListener("mouseup",$t,!0),se.removeEventListener("keydown",Zt,!0),se.removeEventListener("paste",K,!0),se.removeEventListener("dragenter",Q,!0),se.removeEventListener("dragover",Q,!0),se.removeEventListener("drop",re,!0),window.removeEventListener("resize",Ue),Bt&&(Bt.removeEventListener("resize",Ue),Bt.removeEventListener("scroll",Ue)),Si&&Si.disconnect(),qe&&cancelAnimationFrame(qe),U.close(),j.dispose()}},[e,t,n,s,o,c,d,p,m,S,b]),h.jsxs("div",{className:`nc-terminal${v?" selecting":""}`,children:[h.jsx("div",{className:"nc-terminal-host",ref:C}),Z&&h.jsx("div",{className:`nc-upload-state${Z.error?" error":""}`,role:"status",children:Z.error?Z.error:Z.done?y("attach-uploaded").replace("{n}",String(Z.total||0)):y("attach-upload-progress").replace("{n}",String(Z.current||0)).replace("{total}",String(Z.total||0))}),(A||v)&&h.jsxs("div",{className:"nc-selection-tools",children:[A?h.jsx("button",{type:"button",onClick:G,children:O||y("copy")}):h.jsx("span",{children:y("select-drag")}),h.jsx("button",{type:"button",onClick:()=>{var j,E;(E=(j=k.current)==null?void 0:j.term)==null||E.clearSelection(),J(""),w==null||w(!1)},children:y("cancel")}),O===y("copy-manual")&&h.jsx("textarea",{readOnly:!0,value:A,onFocus:j=>j.target.select()})]})]})}const og="",ai="\x1B",SC=[{label:"↑",seq:ai+"[A"},{label:"↓",seq:ai+"[B"},{label:"PGUP",seq:ai+"[5~"},{label:"PGDN",seq:ai+"[6~"}];function wC({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:l=!1,onSelectionMode:c}){const[d,p]=L.useState(!1),[m,S]=L.useState(!1),[b,_]=L.useState(!1),v=k=>{b?(e(ai+k),_(!1)):e(k)},w=(k,N,D)=>h.jsx("button",{onMouseDown:B=>{B.preventDefault(),v(N),D&&D()},children:k},k),C=(k,N)=>h.jsx("button",{onMouseDown:D=>{D.preventDefault(),t(N),S(!1)},children:k},k);return d?h.jsxs("div",{className:"nc-keybar copy",children:[h.jsx("span",{className:"tag",children:"copy-mode"}),SC.map(k=>w(k.label,k.seq)),w("ESCI (q)","q",()=>p(!1))]}):h.jsxs("div",{className:"nc-keybar termux",children:[m&&h.jsxs("div",{className:"nc-keymenu",children:[C("←WIN","prev-window"),C("WIN→","next-window"),C("⬅PANE","pane-left"),C("PANE➡","pane-right"),w("SCROLL",og+"[",()=>{p(!0),S(!1)}),h.jsx("button",{className:l?"armed":"",onMouseDown:k=>{k.preventDefault(),c==null||c(!l),S(!1)},children:"SELECT"}),w("⌃C","",()=>S(!1)),w("DETACH",og+"d",()=>S(!1))]}),h.jsxs("div",{className:"row",children:[w("ESC",ai),h.jsx("button",{className:m?"armed":"",onMouseDown:k=>{k.preventDefault(),S(N=>!N)},children:"☰"},"menu"),w("/","/"),w("—","-"),w("HOME",ai+"[H"),w("↑",ai+"[A"),w("END",ai+"[F"),w("PGUP",ai+"[5~")]}),h.jsxs("div",{className:"row",children:[w("⇥"," "),h.jsx("button",{onMouseDown:k=>{k.preventDefault(),o&&o()},children:"⌨"},"kbd"),h.jsx("button",{className:n?"armed":"",onMouseDown:k=>{k.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),h.jsx("button",{className:b?"armed":"",onMouseDown:k=>{k.preventDefault(),_(N=>!N)},children:"ALT"},"alt"),w("←",ai+"[D"),w("↓",ai+"[B"),w("→",ai+"[C"),w("PGDN",ai+"[6~")]})]})}const bC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function w_({session:e,node:t,token:n,filesEvent:s,onClose:o}){yi();const l=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=t?`${t}:${e}`:e,[d,p]=L.useState("outbox"),[m,S]=L.useState({inbox:[],outbox:[]}),[b,_]=L.useState(""),v=L.useRef(null);async function w(){try{const B=await(await Tt(`${l}/files?session=${encodeURIComponent(e)}`,n)).json();if(B.error){_(B.error);return}S(B);const A=B.outbox[0]?B.outbox[0].mtime:0;localStorage.setItem(hv(c),String(A))}catch(D){_(String(D))}}L.useEffect(()=>{w()},[e,t]),L.useEffect(()=>{s&&s.session===e&&w()},[s]);async function C(D){for(const B of D){_(`carico ${B.name}…`);const A=new FormData;A.append("session",e),A.append("file",B);try{const O=await(await Tt(`${l}/files/upload`,n,{method:"POST",body:A})).json();_(O.error?`errore: ${O.error}`:"")}catch(J){_(String(J))}}w()}async function k(D){const B=await Tt(`${l}/files/download?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(D)}`,n);if(!B.ok){_("errore download");return}const A=await B.blob(),J=URL.createObjectURL(A),O=document.createElement("a");O.href=J,O.download=D,O.click(),URL.revokeObjectURL(J)}async function N(D){await Tt(`${l}/files?session=${encodeURIComponent(e)}&box=${d}&name=${encodeURIComponent(D)}`,n,{method:"DELETE"}),w()}return h.jsxs("div",{className:"nc-files",children:[h.jsxs("header",{children:[h.jsx("b",{children:t?`${t}:${e}`:e}),h.jsx("button",{onClick:o,title:y("close"),children:h.jsx(Ze,{name:"x",size:20})})]}),h.jsxs("nav",{children:[h.jsx("button",{className:d==="outbox"?"on":"",onClick:()=>p("outbox"),children:"outbox"}),h.jsx("button",{className:d==="inbox"?"on":"",onClick:()=>p("inbox"),children:"inbox"}),h.jsxs("button",{className:"up",onClick:()=>v.current&&v.current.click(),children:[h.jsx(Ze,{name:"upload",size:18})," ",y("upload")]}),h.jsx("input",{type:"file",multiple:!0,ref:v,style:{display:"none"},onChange:D=>{C(Array.from(D.target.files||[])),D.target.value=""}})]}),b&&h.jsx("div",{className:"nc-busy",children:b}),h.jsxs("ul",{children:[m[d].map(D=>h.jsxs("li",{children:[h.jsx("span",{className:"name",onClick:()=>k(D.name),children:D.name}),h.jsx("small",{children:bC(D.size)}),h.jsx("button",{onClick:()=>N(D.name),title:"elimina",children:h.jsx(Ze,{name:"trash",size:18})})]},D.name)),m[d].length===0&&h.jsx("li",{className:"empty",children:y("empty-files")})]})]})}function b_({submitText:e,token:t,session:n,node:s}){yi();const o=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",[l,c]=L.useState(""),[d,p]=L.useState(!1),[m,S]=L.useState(""),[b,_]=L.useState(!1),v=L.useRef(null),w=L.useRef(null),C=L.useRef(null),[k,N]=L.useState(!1),[D,B]=L.useState({left:0,bottom:0}),[A,J]=L.useState(!1),[O,F]=L.useState(!1),Z=L.useRef(null),W=L.useRef(null),G=L.useRef(null),X=L.useRef(null),j=L.useRef(null),E=L.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);L.useEffect(()=>{let Q=!1;if(s){_(!1);return}return Tt(`${o}/voice/status`,t).then(re=>re.json()).then(re=>{Q||_(!!re.serverSttConfigured)}).catch(()=>{Q||_(!1)}),()=>{Q=!0}},[t,o]);const U=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||b);async function R(){const Q=l,re=dC(Q);if(!re||O)return;F(!0),S("");let oe=!1;try{oe=!!await e(re)}catch{oe=!1}oe?c(le=>le===Q?"":le):S(y("composer-send-failed")),F(!1),requestAnimationFrame(()=>{var le;return(le=C.current)==null?void 0:le.focus({preventScroll:!0})})}function H(){const Q=Z.current&&Z.current.getBoundingClientRect();Q&&B({left:Math.max(6,Math.min(Q.left,window.innerWidth-186)),bottom:window.innerHeight-Q.top+6}),N(!0)}function I(Q){N(!1),Q&&Z.current&&Z.current.focus()}L.useEffect(()=>{if(!k)return;const Q=oe=>{oe.key==="Escape"&&I(!0)},re=oe=>{const le=W.current&&W.current.contains(oe.target),V=Z.current&&Z.current.contains(oe.target);!le&&!V&&I(!1)};return document.addEventListener("keydown",Q),document.addEventListener("pointerdown",re),()=>{document.removeEventListener("keydown",Q),document.removeEventListener("pointerdown",re)}},[k]);function se(Q){I(!1),Q.current&&Q.current.click()}async function q(Q){if(!Q.length||!n)return;J(!0),S("");const{paths:re,errors:oe}=await y_({files:Q,token:t,session:n,node:s,paste:!1});oe.length&&S(oe.map(le=>`${le.name}: ${le.message}`).join(" · ")),re.length&&c(le=>le+(le&&!le.endsWith(" ")?" ":"")+re.join(" ")),J(!1)}function M(){v.current&&v.current.stop(),w.current&&w.current.stop(),p(!1)}async function K(){S("");const Q=window.SpeechRecognition||window.webkitSpeechRecognition;if(Q){const re=new Q;re.lang="it-IT",re.continuous=!1,re.interimResults=!0;const oe=l?`${l} `:"";re.onresult=le=>{const V=Array.from(le.results).map(z=>z[0].transcript).join("");c(oe+V)},re.onend=()=>p(!1),re.onerror=le=>{S(`voice: ${le.error||"errore"}`),p(!1)},v.current=re,re.start(),p(!0);return}try{const re=await navigator.mediaDevices.getUserMedia({audio:!0}),oe=new MediaRecorder(re),le=[];oe.ondataavailable=V=>le.push(V.data),oe.onstop=async()=>{re.getTracks().forEach(V=>V.stop()),p(!1),S("trascrivo…");try{const V=new Blob(le,{type:oe.mimeType||"audio/webm"}),pe=await(await Tt(`${o}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:V})).json();pe.error?S(pe.error):(S(""),c(ye=>ye+(ye?" ":"")+(pe.text||"")))}catch(V){S(String(V))}},w.current={stop:()=>oe.state!=="inactive"&&oe.stop()},oe.start(),p(!0)}catch{S("microfono non disponibile"),p(!1)}}return h.jsxs("div",{className:"nc-composer",children:[m&&h.jsx("div",{className:"nc-composer-err",children:m}),h.jsxs("div",{className:"nc-composer-row",children:[n&&h.jsx("button",{ref:Z,className:A?"attach busy":"attach",disabled:A,onClick:()=>k?I(!1):H(),title:y(A?"attach-uploading":"attach"),"aria-label":y("attach"),"aria-haspopup":"menu","aria-expanded":k,"aria-controls":E.current,children:h.jsx(Ze,{name:"attach",size:22})}),k&&h.jsxs("div",{ref:W,id:E.current,role:"menu",className:"nc-attach-menu",style:{left:D.left,bottom:D.bottom},children:[h.jsxs("button",{role:"menuitem",onClick:()=>se(G),children:[h.jsx(Ze,{name:"file",size:18})," ",y("attach-file")]}),h.jsxs("button",{role:"menuitem",onClick:()=>se(X),children:[h.jsx(Ze,{name:"camera",size:18})," ",y("attach-camera")]}),h.jsxs("button",{role:"menuitem",onClick:()=>se(j),children:[h.jsx(Ze,{name:"image",size:18})," ",y("attach-gallery")]})]}),h.jsx("input",{ref:G,type:"file",multiple:!0,hidden:!0,onChange:Q=>{q(Array.from(Q.target.files||[])),Q.target.value=""}}),h.jsx("input",{ref:X,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:Q=>{q(Array.from(Q.target.files||[])),Q.target.value=""}}),h.jsx("input",{ref:j,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:Q=>{q(Array.from(Q.target.files||[])),Q.target.value=""}}),h.jsx("textarea",{ref:C,rows:2,value:l,placeholder:y("composer-placeholder"),onChange:Q=>c(Q.target.value)}),U&&h.jsx("button",{className:d?"mic on":"mic",onClick:d?M:K,title:y("voice"),children:h.jsx(Ze,{name:"mic",size:22})}),h.jsx("button",{type:"button",className:"go",disabled:O,onPointerDown:Q=>Q.preventDefault(),onClick:R,title:y("send"),children:h.jsx(Ze,{name:"enter",size:22})})]})]})}function ag(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const CC=180,kC=480;function xC({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:l,onPower:c,onNodePower:d,onKill:p,onVisibility:m,onNew:S,onSettings:b,width:_=240,collapsed:v=!1,onResize:w,onToggleCollapse:C}){const[k,N]=yi(),{pins:D,orders:B,togglePin:A,viewFor:J,updateView:O,canMoveRoster:F,moveRoster:Z,stepRoster:W}=xv(),G=new Set((t||[]).map(V=>V.tmuxSession)),X=new Map((e||[]).map(V=>[V.name,V])),j=(V,z)=>Yw(D,V,z),E=Xw,P=[...t||[]].sort((V,z)=>E(j(V.tmuxSession,(X.get(V.tmuxSession)||{}).activity),j(z.tmuxSession,(X.get(z.tmuxSession)||{}).activity))),U=(e||[]).filter(V=>!G.has(V.name)).sort((V,z)=>E(j(V.name,V.activity),j(z.name,z.activity))||V.name.localeCompare(z.name)),R=new Set(n||[]),H=Nv(P,U,X),I=ar(H,D,J("local").filter,zn(B,"local")),se=(s||[]).map(V=>{const z=(V.route||[V.name]).join("/"),pe=J(z),{rawItems:ye}=Rv(V),xe=ar(ye,D,pe.filter,zn(B,z));return{g:V,nodeRoute:z,groupView:pe,rawItems:ye,items:xe}}),[q,M]=L.useState(null),K=(V,z)=>{const pe=V.currentTarget.getBoundingClientRect();M({text:z,y:pe.top+pe.height/2})},Q=()=>M(null),re=L.useRef(null);L.useEffect(()=>()=>{re.current&&re.current()},[]);function oe(V){V.preventDefault(),V.stopPropagation();const z=V.clientX,pe=_,ye=te=>{const de=Math.max(CC,Math.min(kC,pe+(te.clientX-z)));w&&w(de)},xe=()=>{window.removeEventListener("pointermove",ye),window.removeEventListener("pointerup",xe),window.removeEventListener("pointercancel",xe),window.removeEventListener("blur",xe),re.current=null};window.addEventListener("pointermove",ye),window.addEventListener("pointerup",xe),window.addEventListener("pointercancel",xe),window.addEventListener("blur",xe),re.current=xe}const le=v?{width:48,flex:"0 0 48px"}:{width:_,flex:`0 0 ${_}px`};return v?h.jsxs("aside",{className:"nc-sidebar mini",style:le,children:[h.jsx("div",{className:"nc-side-head mini",children:h.jsx("button",{className:"nc-collapse-btn",onClick:C,title:y("expand"),children:"⟩"})}),h.jsx("button",{className:"nc-side-gear mini",onClick:()=>b&&b("nodes",!1),title:y("settings"),onMouseEnter:V=>K(V,y("settings")),onMouseLeave:Q,children:h.jsx(Ze,{name:"gear",size:16})}),h.jsx("div",{className:"nc-side-scroll mini",children:h.jsxs("div",{className:"nc-side-group mini",children:[J("local").open&&I.map(V=>V.type==="cell"?(()=>{const z=V.value,pe=z.degraded?"warn":z.tmux?"on":"",ye=!!z.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${R.has(z.tmuxSession)?" active":""}`,onMouseEnter:xe=>K(xe,z.cell),onMouseLeave:Q,draggable:ye,onDragStart:ye?xe=>xe.dataTransfer.setData("text/nc-session",z.tmuxSession):void 0,onClick:ye?()=>l&&l(z.tmuxSession):()=>c&&c(z),onDoubleClick:ye?()=>o&&o(z.tmuxSession):void 0,children:h.jsx("span",{className:`nc-dot ${pe}`})},V.key)})():(()=>{const z=V.value;return h.jsx("button",{type:"button",className:`nc-mini-init${R.has(z.name)?" active":""}`,onMouseEnter:pe=>K(pe,z.name),onMouseLeave:Q,draggable:!0,onDragStart:pe=>pe.dataTransfer.setData("text/nc-session",z.name),onClick:()=>l&&l(z.name),onDoubleClick:()=>o&&o(z.name),children:ag(z.name)},V.key)})()),se.flatMap(({g:V,nodeRoute:z,groupView:pe,items:ye})=>V.status==="up"?pe.open?ye.map(xe=>xe.type==="cell"?(()=>{const te=xe.value,de=!!te.tmux;return h.jsx("button",{type:"button",className:`nc-mini-dot${R.has(xe.key)?" active":""}`,onMouseEnter:Ne=>K(Ne,`${V.label||z}: ${te.cell}`),onMouseLeave:Q,draggable:de,onDragStart:de?Ne=>Ne.dataTransfer.setData("text/nc-session",xe.key):void 0,onClick:de?()=>l&&l(xe.key):()=>c&&c({...te,route:V.route,availableEngines:V.engines||[]}),onDoubleClick:de?()=>o&&o({session:te.tmuxSession,node:z}):void 0,children:h.jsx("span",{className:`nc-dot ${te.degraded?"warn":de?"on":""}`})},xe.key)})():(()=>{const te=xe.value;return h.jsx("button",{type:"button",className:`nc-mini-init${R.has(xe.key)?" active":""}`,onMouseEnter:de=>K(de,`${V.label||z}: ${te.name}`),onMouseLeave:Q,draggable:!0,onDragStart:de=>de.dataTransfer.setData("text/nc-session",xe.key),onClick:()=>l&&l(xe.key),onDoubleClick:()=>o&&o({session:te.name,node:z}),children:ag(te.name)},xe.key)})()):[]:[h.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:xe=>K(xe,`${V.label||(V.route||[V.name]).join(" › ")}: ${qr(V)}`),onMouseLeave:Q,children:h.jsx("span",{className:`nc-dot${V.status==="passive"?"":" warn"}`})},`nodo-${(V.route||[V.name]).join("/")}`)])]})}),q&&h.jsx("div",{className:"nc-mini-tip",style:{top:q.y},children:q.text})]}):h.jsxs("aside",{className:"nc-sidebar",style:le,children:[h.jsxs("div",{className:"nc-side-head",children:[h.jsx("button",{className:"nc-collapse-btn",onClick:C,title:y("collapse"),children:"⟨"}),h.jsx("span",{className:"nc-side-title",children:y("fleet")}),h.jsxs("button",{className:"nc-new-btn",onClick:S,title:y("fleet-new-cell"),children:["+ ",y("new")]})]}),h.jsxs("button",{className:"nc-side-gear",onClick:()=>b&&b("nodes",!1),title:y("settings"),children:[h.jsx(Ze,{name:"gear",size:15})," ",y("settings")]}),h.jsxs("div",{className:"nc-side-scroll",children:[h.jsx(EC,{label:y("position-local"),count:I.length,state:J("local"),onToggle:()=>O("local",{open:!J("local").open}),onFilter:V=>O("local",{filter:V})}),J("local").open&&h.jsxs("div",{className:"nc-side-group",children:[I.map(V=>V.type==="cell"?(()=>{const z=V.value,pe=z.degraded?"warn":z.tmux?"on":"",ye=z.degraded?y("cell-degraded"):z.tmux?y("cell-on"):y("cell-off"),xe=!!z.tmux;return h.jsxs("div",{"data-roster-key":V.key,"data-position":"local",className:`nc-cell${xe?" live":""}${R.has(z.tmuxSession)?" active":""}`,title:`${z.cell} · ${z.engine}${z.key?`·${z.key}`:""} · ${ye}`,"aria-label":`${z.cell}, ${z.engine}${z.key?` ${z.key}`:""}, ${ye}`,draggable:xe,onDragStart:xe?te=>te.dataTransfer.setData("text/nc-session",z.tmuxSession):void 0,onClick:xe?()=>l&&l(z.tmuxSession):void 0,onDoubleClick:xe?()=>o&&o(z.tmuxSession):void 0,children:[h.jsx(Ur,{position:"local",itemKey:V.key,label:z.cell,canMove:F,onMove:(te,de)=>Z("local",te,de,H),onStep:te=>W("local",V.key,te,H)}),h.jsx("span",{className:`nc-dot ${pe}`}),h.jsxs("span",{className:"nc-cell-main",children:[h.jsx("b",{title:z.cell,children:z.cell}),h.jsxs("small",{title:`${z.engine}${z.key?`·${z.key}`:""}`,children:[z.engine,z.key?`·${z.key}`:""]})]}),h.jsx("button",{className:`nc-pin${D.includes(V.key)?" on":""}`,title:y("pin"),onClick:te=>{te.stopPropagation(),A(V.key)},children:D.includes(V.key)?"★":"☆"}),h.jsx("button",{className:`nc-power${z.tmux?" on":""}${z.degraded?" warn":""}`,onClick:te=>{te.stopPropagation(),c&&c(z)},title:z.active?y("power-off"):y("power-on"),children:h.jsx(Ze,{name:"power",size:14})})]},V.key)})():(()=>{var pe;const z=V.value;return h.jsxs("div",{"data-roster-key":V.key,"data-position":"local",className:`nc-side-card${R.has(z.name)?" active":""}`,draggable:!0,onDragStart:ye=>ye.dataTransfer.setData("text/nc-session",z.name),onClick:()=>l&&l(z.name),onDoubleClick:()=>o&&o(z.name),children:[h.jsx(Ur,{position:"local",itemKey:V.key,label:z.name,canMove:F,onMove:(ye,xe)=>Z("local",ye,xe,H),onStep:ye=>W("local",V.key,ye,H)}),h.jsx("span",{className:z.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:z.name}),h.jsxs("small",{children:[z.preview||z.cmd||y("windows").replace("{n}",String(z.windows||0)),((pe=z.outbox)==null?void 0:pe.count)>0?` · 📦${z.outbox.count}`:""]})]}),z.activity?h.jsx("span",{className:"nc-rel",children:Gr(z.activity)}):null,h.jsx("button",{className:`nc-pin${D.includes(V.key)?" on":""}`,title:y("pin"),onClick:ye=>{ye.stopPropagation(),A(V.key)},children:D.includes(V.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${z.technical?" on":""}`,title:z.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${z.technical?y("mark-normal"):y("mark-technical")} ${z.name}`,onClick:ye=>{ye.stopPropagation(),m&&m(z.name,!z.technical,[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),onClick:ye=>{ye.stopPropagation(),window.confirm(y("terminate-confirm").replace("{name}",z.name))&&p&&p(z.name)},children:"⋯"})]},V.key)})()),I.length===0&&h.jsx("div",{className:"nc-empty",children:y("no-sessions-short")})]}),se.map(({g:V,nodeRoute:z,groupView:pe,rawItems:ye,items:xe})=>{const de=Ev(V.health)||(V.status==="up"?"on":V.status==="passive"?"":"warn");return h.jsxs("div",{children:[h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>O(z,{open:!pe.open}),onKeyDown:Ne=>{(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),O(z,{open:!pe.open}))},children:[h.jsx("span",{className:"nc-node-chevron",children:pe.open?"⌄":"›"}),h.jsx("span",{className:`nc-dot ${de}`,title:V.health?Fa(V.health):""}),h.jsx("b",{children:V.label||V.name}),h.jsxs("small",{children:[" · ",V.status==="up"?y("node-sessions").replace("{n}",String(xe.length)):V.health&&Fa(V.health)||qr(V)]}),h.jsxs("select",{className:"nc-node-filter",value:pe.filter,title:y(`view-${pe.filter}`),onClick:Ne=>Ne.stopPropagation(),onChange:Ne=>O(z,{filter:Ne.target.value}),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("view-technical")})]}),V.direct&&V.health&&V.health.managed!==!1&&h.jsx("button",{type:"button",className:`nc-power${V.tunnelStatus==="up"?" on":""}`,title:V.tunnelStatus==="up"?y("power-off"):y("power-on"),onClick:Ne=>{Ne.stopPropagation(),d&&d(V)},children:h.jsx(Ze,{name:"power",size:14})})]}),V.status==="up"&&pe.open&&h.jsxs("div",{className:"nc-side-group",children:[xe.map(Ne=>Ne.type==="cell"?(()=>{const ke=Ne.value,Ve=!!ke.tmux,Qe=ke.degraded?"warn":ke.tmux?"on":"";return h.jsxs("div",{"data-roster-key":Ne.key,"data-position":z,className:`nc-side-card nc-cell${Ve?" live":""}${R.has(ke.key)?" active":""}`,title:ke.active?y("cell-on"):y("cell-off"),draggable:Ve,onDragStart:Ve?Ke=>Ke.dataTransfer.setData("text/nc-session",ke.key):void 0,onClick:Ve?()=>l&&l(ke.key):void 0,onDoubleClick:Ve?()=>o&&o({session:ke.tmuxSession,node:z}):void 0,children:[h.jsx(Ur,{position:z,itemKey:Ne.key,label:ke.cell,canMove:F,onMove:(Ke,ie)=>Z(z,Ke,ie,ye),onStep:Ke=>W(z,Ne.key,Ke,ye)}),h.jsx("span",{className:`nc-dot ${Qe}`}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:ke.cell}),h.jsxs("small",{children:[ke.engine,ke.key?`·${ke.key}`:"",ke.active?"":` · ${y("cell-off")}`]})]}),h.jsx("button",{className:`nc-pin${D.includes(Ne.key)?" on":""}`,title:y("pin"),onClick:Ke=>{Ke.stopPropagation(),A(Ne.key)},children:D.includes(Ne.key)?"★":"☆"}),(V.capabilities||[]).includes(ke.active?"down":"up")&&h.jsx("button",{className:`nc-power${ke.active?" on":""}${ke.degraded?" warn":""}`,onClick:Ke=>{Ke.stopPropagation(),c&&c({...ke,route:V.route,availableEngines:V.engines||[]})},title:ke.active?y("power-off"):y("power-on"),children:h.jsx(Ze,{name:"power",size:14})})]},Ne.key)})():(()=>{const ke=Ne.value;return h.jsxs("div",{"data-roster-key":Ne.key,"data-position":z,className:`nc-side-card${R.has(ke.key)?" active":""}`,draggable:!0,onDragStart:Ve=>Ve.dataTransfer.setData("text/nc-session",ke.key),onClick:()=>l&&l(ke.key),onDoubleClick:()=>o&&o({session:ke.name,node:ke.node}),children:[h.jsx(Ur,{position:z,itemKey:Ne.key,label:ke.name,canMove:F,onMove:(Ve,Qe)=>Z(z,Ve,Qe,ye),onStep:Ve=>W(z,Ne.key,Ve,ye)}),h.jsx("span",{className:ke.attached?"nc-dot on":"nc-dot"}),h.jsxs("span",{className:"nc-card-main",children:[h.jsx("b",{children:ke.name}),h.jsx("small",{children:ke.preview?ke.preview:ke.cmd?ke.cmd:y("windows").replace("{n}",String(ke.windows||0))})]}),ke.activity?h.jsx("span",{className:"nc-rel",children:Gr(ke.activity)}):null,h.jsx("button",{className:`nc-pin${D.includes(Ne.key)?" on":""}`,title:y("pin"),onClick:Ve=>{Ve.stopPropagation(),A(Ne.key)},children:D.includes(Ne.key)?"★":"☆"}),h.jsx("button",{className:`nc-technical${ke.technical?" on":""}`,title:ke.technical?y("mark-normal"):y("mark-technical"),"aria-label":`${ke.technical?y("mark-normal"):y("mark-technical")} ${ke.name}`,onClick:Ve=>{Ve.stopPropagation(),m&&m(ke.name,!ke.technical,V.route||[])},children:"T"}),h.jsx("button",{className:"nc-menu",title:y("terminate"),onClick:Ve=>{Ve.stopPropagation(),window.confirm(y("terminate-confirm").replace("{name}",ke.name))&&p&&p(ke.name,V.route)},children:"⋯"})]},Ne.key)})()),xe.length===0&&h.jsx("div",{className:"nc-empty",children:y("no-sessions-short")})]})]},`nodo-${(V.route||[V.name]).join("/")}`)})]}),h.jsx("div",{className:"nc-side-lang",children:kv.map((V,z)=>h.jsxs("span",{children:[z>0&&" · ",h.jsx("button",{className:`nc-lang-btn${k===V?" on":""}`,onClick:()=>N(V),title:V,children:V.toUpperCase()})]},V))}),h.jsx("div",{className:"nc-side-resize",onPointerDown:oe,title:""})]})}function EC({label:e,count:t,state:n,onToggle:s,onFilter:o}){return h.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),s())},children:[h.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),h.jsx("span",{className:"nc-dot on"}),h.jsx("b",{children:e}),h.jsxs("small",{children:[" · ",y("node-sessions").replace("{n}",String(t))]}),h.jsxs("select",{className:"nc-node-filter",value:n.filter,title:y(`view-${n.filter}`),onClick:l=>l.stopPropagation(),onChange:l=>o(l.target.value),children:[h.jsx("option",{value:"all",children:y("view-all")}),h.jsx("option",{value:"pinned",children:y("view-pinned")}),h.jsx("option",{value:"active",children:y("view-active")}),h.jsx("option",{value:"off",children:y("view-off")}),h.jsx("option",{value:"technical",children:y("view-technical")})]})]})}const Gh=9,Ya=.2,NC=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,C_=/^[a-f0-9]{16,64}$/,wh=e=>NC.test(e)&&new Set(e.split("/")).size===e.split("/").length;function Hn(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const n=e.slice(0,t),s=e.slice(t+1);return!wh(n)||!s?null:{session:s,node:n}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&C_.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"&&wh(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function vi(e){const t=Hn(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const k_=9,x_=24,lo=11,RC=e=>{const t=Number(e);return t>=k_&&t<=x_?t:lo};function Vr(){return{columns:[]}}function Qi(e){return e.columns.flatMap(t=>t.tiles.map(n=>vi(n)))}function PC(e){const t=[],n=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(vi(o.tiles[s]));return t}const ts=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function Qh(e,t,n,s){const o=Hn(t);if(!o||Qi(e).includes(vi(o))||Qi(e).length>=Gh)return e;const l=ts(e),c={session:o.session,height:1,fontSize:lo,...s||{}};if(o.node&&(c.node=o.node),o.ownerId&&(c.ownerId=o.ownerId),n==="end")return l.columns.push({width:1,tiles:[c]}),l;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&l.columns[n.col])return l.columns[n.col].tiles.splice(n.row,0,c),l;if(n&&typeof n.col=="number"){const d=Math.max(0,Math.min(l.columns.length,n.col));return l.columns.splice(d,0,{width:1,tiles:[c]}),l}return l.columns.push({width:1,tiles:[c]}),l}function E_(e,t){const n=vi(t);if(!n||Qi(e).includes(n)||Qi(e).length>=Gh)return e;const s=Qi(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let S=0;for(let b=1;b<e.columns.length;b+=1)e.columns[b].tiles.length<e.columns[S].tiles.length&&(S=b);return Qh(e,t,{col:S,row:e.columns[S].tiles.length})}const l=[...PC(e),n],c=new Map(e.columns.flatMap(S=>S.tiles.map(b=>[vi(b),b]))),d=Hn(t),p=e.columns.length?e.columns.reduce((S,b)=>S+(Number(b.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(S,b)=>{var _;return{width:((_=e.columns[b])==null?void 0:_.width)||p,tiles:[]}});return l.forEach((S,b)=>{const _=Hn(S);if(!_)return;const v=c.get(S)||(S===n?d:{})||{},w={session:_.session,height:v.height||1,fontSize:v.fontSize||lo};_.node&&(w.node=_.node),v.ownerId&&(w.ownerId=v.ownerId),v.unavailable===!0&&(w.unavailable=!0),m[b%o].tiles.push(w)}),{columns:m.filter(S=>S.tiles.length)}}function Xa(e,t){const n=vi(t),s=ts(e);for(const o of s.columns)o.tiles=o.tiles.filter(l=>vi(l)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function DC(e,t,n){const s=vi(t);if(!Qi(e).includes(s))return e;const o=e.columns.flatMap(l=>l.tiles).find(l=>vi(l)===s);return Qh(Xa(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function LC(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=ts(e);for(const o of s.columns)for(const l of o.tiles){const c=t.get(vi(l));if(!c)continue;const d=Hn(c);d&&(l.session=d.session,d.node?l.node=d.node:delete l.node,d.ownerId&&(l.ownerId=d.ownerId),n=!0)}return n?cr(s):e}function MC(e,t,n){const s=ts(e);return s.columns[t]&&(s.columns[t].width=Math.max(Ya,Number(n)||1)),s}function jC(e,t,n,s){const o=ts(e),l=o.columns[t]&&o.columns[t].tiles[n];return l&&(l.height=Math.max(Ya,Number(s)||1)),o}function TC(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const l=ts(e),c=l.columns[t].tiles[n],d=Number(c.fontSize)||lo;return c.fontSize=Math.max(k_,Math.min(x_,d+(Number(s)||0))),l}function AC(e,t,n,s){const o=e.columns[t];if(!o||!o.tiles[n])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:n};case"bottom":return{col:t,row:n+1};default:return null}}function lg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function cr(e){if(!e||!Array.isArray(e.columns))return Vr();const t=e.columns.map(s=>({width:Math.max(Ya,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"&&wh(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&C_.test(o.ownerId)).map(o=>{const l={session:o.session,height:Math.max(Ya,Number(o.height)||1),fontSize:RC(o.fontSize)};return o.node!=null&&(l.node=o.node),o.ownerId!=null&&(l.ownerId=o.ownerId),o.unavailable===!0&&(l.unavailable=!0),l})})).filter(s=>s.tiles.length>0),n=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!n.has(vi(o))&&n.add(vi(o))&&n.size<=Gh);return{columns:t.filter(s=>s.tiles.length>0)}}function BC(e,t,n){return!e&&t?n+1:n}function IC({session:e,node:t,token:n,readonly:s=!1,focused:o,onFocus:l,onClose:c,onOpenSingle:d,alive:p=!0,available:m=!0,fontSize:S=lo,onZoom:b,decks:_=[],currentDeck:v,onSendToDeck:w}){const C=L.useRef(()=>{}),k=L.useRef(()=>!1),N=L.useRef(()=>{}),D=L.useRef(!1),[B,A]=L.useState(!1),[J,O]=L.useState(!1),[F,Z]=L.useState(!1),[W,G]=L.useState(null),[X,j]=L.useState(0),E=L.useRef(p),P=t?`${t}:${e}`:e,U=_.filter(R=>R.id!==v&&R.available!==!1);return L.useEffect(()=>{const R=E.current;!R&&p&&j(H=>BC(R,p,H)),E.current=p},[p]),h.jsxs("div",{className:`nc-tile${o?" focused":""}`,onMouseDown:()=>l&&l(P),children:[h.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:R=>{R.dataTransfer.setData("text/nc-session",P),R.dataTransfer.effectAllowed="move"},children:[h.jsxs("button",{className:"nc-tile-name",onClick:()=>l&&l(P),children:[h.jsx("span",{className:p?"nc-dot on":"nc-dot"}),h.jsx("b",{children:e}),t&&h.jsxs("small",{className:"nc-tile-node",children:["@",t]})]}),h.jsxs("span",{className:"nc-tile-actions",children:[b&&h.jsx("button",{onClick:()=>b(-1),title:y("zoom-out"),children:h.jsx(Ze,{name:"zoomOut",size:14})}),b&&h.jsx("button",{onClick:()=>b(1),title:y("zoom-in"),children:h.jsx(Ze,{name:"zoomIn",size:14})}),w&&U.length>0&&h.jsxs("select",{className:"nc-tile-deck",title:y("send-to-deck"),value:"",onMouseDown:R=>R.stopPropagation(),onChange:R=>{const H=R.target.value;H&&w(P,H),R.target.value=""},children:[h.jsx("option",{value:"",children:y("send-to-deck")}),U.map(R=>h.jsxs("option",{value:R.id,children:[R.ownerLabel," · ",R.name]},R.id))]}),h.jsx("button",{onClick:()=>O(R=>!R),title:"composer",children:"⌨"}),h.jsx("button",{onClick:()=>Z(R=>!R),title:"file",children:"📁"}),d&&h.jsx("button",{onClick:()=>d({session:e,node:t}),title:"vista singola",children:"↗"}),c&&h.jsx("button",{className:"nc-tile-close",onClick:()=>c(P),title:"chiudi",children:"✕"})]})]}),h.jsxs("div",{className:"nc-tile-body",children:[m?h.jsx(S_,{session:e,node:t,token:n,readonly:s,takeSize:!1,focused:o,sendRef:C,composerRef:k,actionRef:N,ctrlRef:D,setCtrlArmed:A,onFiles:G,fontSize:S},`${P}:${X}`):h.jsx("div",{className:"nc-tile-unavailable",children:y("deck-owner-unavailable")}),m&&F&&h.jsx("div",{className:"nc-tile-files",onMouseDown:R=>R.stopPropagation(),children:h.jsx(w_,{session:e,node:t,token:n,filesEvent:W,onClose:()=>Z(!1)})})]}),m&&J&&h.jsx("div",{className:"nc-tile-composer",onMouseDown:R=>R.stopPropagation(),children:h.jsx(b_,{submitText:R=>k.current(R),token:n,session:e,node:t})})]})}const cg=.2,ug=.28,N_=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),lu=e=>N_(e,"text/nc-session"),hg=e=>{var t;return N_(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function OC(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<ug?"left":s>1-ug?"right":o<.5?"top":"bottom"}function zC({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:l,onFocus:c,onOpenSingle:d,decks:p=[],currentDeck:m,onSendToDeck:S}){yi();const[b,_]=L.useState(null),v=L.useRef(null),w=L.useRef([]),C=L.useRef(null);function k(W,G){const X=()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",X),window.removeEventListener("pointercancel",X),window.removeEventListener("blur",X),C.current=null};window.addEventListener("pointermove",W),window.addEventListener("pointerup",X),window.addEventListener("pointercancel",X),window.addEventListener("blur",X),C.current=X}L.useEffect(()=>()=>{C.current&&C.current()},[]),L.useEffect(()=>{const W=()=>_(null);return window.addEventListener("dragend",W),window.addEventListener("drop",W),()=>{window.removeEventListener("dragend",W),window.removeEventListener("drop",W)}},[]);const N=e.columns.length,D=W=>b&&b.col===W&&b.row===void 0,B=!!b&&b.col===N,A=(W,G)=>b&&b.col===W&&b.row===G&&b.quadrant?` drop-${b.quadrant}`:"";function J(W){if(W.preventDefault(),hg(W.dataTransfer)){_(null);return}const G=W.dataTransfer.getData("text/nc-session"),X=b;if(_(null),!G||!X)return;let j;if(X.quadrant){if(j=AC(e,X.col,X.row,X.quadrant),!j)return}else j={col:X.col};t(Qi(e).includes(G)?DC(e,G,j):Qh(e,G,j))}function O(W,G){W.preventDefault(),W.stopPropagation();const X=W.clientX,j=e.columns[G].width,E=v.current&&v.current.clientWidth||1,P=e.columns[G+1];k(R=>{let H=Math.max(cg,j+(R.clientX-X)/E);if(P){const I=lg(H/(H+P.width));H=I/(1-I)*P.width}t(MC(e,G,H))})}function F(W,G,X){W.preventDefault(),W.stopPropagation();const j=W.clientY,E=e.columns[G].tiles[X].height,P=w.current[G],U=P&&P.clientHeight||1,R=e.columns[G].tiles[X+1];k(I=>{let se=Math.max(cg,E+(I.clientY-j)/U);if(R){const q=lg(se/(se+R.height));se=q/(1-q)*R.height}t(jC(e,G,X,se))})}function Z(W){t(Xa(e,W))}return h.jsxs("div",{className:"nc-grid",ref:v,onDragOver:W=>{if(hg(W.dataTransfer)){W.preventDefault(),_(null);return}lu(W.dataTransfer)&&(W.preventDefault(),b&&b.col===N||_({col:N}))},onDrop:J,onDragLeave:W=>{const G=W.relatedTarget;(!G||!(v.current&&v.current.contains(G)))&&_(null)},children:[e.columns.flatMap((W,G)=>{const X=[];return X.push(h.jsx("div",{className:`nc-col${D(G)?" drop-newcol":""}`,ref:j=>{w.current[G]=j},style:{flexGrow:W.width,flexBasis:0},onDragOver:j=>{lu(j.dataTransfer)&&(j.preventDefault(),j.stopPropagation(),b&&b.col===G&&b.row===void 0||_({col:G}))},children:W.tiles.flatMap((j,E)=>{const P=[],U=vi(j);return P.push(h.jsx("div",{className:`nc-tile-slot${A(G,E)}`,style:{flexGrow:j.height,flexBasis:0},onDragOver:R=>{if(!lu(R.dataTransfer))return;R.preventDefault(),R.stopPropagation();const H=OC(R.clientX,R.clientY,R.currentTarget.getBoundingClientRect());b&&b.col===G&&b.row===E&&b.quadrant===H||_({col:G,row:E,quadrant:H})},children:h.jsx(IC,{session:j.session,node:j.node,token:n,readonly:s,focused:l===U,onFocus:c,onClose:Z,onOpenSingle:d,available:j.unavailable!==!0,alive:j.unavailable!==!0&&(!o||o.has(U)),fontSize:j.fontSize,onZoom:R=>t(TC(e,G,E,R)),decks:p,currentDeck:m,onSendToDeck:S})},U)),E<W.tiles.length-1&&P.push(h.jsx("div",{className:"nc-divider-h",onPointerDown:R=>F(R,G,E)},`h${E}`)),P})},`c${G}`)),G<N-1&&X.push(h.jsx("div",{className:"nc-divider-v",onPointerDown:j=>O(j,G)},`v${G}`)),X}),B&&h.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),N===0&&h.jsx("div",{className:"nc-grid-empty",children:y("grid-empty")})]})}const un="local",Li=/^[a-f0-9]{16,64}$/;function Yr(e,t){return`${e&&Li.test(e)?e:un}:${t}`}function Jh(e){const t=String(e||""),n=t.indexOf(":");if(n<1)return null;const s=t.slice(0,n),o=t.slice(n+1);return s!==un&&!Li.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===un?null:s,name:o}}function tl(e){return Array.isArray(e)&&e.length?e.join("/"):""}function Zh(e){return{columns:cr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function FC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Li.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(tl(n.route),n.instanceId);return t}function HC(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&Li.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function bh(e,t,n=[]){const s=Zh(e),o=FC(n);for(const l of s.columns)for(const c of l.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 Ch(e,t,n=[]){const s=Zh(e),o=new Map;for(const l of n)l&&Li.test(String(l.instanceId||""))&&Array.isArray(l.route)&&o.set(l.instanceId,[...l.route]);for(const l of s.columns)for(const c of l.tiles)c.ownerId&&(c.ownerId===t?(delete c.node,delete c.unavailable):o.has(c.ownerId)?(c.node=tl(o.get(c.ownerId)),delete c.unavailable):c.unavailable=!0);return s}function dg(e,t,n=[]){const s=Zh(e),o=HC(n);for(const l of s.columns)for(const c of l.tiles)delete c.unavailable,c.ownerId&&(c.ownerId===t?delete c.node:o.has(c.ownerId)&&(c.node=tl(o.get(c.ownerId))));return s}function R_(e,t,n=[]){const s=Hn(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Li.test(String(t||""))?{ownerId:t}:{}};const o=n.find(l=>tl(l&&l.route)===s.node);return{...s,...o&&Li.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const $C=/^[a-z0-9-]{1,32}$/,_i="main",P_="nc_decks",D_="nc_deck_order_v1",L_=24;function fg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Jr(e){return typeof e=="string"&&$C.test(e)}function WC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return Jr(n)?n:_i}return _i}function UC(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Yr(null,_i),ownerId:null,name:_i}}if(Li.test(s)&&Jr(o))return{id:Yr(s,o),ownerId:s,name:o}}const n=WC(e);return{id:Yr(null,n),ownerId:null,name:n}}function cu(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:Jh(e)||{ownerId:null,name:e},s=Jr(n.name)?n.name:_i,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===_i?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function M_(e){return e===_i?"nc_grid_v1":`nc_grid_v1__${e}`}function j_(e){const t=[_i];if(Array.isArray(e)){for(const n of e)if(Jr(n)&&n!==_i&&!t.includes(n)&&t.push(n),t.length>=L_)break}return t}function is(){return typeof localStorage<"u"?localStorage:null}function KC(){const e=is();if(!e)return[_i];try{return j_(JSON.parse(e.getItem(P_)||"null"))}catch{return[_i]}}function qC(e){const t=is();if(t)try{t.setItem(P_,JSON.stringify(j_(e)))}catch{}}function co(e){return e==="local"||Li.test(String(e||""))}function il(e,t){const n=Jh(e);return!!n&&(n.ownerId||"local")===t}function Ji(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e).slice(0,64)){if(!co(n)||!Array.isArray(s))continue;const o=[...new Set(s.filter(l=>typeof l=="string"&&l.length<=100&&il(l,n)))].slice(0,L_);o.length&&(t[n]=o)}return t}function Ra(e=is()){if(!e)return{};try{return Ji(JSON.parse(e.getItem(D_)||"null"))}catch{return{}}}function uu(e,t=is()){const n=Ji(e);if(t)try{t.setItem(D_,JSON.stringify(n))}catch{}return n}function nl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function VC(e,t,n,s,o=[]){if(!co(t)||n===s)return Ji(e);const l=[...new Set(o.filter(b=>il(b,t)))];if(!l.includes(n)||!l.includes(s))return Ji(e);const c=nl(e,t).filter(b=>l.includes(b)),d=[...c,...l.filter(b=>!c.includes(b))],p=d.indexOf(n),m=d.indexOf(s);d.splice(p,1);const S=d.indexOf(s);return d.splice(p<m?S+1:S,0,n),Ji({...e,[t]:d})}function YC(e,t,n,s){if(!co(t)||!il(s,t))return Ji(e);const o=nl(e,t);return o.includes(n)?Ji({...e,[t]:o.map(l=>l===n?s:l)}):Ji(e)}function XC(e,t,n){return co(t)?Ji({...e,[t]:nl(e,t).filter(s=>s!==n)}):Ji(e)}function pg(e,t={}){const n=new Map;for(const o of Array.isArray(e)?e:[]){const l=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!co(l)||!il(o==null?void 0:o.id,l)||(n.has(l)||n.set(l,[]),n.get(l).push(o))}const s=[];for(const[,o]of n){const l=o[0].local?"local":o[0].ownerId,c=nl(t,l),d=new Map(c.map((p,m)=>[p,m]));o.sort((p,m)=>{const S=d.has(p.id)?d.get(p.id):Number.MAX_SAFE_INTEGER,b=d.has(m.id)?d.get(m.id):Number.MAX_SAFE_INTEGER;return S-b}),s.push(...o)}return s}function kh(e){const t=is();if(!t)return null;try{return JSON.parse(t.getItem(M_(e))||"null")}catch{return null}}function GC(e,t){const n=is();if(n)try{n.setItem(M_(e),JSON.stringify(t))}catch{}}const mg=52,gg=18;function QC({ownerKey:e,deckId:t,label:n,onMove:s,onStep:o}){const l=L.useRef(null),c=L.useRef(0),[d,p]=L.useState(!1),m=()=>{var C,k,N,D;const w=l.current;(k=(C=w==null?void 0:w.over)==null?void 0:C.classList)==null||k.remove("nc-deck-over"),(D=(N=w==null?void 0:w.source)==null?void 0:N.classList)==null||D.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},S=(w=!1)=>{const C=l.current;if(!C)return;const k=C.target;m(),l.current=null,p(!1);try{C.handle.releasePointerCapture(C.pointerId)}catch{}w&&k&&k!==t&&s(t,k)},b=(w,C)=>{var A,J,O,F,Z,W,G,X;const k=l.current;if(!k)return;k.x=w,k.y=C;const N=(J=(A=document.elementFromPoint(w,C))==null?void 0:A.closest)==null?void 0:J.call(A,"[data-deck-id][data-owner-key]"),D=(O=N==null?void 0:N.dataset)==null?void 0:O.deckId,B=((F=N==null?void 0:N.dataset)==null?void 0:F.ownerKey)===e&&D&&D!==t;k.over!==(B?N:null)&&((W=(Z=k.over)==null?void 0:Z.classList)==null||W.remove("nc-deck-over"),k.over=B?N:null,(X=(G=k.over)==null?void 0:G.classList)==null||X.add("nc-deck-over")),k.target=B?D:null},_=()=>{var k,N;const w=l.current;if(!w){c.current=0;return}const C=(N=(k=w.container)==null?void 0:k.getBoundingClientRect)==null?void 0:N.call(k);if(C){const D=w.x<C.left+mg?-gg:w.x>C.right-mg?gg:0;D&&(w.container.scrollLeft+=D,b(w.x,w.y))}c.current=requestAnimationFrame(_)};L.useEffect(()=>{const w=k=>{k.key==="Escape"&&l.current&&(k.preventDefault(),S(!1))},C=()=>S(!1);return window.addEventListener("keydown",w),window.addEventListener("blur",C),()=>{window.removeEventListener("keydown",w),window.removeEventListener("blur",C),m(),l.current=null}},[t,e]);const v=w=>{var N;if(w.pointerType==="mouse"&&w.button!==0)return;w.preventDefault(),w.stopPropagation(),w.currentTarget.focus({preventScroll:!0});const C=w.currentTarget.closest("[data-deck-id][data-owner-key]"),k=w.currentTarget.closest(".nc-deckbar");l.current={pointerId:w.pointerId,handle:w.currentTarget,source:C,container:k,target:null,over:null,x:w.clientX,y:w.clientY},(N=C==null?void 0:C.classList)==null||N.add("nc-deck-dragging");try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}p(!0),c.current=requestAnimationFrame(_)};return h.jsx("button",{type:"button",className:`nc-deck-handle${d?" active":""}`,"aria-label":`${y("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:y("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:v,onPointerMove:w=>{!l.current||w.pointerId!==l.current.pointerId||(w.preventDefault(),w.stopPropagation(),b(w.clientX,w.clientY))},onPointerUp:w=>{!l.current||w.pointerId!==l.current.pointerId||(w.preventDefault(),w.stopPropagation(),S(!0))},onPointerCancel:()=>S(!1),onLostPointerCapture:()=>{l.current&&S(!1)},children:"↔"})}function JC({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onReorder:l,onOpenWindow:c,onNavigate:d,saveState:p="idle",error:m="",sidebarVisible:S,onToggleSidebar:b}){yi();const[_,v]=L.useState(null),[w,C]=L.useState(""),[k,N]=L.useState(!1),[D,B]=L.useState(""),[A,J]=L.useState(""),O=fg(w),F=Jr(O),Z=[];for(const E of e){const P=E.local?"local":E.ownerId;let U=Z.find(R=>R.key===P);U||(U={key:P,label:E.ownerLabel||(E.local?"Local":P),local:!!E.local,decks:[]},Z.push(U)),U.decks.push(E)}const W=async()=>{if(F){N(!0),B("");try{n&&await n(O,_),C(""),v(null)}catch(E){B(String(E.message||E))}N(!1)}},G=E=>{J(""),c&&c(E.id)||J(E.id)},X=async E=>{if(!(E.id===t||!d||k||E.available===!1)){N(!0),B("");try{await d(E.id)}catch(P){B(String((P==null?void 0:P.message)||P))}N(!1)}},j=(E,P,U)=>{const R=E.decks.findIndex(I=>I.id===P.id),H=E.decks[R+U];R>=0&&H&&l&&!k&&l(P.id,H.id)};return h.jsxs("div",{className:"nc-deckbar",children:[b&&h.jsx("button",{className:"nc-deck-sidebar-toggle",title:y("toggle-sidebar"),onClick:b,children:S?"◀":"☰"}),h.jsx("span",{className:"nc-deckbar-label",children:y("decks")}),h.jsx("div",{className:"nc-deck-chips",children:Z.map(E=>h.jsxs("span",{className:"nc-deck-owner-group",children:[h.jsx("span",{className:"nc-deck-owner",children:E.local?"Local":E.label}),E.decks.map(P=>h.jsxs("span",{"data-deck-id":P.id,"data-owner-key":E.key,className:`nc-deck-chip${P.id===t?" current":""}${P.available===!1?" offline":""}`,children:[h.jsx(QC,{ownerKey:E.key,deckId:P.id,label:`${E.label} · ${P.name}`,onMove:(U,R)=>{l&&!k&&l(U,R)},onStep:U=>j(E,P,U)}),h.jsxs("button",{className:"nc-deck-open",title:P.available===!1?`${P.ownerLabel} offline`:P.id===t?y("deck-current"):`${P.ownerLabel} · ${P.name}`,disabled:k||P.available===!1,onClick:()=>X(P),children:[P.name,P.id===t?" •":""]}),h.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:y("detach-deck"),onClick:()=>G(P),children:"↗"}),P.name!==_i&&h.jsxs(h.Fragment,{children:[h.jsx("button",{className:"nc-deck-mini",disabled:P.available===!1,title:y("rename-deck"),onClick:()=>{const U=(typeof window<"u"?window.prompt(y("rename-deck"),P.name):"")||"",R=fg(U);Jr(R)&&R!==P.name&&s&&s(P.id,R).catch(H=>B(String(H.message||H)))},children:"✎"}),h.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:P.available===!1,title:y("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(y("delete-deck-confirm").replace("{name}",`${P.ownerLabel} · ${P.name}`)))&&o&&o(P.id).catch(U=>B(String(U.message||U)))},children:"✕"})]})]},P.id)),_===E.key?h.jsxs("span",{className:"nc-deck-add",children:[h.jsx("input",{autoFocus:!0,className:F||!w?"":"invalid",placeholder:y("deck-name"),value:w,onChange:P=>C(P.target.value),onKeyDown:P=>{P.key==="Enter"&&W(),P.key==="Escape"&&(C(""),v(null))}}),w&&F&&O!==w&&h.jsxs("span",{className:"nc-deck-slug",children:["→ ",O]}),h.jsx("button",{className:"nc-deck-ok",disabled:!F||k,onClick:W,children:y("create")}),h.jsx("button",{className:"nc-deck-cancel",onClick:()=>{C(""),v(null)},children:y("cancel")})]}):h.jsxs("button",{className:"nc-deck-newbtn",disabled:k||E.decks.every(P=>P.available===!1),title:`${y("new-deck")} · ${E.label}`,onClick:()=>{C(""),v(E.key)},children:["+ ",y("new")]})]},E.key))}),h.jsx("span",{className:`nc-deck-state ${p}`,title:y("deck-autosave"),children:y(p==="saving"?"saving":p==="saved"?"saved":"deck-autosave")}),(D||m)&&h.jsx("span",{className:"nc-deck-error",children:D||m}),A&&h.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(A),children:y("popup-blocked")})]})}var $r={},hu,vg;function ZC(){return vg||(vg=1,hu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),hu}var du={},Bn={},_g;function pr(){if(_g)return Bn;_g=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(n){let s=0;for(;n!==0;)s++,n>>>=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 fu={},yg;function ed(){return yg||(yg=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.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: "+n)}}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}}})(fu)),fu}var pu,Sg;function ek(){if(Sg)return pu;Sg=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let s=0;s<n;s++)this.putBit((t>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},pu=e,pu}var mu,wg;function tk(){if(wg)return mu;wg=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,n,s,o){const l=t*this.size+n;this.data[l]=s,o&&(this.reservedBit[l]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,s){this.data[t*this.size+n]^=s},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},mu=e,mu}var gu={},bg;function ik(){return bg||(bg=1,(function(e){const t=pr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,l=t(s),c=l===145?26:Math.ceil((l-13)/(2*o-2))*2,d=[l-7];for(let p=1;p<o-1;p++)d[p]=d[p-1]-c;return d.push(6),d.reverse()},e.getPositions=function(s){const o=[],l=e.getRowColCoords(s),c=l.length;for(let d=0;d<c;d++)for(let p=0;p<c;p++)d===0&&p===0||d===0&&p===c-1||d===c-1&&p===0||o.push([l[d],l[p]]);return o}})(gu)),gu}var vu={},Cg;function nk(){if(Cg)return vu;Cg=1;const e=pr().getSymbolSize,t=7;return vu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},vu}var _u={},kg;function rk(){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 l=o.size;let c=0,d=0,p=0,m=null,S=null;for(let b=0;b<l;b++){d=p=0,m=S=null;for(let _=0;_<l;_++){let v=o.get(b,_);v===m?d++:(d>=5&&(c+=t.N1+(d-5)),m=v,d=1),v=o.get(_,b),v===S?p++:(p>=5&&(c+=t.N1+(p-5)),S=v,p=1)}d>=5&&(c+=t.N1+(d-5)),p>=5&&(c+=t.N1+(p-5))}return c},e.getPenaltyN2=function(o){const l=o.size;let c=0;for(let d=0;d<l-1;d++)for(let p=0;p<l-1;p++){const m=o.get(d,p)+o.get(d,p+1)+o.get(d+1,p)+o.get(d+1,p+1);(m===4||m===0)&&c++}return c*t.N2},e.getPenaltyN3=function(o){const l=o.size;let c=0,d=0,p=0;for(let m=0;m<l;m++){d=p=0;for(let S=0;S<l;S++)d=d<<1&2047|o.get(m,S),S>=10&&(d===1488||d===93)&&c++,p=p<<1&2047|o.get(S,m),S>=10&&(p===1488||p===93)&&c++}return c*t.N3},e.getPenaltyN4=function(o){let l=0;const c=o.data.length;for(let p=0;p<c;p++)l+=o.data[p];return Math.abs(Math.ceil(l*100/c/5)-10)*t.N4};function n(s,o,l){switch(s){case e.Patterns.PATTERN000:return(o+l)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return l%3===0;case e.Patterns.PATTERN011:return(o+l)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(l/3))%2===0;case e.Patterns.PATTERN101:return o*l%2+o*l%3===0;case e.Patterns.PATTERN110:return(o*l%2+o*l%3)%2===0;case e.Patterns.PATTERN111:return(o*l%3+(o+l)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,l){const c=l.size;for(let d=0;d<c;d++)for(let p=0;p<c;p++)l.isReserved(p,d)||l.xor(p,d,n(o,p,d))},e.getBestMask=function(o,l){const c=Object.keys(e.Patterns).length;let d=0,p=1/0;for(let m=0;m<c;m++){l(m),e.applyMask(m,o);const S=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),S<p&&(p=S,d=m)}return d}})(_u)),_u}var Pa={},xg;function T_(){if(xg)return Pa;xg=1;const e=ed(),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],n=[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 Pa.getBlocksCount=function(o,l){switch(l){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}},Pa.getTotalCodewordsCount=function(o,l){switch(l){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},Pa}var yu={},qs={},Eg;function sk(){if(Eg)return qs;Eg=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]})(),qs.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},qs.exp=function(s){return e[s]},qs.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},qs}var Ng;function ok(){return Ng||(Ng=1,(function(e){const t=sk();e.mul=function(s,o){const l=new Uint8Array(s.length+o.length-1);for(let c=0;c<s.length;c++)for(let d=0;d<o.length;d++)l[c+d]^=t.mul(s[c],o[d]);return l},e.mod=function(s,o){let l=new Uint8Array(s);for(;l.length-o.length>=0;){const c=l[0];for(let p=0;p<o.length;p++)l[p]^=t.mul(o[p],c);let d=0;for(;d<l.length&&l[d]===0;)d++;l=l.slice(d)}return l},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let l=0;l<s;l++)o=e.mul(o,new Uint8Array([1,t.exp(l)]));return o}})(yu)),yu}var Su,Rg;function ak(){if(Rg)return Su;Rg=1;const e=ok();function t(n){this.genPoly=void 0,this.degree=n,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 l=e.mod(o,this.genPoly),c=this.degree-l.length;if(c>0){const d=new Uint8Array(this.degree);return d.set(l,c),d}return l},Su=t,Su}var wu={},bu={},Cu={},Pg;function A_(){return Pg||(Pg=1,Cu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Cu}var Vi={},Dg;function B_(){if(Dg)return Vi;Dg=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
|
|
82
|
+
]))+`;Vi.KANJI=new RegExp(n,"g"),Vi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Vi.BYTE=new RegExp(s,"g"),Vi.NUMERIC=new RegExp(e,"g"),Vi.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),l=new RegExp("^"+e+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Vi.testKanji=function(p){return o.test(p)},Vi.testNumeric=function(p){return l.test(p)},Vi.testAlphanumeric=function(p){return c.test(p)},Vi}var Lg;function mr(){return Lg||(Lg=1,(function(e){const t=A_(),n=B_();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(l,c){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?l.ccBits[0]:c<27?l.ccBits[1]:l.ccBits[2]},e.getBestModeForData=function(l){return n.testNumeric(l)?e.NUMERIC:n.testAlphanumeric(l)?e.ALPHANUMERIC:n.testKanji(l)?e.KANJI:e.BYTE},e.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},e.isValid=function(l){return l&&l.bit&&l.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(l,c){if(e.isValid(l))return l;try{return s(l)}catch{return c}}})(bu)),bu}var Mg;function lk(){return Mg||(Mg=1,(function(e){const t=pr(),n=T_(),s=ed(),o=mr(),l=A_(),c=7973,d=t.getBCHDigit(c);function p(_,v,w){for(let C=1;C<=40;C++)if(v<=e.getCapacity(C,w,_))return C}function m(_,v){return o.getCharCountIndicator(_,v)+4}function S(_,v){let w=0;return _.forEach(function(C){const k=m(C.mode,v);w+=k+C.getBitsLength()}),w}function b(_,v){for(let w=1;w<=40;w++)if(S(_,w)<=e.getCapacity(w,v,o.MIXED))return w}e.from=function(v,w){return l.isValid(v)?parseInt(v,10):w},e.getCapacity=function(v,w,C){if(!l.isValid(v))throw new Error("Invalid QR Code version");typeof C>"u"&&(C=o.BYTE);const k=t.getSymbolTotalCodewords(v),N=n.getTotalCodewordsCount(v,w),D=(k-N)*8;if(C===o.MIXED)return D;const B=D-m(C,v);switch(C){case o.NUMERIC:return Math.floor(B/10*3);case o.ALPHANUMERIC:return Math.floor(B/11*2);case o.KANJI:return Math.floor(B/13);case o.BYTE:default:return Math.floor(B/8)}},e.getBestVersionForData=function(v,w){let C;const k=s.from(w,s.M);if(Array.isArray(v)){if(v.length>1)return b(v,k);if(v.length===0)return 1;C=v[0]}else C=v;return p(C.mode,C.getLength(),k)},e.getEncodedBits=function(v){if(!l.isValid(v)||v<7)throw new Error("Invalid QR Code version");let w=v<<12;for(;t.getBCHDigit(w)-d>=0;)w^=c<<t.getBCHDigit(w)-d;return v<<12|w}})(wu)),wu}var ku={},jg;function ck(){if(jg)return ku;jg=1;const e=pr(),t=1335,n=21522,s=e.getBCHDigit(t);return ku.getEncodedBits=function(l,c){const d=l.bit<<3|c;let p=d<<10;for(;e.getBCHDigit(p)-s>=0;)p^=t<<e.getBCHDigit(p)-s;return(d<<10|p)^n},ku}var xu={},Eu,Tg;function uk(){if(Tg)return Eu;Tg=1;const e=mr();function t(n){this.mode=e.NUMERIC,this.data=n.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,l,c;for(o=0;o+3<=this.data.length;o+=3)l=this.data.substr(o,3),c=parseInt(l,10),s.put(c,10);const d=this.data.length-o;d>0&&(l=this.data.substr(o),c=parseInt(l,10),s.put(c,d*3+1))},Eu=t,Eu}var Nu,Ag;function hk(){if(Ag)return Nu;Ag=1;const e=mr(),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 n(s){this.mode=e.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let l;for(l=0;l+2<=this.data.length;l+=2){let c=t.indexOf(this.data[l])*45;c+=t.indexOf(this.data[l+1]),o.put(c,11)}this.data.length%2&&o.put(t.indexOf(this.data[l]),6)},Nu=n,Nu}var Ru,Bg;function dk(){if(Bg)return Ru;Bg=1;const e=mr();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}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(n){for(let s=0,o=this.data.length;s<o;s++)n.put(this.data[s],8)},Ru=t,Ru}var Pu,Ig;function fk(){if(Ig)return Pu;Ig=1;const e=mr(),t=pr();function n(s){this.mode=e.KANJI,this.data=s}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let l=t.toSJIS(this.data[o]);if(l>=33088&&l<=40956)l-=33088;else if(l>=57408&&l<=60351)l-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
83
|
+
Make sure your charset is UTF-8`);l=(l>>>8&255)*192+(l&255),s.put(l,13)}},Pu=n,Pu}var Du={exports:{}},Og;function pk(){return Og||(Og=1,(function(e){var t={single_source_shortest_paths:function(n,s,o){var l={},c={};c[s]=0;var d=t.PriorityQueue.make();d.push(s,0);for(var p,m,S,b,_,v,w,C,k;!d.empty();){p=d.pop(),m=p.value,b=p.cost,_=n[m]||{};for(S in _)_.hasOwnProperty(S)&&(v=_[S],w=b+v,C=c[S],k=typeof c[S]>"u",(k||C>w)&&(c[S]=w,d.push(S,w),l[S]=m))}if(typeof o<"u"&&typeof c[o]>"u"){var N=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(N)}return l},extract_shortest_path_from_predecessor_list:function(n,s){for(var o=[],l=s;l;)o.push(l),n[l],l=n[l];return o.reverse(),o},find_path:function(n,s,o){var l=t.single_source_shortest_paths(n,s,o);return t.extract_shortest_path_from_predecessor_list(l,o)},PriorityQueue:{make:function(n){var s=t.PriorityQueue,o={},l;n=n||{};for(l in s)s.hasOwnProperty(l)&&(o[l]=s[l]);return o.queue=[],o.sorter=n.sorter||s.default_sorter,o},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var o={value:n,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})(Du)),Du.exports}var zg;function mk(){return zg||(zg=1,(function(e){const t=mr(),n=uk(),s=hk(),o=dk(),l=fk(),c=B_(),d=pr(),p=pk();function m(N){return unescape(encodeURIComponent(N)).length}function S(N,D,B){const A=[];let J;for(;(J=N.exec(B))!==null;)A.push({data:J[0],index:J.index,mode:D,length:J[0].length});return A}function b(N){const D=S(c.NUMERIC,t.NUMERIC,N),B=S(c.ALPHANUMERIC,t.ALPHANUMERIC,N);let A,J;return d.isKanjiModeEnabled()?(A=S(c.BYTE,t.BYTE,N),J=S(c.KANJI,t.KANJI,N)):(A=S(c.BYTE_KANJI,t.BYTE,N),J=[]),D.concat(B,A,J).sort(function(F,Z){return F.index-Z.index}).map(function(F){return{data:F.data,mode:F.mode,length:F.length}})}function _(N,D){switch(D){case t.NUMERIC:return n.getBitsLength(N);case t.ALPHANUMERIC:return s.getBitsLength(N);case t.KANJI:return l.getBitsLength(N);case t.BYTE:return o.getBitsLength(N)}}function v(N){return N.reduce(function(D,B){const A=D.length-1>=0?D[D.length-1]:null;return A&&A.mode===B.mode?(D[D.length-1].data+=B.data,D):(D.push(B),D)},[])}function w(N){const D=[];for(let B=0;B<N.length;B++){const A=N[B];switch(A.mode){case t.NUMERIC:D.push([A,{data:A.data,mode:t.ALPHANUMERIC,length:A.length},{data:A.data,mode:t.BYTE,length:A.length}]);break;case t.ALPHANUMERIC:D.push([A,{data:A.data,mode:t.BYTE,length:A.length}]);break;case t.KANJI:D.push([A,{data:A.data,mode:t.BYTE,length:m(A.data)}]);break;case t.BYTE:D.push([{data:A.data,mode:t.BYTE,length:m(A.data)}])}}return D}function C(N,D){const B={},A={start:{}};let J=["start"];for(let O=0;O<N.length;O++){const F=N[O],Z=[];for(let W=0;W<F.length;W++){const G=F[W],X=""+O+W;Z.push(X),B[X]={node:G,lastCount:0},A[X]={};for(let j=0;j<J.length;j++){const E=J[j];B[E]&&B[E].node.mode===G.mode?(A[E][X]=_(B[E].lastCount+G.length,G.mode)-_(B[E].lastCount,G.mode),B[E].lastCount+=G.length):(B[E]&&(B[E].lastCount=G.length),A[E][X]=_(G.length,G.mode)+4+t.getCharCountIndicator(G.mode,D))}}J=Z}for(let O=0;O<J.length;O++)A[J[O]].end=0;return{map:A,table:B}}function k(N,D){let B;const A=t.getBestModeForData(N);if(B=t.from(D,A),B!==t.BYTE&&B.bit<A.bit)throw new Error('"'+N+'" cannot be encoded with mode '+t.toString(B)+`.
|
|
84
|
+
Suggested mode is: `+t.toString(A));switch(B===t.KANJI&&!d.isKanjiModeEnabled()&&(B=t.BYTE),B){case t.NUMERIC:return new n(N);case t.ALPHANUMERIC:return new s(N);case t.KANJI:return new l(N);case t.BYTE:return new o(N)}}e.fromArray=function(D){return D.reduce(function(B,A){return typeof A=="string"?B.push(k(A,null)):A.data&&B.push(k(A.data,A.mode)),B},[])},e.fromString=function(D,B){const A=b(D,d.isKanjiModeEnabled()),J=w(A),O=C(J,B),F=p.find_path(O.map,"start","end"),Z=[];for(let W=1;W<F.length-1;W++)Z.push(O.table[F[W]].node);return e.fromArray(v(Z))},e.rawSplit=function(D){return e.fromArray(b(D,d.isKanjiModeEnabled()))}})(xu)),xu}var Fg;function gk(){if(Fg)return du;Fg=1;const e=pr(),t=ed(),n=ek(),s=tk(),o=ik(),l=nk(),c=rk(),d=T_(),p=ak(),m=lk(),S=ck(),b=mr(),_=mk();function v(O,F){const Z=O.size,W=l.getPositions(F);for(let G=0;G<W.length;G++){const X=W[G][0],j=W[G][1];for(let E=-1;E<=7;E++)if(!(X+E<=-1||Z<=X+E))for(let P=-1;P<=7;P++)j+P<=-1||Z<=j+P||(E>=0&&E<=6&&(P===0||P===6)||P>=0&&P<=6&&(E===0||E===6)||E>=2&&E<=4&&P>=2&&P<=4?O.set(X+E,j+P,!0,!0):O.set(X+E,j+P,!1,!0))}}function w(O){const F=O.size;for(let Z=8;Z<F-8;Z++){const W=Z%2===0;O.set(Z,6,W,!0),O.set(6,Z,W,!0)}}function C(O,F){const Z=o.getPositions(F);for(let W=0;W<Z.length;W++){const G=Z[W][0],X=Z[W][1];for(let j=-2;j<=2;j++)for(let E=-2;E<=2;E++)j===-2||j===2||E===-2||E===2||j===0&&E===0?O.set(G+j,X+E,!0,!0):O.set(G+j,X+E,!1,!0)}}function k(O,F){const Z=O.size,W=m.getEncodedBits(F);let G,X,j;for(let E=0;E<18;E++)G=Math.floor(E/3),X=E%3+Z-8-3,j=(W>>E&1)===1,O.set(G,X,j,!0),O.set(X,G,j,!0)}function N(O,F,Z){const W=O.size,G=S.getEncodedBits(F,Z);let X,j;for(X=0;X<15;X++)j=(G>>X&1)===1,X<6?O.set(X,8,j,!0):X<8?O.set(X+1,8,j,!0):O.set(W-15+X,8,j,!0),X<8?O.set(8,W-X-1,j,!0):X<9?O.set(8,15-X-1+1,j,!0):O.set(8,15-X-1,j,!0);O.set(W-8,8,1,!0)}function D(O,F){const Z=O.size;let W=-1,G=Z-1,X=7,j=0;for(let E=Z-1;E>0;E-=2)for(E===6&&E--;;){for(let P=0;P<2;P++)if(!O.isReserved(G,E-P)){let U=!1;j<F.length&&(U=(F[j]>>>X&1)===1),O.set(G,E-P,U),X--,X===-1&&(j++,X=7)}if(G+=W,G<0||Z<=G){G-=W,W=-W;break}}}function B(O,F,Z){const W=new n;Z.forEach(function(P){W.put(P.mode.bit,4),W.put(P.getLength(),b.getCharCountIndicator(P.mode,O)),P.write(W)});const G=e.getSymbolTotalCodewords(O),X=d.getTotalCodewordsCount(O,F),j=(G-X)*8;for(W.getLengthInBits()+4<=j&&W.put(0,4);W.getLengthInBits()%8!==0;)W.putBit(0);const E=(j-W.getLengthInBits())/8;for(let P=0;P<E;P++)W.put(P%2?17:236,8);return A(W,O,F)}function A(O,F,Z){const W=e.getSymbolTotalCodewords(F),G=d.getTotalCodewordsCount(F,Z),X=W-G,j=d.getBlocksCount(F,Z),E=W%j,P=j-E,U=Math.floor(W/j),R=Math.floor(X/j),H=R+1,I=U-R,se=new p(I);let q=0;const M=new Array(j),K=new Array(j);let Q=0;const re=new Uint8Array(O.buffer);for(let pe=0;pe<j;pe++){const ye=pe<P?R:H;M[pe]=re.slice(q,q+ye),K[pe]=se.encode(M[pe]),q+=ye,Q=Math.max(Q,ye)}const oe=new Uint8Array(W);let le=0,V,z;for(V=0;V<Q;V++)for(z=0;z<j;z++)V<M[z].length&&(oe[le++]=M[z][V]);for(V=0;V<I;V++)for(z=0;z<j;z++)oe[le++]=K[z][V];return oe}function J(O,F,Z,W){let G;if(Array.isArray(O))G=_.fromArray(O);else if(typeof O=="string"){let U=F;if(!U){const R=_.rawSplit(O);U=m.getBestVersionForData(R,Z)}G=_.fromString(O,U||40)}else throw new Error("Invalid data");const X=m.getBestVersionForData(G,Z);if(!X)throw new Error("The amount of data is too big to be stored in a QR Code");if(!F)F=X;else if(F<X)throw new Error(`
|
|
85
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
+
Minimum version required to store current data is: `+X+`.
|
|
87
|
+
`);const j=B(F,Z,G),E=e.getSymbolSize(F),P=new s(E);return v(P,F),w(P),C(P,F),N(P,Z,0),F>=7&&k(P,F),D(P,j),isNaN(W)&&(W=c.getBestMask(P,N.bind(null,P,Z))),c.applyMask(W,P),N(P,Z,W),{modules:P,version:F,errorCorrectionLevel:Z,maskPattern:W,segments:G}}return du.create=function(F,Z){if(typeof F>"u"||F==="")throw new Error("No input text");let W=t.M,G,X;return typeof Z<"u"&&(W=t.from(Z.errorCorrectionLevel,t.M),G=m.from(Z.version),X=c.from(Z.maskPattern),Z.toSJISFunc&&e.setToSJISFunction(Z.toSJISFunc)),J(F,G,W,X)},du}var Lu={},Mu={},Hg;function I_(){return Hg||(Hg=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(l){return[l,l]}))),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,l=s.width&&s.width>=21?s.width:void 0,c=s.scale||4;return{width:l,scale:l?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 l=e.getScale(s,o);return Math.floor((s+o.margin*2)*l)},e.qrToImageData=function(s,o,l){const c=o.modules.size,d=o.modules.data,p=e.getScale(c,l),m=Math.floor((c+l.margin*2)*p),S=l.margin*p,b=[l.color.light,l.color.dark];for(let _=0;_<m;_++)for(let v=0;v<m;v++){let w=(_*m+v)*4,C=l.color.light;if(_>=S&&v>=S&&_<m-S&&v<m-S){const k=Math.floor((_-S)/p),N=Math.floor((v-S)/p);C=b[d[k*c+N]?1:0]}s[w++]=C.r,s[w++]=C.g,s[w++]=C.b,s[w]=C.a}}})(Mu)),Mu}var $g;function vk(){return $g||($g=1,(function(e){const t=I_();function n(o,l,c){o.clearRect(0,0,l.width,l.height),l.style||(l.style={}),l.height=c,l.width=c,l.style.height=c+"px",l.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(l,c,d){let p=d,m=c;typeof p>"u"&&(!c||!c.getContext)&&(p=c,c=void 0),c||(m=s()),p=t.getOptions(p);const S=t.getImageWidth(l.modules.size,p),b=m.getContext("2d"),_=b.createImageData(S,S);return t.qrToImageData(_.data,l,p),n(b,m,S),b.putImageData(_,0,0),m},e.renderToDataURL=function(l,c,d){let p=d;typeof p>"u"&&(!c||!c.getContext)&&(p=c,c=void 0),p||(p={});const m=e.render(l,c,p),S=p.type||"image/png",b=p.rendererOpts||{};return m.toDataURL(S,b.quality)}})(Lu)),Lu}var ju={},Wg;function _k(){if(Wg)return ju;Wg=1;const e=I_();function t(o,l){const c=o.a/255,d=l+'="'+o.hex+'"';return c<1?d+" "+l+'-opacity="'+c.toFixed(2).slice(1)+'"':d}function n(o,l,c){let d=o+l;return typeof c<"u"&&(d+=" "+c),d}function s(o,l,c){let d="",p=0,m=!1,S=0;for(let b=0;b<o.length;b++){const _=Math.floor(b%l),v=Math.floor(b/l);!_&&!m&&(m=!0),o[b]?(S++,b>0&&_>0&&o[b-1]||(d+=m?n("M",_+c,.5+v+c):n("m",p,0),p=0,m=!1),_+1<l&&o[b+1]||(d+=n("h",S),S=0)):p++}return d}return ju.render=function(l,c,d){const p=e.getOptions(c),m=l.modules.size,S=l.modules.data,b=m+p.margin*2,_=p.color.light.a?"<path "+t(p.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",v="<path "+t(p.color.dark,"stroke")+' d="'+s(S,m,p.margin)+'"/>',w='viewBox="0 0 '+b+" "+b+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+w+' shape-rendering="crispEdges">'+_+v+`</svg>
|
|
88
|
+
`;return typeof d=="function"&&d(null,k),k},ju}var Ug;function yk(){if(Ug)return $r;Ug=1;const e=ZC(),t=gk(),n=vk(),s=_k();function o(l,c,d,p,m){const S=[].slice.call(arguments,1),b=S.length,_=typeof S[b-1]=="function";if(!_&&!e())throw new Error("Callback required as last argument");if(_){if(b<2)throw new Error("Too few arguments provided");b===2?(m=d,d=c,c=p=void 0):b===3&&(c.getContext&&typeof m>"u"?(m=p,p=void 0):(m=p,p=d,d=c,c=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(d=c,c=p=void 0):b===2&&!c.getContext&&(p=d,d=c,c=void 0),new Promise(function(v,w){try{const C=t.create(d,p);v(l(C,c,p))}catch(C){w(C)}})}try{const v=t.create(d,p);m(null,l(v,c,p))}catch(v){m(v)}}return $r.create=t.create,$r.toCanvas=o.bind(null,n.render),$r.toDataURL=o.bind(null,n.renderToDataURL),$r.toString=o.bind(null,function(l,c,d){return s.render(l,d)}),$r}var Sk=yk();const wk=Dh(Sk),O_=/^[a-z0-9-]{1,32}$/,bk=/^[A-Za-z0-9._-]{1,32}$/,Ck=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,kk=320;function xk(e){return typeof e=="string"&&O_.test(e)}const Ek=64;function xh(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=Ek&&!/[\x00-\x1f\x7f]/.test(t)}function Xr(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function z_(e){if(typeof e!="string"||!e||e.length>kk||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:bk.test(e.slice(0,t))&&Ck.test(e.slice(t+1))}function Kg(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function qg({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,l=typeof t=="string"?t.trim():t;if(!xk(o))return{ok:!1,error:"err-node-name"};if(!z_(l))return{ok:!1,error:"err-ssh"};const c=Kg(n);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const d=Kg(s);if(d===void 0)return{ok:!1,error:"err-node-port"};const p={name:o,ssh:l};return c!==null&&(p.sshPort=c),d!==null&&(p.remotePort=d),{ok:!0,value:p}}function Nk(e,t){if(!e||!t||t<e)return null;const n=Math.floor((t-e)/1e3);return n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Vg(e,t){const n=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?Nk(e.since,t):null}}const Rk=new Set(["v","instanceId","port","label","invite"]),Pk=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function Dk(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),o=Uint8Array.from(s,l=>l.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function Lk(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 n;try{n=JSON.parse(Dk(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?Rk:n.v===2?Pk:null;if(!s)return{ok:!1};for(const c of Object.keys(n))if(!s.has(c))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const o=Number(n.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const l={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:o};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!O_.test(n.name))return{ok:!1};l.name=n.name}if(n.ssh!==void 0){if(!z_(n.ssh))return{ok:!1};l.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const c=Number(n.sshPort);if(!Number.isInteger(c)||c<1||c>65535)return{ok:!1};l.sshPort=c}}return l}function Mk(e,t,n=new Set){if(!t||!t.ok)return e;const s={...e},o=(l,c)=>{c==null||c===""||n.has(l)||(s[l]=c)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Xr(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}function Yg(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function jk(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=Lk(t);if(!n||!n.ok)return{kind:"invalid"};const s=[];return n.ssh||s.push("ssh"),n.name||s.push("name"),s.length?{kind:"partial",decoded:n,missing:s}:{kind:"complete",decoded:n}}function Tk(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=Mk(e,t,n);return t.version===2&&t.name&&!n.has("name")&&!s&&(o.name=t.name),!n.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function Xg(e,t,n=new Set,s=!1){const o=String(t||"").trim(),l=jk(o);let c={...e,pairingUrl:o};return(l.kind==="complete"||l.kind==="partial")&&(c={...Tk(c,l.decoded,n,s),pairingUrl:o}),{classification:l,form:c}}function Ak(e,{deviceDefault:t=""}={}){const n={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&&(n.localLabel=s),n}function Bk(){const e=new Set;let t=!1;return{canAuto(n){return!t&&!e.has(String(n||""))},start(n){return t?!1:(t=!0,e.add(String(n||"")),!0)},finish(){t=!1},reset(n){e.delete(String(n||""))},isBusy(){return t}}}const Ik=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function Ok(e){const t=e&&e.data||{},n=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:n,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",retryable:typeof t.retryable=="boolean"?t.retryable:!n,message:s||String(e&&e.message||e)}}const zk="modulepreload",Fk=function(e){return"/"+e},Gg={},Hk=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let c=function(m){return Promise.all(m.map(S=>Promise.resolve(S).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));o=c(n.map(m=>{if(m=Fk(m),m in Gg)return;Gg[m]=!0;const S=m.endsWith(".css"),b=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${b}`))return;const _=document.createElement("link");if(_.rel=S?"stylesheet":zk,S||(_.as="script"),_.crossOrigin="",_.href=m,p&&_.setAttribute("nonce",p),document.head.appendChild(_),S)return new Promise((v,w)=>{_.addEventListener("load",v),_.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${m}`)))})}))}function l(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"&&l(d.reason);return t().catch(l)})};class ze{constructor(t,n,s,o,l){this._legacyCanvasSize=ze.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=n:(console.warn(s||o||l?"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=n),n=typeof s=="object"?s:{},this._onDecodeError=n.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||l||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.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,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.overlay||document.createElement("div"),l=this.$overlay.style,l.position="absolute",l.display="none",l.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&n.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)}n.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=ze.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 ze.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await n()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,l)=>({id:o.deviceId,label:o.label||(l===0?"Default Camera":`Camera ${l+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),ze._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"),ze._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(),ze._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:n}=await this._getCameraStream();!this._active||this._paused?ze._stopVideoStream(t):(this._setVideoMirror(n),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 n=()=>{this.$video.srcObject instanceof MediaStream&&(ze._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,s,o,l=!1,c=!1){let d,p=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(d=n.scanRegion,s=n.qrEngine,o=n.canvas,l=n.disallowCanvasResizing||!1,c=n.alsoTryWithoutScanRegion||!1,p=!0):console.warn(n||s||o||l||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."),n=!!s;try{let m,S;[s,m]=await Promise.all([s||ze.createQrEngine(),ze._loadImage(t)]),[o,S]=ze._drawToCanvas(m,d,o,l);let b;if(s instanceof Worker){let _=s;n||ze._postWorkerMessageSync(_,"inversionMode","both"),b=await new Promise((v,w)=>{let C,k,N,D=-1;k=A=>{A.data.id===D&&(_.removeEventListener("message",k),_.removeEventListener("error",N),clearTimeout(C),A.data.data!==null?v({data:A.data.data,cornerPoints:ze._convertPoints(A.data.cornerPoints,d)}):w(ze.NO_QR_CODE_FOUND))},N=A=>{_.removeEventListener("message",k),_.removeEventListener("error",N),clearTimeout(C),w("Scanner error: "+(A?A.message||A:"Unknown Error"))},_.addEventListener("message",k),_.addEventListener("error",N),C=setTimeout(()=>N("timeout"),1e4);let B=S.getImageData(0,0,o.width,o.height);D=ze._postWorkerMessageSync(_,"decode",B,[B.data.buffer])})}else b=await Promise.race([new Promise((_,v)=>window.setTimeout(()=>v("Scanner error: timeout"),1e4)),(async()=>{try{var[_]=await s.detect(o);if(!_)throw ze.NO_QR_CODE_FOUND;return{data:_.rawValue,cornerPoints:ze._convertPoints(_.cornerPoints,d)}}catch(v){if(_=v.message||v,/not implemented|service unavailable/.test(_))return ze._disableBarcodeDetector=!0,ze.scanImage(t,{scanRegion:d,canvas:o,disallowCanvasResizing:l,alsoTryWithoutScanRegion:c});throw`Scanner error: ${_}`}})()]);return p?b:b.data}catch(m){if(!d||!c)throw m;let S=await ze.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:l});return p?S:S.data}finally{n||ze._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){ze._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){ze._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=()=>Hk(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!ze._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(n.platform)&&await n.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 n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,l=t.offsetHeight,c=t.offsetLeft,d=t.offsetTop,p=window.getComputedStyle(t),m=p.objectFit,S=n/s,b=o/l;switch(m){case"none":var _=n,v=s;break;case"fill":_=o,v=l;break;default:(m==="cover"?S>b:S<b)?(v=l,_=v*S):(_=o,v=_/S),m==="scale-down"&&(_=Math.min(_,n),v=Math.min(v,s))}var[w,C]=p.objectPosition.split(" ").map((N,D)=>{const B=parseFloat(N);return N.endsWith("%")?(D?l-v:o-_)*B/100:B});p=this._scanRegion.width||n,b=this._scanRegion.height||s,m=this._scanRegion.x||0;var k=this._scanRegion.y||0;S=this.$overlay.style,S.width=`${p/n*_}px`,S.height=`${b/s*v}px`,S.top=`${d+C+k/s*v}px`,s=/scaleX\(-1\)/.test(t.style.transform),S.left=`${c+(s?o-w-_:w)+(s?n-m-p:m)/n*_}px`,S.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let s=n.x||0,o=n.y||0,l=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let c of t)c.x=c.x*l+s,c.y=c.y*n+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,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var s=await ze.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!ze._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=ze.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:l})=>`${o},${l}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==ze.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",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...n])try{let l=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),c=this._getFacingMode(l)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:l,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 n of t.getTracks())n.stop(),t.removeTrack(n)}_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,n,s,o=!1){s=s||document.createElement("canvas");let l=n&&n.x?n.x:0,c=n&&n.y?n.y:0,d=n&&n.width?n.width:t.videoWidth||t.width,p=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:d,n=n&&n.downScaledHeight?n.downScaledHeight:p,s.width!==o&&(s.width=o),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,l,c,d,p,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await ze._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 n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await ze._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,s)=>{let o=l=>{t.removeEventListener("load",o),t.removeEventListener("error",o),l instanceof ErrorEvent?s("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,s,o){return ze._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let l=ze._workerMessageId++;return t.postMessage({id:l,type:n,data:s},o),l}}ze.DEFAULT_CANVAS_SIZE=400;ze.NO_QR_CODE_FOUND="No QR code found";ze._disableBarcodeDetector=!1;ze._workerMessageId=0;function $k({onResult:e,onClose:t}){const n=L.useRef(null),s=L.useRef(null),o=L.useRef(!1),[l,c]=L.useState("");L.useEffect(()=>{let p=!1;const m=n.current,S=b=>{p||o.current||(o.current=!0,e(b))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(y("qr-unsupported"));return}let b=!1;try{b=await ze.hasCamera()}catch{b=!1}if(!b){c(y("qr-no-camera"));return}if(p||!m)return;const _=new ze(m,v=>{const w=Yg(v);w&&S(w)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:v=>{const w=v.videoWidth||640,C=v.videoHeight||480,k=Math.max(1,Math.round(Math.min(w,C)*.92));return{x:Math.round((w-k)/2),y:Math.round((C-k)/2),width:k,height:k,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=_;try{await _.start()}catch(v){if(p)return;const w=v&&v.name||"";c(y(w==="NotAllowedError"||w==="SecurityError"?"qr-permission":w==="NotFoundError"||w==="OverconstrainedError"||w==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{p=!0;const b=s.current;if(b){try{b.stop()}catch{}try{b.destroy()}catch{}s.current=null}const _=m,v=_&&_.srcObject;if(v&&typeof v.getTracks=="function"){for(const w of v.getTracks())try{w.stop()}catch{}try{_.srcObject=null}catch{}}}},[]);const d=async p=>{const m=p.target.files&&p.target.files[0];if(p.target.value="",!!m)try{const S=await ze.scanImage(m,{returnDetailedScanResult:!0}),b=Yg(S);if(!b)throw new Error("empty");o.current||(o.current=!0,e(b))}catch{c(y("pairing-qr-invalid"))}};return h.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:h.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:p=>p.stopPropagation(),children:[h.jsx("div",{className:"nc-sheet-head",children:h.jsx("b",{children:y("scan-qr")})}),h.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),l&&h.jsx("div",{className:"nc-err",role:"alert",children:l}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[y("qr-upload"),h.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:d})]}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:y("cancel")})]})]})})}const Qg=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:""});function F_({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",readonly:o=!1,onSuccess:l,onBusyChange:c}){const[d,p]=L.useState(Qg),[m,S]=L.useState(!1),[b,_]=L.useState(!1),[v,w]=L.useState("idle"),[C,k]=L.useState(null),[N,D]=L.useState(""),[B,A]=L.useState(!1),J=L.useRef(Bk()),O=L.useRef(new Set),F=v==="busy";L.useEffect(()=>(c&&c(F),()=>{c&&c(!1)}),[F,c]);const Z=async P=>{const U=String(P.pairingUrl||"").trim();if(J.current.start(U)){w("busy"),k(null),D("");try{await Sw(e,Ak(P,{deviceDefault:s})),w("ok"),S(!1),p(Qg()),O.current=new Set,A(!1),J.current.finish(),l&&await l()}catch(R){const H=Ok(R);k(H),w("idle"),J.current.finish(),(H.stage==="validation"||H.stage==="conflict"||H.stage==="ssh-start"||H.stage==="ssh-ready"||String(H.code||"").startsWith("ssh-"))&&S(!0)}}},W=(P,U=!0)=>{const{classification:R,form:H}=Xg(d,P,O.current,B),I=H.pairingUrl;if(k(null),D(""),v==="ok"&&w("idle"),p(H),R.kind==="invalid"){k({stage:"validation",code:"bad-link",message:y("pair-invalid-link"),hint:y("pair-invalid-hint"),retryable:!0});return}if(R.kind==="partial"){S(!0),D(R.missing.includes("ssh")?y("pair-missing-ssh"):y("pair-missing-name"));return}R.kind==="complete"&&U&&!o&&J.current.canAuto(I)&&Z(H)};L.useEffect(()=>{t&&W(t,n)},[]);const G=()=>{const P=String(d.pairingUrl||"").trim(),{classification:U,form:R}=Xg(d,P,O.current,B);if(p(R),D(""),k(null),U.kind==="empty"){k({stage:"validation",message:y("pairing-required"),retryable:!0});return}if(U.kind==="invalid"){k({stage:"validation",code:"bad-link",message:y("pair-invalid-link"),hint:y("pair-invalid-hint"),retryable:!0});return}if(!R.ssh||!R.name){S(!0),D(R.ssh?y("pair-missing-name"):y("pair-missing-ssh"));return}if(R.label&&!xh(R.label)){k({stage:"validation",message:y("err-label"),retryable:!0});return}if(R.localLabel&&!xh(R.localLabel)){k({stage:"validation",message:y("err-label"),retryable:!0});return}J.current.reset(P),Z(R)},X=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const P=await navigator.clipboard.readText();P&&P.trim()?W(P):D(y("pair-clipboard-empty"))}catch{D(y("pair-clipboard-denied"))}},j=(P,U)=>{O.current.add(P),p(R=>({...R,[P]:U}))},E=C&&C.stage&&(Ik.includes(C.stage)||C.stage==="internal")?y(`pair-stage-${C.stage}`):y("pair-stage-generic");return h.jsxs("div",{className:"nc-set-form nc-pair-card",children:[h.jsx("div",{className:"nc-sheet-label",children:y("pair-card-title")}),h.jsx("div",{className:"nc-set-info",children:y("pair-card-help")}),h.jsx("input",{className:"nc-pair-input",placeholder:y("pair-paste-ph"),value:d.pairingUrl,disabled:o||F,onChange:P=>{p({...d,pairingUrl:P.target.value}),k(null),D("")},onPaste:P=>{const U=P.clipboardData&&P.clipboardData.getData("text")||"";U.trim()&&(P.preventDefault(),W(U))},onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),G())}}),h.jsxs("div",{className:"nc-pair-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:X,children:y("pair-paste-btn")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:()=>_(!0),children:y("scan-qr")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||F,title:o?y("settings-readonly"):"",onClick:G,children:y("test-and-connect")})]}),h.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[F&&h.jsx("div",{className:"nc-pair-progress",children:y("pair-progress")}),v==="ok"&&h.jsx("div",{className:"nc-set-test ok",children:y("node-connected")}),N&&h.jsx("div",{className:"nc-set-hint nc-pair-notice",children:N}),C&&h.jsxs("div",{className:"nc-err",role:"alert",children:[h.jsx("b",{children:E})," — ",C.message,C.hint&&h.jsx("div",{className:"nc-pair-hint",children:C.hint}),C.retryable&&h.jsx("div",{children:h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||F,onClick:G,children:y("pair-retry")})})]})]}),h.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:F,onClick:()=>S(P=>!P),children:[m?"▾":"▸"," ",y("pair-advanced")]}),m&&h.jsxs("div",{className:"nc-pair-advanced",children:[h.jsxs("label",{className:"nc-field",children:[y("node-display-label"),h.jsx("input",{placeholder:"Home Relay",value:d.label,disabled:o||F,onChange:P=>{O.current.add("label"),p(U=>({...U,label:P.target.value,name:B?U.name:Xr(P.target.value)}))}})]}),h.jsxs("label",{className:"nc-field",children:[y("node-name-label"),h.jsx("input",{placeholder:y("node-name-ph"),value:d.name,disabled:o||F,onChange:P=>{A(!0),O.current.add("name"),p(U=>({...U,name:P.target.value?Xr(P.target.value):""}))}})]}),h.jsx("small",{className:"nc-set-hint",children:y("node-slug-hint").replace("{slug}",d.name||"home-relay")}),h.jsxs("label",{className:"nc-field",children:[y("pair-ssh-local-label"),h.jsx("input",{placeholder:"my-relay",value:d.ssh,disabled:o||F,onChange:P=>{O.current.add("ssh"),j("ssh",P.target.value)}}),h.jsx("small",{className:"nc-set-hint",children:y("node-ssh-local-help")})]}),h.jsxs("label",{className:"nc-field",children:[y("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:y("node-ssh-port-help"),value:d.sshPort,disabled:o||F,onChange:P=>j("sshPort",P.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),h.jsxs("label",{className:"nc-field",children:[y("device-name-label"),h.jsx("input",{placeholder:s||"NexusCrew",value:d.localLabel,disabled:o||F,onChange:P=>j("localLabel",P.target.value)}),h.jsx("small",{className:"nc-set-hint",children:y("device-name-hint")})]})]}),b&&h.jsx($k,{onResult:P=>{_(!1),W(P)},onClose:()=>_(!1)})]})}function td(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function Wk(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),o=new Uint8Array(s.length);for(let l=0;l<s.length;l+=1)o[l]=s.charCodeAt(l);return o}async function Uk(){if(!td())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function Kk(e){if(!td())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await Tt("/api/push/vapid",e),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const l=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Wk(s)}),c=await Tt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:l.toJSON()})});if(!c.ok){try{await l.unsubscribe()}catch{}const d=await c.json().catch(()=>({}));throw new Error(d.error||`HTTP ${c.status}`)}return!0}async function qk(e){if(!td())return!1;const n=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!n)return!1;const s=n.endpoint;try{await n.unsubscribe()}catch{}try{await Tt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const H_="nexuscrew.fleet",$_=2,Vk="nexuscrew.cells",Yk=/^[A-Za-z0-9._-]{1,32}$/,id=/^[a-z0-9._-]{1,32}$/,W_=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,Xk=new Set(["standard","unsafe"]),Gk=4096,Jg=256,Qk=8192,Jk=32,Zk=24,ex=new Set(["format","version","exportedAt","cells","engines"]),tx=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]),ix=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),nx=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function sr(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function U_(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 Zg(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const n=Object.entries(e);if(n.length>128)return null;const s={};for(const[o,l]of n){if(!id.test(o)||!t(l))return null;s[o]=l}return s}function K_(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!tx.has(l))||!Yk.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>Gk||!id.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Jg)||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>Qk)return null;const n=Zg(e.models,l=>typeof l=="string"&&!!l&&l.length<=Jg),s=Zg(e.permissionPolicies,l=>Xk.has(l));if(n===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(n).length&&(o.models=n),Object.keys(s).length&&(o.permissionPolicies=s),o}function rx(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!nx.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!sr(s,n==="baseUrl"?512:128)||U_(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!W_.test(t.envKey)?null:t}function q_(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!ix.has(s))||!id.test(String(e.id||""))||!sr(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=rx(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!sr(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!sr(s,1024)||U_(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!sr(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")||!sr(e.model.flag,32)||/\s/.test(e.model.flag)||!sr(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const n=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!W_.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(n)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function V_(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},n=q_(t);return n||null}function sx(e,t,n=[],s=[],o=new Date){n instanceof Date&&(o=n,n=[],s=[]);const l=t instanceof Set?t:new Set(t||[]),c=s instanceof Set?s:new Set(s||[]),d=[];for(const m of Array.isArray(e)?e:[]){if(!l.has(m.id))continue;const S=K_({id:m.id,cwd:m.cwd,engine:m.engine,boot:m.boot===!0,...m.model?{model:m.model}:{},...m.models?{models:m.models}:{},...m.permissionPolicies?{permissionPolicies:m.permissionPolicies}:{},systemPrompt:m.prompt||""});S&&d.push(S)}const p=[];for(const m of Array.isArray(n)?n:[]){if(!c.has(m.id))continue;const S=V_(m);S&&p.push(S)}return{format:H_,version:$_,exportedAt:o.toISOString(),cells:d,engines:p}}function ox(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(t==null?void 0:t.format)===Vk&&(t==null?void 0:t.version)===1;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(d=>!ex.has(d))||!n&&(t.format!==H_||t.version!==$_)||!Array.isArray(t.cells)||t.cells.length>Jk||!n&&(!Array.isArray(t.engines)||t.engines.length>Zk))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const s=[],o=new Set;for(const d of t.cells){const p=K_(d);if(!p)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(o.has(p.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};o.add(p.id),s.push(p)}const l=[],c=new Set;for(const d of n?[]:t.engines){const p=q_(d);if(!p)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(c.has(p.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};c.add(p.id),l.push(p)}return{ok:!0,cells:s,engines:l,legacy:n,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function ax(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=p=>Object.fromEntries(Object.entries(p||{}).filter(([m])=>s.has(m))),l={id:e.id,cwd:e.cwd,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};t===e.engine&&e.model?l.model=e.model:e.models&&e.models[t]&&(l.model=e.models[t]);const c=o(e.models),d=o(e.permissionPolicies);return Object.keys(c).length&&(l.models=c),Object.keys(d).length&&(l.permissionPolicies=d),l}const lx=()=>({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:[]}),ev=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:""}),Y_=e=>e==="claude"?"unsafe":"standard",Ga=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),cx=(e,t)=>{var n;return((n=Ga(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function ux(e){var t,n,s,o,l,c,d,p,m,S,b,_,v,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:((n=e.managed)==null?void 0:n.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((l=e.managed)==null?void 0:l.permissionPolicy)||Y_((c=e.managed)==null?void 0:c.client),displayName:((d=e.managed)==null?void 0:d.displayName)||"",protocol:((p=e.managed)==null?void 0:p.protocol)||"",baseUrl:((m=e.managed)==null?void 0:m.baseUrl)||"",envKey:((S=e.managed)==null?void 0:S.envKey)||"",providerId:((b=e.managed)==null?void 0:b.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((_=e.managedInfo)==null?void 0:_.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((v=e.model)==null?void 0:v.flag)||"",modelValue:((w=e.model)==null?void 0:w.value)||"",envRows:(e.envKeys||[]).map(C=>({key:C,value:"",configured:!0,remove:!1}))}}function hx(e,t,n=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.managedModel||"",permissionPolicy:e.permissionPolicy||Y_(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const l=Ga(n,e);return l!=null&&l.credentialEnv&&(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||cx(n,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 Wr({children:e,onClose:t,label:n,error:s=""}){const o=L.useRef(null),l=L.useRef(null),c=L.useRef(t);return c.current=t,L.useEffect(()=>{const d=document.activeElement,p=o.current,m=()=>Array.from((p==null?void 0:p.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(_=>_.offsetParent!==null),S=requestAnimationFrame(()=>{var _;return(_=m()[0]||p)==null?void 0:_.focus({preventScroll:!0})}),b=_=>{var k;if(_.key==="Escape"){_.preventDefault(),(k=c.current)==null||k.call(c);return}if(_.key!=="Tab")return;const v=m();if(!v.length){_.preventDefault(),p==null||p.focus();return}const w=v[0],C=v[v.length-1];_.shiftKey&&document.activeElement===w?(_.preventDefault(),C.focus()):!_.shiftKey&&document.activeElement===C&&(_.preventDefault(),w.focus())};return document.addEventListener("keydown",b),()=>{cancelAnimationFrame(S),document.removeEventListener("keydown",b),d&&d.isConnected&&typeof d.focus=="function"&&d.focus({preventScroll:!0})}},[]),L.useEffect(()=>{s&&requestAnimationFrame(()=>{var d;return(d=l.current)==null?void 0:d.scrollIntoView({block:"nearest"})})},[s]),h.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:d=>{d.target===d.currentTarget&&t()},children:h.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||y("settings"),tabIndex:-1,children:[e,s&&h.jsx("div",{ref:l,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function tv({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[l,c]=L.useState([]),[d,p]=L.useState(0);L.useEffect(()=>{let k=!0;async function N(){const B=[{route:[],label:y("local")}].concat((t||[]).map(J=>({route:Array.isArray(J.route)?J.route:[],label:J.label||(J.route||[]).join(" › ")}))),A=await Promise.all(B.map(async J=>{const O={...J,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const F=await dr(e,J.route);O.available=!!F.available,O.capabilities=F.capabilities||[],O.provider=F.provider||null,O.cells=(F.cells||[]).map(Z=>({...Z,route:J.route}));try{O.readonly=!!(await Ah(e,J.route)).readonlyDefault}catch{}try{const Z=await vv(e,J.route),W=new Set(O.cells.map(G=>G.tmuxSession).filter(Boolean));O.unmanaged=(Z.sessions||[]).filter(G=>G&&!W.has(G.name))}catch{}}catch(F){O.err=String(F&&F.message||F)}return O}));k&&c(A)}N();const D=setInterval(N,6e3);return()=>{k=!1,clearInterval(D)}},[e,t,d]);const m=(k,N)=>Array.isArray(k.capabilities)&&k.capabilities.includes(N)&&!n&&!k.readonly,S=()=>p(k=>k+1),b=(k,N)=>{s&&s({...k,route:N})},_=(k,N)=>{s&&s({...k,route:N})},v=async(k,N)=>{try{await Ys(e,k.cell,N)}catch{}S()},w=async(k,N)=>{if(window.confirm(y("fleet-remove-cell").replace("{id}",k.cell))){try{await dv(e,k.cell,!0,N)}catch{}S()}},C=async(k,N)=>{if(window.confirm(y("terminate-confirm").replace("{name}",k.name))){try{await Th(e,k.name,N)}catch{}S()}};return h.jsxs("div",{className:"nc-fleet-inventory",children:[h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-inventory")}),h.jsx("small",{children:y("fleet-inventory-help")})]}),l.map(k=>{const N=k.route.length?k.route.join("/"):"local";return h.jsxs("div",{className:"nc-fleet-pos",children:[h.jsxs("div",{className:"nc-fleet-pos-title",children:[h.jsx("span",{className:`dot ${k.available?"on":"warn"}`}),h.jsx("b",{children:k.label}),h.jsx("small",{children:k.available?`${k.cells.length} ${y("fleet-cells")} · ${k.unmanaged.length} ${y("fleet-tmux")}`:k.err||y("fleet-not-available")})]}),k.cells.map(D=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[h.jsxs("span",{children:[h.jsx("b",{children:D.cell}),h.jsx("small",{children:`${D.engine||""}${D.key?`·${D.key}`:""}${D.active?"":` · ${y("cell-off")}`}`})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[D.active&&m(k,"down")&&h.jsx("button",{className:"nc-btn ghost",title:y("power-off"),onClick:()=>_(D,k.route),children:y("stop")}),!D.active&&m(k,"up")&&h.jsx("button",{className:"nc-btn ghost",title:y("power-on"),onClick:()=>b(D,k.route),children:y("start")}),m(k,"restart")&&D.active&&h.jsx("button",{className:"nc-btn ghost",title:y("restart"),onClick:()=>v(D,k.route),children:y("restart")}),m(k,"remove")&&h.jsx("button",{className:"nc-btn danger",title:y("delete"),onClick:()=>w(D,k.route),children:"×"})]})]},`${N}:${D.cell}`)),k.unmanaged.map(D=>h.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[h.jsxs("span",{children:[h.jsx("b",{children:D.name}),h.jsx("small",{children:y("fleet-tmux")})]}),h.jsxs("span",{className:"nc-fleet-cell-actions",children:[m(k,"import")&&o&&h.jsx("button",{className:"nc-btn ghost",title:y("import-as-cell"),onClick:()=>o(D,k.route),children:y("import-as-cell")}),h.jsx("button",{className:"nc-btn danger",title:y("terminate"),onClick:()=>C(D,k.route),children:"×"})]})]},`${N}:u:${D.name}`)),k.available&&k.cells.length===0&&k.unmanaged.length===0&&h.jsx("div",{className:"nc-empty",children:y("fleet-inventory-empty")})]},N)})]})}function dx({cells:e=[],engines:t=[],busy:n,canRestore:s=!1,onRestore:o,onClose:l}){const[c,d]=L.useState("export"),[p,m]=L.useState(()=>new Set(e.map(E=>E.id))),[S,b]=L.useState(()=>new Set(t.map(E=>E.id))),[_,v]=L.useState([]),[w,C]=L.useState([]),[k,N]=L.useState(""),D=new Set(t.map(E=>E.id)),B=new Set(e.map(E=>E.id)),A=(E,P)=>E(U=>{const R=new Set(U);return R.has(P)?R.delete(P):R.add(P),R}),J=()=>{const E=sx(e,p,t,S),P=t.filter(I=>S.has(I.id)).length;if(E.engines.length!==P){N(y("fleet-backup-invalid-engine"));return}if(!E.cells.length&&!E.engines.length){N(y("fleet-backup-select-one"));return}const U=new Blob([`${JSON.stringify(E,null,2)}
|
|
91
|
+
`],{type:"application/json"}),R=URL.createObjectURL(U),H=document.createElement("a");H.href=R,H.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(H),H.click(),H.remove(),setTimeout(()=>URL.revokeObjectURL(R),0),N("")},O=async E=>{if(N(""),v([]),C([]),!!E){if(E.size>1024*1024){N(y("fleet-backup-too-large"));return}try{const P=ox(await E.text());if(!P.ok){N(y(`fleet-backup-${P.error}`));return}const U=new Set(P.engines.map(R=>R.id));C(P.engines.map(R=>({engine:R,exists:D.has(R.id),selected:!D.has(R.id)}))),v(P.cells.map(R=>{const H=D.has(R.engine)||U.has(R.engine),I=B.has(R.id);return{cell:R,engine:H?R.engine:"",selected:H&&!I,exists:I}}))}catch(P){N(String(P.message||P))}}},F=(E,P)=>v(U=>U.map((R,H)=>H===E?{...R,...P}:R)),Z=(E,P)=>C(U=>U.map((R,H)=>H===E?{...R,...P}:R)),W=new Set([...D,...w.filter(E=>E.selected).map(E=>E.engine.id)]),G=_.filter(E=>E.selected&&E.engine&&W.has(E.engine)),X=w.filter(E=>E.selected),j=[...new Map([...t.map(E=>[E.id,E.label||E.id]),...w.filter(E=>E.selected).map(E=>[E.engine.id,E.engine.label||E.engine.id])]).entries()];return h.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[h.jsx("b",{children:y("fleet-backup")}),h.jsx("small",{children:y("fleet-backup-help")}),h.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[h.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="export"?" on":""}`,onClick:()=>{d("export"),N("")},children:y("fleet-backup-export")}),h.jsx("button",{type:"button",className:`nc-set-tabbtn${c==="import"?" on":""}`,disabled:!s,title:s?"":y("fleet-backup-restore-unavailable"),onClick:()=>{d("import"),N("")},children:y("fleet-backup-import")})]}),c==="export"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set(e.map(E=>E.id))),b(new Set(t.map(E=>E.id)))},children:y("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{m(new Set),b(new Set)},children:y("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[h.jsx("b",{children:y("fleet-engines")}),t.map(E=>{var P;return h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:S.has(E.id),onChange:()=>A(b,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.label||E.id}),h.jsxs("small",{children:[E.id,(P=E.envKeys)!=null&&P.length?` · ${E.envKeys.length} ${y("fleet-backup-env-names")}`:""]})]})]},E.id)}),h.jsx("b",{children:y("fleet-cells")}),e.map(E=>h.jsxs("label",{className:"nc-check nc-backup-row",children:[h.jsx("input",{type:"checkbox",checked:p.has(E.id),onChange:()=>A(m,E.id)}),h.jsxs("span",{children:[h.jsx("b",{children:E.id}),h.jsxs("small",{children:[E.engine," · ",y("fleet-system-prompt")," ",(E.prompt||"").length," ",y("characters")]})]})]},E.id)),!e.length&&!t.length&&h.jsx("div",{className:"nc-empty",children:y("fleet-backup-empty")})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:!p.size&&!S.size,onClick:J,children:y("fleet-backup-download")})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{type:"file",accept:"application/json,.json",disabled:n,onChange:E=>O(E.target.files&&E.target.files[0])}),h.jsx("small",{children:y("fleet-backup-import-help")}),!!(_.length||w.length)&&h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(E=>E.map(P=>({...P,selected:!0}))),v(E=>E.map(P=>({...P,selected:!!P.engine})))},children:y("select-all")}),h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{C(E=>E.map(P=>({...P,selected:!1}))),v(E=>E.map(P=>({...P,selected:!1})))},children:y("select-none")})]}),h.jsxs("div",{className:"nc-backup-list",children:[!!w.length&&h.jsx("b",{children:y("fleet-engines")}),w.map((E,P)=>{var U;return h.jsx("div",{className:"nc-backup-import-row",children:h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:E.selected,onChange:R=>Z(P,{selected:R.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.engine.label||E.engine.id}),h.jsxs("small",{children:[E.engine.id," · ",E.exists?y("fleet-backup-overwrite"):y("fleet-backup-new"),(U=E.engine.envKeys)!=null&&U.length?` · ${y("fleet-backup-env-values-required")}`:""]})]})]})},E.engine.id)}),!!_.length&&h.jsx("b",{children:y("fleet-cells")}),_.map((E,P)=>h.jsxs("div",{className:"nc-backup-import-row",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:E.selected,disabled:!E.engine||!W.has(E.engine),onChange:U=>F(P,{selected:U.target.checked})}),h.jsxs("span",{children:[h.jsx("b",{children:E.cell.id}),h.jsxs("small",{children:[E.exists?y("fleet-backup-overwrite"):y("fleet-backup-new")," · ",y("fleet-system-prompt")," ",E.cell.systemPrompt.length," ",y("characters")]})]})]}),h.jsxs("select",{value:E.engine,onChange:U=>F(P,{engine:U.target.value,selected:!!U.target.value}),children:[h.jsx("option",{value:"",children:y("fleet-backup-engine-missing")}),j.map(([U,R])=>h.jsx("option",{value:U,children:R},U))]})]},E.cell.id))]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",onClick:l,children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!G.length&&!X.length,onClick:()=>o({engineRows:w,cellRows:_}),children:y("fleet-backup-restore")})]})]}),k&&h.jsx("div",{className:"nc-err",children:k})]})}function fx({state:e,setState:t,busy:n,onSave:s,catalog:o}){var _;const l=e.form,c=v=>t({...e,form:{...l,...v}}),d=l.envRows||[],p=[...new Map(o.map(v=>[v.client,v.clientLabel||v.client])).entries()],m=o.filter(v=>v.client===l.client),S=Ga(o,l),b=v=>{v&&c({client:v.client,provider:v.provider,credentialProfile:v.credentialProfile||"",managedModel:v.model||"",protocol:v.protocol||"",permissionPolicy:v.permissionPolicyDefault||"standard",rc:!!v.rc,displayName:v.custom?y("fleet-custom-provider-default"):"",baseUrl:v.custom?"":v.endpoint||"",envKey:v.defaultEnvKey||"",providerId:"nexuscrew-custom",...e.mode==="new"?{id:v.id,label:""}:{}})};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:e.mode==="new"?y("fleet-new-engine"):`${y("edit")} ${l.id}`}),h.jsx("input",{value:l.id,disabled:e.mode!=="new",placeholder:"id",onChange:v=>c({id:v.target.value})}),h.jsx("input",{value:l.label,placeholder:y("label"),onChange:v=>c({label:v.target.value})}),h.jsxs("select",{value:l.kind,disabled:e.mode!=="new",onChange:v=>c({kind:v.target.value}),children:[h.jsx("option",{value:"managed",children:y("fleet-managed")}),h.jsx("option",{value:"custom",children:y("fleet-custom")})]}),l.kind==="managed"?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("select",{value:l.client,disabled:e.mode!=="new",onChange:v=>b(o.find(w=>w.client===v.target.value&&w.default)||o.find(w=>w.client===v.target.value)),children:p.map(([v,w])=>h.jsx("option",{value:v,children:w},v))}),h.jsx("select",{value:((_=Ga(o,l))==null?void 0:_.id)||"",disabled:e.mode!=="new",onChange:v=>b(o.find(w=>w.id===v.target.value)),children:m.map(v=>h.jsx("option",{value:v.id,children:v.label},v.id))})]}),h.jsx("input",{value:l.managedModel,list:"nc-managed-models",placeholder:y(S!=null&&S.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:v=>c({managedModel:v.target.value})}),h.jsx("datalist",{id:"nc-managed-models",children:[...(S==null?void 0:S.models)||[],...l.modelOptions||[]].filter((v,w,C)=>v&&C.indexOf(v)===w).map(v=>h.jsx("option",{value:v},v))}),S!=null&&S.supportsUnsafe?h.jsxs("select",{value:l.permissionPolicy,onChange:v=>c({permissionPolicy:v.target.value}),children:[h.jsx("option",{value:"standard",children:y("fleet-standard-permissions")}),h.jsx("option",{value:"unsafe",children:y("fleet-unsafe-permissions")})]}):h.jsx("small",{children:y("fleet-standard-permissions")}),(S==null?void 0:S.supportsUnsafe)&&l.permissionPolicy==="unsafe"&&h.jsx("small",{className:"nc-err",children:y("fleet-unsafe-warning")}),(S==null?void 0:S.credentialEnv)&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.envKey,placeholder:y("fleet-api-key-env"),onChange:v=>c({envKey:v.target.value})}),h.jsx("small",{children:y("fleet-custom-secret-help")})]}),l.provider==="custom"&&h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.displayName,placeholder:y("fleet-provider-display"),onChange:v=>c({displayName:v.target.value})}),h.jsx("input",{value:l.baseUrl,placeholder:"https://api.example.com/v1",onChange:v=>c({baseUrl:v.target.value})}),((S==null?void 0:S.protocols)||[]).length>1&&h.jsx("select",{value:l.protocol,onChange:v=>c({protocol:v.target.value}),children:S.protocols.map(v=>h.jsx("option",{value:v,children:v},v))}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.envKey,placeholder:y("fleet-api-key-env"),onChange:v=>c({envKey:v.target.value})}),h.jsx("input",{value:l.providerId,placeholder:y("fleet-provider-id"),onChange:v=>c({providerId:v.target.value})})]}),h.jsxs("small",{children:[l.protocol," · ",y("fleet-custom-secret-help")]})]}),h.jsx("small",{children:y("fleet-managed-help")})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{value:l.command,placeholder:y("command-path"),onChange:v=>c({command:v.target.value})}),h.jsx("textarea",{value:l.argsText,placeholder:y("args-lines"),onChange:v=>c({argsText:v.target.value})}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:l.rc,onChange:v=>c({rc:v.target.checked})})," remote control"]}),h.jsxs("select",{value:l.promptMode,onChange:v=>c({promptMode:v.target.value}),children:[h.jsx("option",{value:"send-keys",children:"send-keys"}),h.jsx("option",{value:"flag",children:"flag"})]}),l.promptMode==="flag"&&h.jsx("input",{value:l.promptFlag,placeholder:"prompt flag",onChange:v=>c({promptFlag:v.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:l.modelFlag,placeholder:"model flag",onChange:v=>c({modelFlag:v.target.value})}),h.jsx("input",{value:l.modelValue,placeholder:"model default",onChange:v=>c({modelValue:v.target.value})})]}),h.jsx("small",{children:y("env-write-only")}),d.map((v,w)=>h.jsxs("div",{className:"nc-fleet-env",children:[h.jsx("input",{value:v.key,disabled:v.configured,placeholder:"ENV_KEY",onChange:C=>{const k=d.slice();k[w]={...v,key:C.target.value},c({envRows:k})}}),h.jsx("input",{type:"password",value:v.value,placeholder:v.configured?"•••••• (unchanged)":"value",onChange:C=>{const k=d.slice();k[w]={...v,value:C.target.value},c({envRows:k})}}),h.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:d.filter((C,k)=>k!==w)}),children:"×"})]},`${v.key}-${w}`)),h.jsx("button",{className:"nc-btn ghost",onClick:()=>c({envRows:[...d,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:n||!l.id||l.kind==="custom"&&!l.command||l.kind==="managed"&&(S==null?void 0:S.requiresModel)&&!l.managedModel||l.kind==="managed"&&(S==null?void 0:S.credentialEnv)&&!l.envKey||l.kind==="managed"&&l.provider==="custom"&&(!l.displayName||!l.baseUrl||!l.envKey||!l.providerId),onClick:s,children:y("save")})]})]})}function px({token:e,route:t,targets:n=[],location:s,setLocation:o,state:l,setState:c,engines:d,busy:p,onSave:m}){const[S,b]=L.useState(null),[_,v]=L.useState(""),w=l.form,C=B=>c({...l,form:{...w,...B}}),k=d.find(B=>B.id===w.engine),N=B=>{var J,O,F;const A=d.find(Z=>Z.id===B);C({engine:B,model:((J=w.models)==null?void 0:J[B])||((O=A==null?void 0:A.managed)==null?void 0:O.model)||((F=A==null?void 0:A.model)==null?void 0:F.value)||""})},D=async B=>{try{const A=await pv(e,B,t);b(A),C({cwd:A.path}),v("")}catch(A){v(String(A.message||A))}};return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsx("b",{children:l.mode==="new"?y("fleet-new-cell"):`${y("edit")} ${w.id}`}),l.mode==="new"&&h.jsxs("label",{className:"nc-field",children:[y("location"),h.jsx("span",{className:"nc-req",children:" *"}),h.jsxs("select",{value:s,onChange:B=>{o(B.target.value),C({engine:""})},children:[h.jsx("option",{value:"",children:y("local")}),n.map(B=>h.jsxs("option",{value:B.route.join("/"),disabled:B.status&&B.status!=="up",children:[B.label,B.status&&B.status!=="up"?` · ${y("node-offline")}`:""]},B.route.join("/")))]})]}),h.jsx("input",{value:w.id,disabled:l.mode!=="new",placeholder:"id",onChange:B=>C({id:B.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:w.cwd,placeholder:y("cwd"),onChange:B=>C({cwd:B.target.value})}),h.jsx("button",{className:"nc-btn ghost",onClick:()=>S?b(null):D(w.cwd),children:y("browse")})]}),S&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:S.path}),h.jsxs("div",{className:"nc-fs-list",children:[S.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>D(S.parent),children:["↑ ",y("fs-parent")]}),(S.dirs||[]).map(B=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>D(`${S.path.replace(/\/$/,"")}/${B}`),children:["📁 ",B]},B))]})]}),_&&h.jsx("div",{className:"nc-err",children:_}),h.jsx("select",{value:w.engine,onChange:B=>N(B.target.value),children:d.map(B=>h.jsx("option",{value:B.id,children:B.label},B.id))}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:B=>C({boot:B.target.checked})})," boot"]}),h.jsx("input",{value:w.model||"",list:"nc-cell-models",placeholder:y("fleet-model-override"),onChange:B=>C({model:B.target.value})}),h.jsx("datalist",{id:"nc-cell-models",children:((k==null?void 0:k.availableModels)||[]).map(B=>h.jsx("option",{value:B},B))}),h.jsx("textarea",{value:w.prompt||"",placeholder:"prompt",onChange:B=>C({prompt:B.target.value})}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:p||!w.id||!w.cwd||!w.engine,onClick:m,children:y("save")})]})]})}function iv({token:e,route:t=[],state:n,setState:s,busy:o,onSave:l}){const[c,d]=L.useState(null),[p,m]=L.useState([]),[S,b]=L.useState(""),_=Array.isArray(t)?t.join("/"):"";L.useEffect(()=>{let N=!0;return jh(e,_?_.split("/"):[]).then(D=>{N&&(m(D.engines||[]),b(""))}).catch(D=>{N&&(m([]),b(String(D.message||D)))}),()=>{N=!1}},[e,_]);const v=n.form,w=N=>s({...n,form:{...v,...N}}),C=async N=>{try{const D=await pv(e,N,t);d(D),w({cwd:D.path})}catch{}},k=!v.id&&v.tmuxSession?v.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):v.id;return h.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[h.jsxs("b",{children:[y("import-as-cell")," · ",v.tmuxSession]}),h.jsx("small",{children:y("import-help")}),h.jsx("input",{value:v.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),h.jsx("input",{value:v.id,placeholder:y("name"),onChange:N=>w({id:N.target.value})}),h.jsxs("div",{className:"nc-fleet-pair",children:[h.jsx("input",{value:v.cwd,placeholder:y("cwd"),onChange:N=>w({cwd:N.target.value})}),h.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?d(null):C(v.cwd),children:y("browse")})]}),c&&h.jsxs("div",{className:"nc-fs",children:[h.jsx("div",{className:"nc-fs-path",children:c.path}),h.jsxs("div",{className:"nc-fs-list",children:[c.parent&&h.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>C(c.parent),children:["↑ ",y("fs-parent")]}),(c.dirs||[]).map(N=>h.jsxs("button",{className:"nc-fs-item",onClick:()=>C(`${c.path.replace(/\/$/,"")}/${N}`),children:["📁 ",N]},N))]})]}),h.jsxs("select",{value:v.engine,onChange:N=>w({engine:N.target.value}),children:[h.jsx("option",{value:"",children:y("import-engine-required")}),p.map(N=>h.jsx("option",{value:N.id,children:N.label},N.id))]}),h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:!!v.boot,onChange:N=>w({boot:N.target.checked})})," boot"]}),(n.err||S)&&h.jsx("div",{className:"nc-err",children:n.err||S}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:o||!v.tmuxSession||!v.engine||!p.length,onClick:l,children:y(k?"import-as-cell":"save")})]})]})}function mx({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[l,c]=L.useState({engines:[],cells:[],managedCatalog:[]}),[d,p]=L.useState({available:!1,capabilities:[]}),[m,S]=L.useState(null),[b,_]=L.useState(null),[v,w]=L.useState(!1),[C,k]=L.useState(""),[N,D]=L.useState(""),[B,A]=L.useState(o),[J,O]=L.useState(!1),[F,Z]=L.useState(null),[W,G]=L.useState(null),[X,j]=L.useState(!1),[E,P]=L.useState([]),[U,R]=L.useState(null),[H,I]=L.useState("manage"),se=L.useRef(!1),q=B?B.split("/"):[],M=L.useCallback(async()=>{try{const ie=await dr(e,q);p(ie);try{const we=await Ah(e,q);O(!!we.readonlyDefault)}catch{O(!1)}if(ie.provider==="builtin"&&(ie.capabilities||[]).includes("definitions")){const we=await jh(e,q),Te=new Map((ie.engines||[]).map(Se=>[Se.id,Se]));if(we.engines=(we.engines||[]).map(Se=>{var Xe;return{...Se,availableModels:((Xe=Te.get(Se.id))==null?void 0:Xe.models)||[]}}),c(we),(ie.capabilities||[]).includes("credentials"))try{P((await aw(e,q)).credentials||[])}catch{P([])}else P([])}}catch(ie){k(String(ie.message||ie))}},[e,B]);L.useEffect(()=>{M();const ie=setInterval(M,5e3);return()=>clearInterval(ie)},[M]);const K=new Set((d.cells||[]).filter(ie=>ie.active).map(ie=>ie.cell)),Q=d.provider==="builtin"&&(d.capabilities||[]).includes("edit"),re=(d.capabilities||[]).includes("restore");L.useEffect(()=>{!s||se.current||!Q||!l.engines.length||(se.current=!0,_({mode:"new",form:ev(l.engines[0].id)}))},[s,Q,l.engines]);const oe=async ie=>{w(!0),k(""),D("");try{await ie(),await M()}catch(we){k(String(we.message||we))}w(!1)},le=()=>oe(async()=>{const ie=m.mode==="new",we=hx(m.form,ie,l.managedCatalog||[]);!ie&&m.form.kind==="custom"&&!m.form.modelFlag&&(we.model=null),!ie&&m.form.kind==="custom"&&m.form.promptMode!=="flag"&&(we.promptFlag=null);let Te;if(ie)Te=await uw(e,we,q);else{const Xe=m.original,ci=new Set(m.form.envRows.filter(Ue=>!Ue.remove).map(Ue=>Ue.key)),$t=(Xe.envKeys||[]).filter(Ue=>!ci.has(Ue)),Zt=Object.fromEntries(m.form.envRows.filter(Ue=>!Ue.remove&&Ue.key&&(!Ue.configured||Ue.value!=="")).map(Ue=>[Ue.key,Ue.value]));Te=await hw(e,Xe.id,we,m.form.kind==="custom"?{set:Zt,remove:$t}:void 0,q)}S(null),D(y("fleet-saved"));const Se=(Te==null?void 0:Te.activeCells)||[];if(Se.length&&window.confirm(y("fleet-restart-confirm").replace("{cells}",Se.join(", "))))for(const Xe of Se)await Ys(e,Xe,q)}),V=()=>oe(async()=>{const ie=b.mode==="new",we=b.form,Te={...ie?{id:we.id}:{},cwd:we.cwd,engine:we.engine,boot:!!we.boot};ie?(we.model&&(Te.model=we.model),we.prompt&&(Te.prompt=we.prompt)):(Te.model=we.model||null,Te.prompt=we.prompt||null);const Se=ie?await fw(e,Te,q):await pw(e,b.original.id,Te,q),Xe=ie?we.id:b.original.id;_(null),D(y("fleet-saved")),!ie&&(Se!=null&&Se.active)&&window.confirm(y("fleet-restart-confirm").replace("{cells}",Xe))&&await Ys(e,Xe,q)}),z=t||J,pe=ie=>E.find(we=>{var Te;return(Te=we.engines)==null?void 0:Te.includes(ie.id)})||null,ye=()=>oe(async()=>{var Te;const ie=await lw(e,U.envKey,U.value,q);P(ie.credentials||[]),R(null),D(y("fleet-credential-saved"));const we=((Te=(ie.credentials||[]).find(Se=>Se.envKey===U.envKey))==null?void 0:Te.activeCells)||[];if(we.length&&window.confirm(y("fleet-restart-confirm").replace("{cells}",we.join(", "))))for(const Se of we)await Ys(e,Se,q)}),xe=ie=>oe(async()=>{if(!window.confirm(y("fleet-credential-remove-confirm").replace("{key}",ie.envKey)))return;const we=await cw(e,ie.envKey,q);P(we.credentials||[]),D(y("fleet-credential-removed"))}),te=ie=>Z({...ie,route:Array.isArray(ie==null?void 0:ie.route)?ie.route:q}),de=async ie=>{if(!F)return;const we=F.cell||F.id,Te=Array.isArray(F.route)?F.route:q;ie.action==="up"?await Mh(e,{cell:we,boot:!!ie.boot,...ie.engine?{engine:ie.engine}:{},...ie.model!==void 0?{model:ie.model}:{},...ie.permissionPolicy?{permissionPolicy:ie.permissionPolicy}:{}},Te):await Ia(e,{cell:we,boot:!!ie.boot},Te)},Ne=(ie,we)=>{k(""),G({mode:"new",route:Array.isArray(we)?we:q,form:{tmuxSession:ie.name,id:"",engine:"",cwd:"",boot:!1},err:""})},ke=()=>oe(async()=>{const ie=W.form;if(!ie.engine){G({...W,err:y("import-engine-required")});return}await mw(e,{tmuxSession:ie.tmuxSession,id:ie.id||void 0,engine:ie.engine,cwd:ie.cwd||void 0,boot:!!ie.boot},ie.route||q),G(null),D(y("fleet-saved"))}),Ve=({engineRows:ie=[],cellRows:we=[]})=>oe(async()=>{const Te=ie.filter(qe=>qe.selected),Se=Te.map(qe=>V_(qe.engine));if(Se.some(qe=>!qe))throw new Error(y("fleet-backup-invalid-engine"));const Xe=Te.filter(qe=>qe.exists).map(qe=>qe.engine.id);if(Xe.length&&!window.confirm(y("fleet-backup-confirm-engine-overwrite").replace("{engines}",Xe.join(", "))))return;const ci=[...new Set([...l.engines.map(qe=>qe.id),...Se.map(qe=>qe.id)])],$t=[];for(const qe of we.filter(me=>me.selected)){const me=ax(qe.cell,qe.engine,ci);if(!me)throw new Error(`${qe.cell.id}: ${y("fleet-backup-engine-missing")}`);$t.push(me)}const Zt=we.filter(qe=>qe.selected&&qe.exists).map(qe=>qe.cell.id);if(Zt.length&&!window.confirm(y("fleet-backup-confirm-overwrite").replace("{cells}",Zt.join(", "))))return;const Ue=Se.length?await vw(e,Se,Xe.length>0,q):{needsRestart:[]},Bt=$t.length?await gw(e,$t,q):{needsRestart:[]},Si=[...new Set([...Ue.needsRestart||[],...Bt.needsRestart||[]])];j(!1),D(`${y("fleet-backup-restored").replace("{n}",String($t.length))}${Se.length?` · ${Se.length} ${y("fleet-engines").toLowerCase()}`:""}${Si.length?` · ${y("fleet-backup-needs-restart").replace("{cells}",Si.join(", "))}`:""}`)}),Qe=h.jsxs("label",{className:"nc-field",children:[y("location"),h.jsxs("select",{value:B,onChange:ie=>{A(ie.target.value),S(null),_(null),k(""),D(""),O(!1),p({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),P([]),R(null)},children:[h.jsx("option",{value:"",children:y("local")}),n.map(ie=>h.jsxs("option",{value:ie.route.join("/"),disabled:ie.status&&ie.status!=="up",children:[ie.label,ie.status&&ie.status!=="up"?` · ${y("node-offline")}`:""]},ie.route.join("/")))]})]}),Ke=h.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":y("tab-fleet"),children:[h.jsx("button",{type:"button",role:"tab","aria-selected":H==="manage",className:`nc-set-tabbtn${H==="manage"?" on":""}`,onClick:()=>I("manage"),children:y("fleet-manage-location")}),h.jsx("button",{type:"button",role:"tab","aria-selected":H==="overview",className:`nc-set-tabbtn${H==="overview"?" on":""}`,onClick:()=>I("overview"),children:y("fleet-network-overview")})]});return Q?h.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[Ke,H==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-overview-help")}),h.jsx(tv,{token:e,targets:n,readonly:t,onPower:te,onImport:Ne})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-manage-help")}),Qe,h.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:z||v,onClick:()=>{k(""),j(!0)},children:y("fleet-backup")}),h.jsx("small",{children:y("fleet-backup-help")})]}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-cells")}),h.jsx("span",{className:"nc-fleet-head-actions",children:h.jsxs("button",{className:"nc-btn primary",disabled:z||v||!l.engines.length,onClick:()=>{var ie;k(""),_({mode:"new",form:ev((ie=l.engines[0])==null?void 0:ie.id)})},children:["+ ",y("add")]})})]}),l.cells.map(ie=>{const we=K.has(ie.id),Te=d.capabilities||[];return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:ie.id}),h.jsxs("small",{children:[ie.engine," · ",ie.cwd,we?` · ${y("service-active")}`:` · ${y("cell-off")}`]})]}),h.jsxs("span",{children:[we&&Te.includes("down")&&h.jsx("button",{className:"nc-btn ghost",disabled:z||v,onClick:()=>oe(()=>Ia(e,{cell:ie.id},q)),children:y("stop")}),!we&&Te.includes("up")&&h.jsx("button",{className:"nc-btn primary",disabled:z||v,onClick:()=>te({cell:ie.id,id:ie.id,engine:ie.engine,model:ie.model,models:ie.models,permissionPolicies:ie.permissionPolicies,active:!1,boot:ie.boot}),children:y("start")}),we&&Te.includes("restart")&&h.jsx("button",{className:"nc-btn ghost",disabled:z||v,onClick:()=>oe(()=>Ys(e,ie.id,q)),children:y("restart")}),h.jsx("button",{className:"nc-btn ghost",disabled:z||v,onClick:()=>{k(""),_({mode:"edit",original:ie,form:{...ie}})},children:y("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:z||v,onClick:()=>oe(async()=>{window.confirm(y("fleet-remove-cell").replace("{id}",ie.id))&&await dv(e,ie.id,!0,q)}),children:"×"})]})]},ie.id)}),h.jsxs("div",{className:"nc-fleet-section-head",children:[h.jsx("b",{children:y("fleet-engines")}),h.jsxs("button",{className:"nc-btn primary",disabled:z||v,onClick:()=>{k(""),S({mode:"new",form:lx()})},children:["+ ",y("add")]})]}),l.engines.map(ie=>{var Te,Se;const we=pe(ie);return h.jsxs("div",{className:"nc-fleet-item",children:[h.jsxs("span",{children:[h.jsx("b",{children:ie.label}),h.jsx("small",{children:ie.managed?`${ie.id} · ${ie.managed.client} / ${ie.managed.provider} · ${(Te=ie.managedInfo)!=null&&Te.configured?y("fleet-ready"):((Se=ie.managedInfo)==null?void 0:Se.reason)||y("fleet-not-ready")}`:`${ie.id} · ${ie.command}`}),we&&h.jsxs("small",{children:[we.envKey," · ",y(`fleet-credential-source-${we.source||"missing"}`)]})]}),h.jsxs("span",{children:[we&&h.jsx("button",{className:"nc-btn ghost",disabled:z||v,onClick:()=>{k(""),R({envKey:we.envKey,value:""})},children:we.configured?y("fleet-credential-change"):y("fleet-credential-set")}),(we==null?void 0:we.source)==="local"&&h.jsx("button",{className:"nc-btn danger",disabled:z||v,onClick:()=>xe(we),children:y("fleet-credential-forget")}),h.jsx("button",{className:"nc-btn ghost",disabled:z||v,onClick:()=>{k(""),S({mode:"edit",original:ie,form:ux(ie)})},children:y("edit")}),h.jsx("button",{className:"nc-btn danger",disabled:z||v,onClick:()=>oe(async()=>{window.confirm(y("fleet-remove-engine").replace("{id}",ie.id))&&await dw(e,ie.id,q)}),children:"×"})]})]},ie.id)})]}),m&&h.jsx(Wr,{onClose:()=>S(null),label:y("fleet-new-engine"),error:C,children:h.jsx(fx,{state:m,setState:S,busy:v,onSave:le,catalog:l.managedCatalog||[]})}),b&&h.jsx(Wr,{onClose:()=>_(null),label:y("fleet-new-cell"),error:C,children:h.jsx(px,{token:e,route:q,targets:n,location:B,setLocation:A,state:b,setState:_,engines:l.engines,busy:v,onSave:V})}),N&&h.jsx("div",{className:"nc-set-note",children:N}),C&&h.jsx("div",{className:"nc-err",children:C}),X&&h.jsx(Wr,{onClose:()=>j(!1),label:y("fleet-backup"),error:C,children:h.jsx(dx,{cells:l.cells,engines:l.engines,busy:v,canRestore:re,onRestore:Ve,onClose:()=>j(!1)})}),U&&h.jsx(Wr,{onClose:()=>R(null),label:y("fleet-credential-title"),error:C,children:h.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[h.jsx("b",{children:y("fleet-credential-title")}),h.jsx("small",{children:y("fleet-credential-help")}),h.jsxs("label",{className:"nc-field",children:[U.envKey,h.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:U.value,onChange:ie=>R({...U,value:ie.target.value})})]}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",onClick:()=>R(null),children:y("cancel")}),h.jsx("button",{className:"nc-btn primary",disabled:v||!U.value,onClick:ye,children:y("save")})]})]})}),W&&h.jsx(Wr,{onClose:()=>G(null),label:y("import-as-cell"),error:C,children:h.jsx(iv,{token:e,route:W.route||q,state:W,setState:G,busy:v,onSave:ke})}),F&&h.jsx(Oa,{cell:F,token:e,route:Array.isArray(F.route)?F.route:q,onConfirm:async ie=>{try{await de(ie)}finally{await M()}},onClose:()=>Z(null)})]}):h.jsxs("div",{className:"nc-set-tab",children:[Ke,H==="overview"?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"nc-set-info",children:y("fleet-overview-help")}),h.jsx(tv,{token:e,targets:n,readonly:t,onPower:te,onImport:Ne})]}):h.jsxs(h.Fragment,{children:[Qe,h.jsx("div",{className:"nc-set-info",children:y("fleet-editor-unavailable")})]}),C&&h.jsx("div",{className:"nc-err",children:C}),W&&h.jsx(Wr,{onClose:()=>G(null),label:y("import-as-cell"),error:C,children:h.jsx(iv,{token:e,route:W.route||q,state:W,setState:G,busy:v,onSave:ke})}),F&&h.jsx(Oa,{cell:F,token:e,route:Array.isArray(F.route)?F.route:q,onConfirm:async ie=>{try{await de(ie)}finally{await M()}},onClose:()=>Z(null)})]})}function gx({text:e}){const[t,n]=L.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return h.jsxs("div",{className:"nc-set-copyline",children:[h.jsx("code",{children:e}),h.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[h.jsx(Ze,{name:"copy",size:14})," ",y(t?"copied":"copy")]})]})}function vx({value:e}){const[t,n]=L.useState("");return L.useEffect(()=>{let s=!0;return wk.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?h.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function _x({token:e,nodes:t,settings:n,readonly:s,refresh:o}){const[l,c]=L.useState(null),[d,p]=L.useState(null),[m,S]=L.useState({}),[b,_]=L.useState(null),[v,w]=L.useState({ssh:"",sshPort:"",name:""}),[C,k]=L.useState(""),[N,D]=L.useState(""),[B,A]=L.useState(""),[J,O]=L.useState(!1),F=Date.now(),Z=n&&n.deviceName||"",W=(t||[]).filter(R=>R&&R.direction==="outbound"&&R.name&&R.ssh),G=W.find(R=>R.name===C)||W[0]||null,X=W.find(R=>R.name===N)||W[0]||null,j=X?Vg(X.tunnel,F):null,E=async(R,H)=>{c(null),p(`${R}:${H}`);try{const I=await Bh(e,R,H);H==="test"&&S(se=>({...se,[R]:I})),await o()}catch(I){c(`${R}: ${String(I.message||I)}`)}p(null)},P=async R=>{if(window.confirm(y("node-remove-confirm").replace("{name}",R))){c(null),p(`${R}:remove`);try{await bw(e,R),await o()}catch(H){c(`${R}: ${String(H.message||H)}`)}p(null)}},U=async()=>{if(c(null),G){const I=qg({name:G.name,ssh:G.ssh,sshPort:G.sshPort||""});if(!I.ok){c(y(I.error));return}p("invite");try{_(await Jp(e,{ssh:I.value.ssh,...I.value.sshPort?{sshPort:I.value.sshPort}:{}},[G.name]))}catch(se){c(String(se.message||se))}p(null);return}const R=Xr(v.name||B||Z||"NexusCrew"),H=qg({name:R,ssh:v.ssh,sshPort:v.sshPort});if(!H.ok){c(y(H.error));return}p("invite");try{_(await Jp(e,{...B||Z?{label:B||Z}:{},name:R,ssh:H.value.ssh,...H.value.sshPort?{sshPort:H.value.sshPort}:{}}))}catch(I){c(String(I.message||I))}p(null)};return h.jsxs("div",{className:"nc-set-tab",children:[h.jsx(F_,{token:e,deviceDefault:Z,readonly:s,onSuccess:o}),X&&h.jsxs("div",{className:"nc-set-form nc-local-share",children:[h.jsx("div",{className:"nc-sheet-label",children:y("share-local-heading")}),W.length>1&&h.jsxs("label",{className:"nc-field",children:[y("share-local-hub"),h.jsx("select",{value:X.name,disabled:s||!!d,onChange:R=>D(R.target.value),children:W.map(R=>h.jsx("option",{value:R.name,children:R.label||R.name},R.name))})]}),h.jsxs("label",{className:"nc-check nc-node-share",children:[h.jsx("input",{type:"checkbox",checked:X.shared===!0,disabled:s||!!d||!(j!=null&&j.up)&&!X.shared,onChange:async R=>{c(null),p(`${X.name}:share`);try{await Cw(e,X.name,R.target.checked),await o()}catch(H){c(`${X.name}: ${String(H.message||H)}`)}p(null)}}),h.jsxs("span",{children:[h.jsx("b",{children:y("share-local-through").replace("{device}",Z||y("local")).replace("{hub}",X.label||X.name)}),h.jsx("small",{children:y(X.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),h.jsx("div",{className:`nc-set-test${X.shared&&(j!=null&&j.up)?" ok":""}`,children:X.shared?y("share-local-active"):y("share-local-private")})]}),(t||[]).length===0&&h.jsx("div",{className:"nc-empty",children:y("no-nodes")}),(t||[]).map(R=>{var se,q,M,K,Q;const H=Vg(R.tunnel,F),I=m[R.name];return h.jsxs("div",{className:"nc-set-node",children:[h.jsxs("div",{className:"nc-set-node-head",children:[h.jsx("span",{className:`nc-dot ${H.up?"on":""}`}),h.jsx("b",{children:R.label||R.name}),h.jsxs("small",{children:[R.name,R.direction==="outbound"?` · SSH ${R.ssh||""}`:` · ${y("node-connected-client")}`,(se=R.tunnel)!=null&&se.transport?` · ${R.tunnel.transport} ${y("transport-used")}`:""]}),h.jsxs("span",{className:`nc-set-tunnel${H.up?" up":""}`,children:[y(H.label),H.since?` · ${H.since}`:""]})]}),R.direction==="inbound"&&h.jsx("div",{className:"nc-set-info",children:y(R.shared?"peer-shared":"peer-private")}),R.direction==="inbound"&&R.shared&&h.jsxs(h.Fragment,{children:[h.jsxs("select",{value:R.visibility||"network",disabled:s||!!d,onChange:async re=>{p(`${R.name}:visibility`);try{await Zp(e,R.name,re.target.value),await o()}catch(oe){c(String(oe.message||oe))}p(null)},children:[h.jsx("option",{value:"network",children:y("visibility-network")}),h.jsx("option",{value:"relay-only",children:y("visibility-relay")}),h.jsx("option",{value:"selected",children:y("visibility-selected")})]}),R.visibility==="selected"&&h.jsx("div",{className:"nc-set-row",children:(t||[]).filter(re=>re.name!==R.name&&re.nodeId).map(re=>{const oe=(R.selected||[]).includes(re.nodeId);return h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:oe,disabled:s||!!d,onChange:async le=>{const V=le.target.checked?[...R.selected||[],re.nodeId]:(R.selected||[]).filter(z=>z!==re.nodeId);p(`${R.name}:visibility`);try{await Zp(e,R.name,"selected",V),await o()}catch(z){c(String(z.message||z))}p(null)}})," ",re.label||re.name]},re.nodeId)})})]}),h.jsxs("div",{className:"nc-set-node-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!d,onClick:async()=>{const re=window.prompt(y("node-display-label"),R.label||R.name);if(re!=null){if(!xh(re)){c(y("err-label"));return}p(`${R.name}:label`);try{await ww(e,R.name,re),await o()}catch(oe){c(String(oe.message||oe))}p(null)}},children:y("edit")}),((q=R.health)==null?void 0:q.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"test"),children:y("node-test")}),((M=R.health)==null?void 0:M.managed)!==!1&&(H.up?h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"down"),children:y("tunnel-stop")}):h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"up"),children:y("tunnel-start")})),((K=R.health)==null?void 0:K.managed)!==!1&&h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>E(R.name,"restart"),children:y("tunnel-restart")}),h.jsx("button",{type:"button",className:"nc-btn danger",disabled:s||!!d,title:y(s?"settings-readonly":"terminate"),onClick:()=>P(R.name),children:h.jsx(Ze,{name:"trash",size:14})})]}),((Q=R.health)==null?void 0:Q.detail)&&h.jsx("div",{className:`nc-set-test${R.health.status==="healthy"?" ok":R.health.status==="passive"?"":" ko"}`,children:R.health.detail}),I&&h.jsxs("div",{className:`nc-set-test${I.ok?" ok":" ko"}`,children:[I.result,I.detail?` — ${I.detail}`:""]})]},R.name)}),h.jsxs("div",{className:"nc-set-form",children:[h.jsx("div",{className:"nc-sheet-label",children:y("invite-node")}),h.jsx("small",{className:"nc-set-hint",children:y(G?"invite-network-hint":"invite-v2-hint")}),G?h.jsxs(h.Fragment,{children:[W.length>1&&h.jsxs("label",{className:"nc-field",children:[y("invite-network-label"),h.jsx("select",{value:G.name,disabled:s||!!d,onChange:R=>{k(R.target.value),_(null)},children:W.map(R=>h.jsx("option",{value:R.name,children:R.label||R.name},R.name))})]}),h.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[y("invite-network-via"),": ",h.jsx("b",{children:G.label||G.name})," · ",G.ssh,G.sshPort?`:${G.sshPort}`:""]}),h.jsx("small",{className:"nc-set-hint",children:y("invite-network-route")})]}):h.jsxs("label",{className:"nc-field",children:[y("invite-endpoint-label"),h.jsx("input",{placeholder:"user@host",value:v.ssh,disabled:s,onChange:R=>w({...v,ssh:R.target.value})}),h.jsx("small",{className:"nc-set-hint",children:y("invite-endpoint-needed")})]}),!G&&J&&h.jsxs("div",{className:"nc-invite-advanced",children:[h.jsxs("label",{className:"nc-field",children:[y("node-ssh-port-label"),h.jsx("input",{inputMode:"numeric",placeholder:"22",value:v.sshPort,disabled:s,onChange:R=>w({...v,sshPort:R.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),h.jsxs("label",{className:"nc-field",children:[y("device-name-label"),h.jsx("input",{placeholder:Z||"NexusCrew",value:B,disabled:s,onChange:R=>A(R.target.value)}),h.jsx("small",{className:"nc-set-hint",children:y("device-name-hint")})]}),h.jsxs("label",{className:"nc-field",children:[y("node-name-label"),h.jsx("input",{placeholder:Xr(B||Z||y("node-name-ph")),value:v.name,disabled:s,onChange:R=>w({...v,name:R.target.value?Xr(R.target.value):""})})]})]}),h.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[h.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!d||!G&&!v.ssh.trim(),onClick:U,children:y("create-pairing-link")}),!G&&h.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!d,onClick:()=>O(R=>!R),children:[J?"▾":"▸"," ",y("pair-advanced")]})]}),b&&h.jsxs(h.Fragment,{children:[h.jsx(vx,{value:b.pairingUrl}),h.jsx(gx,{text:b.pairingUrl}),h.jsx("div",{className:"nc-set-info",children:y("invite-next-steps")})]})]}),l&&h.jsx("div",{className:"nc-err",children:l})]})}function yx({token:e,readonly:t}){const[n,s]=L.useState("idle"),[o,l]=L.useState(!1),[c,d]=L.useState(null);L.useEffect(()=>{let m=!1;return Uk().then(S=>{m||s(S)}),()=>{m=!0}},[]);const p=async()=>{d(null),l(!0);try{n==="subscribed"?(await qk(e),s("idle")):(await Kk(e),s("subscribed"))}catch(m){const S=String(m.message||m);S==="push-denied"?(s("denied"),d(y("push-denied"))):S==="push-unsupported"?(s("unsupported"),d(y("push-unsupported"))):d(S)}l(!1)};return n==="unsupported"?h.jsx("div",{className:"nc-set-info",children:y("push-unsupported")}):h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?y("settings-readonly"):"",onClick:p,children:y(n==="subscribed"?"push-disable":"push-enable")}),h.jsx("span",{className:"nc-set-info",children:y(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),c&&h.jsx("div",{className:"nc-err",children:c})]})}function Sx({token:e,settings:t,readonly:n,refresh:s}){const[o,l]=L.useState(null),[c,d]=L.useState(null),[p,m]=L.useState(!1),[S,b]=L.useState(!1),[_,v]=L.useState(null),[w,C]=L.useState(!0);L.useEffect(()=>{v(t&&t.update||null),C(!t||t.autoUpdate!==!1)},[t]);const k=async()=>{l(null),d(null),b(!0);try{const O=await yw(e);d(O.note||"ok"),m(!1)}catch(O){l(String(O.message||O))}b(!1)},N=async()=>{l(null),d(null),b(!0);try{const O=await kw(e);d(`${O.note||"ok"}${O.target?` (${O.target})`:""}`)}catch(O){l(String(O.message||O))}b(!1)},D=async O=>{l(null),d(null),b(!0);try{await _v(e,{autoUpdate:O}),C(O),s&&await s()}catch(F){l(String(F.message||F))}b(!1)},B=async()=>{l(null),d(null),b(!0);try{v(await xw(e))}catch(O){l(String(O.message||O))}b(!1)},A=async()=>{l(null),d(null),b(!0);try{const O=await Ew(e);v(O),d(y("npm-update-restarting"))}catch(O){l(String(O.message||O))}b(!1)},J=t&&t.service;return h.jsxs("div",{className:"nc-set-tab",children:[t&&h.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,h.jsx("br",{}),J&&J.installed?y("service-installed"):y("service-missing"),J&&J.installed?` · ${J.active?y("service-active"):y("service-inactive")}`:"",J?` · boot ${J.boot?"on":"off"}`:""]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?y("settings-readonly"):"",onClick:()=>{l(null),d(null),m(!0)},children:y("token-rotate")}),h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?y("settings-readonly"):"",onClick:N,children:y("service-regenerate")})]}),h.jsxs("div",{className:"nc-set-form nc-update-settings",children:[h.jsxs("label",{className:"nc-check",children:[h.jsx("input",{type:"checkbox",checked:w,disabled:n||S||_&&!_.supported,onChange:O=>D(O.target.checked)}),h.jsxs("span",{children:[h.jsx("b",{children:y("npm-auto-update")}),h.jsx("small",{children:y("npm-auto-update-help")})]})]}),_&&h.jsxs("div",{className:"nc-set-info",children:[y("npm-update-current")," v",_.current,_.latest?` · ${y("npm-update-latest")} v${_.latest}`:""," · ",y(`npm-update-${_.supported?_.phase:"unsupported"}`)]}),h.jsxs("div",{className:"nc-set-row",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S||!_||!_.supported,onClick:B,children:y("npm-update-check")}),_&&_.available&&h.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||S||_.phase==="installing",onClick:A,children:y("npm-update-install")})]}),_&&_.lastError&&h.jsx("div",{className:"nc-err",children:_.lastError})]}),h.jsx(yx,{token:e,readonly:n}),p&&h.jsxs("div",{className:"nc-set-confirm",children:[h.jsx("div",{children:y("token-rotate-explain")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>m(!1),children:y("cancel")}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:S,onClick:k,children:y("confirm")})]})]}),c&&h.jsx("div",{className:"nc-set-note",children:c}),o&&h.jsx("div",{className:"nc-err",children:o})]})}function wx({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){yi();const[l,c]=L.useState(n),[d,p]=L.useState(null),[m,S]=L.useState([]),[b,_]=L.useState(!1),[v,w]=L.useState(null),C=Oh(e),k=L.useCallback(async()=>{try{const N=await mv(e);p(N),w(null)}catch(N){w(String(N.message||N))}try{const N=await gv(e);S(N.nodes||[])}catch(N){w(String(N.message||N))}},[e]);return L.useEffect(()=>{k();const N=setInterval(k,5e3);return()=>clearInterval(N)},[k]),L.useEffect(()=>{let N=!1;return Tt("/api/config",e).then(D=>D.json()).then(D=>{N||_(!!D.readonlyDefault)}).catch(()=>{}),()=>{N=!0}},[e]),h.jsx("div",{className:"nc-set-overlay",onClick:t,children:h.jsxs("div",{className:"nc-set-panel",onClick:N=>N.stopPropagation(),children:[h.jsxs("div",{className:"nc-set-head",children:[h.jsx(Ze,{name:"gear",size:18}),h.jsx("b",{children:y("settings")}),h.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:y("close"),children:h.jsx(Ze,{name:"x",size:18})})]}),b&&h.jsx("div",{className:"nc-set-readonly",children:y("settings-readonly")}),v&&h.jsx("div",{className:"nc-err",children:v}),h.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","system"].map(N=>h.jsx("button",{type:"button",className:`nc-set-tabbtn${l===N?" on":""}`,onClick:()=>c(N),children:y(`tab-${N}`)},N))}),h.jsxs("div",{className:"nc-set-body",children:[l==="nodes"&&h.jsx(_x,{token:e,nodes:m,settings:d,readonly:b,refresh:k}),l==="fleet"&&h.jsx(mx,{token:e,readonly:b,startNewCell:o,initialLocation:s,targets:C.map(N=>({route:N.route,label:N.label||N.name,status:N.status}))}),l==="system"&&h.jsx(Sx,{token:e,settings:d,readonly:b,refresh:k})]})]})})}function bx({token:e,initialPair:t,onPairDone:n,onDone:s}){yi();const[o,l]=L.useState(t?"pair":"welcome"),[c,d]=L.useState(!1),[p,m]=L.useState(null),S=async()=>{d(!0),m(null);try{await _v(e,{wizardDone:!0}),n&&n(),s()}catch(b){m(String(b.message||b)),d(!1)}};return h.jsx("div",{className:"nc-wiz-overlay",children:h.jsxs("div",{className:"nc-wiz",children:[h.jsxs("div",{className:"nc-wiz-head",children:[h.jsx("b",{children:y("wizard-title")}),h.jsx("small",{children:y("hydra-simple")})]}),o==="welcome"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:y("local-ready")}),h.jsxs("div",{className:"nc-sheet-actions",children:[h.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:S,children:y("local-only")}),h.jsx("button",{className:"nc-btn primary",disabled:c,onClick:()=>l("pair"),children:y("add-node")})]})]}),o==="pair"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx(F_,{token:e,initial:t||"",autoStart:!!t,onBusyChange:d,onSuccess:async()=>{n&&n(),l("done")}}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn ghost",disabled:c,onClick:()=>{n&&n(),l("welcome")},children:y("back")})})]}),o==="done"&&h.jsxs("div",{className:"nc-wiz-body",children:[h.jsx("div",{className:"nc-wiz-done",children:y("node-connected")}),h.jsx("div",{className:"nc-sheet-actions",children:h.jsx("button",{className:"nc-btn primary",disabled:c,onClick:S,children:y("finish")})})]}),p&&h.jsx("div",{className:"nc-err",children:p})]})})}function Cx(e,t){if(typeof EventSource>"u"||!e)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return n.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{n.close()}catch{}}}const kx=6e3,xx=12e3;function Ex({n:e,onClose:t}){return h.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[h.jsxs("div",{className:"nc-ntf-toast-txt",children:[h.jsx("b",{children:e.title}),e.body&&h.jsx("small",{children:e.body}),e.session&&h.jsx("span",{className:"nc-ntf-from",children:e.session})]}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:y("close"),children:h.jsx(Ze,{name:"x",size:14})})]})}function Nx({ask:e,token:t,onAnswered:n}){const[s,o]=L.useState(""),[l,c]=L.useState(!1),[d,p]=L.useState(null),m=async S=>{const b=String(S||"").trim();if(!(!b||l)){p(null),c(!0);try{await Rw(t,e.id,b),n(e.id)}catch(_){p(String(_.message||_))}c(!1)}};return h.jsxs("div",{className:"nc-ask-card",children:[h.jsxs("div",{className:"nc-ask-head",children:[h.jsx("span",{className:"nc-ntf-from",children:e.session}),h.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),h.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&h.jsx("div",{className:"nc-ask-opts",children:e.options.map(S=>h.jsx("button",{type:"button",className:"nc-btn ghost",disabled:l,onClick:()=>m(S),children:S},S))}),h.jsxs("div",{className:"nc-ask-reply",children:[h.jsx("textarea",{rows:2,placeholder:y("ask-reply-ph"),value:s,disabled:l,onChange:S=>o(S.target.value)}),h.jsx("button",{type:"button",className:"nc-btn primary",disabled:l||!s.trim(),onClick:()=>m(s),children:y("send")})]}),d&&h.jsx("div",{className:"nc-err",children:d})]})}function Rx({token:e}){yi();const[t,n]=L.useState([]),[s,o]=L.useState([]),[l,c]=L.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),d=L.useRef(0),p=L.useCallback(b=>{n(_=>_.filter(v=>v.key!==b))},[]),m=L.useCallback(b=>{const _=`t${d.current+=1}`;n(v=>[...v.slice(-3),{...b,key:_}]),setTimeout(()=>p(_),b.urgency==="high"?xx:kx)},[p]);L.useEffect(()=>{if(!e)return;let b=!1;Nw(e).then(v=>{b||o(v.asks||[])}).catch(()=>{});const _=Cx(e,v=>{v.type==="notify"?m(v):v.type==="ask"&&v.ask&&v.ask.id?o(w=>w.some(C=>C.id===v.ask.id)?w:[...w,v.ask]):v.type==="ask-answered"&&v.id&&o(w=>w.filter(C=>C.id!==v.id))});return()=>{b=!0,_()}},[e,m]);const S=b=>o(_=>_.filter(v=>v.id!==b));return h.jsxs(h.Fragment,{children:[t.length>0&&h.jsx("div",{className:"nc-ntf-toasts",children:t.map(b=>h.jsx(Ex,{n:b,onClose:()=>p(b.key)},b.key))}),s.length>0&&!l&&h.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>c(!0),title:y("asks-title"),children:["? ",h.jsx("span",{className:"nc-ask-count",children:s.length})]}),s.length>0&&l&&h.jsxs("div",{className:"nc-ask-panel",children:[h.jsxs("div",{className:"nc-ask-panel-head",children:[h.jsx("b",{children:y("asks-title")}),h.jsx("span",{className:"nc-ask-count",children:s.length}),h.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>c(!1),title:y("close"),children:h.jsx(Ze,{name:"x",size:16})})]}),h.jsx("div",{className:"nc-ask-panel-body",children:s.map(b=>h.jsx(Nx,{ask:b,token:e,onAnswered:S},b.id))})]})]})}const Tu=e=>Qi(cr(e)).length===0,Au=e=>Array.isArray(e)?e.join("/"):"";function Px(e){const t=new Set,n=[];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),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return n.sort((s,o)=>s.label.localeCompare(o.label))}function Vs(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function ir(e,t,n,s=!1,o=!0){const l=t.instanceId;return{...e,id:Yr(s?null:l,e.name),ownerId:l,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(n)?n:[],layout:bh(e.layout,l,n)}}function Dx(e,t,n,s,o=[]){const[l,c]=L.useState([]),[d,p]=L.useState(!1),[m,S]=L.useState("idle"),[b,_]=L.useState(""),[v,w]=L.useState(""),C=L.useRef([]),k=L.useRef([]),N=L.useRef(""),D=L.useRef(t),B=L.useRef(n),A=L.useRef(!1),J=L.useRef(!0),O=L.useRef(""),F=L.useMemo(()=>Px(o),[o]),Z=F.map(q=>`${q.instanceId}:${Au(q.route)}:${q.status}:${q.label}`).join("|");k.current=F,B.current=n,D.current=t,C.current=l;const W=L.useCallback(q=>Ch(q.layout,N.current,k.current),[]),G=L.useCallback((q,M=!0,K=D.current)=>{const Q=pg(q,Ra()),re=C.current.some(le=>le.id===K);C.current=Q,c(Q);const oe=Q.find(le=>le.id===K);if(M&&oe){J.current=!0;const le=W(oe);s(le),oe.local&&GC(oe.name,le)}else re&&!oe&&(J.current=!0,s(Vr()),_("deck non più condiviso dal nodo owner"));qC(Q.filter(le=>le.local).map(le=>le.name))},[s,W]),X=L.useCallback(async q=>{let M=await ya(e);const K=M.decks.find(Q=>Q.name==="main");if(M.decks.length===1&&K&&K.revision===0&&Tu(K.layout)){const Q=KC(),re=cr(kh("main")||Vr());if(!Tu(re)){const oe=bh(re,q,[]);M.decks[0]=await Sa(e,"main",oe,0,[])}for(const oe of Q.filter(le=>le!=="main"))try{let le=await em(e,oe,[]);const V=cr(kh(oe)||Vr());Tu(V)||(le=await Sa(e,oe,bh(V,q,[]),le.revision,[]))}catch{}M=await ya(e)}return M},[e]),j=L.useCallback(async({migrate:q=!1}={})=>{const M=await Ah(e,[]),K=Li.test(String(M.instanceId||""))?M.instanceId:"";if(!K)throw new Error("instanceId locale non disponibile");N.current=K,w(K);const[Q,re]=await Promise.all([q?X(K):ya(e),Qp(e,[]).catch(()=>({nodes:[]}))]),oe={instanceId:K,route:[],label:"Local"},le=Q.decks.map(z=>ir(z,oe,re.nodes,!0,!0)),V=C.current;return await Promise.all(k.current.map(async z=>{if(z.status!=="up"){le.push(...V.filter(pe=>!pe.local&&pe.ownerId===z.instanceId).map(pe=>({...pe,ownerRoute:[...z.route],ownerLabel:z.label,available:!1})));return}try{const[pe,ye]=await Promise.all([ya(e,z.route),Qp(e,z.route).catch(()=>({nodes:[]}))]);le.push(...pe.decks.map(xe=>ir(xe,z,ye.nodes,!1,!0)))}catch{le.push(...V.filter(ye=>!ye.local&&ye.ownerId===z.instanceId).map(ye=>({...ye,ownerRoute:[...z.route],ownerLabel:z.label,available:!1})))}})),le.sort((z,pe)=>z.local===pe.local?z.ownerLabel.localeCompare(pe.ownerLabel)||(z.name==="main"?-1:pe.name==="main"?1:z.name.localeCompare(pe.name)):z.local?-1:1),le},[e,X,Z]);L.useEffect(()=>{if(!e)return;let q=!1;const M=O.current!==e;return O.current=e,j({migrate:M}).then(K=>{if(q)return;const Q=C.current.find(le=>le.id===D.current),re=K.find(le=>le.id===D.current),oe=re&&(!Q||re.revision>Q.revision||Q.available!==re.available||Au(Q.ownerRoute)!==Au(re.ownerRoute));G(K,M||!!oe&&!A.current),p(!0),re&&_("")}).catch(K=>{q||(p(!0),_(String(K.message||K)))}),()=>{q=!0}},[G,j,Z,e]);const E=L.useCallback(async(q=D.current)=>{if(!d||!A.current)return!0;const M=C.current.find(K=>K.id===q);if(!M)return _(`deck inesistente: ${q}`),!1;if(M.available===!1)return _(`nodo owner offline: ${M.ownerLabel}`),!1;S("saving");try{const K=dg(cr(B.current),M.ownerId,M.ownerTopology),Q=await Sa(e,M.name,K,M.revision,M.ownerRoute),re=ir(Q,Vs(M),M.ownerTopology,M.local,!0);return G(C.current.map(oe=>oe.id===q?re:oe),!1),A.current=!1,S("saved"),_(""),setTimeout(()=>S("idle"),1500),!0}catch(K){if(S("error"),_(String(K.message||K)),K.status===409&&K.data&&K.data.current){const Q=C.current.find(oe=>oe.id===q),re=ir(K.data.current,Vs(Q),Q.ownerTopology,Q.local,!0);G(C.current.map(oe=>oe.id===q?re:oe),!1)}return!1}},[d,e,G]);return L.useEffect(()=>{if(!d)return;if(J.current){J.current=!1;return}A.current=!0,S("saving");const q=setTimeout(E,650);return()=>clearTimeout(q)},[n,d,E]),L.useEffect(()=>{if(!d)return;const q=setInterval(async()=>{try{const M=await j(),K=C.current.find(oe=>oe.id===D.current),Q=M.find(oe=>oe.id===D.current),re=Q&&(!K||Q.revision>K.revision||K.available!==Q.available);G(M,re&&!A.current)}catch{}},5e3);return()=>clearInterval(q)},[d,j,G]),{decks:l,records:l,localNodeId:v,ready:d,saveState:m,error:b,setError:_,saveNow:E,select:async q=>{if(A.current&&!await E(D.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const M=C.current.find(K=>K.id===q);if(!M)throw new Error(`deck inesistente: ${q}`);return A.current=!1,J.current=!0,W(M)},add:async(q,M=null)=>{const K=M===un?C.current.find(oe=>oe.local):M?C.current.find(oe=>oe.ownerId===M):null;if(!K||K.available===!1)throw new Error("nodo owner non disponibile");const Q=await em(e,q,K.ownerRoute),re=ir(Q,Vs(K),K.ownerTopology,K.local,!0);return G([...C.current,re],!1),re},rename:async(q,M)=>{const K=C.current.find(V=>V.id===q);if(!K)throw new Error("deck inesistente");if(q===D.current&&A.current&&!await E(q))throw new Error(`salvataggio di "${K.name}" fallito: rinomina annullata`);const Q=C.current.find(V=>V.id===q);if(!Q)throw new Error("deck inesistente");const re=await Pw(e,Q.name,M,Q.revision,Q.ownerRoute),oe=ir(re,Vs(Q),Q.ownerTopology,Q.local,!0),le=Q.local?un:Q.ownerId;return uu(YC(Ra(),le,q,oe.id)),G(C.current.map(V=>V.id===q?oe:V),!1),oe},remove:async q=>{const M=C.current.find(Q=>Q.id===q);if(!M)throw new Error("deck inesistente");q===D.current&&(A.current=!1),await Dw(e,M.name,M.revision,M.ownerRoute);const K=M.local?un:M.ownerId;uu(XC(Ra(),K,q)),G(C.current.filter(Q=>Q.id!==q),!1)},reorder:(q,M)=>{const K=C.current.find(z=>z.id===q),Q=C.current.find(z=>z.id===M);if(!K||!Q)return!1;const re=K.local?un:K.ownerId,oe=Q.local?un:Q.ownerId;if(re!==oe)return!1;const le=C.current.filter(z=>(z.local?un:z.ownerId)===re).map(z=>z.id),V=uu(VC(Ra(),re,q,M,le));return G(pg(C.current,V),!1),!0},addTileTo:async(q,M)=>{const K=C.current.find(z=>z.id===q);if(!K)throw new Error("deck inesistente");if(K.available===!1)throw new Error(`nodo owner offline: ${K.ownerLabel}`);const Q=R_(M,N.current,k.current);if(!Q)throw new Error("riferimento sessione non valido");const re=W(K),oe=dg(E_(re,Q),K.ownerId,K.ownerTopology),le=await Sa(e,K.name,oe,K.revision,K.ownerRoute),V=ir(le,Vs(K),K.ownerTopology,K.local,!0);return G(C.current.map(z=>z.id===q?V:z),!1),V},localMainId:Yr(null,"main"),parseDeckId:Jh}}const Lx="/sw.js",Eh="nc-sw-update";let Nh=null,Rh=!1,Ph=null,X_=Object.freeze({needed:!1,kind:null,version:""}),G_=!1;function Q_(){typeof window<"u"&&window.dispatchEvent(new Event(Eh))}function J_(){const e=Ph||(Rh?{kind:"reload",version:""}:null);X_=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function nv(){return X_}function Mx(e){return typeof window>"u"?()=>{}:(window.addEventListener(Eh,e),()=>window.removeEventListener(Eh,e))}function nd(e){Rh!==e&&(Rh=e,J_(),Q_())}function jx(e,t,n){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&n&&t!==n&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(Ph);Ph=s,J_(),o||Q_()}function Tx(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&nd(!0)})}function Ax(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{G_&&location.reload()}),navigator.serviceWorker.register(Lx).then(e=>{Nh=e,e.waiting&&nd(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&Tx(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function Bx(){G_=!0,nd(!1);const e=Nh&&Nh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function Ix({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),l=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:l};const c=new URLSearchParams(o),d=c.get("token")||"",p=c.get("pair")||"",m=p?`${t||""}${n||""}#pair=${p}`:"";return{token:d,pair:m,nextUrl:l}}const Z_=9,ey=24,ty="nc_side_w",rv="nc_side_min",Ox=240,sv="(min-width:1024px) and (pointer:fine)";function zx(){const e=Number(localStorage.getItem(ty));return e>=180&&e<=480?e:Ox}function Fx(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=Z_&&e<=ey?e:13}function Hx(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=Ix({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(n){e.pair=n;try{sessionStorage.setItem("nc_pair",n)}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 $x(e){try{return cr(kh(e))}catch{return Vr()}}function ov(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 Wx(){const[e,t]=L.useState(()=>window.matchMedia(sv).matches);return L.useEffect(()=>{const n=window.matchMedia(sv),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function av({session:e,node:t,token:n,readonly:s=!1,onBack:o}){yi();const[l,c]=L.useState(!1),[d,p]=L.useState(()=>window.matchMedia("(pointer: coarse)").matches),[m,S]=L.useState(null),[b,_]=L.useState(Fx),[v,w]=L.useState(""),C=W=>_(G=>{const X=Math.max(Z_,Math.min(ey,G+W));return localStorage.setItem("nc_fontsize",String(X)),X}),k=L.useRef(()=>{}),N=L.useRef(()=>!1),D=L.useRef(()=>{}),B=L.useRef(!1),[A,J]=L.useState(!1),[O,F]=L.useState(!1),Z=()=>{B.current=!B.current,J(B.current)};return L.useEffect(()=>{let W=!0;const G=t?t.split("/"):[],X=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function j(){let P=null,U=null;try{const I=await(await Tt(`${X}/sessions`,n)).json();Array.isArray(I.sessions)&&(P=I.sessions.find(se=>se.name===e))}catch{}try{const H=await dr(n,G);H.available&&Array.isArray(H.cells)&&(U=H.cells.find(I=>I.tmuxSession===e))}catch{}if(!W)return;let R="";U?R=`${U.engine}${U.key?`·${U.key}`:""}`:P&&(R=P.attached?`attached · ${ov(P.activity)}`:P.activity?ov(P.activity):""),w(R)}j();const E=setInterval(j,4e3);return()=>{W=!1,clearInterval(E)}},[e,t,n]),h.jsxs("div",{className:"nc-app",children:[h.jsxs("header",{className:"nc-bar nc-bar-single",children:[h.jsxs("button",{onClick:o,title:y("sessions"),children:[h.jsx(Ze,{name:"chevronLeft",size:18}),h.jsx("span",{className:"nc-bar-label",children:y("sessions")})]}),h.jsxs("span",{className:"nc-bar-center",children:[h.jsx("b",{children:t?`${t}:${e}`:e}),v&&h.jsx("small",{className:"nc-bar-sub",children:v})]}),h.jsxs("span",{className:"nc-bar-right",children:[h.jsx("button",{onClick:()=>C(-1),title:y("zoom-out"),children:h.jsx(Ze,{name:"zoomOut",size:18})}),h.jsx("button",{onClick:()=>C(1),title:y("zoom-in"),children:h.jsx(Ze,{name:"zoomIn",size:18})}),h.jsx("button",{onClick:()=>p(W=>!W),title:y("composer"),children:h.jsx(Ze,{name:"keyboard",size:20})}),h.jsx("button",{onClick:()=>c(W=>!W),title:y("files"),children:h.jsx(Ze,{name:"folder",size:20})})]})]}),h.jsx("div",{className:"nc-termwrap",children:h.jsx(S_,{session:e,node:t,token:n,readonly:s,takeSize:!0,sendRef:k,composerRef:N,actionRef:D,ctrlRef:B,setCtrlArmed:J,onFiles:S,fontSize:b,selectionMode:O,onSelectionModeChange:F})}),h.jsx(wC,{onKeyboard:()=>p(W=>!W),send:W=>k.current(W),action:W=>D.current(W),ctrlArmed:A,onCtrl:Z,selectionMode:O,onSelectionMode:F}),d&&h.jsx(b_,{submitText:W=>N.current(W),token:n,session:e,node:t}),l&&h.jsx(w_,{session:e,node:t,token:n,filesEvent:m,onClose:()=>c(!1)})]})}function Ux(){yi();const[e]=L.useState(Hx),[t,n]=L.useState(e.token),[s,o]=L.useState(e.pair||""),l=L.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[c,d]=L.useState(!1),p=Wx(),[m]=L.useState(()=>UC(typeof location<"u"?location.pathname:"/")),[S,b]=L.useState(m.id),_=S===Yr(null,_i),[v,w]=L.useState(null),C=ce=>w(Hn(ce)),[k,N]=L.useState([]),[D,B]=L.useState([]),[A,J]=L.useState(()=>m.ownerId?Vr():$x(m.name)),[O,F]=L.useState(null),[Z,W]=L.useState(null),G=ce=>W(Hn(ce)),X=Oh(t,p),j=L.useMemo(()=>(X||[]).filter(ce=>ce.instanceId).map(ce=>({instanceId:ce.instanceId,route:ce.route,label:ce.label,status:ce.status})),[X]),E=Dx(t,S,A,J,j),P=E.decks;L.useEffect(()=>{const ce=new Map;for(const Pe of X||[]){const Oe=(Pe.route||[Pe.name]).join("/"),Et=new Set((Pe.sessions||[]).map(ui=>ui.name));for(const ui of Pe.cells||[])!ui.cell||!ui.tmuxSession||ui.cell===ui.tmuxSession||Et.has(ui.cell)||ce.set(`${Oe}:${ui.cell}`,`${Oe}:${ui.tmuxSession}`)}J(Pe=>LC(Pe,ce))},[X]),L.useEffect(()=>{E.localNodeId&&J(ce=>{const Pe=Ch(ce,E.localNodeId,j);return JSON.stringify(Pe)===JSON.stringify(ce)?ce:Pe})},[j,E.localNodeId]);const[U,R]=L.useState(null),[H,I]=L.useState(!1),[se,q]=L.useState(zx),[M,K]=L.useState(!_),[Q,re]=L.useState(()=>_?localStorage.getItem(rv)==="1":!0),[oe,le]=L.useState(!1),[V,z]=L.useState("nodes"),[pe,ye]=L.useState(!1),[xe,te]=L.useState(""),de=(ce="nodes",Pe=!1,Oe="")=>{z(ce),ye(Pe),te(Oe),le(!0)},[Ne,ke]=L.useState(!1),[Ve,Qe]=L.useState(!1);L.useEffect(()=>{try{localStorage.setItem(ty,String(se))}catch{}},[se]),L.useEffect(()=>{try{localStorage.setItem(rv,Q?"1":"")}catch{}},[Q]),L.useEffect(()=>{if(!t)return;let ce=!1;return Promise.all([mv(t),Tt("/api/config",t).then(Pe=>Pe.json())]).then(([Pe,Oe])=>{ce||(Qe(!!Oe.readonlyDefault),(Pe.firstRun===!0&&!Oe.readonlyDefault||s)&&ke(!0))}).catch(()=>{}),()=>{ce=!0}},[t,s]);const Ke=L.useCallback(async()=>{try{const Pe=await(await Tt("/api/sessions",t)).json();Pe.error||N(Pe.sessions||[])}catch{}try{const ce=await dr(t);B(ce.available?ce.cells||[]:[])}catch{B([])}},[t]);L.useEffect(()=>{if(!p)return;Ke();const ce=setInterval(Ke,4e3);return()=>clearInterval(ce)},[p,Ke]),L.useEffect(()=>{let ce=!1;return Tt("/api/config",t).then(Pe=>Pe.json()).then(Pe=>{ce||jx(Pe.version,Pe.uiVersion,"0.8.17")}).catch(()=>{}),()=>{ce=!0}},[t]);const ie=new Set([...k.map(ce=>ce.name),...X.flatMap(ce=>ce.sessions.map(Pe=>Pe.key))]),we=Qi(A),Te=ce=>J(Pe=>{const Oe=R_(ce,E.localNodeId,j)||ce,Et=E_(Pe,Oe);return Et===Pe&&Qi(Pe).length>=9&&E.setError(y("grid-full")),Et}),Se=async(ce,Pe=[])=>{try{await Th(t,ce,Pe)}catch{return}const Oe=Pe.length?`${Pe.join("/")}:${ce}`:ce;J(Et=>Xa(Et,Oe)),Ke()},Xe=async(ce,Pe,Oe=[])=>{try{await fv(t,ce,Pe,Oe)}catch{return}Ke()},ci=async ce=>{if(!U)return;const{cell:Pe}=U,Oe=Array.isArray(U.route)?U.route:[];ce.action==="up"?await Mh(t,{cell:Pe,boot:!!ce.boot,...ce.engine?{engine:ce.engine}:{},...ce.model!==void 0?{model:ce.model}:{},...ce.permissionPolicy?{permissionPolicy:ce.permissionPolicy}:{}},Oe):await Ia(t,{cell:Pe,boot:!!ce.boot},Oe),Ke()},$t=async ce=>{if(!(!(ce!=null&&ce.direct)||H)){I(!0);try{await Bh(t,ce.name,ce.tunnelStatus==="up"?"down":"up")}finally{I(!1)}}},Zt=ce=>{const Pe=P.find(Oe=>Oe.id===ce);if(!Pe)return!1;try{const Oe=window.open(cu(Pe,t),"_blank");return Oe&&(Oe.opener=null),!!Oe}catch{return!1}},Ue=async ce=>{if(!ce||ce===S)return;const Pe=await E.select(ce),Oe=E.records.find(Et=>Et.id===ce);b(ce),J(Pe),F(null),W(null);try{history.replaceState(null,"",cu(Oe||ce,null))}catch{}},Bt=async(ce,Pe)=>{const Oe=await E.add(ce,Pe);await Ue(Oe.id)},Si=async(ce,Pe)=>{const Oe=await E.rename(ce,Pe);if(ce===S){b(Oe.id),J(Ch(Oe.layout,E.localNodeId,j)),F(null),W(null);try{history.replaceState(null,"",cu(Oe,null))}catch{}}},qe=async ce=>{await E.remove(ce),ce===S&&await Ue(E.localMainId)},me=async(ce,Pe)=>{!Pe||Pe===S||(await E.addTileTo(Pe,ce),J(Oe=>Xa(Oe,ce)))};if(!t)return h.jsxs("div",{className:"nc-auth",children:[h.jsx("p",{children:y("auth-prompt")}),h.jsx("input",{onChange:ce=>n(ce.target.value.trim()),placeholder:"token"}),h.jsxs("label",{children:[h.jsx("input",{type:"checkbox",checked:c,onChange:ce=>d(ce.target.checked)})," ",y("remember-device")]}),h.jsx("button",{onClick:()=>{(c?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const $e=h.jsxs(h.Fragment,{children:[oe&&h.jsx(wx,{token:t,initialTab:V,initialLocation:xe,startNewCell:pe,onClose:()=>{le(!1),ye(!1),te("")}}),Ne&&h.jsx(bx,{token:t,initialPair:s,onPairDone:l,onDone:()=>ke(!1)}),h.jsx(Rx,{token:t})]});if(!p)return v?h.jsxs(h.Fragment,{children:[h.jsx(av,{session:v.session,node:v.node,token:t,readonly:Ve,onBack:()=>w(null)}),$e]}):h.jsxs(h.Fragment,{children:[h.jsx(Gw,{onPick:C,token:t,onSettings:de}),$e]});const Je=_||!M;return h.jsxs("div",{className:"nc-workspace",children:[Je&&h.jsx(xC,{sessions:k,cells:D,activeSessions:we,nodeGroups:X,onPick:G,onAddTile:Te,onPower:R,onNodePower:$t,onKill:Se,onVisibility:Xe,onNew:()=>de("fleet",!0),onSettings:de,width:se,collapsed:Q,onResize:q,onToggleCollapse:()=>re(ce=>!ce)}),h.jsxs("div",{className:"nc-workspace-main",children:[h.jsx(JC,{decks:P,currentDeck:S,onCreate:Bt,onRename:Si,onDelete:qe,onReorder:E.reorder,onOpenWindow:Zt,onNavigate:Ue,saveState:E.saveState,error:E.error,sidebarVisible:Je,onToggleSidebar:_?null:()=>K(ce=>!ce)}),h.jsx(zC,{layout:A,onLayoutChange:J,token:t,readonly:Ve,sessionsAlive:ie,focusSession:O,onFocus:F,onOpenSingle:G,decks:P,currentDeck:S,onSendToDeck:me})]}),Z&&h.jsx("div",{className:"nc-single-overlay",children:h.jsx(av,{session:Z.session,node:Z.node,token:t,readonly:Ve,onBack:()=>W(null)})}),U&&h.jsx(Oa,{cell:U,token:t,route:Array.isArray(U.route)?U.route:[],onConfirm:ci,onClose:()=>R(null)}),$e]})}function Kx(){yi();const e=L.useSyncExternalStore(Mx,nv,nv);if(!e.needed)return null;const t=e.kind==="install"?y("install-version-mismatch").replace("{v}",e.version):y("update-available").replace("{v}",e.version).replace(" "," ").trim();return h.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[h.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&h.jsx("button",{className:"nc-update-btn",onClick:Bx,children:y("reload")})]})}Ax();ow.createRoot(document.getElementById("root")).render(h.jsxs(ZS.StrictMode,{children:[h.jsx(Ux,{}),h.jsx(Kx,{})]}));
|