@mmmbuto/nexuscrew 0.8.26 → 0.8.28
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/CHANGELOG.md +46 -0
- package/README.md +44 -9
- package/frontend/dist/assets/{index-DqG-mDnV.css → index-BAzlX2nP.css} +1 -1
- package/frontend/dist/assets/index-DiKMLCvW.js +93 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/cli/commands.js +19 -2
- package/lib/cli/doctor.js +166 -1
- package/lib/cli/service.js +10 -5
- package/lib/diagnostics/routes.js +43 -0
- package/lib/diagnostics/store.js +139 -0
- package/lib/fleet/builtin.js +201 -16
- package/lib/fleet/causes.js +68 -0
- package/lib/fleet/cell-exec.js +17 -2
- package/lib/fleet/definitions.js +86 -4
- package/lib/fleet/launch.js +19 -1
- package/lib/fleet/managed.js +73 -12
- package/lib/fleet/routes.js +44 -5
- package/lib/fleet/runtime.js +69 -33
- package/lib/nodes/aliases.js +122 -0
- package/lib/proxy/federation.js +26 -2
- package/lib/runtime/env.js +60 -1
- package/lib/server.js +28 -5
- package/lib/settings/routes.js +32 -0
- package/lib/update/manager.js +8 -0
- package/package.json +1 -1
- package/frontend/dist/assets/index-DkIPrmX6.js +0 -91
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const u of a.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&s(u)}).observe(document,{childList:!0,subtree:!0});function i(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=i(o);fetch(o.href,a)}})();function sh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var hu={exports:{}},to={},fu={exports:{}},Je={};/**
|
|
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 pm;function FS(){if(pm)return Je;pm=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),b=Symbol.iterator;function S(L){return L===null||typeof L!="object"?null:(L=b&&L[b]||L["@@iterator"],typeof L=="function"?L:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,x={};function k(L,z,oe){this.props=L,this.context=z,this.refs=x,this.updater=oe||w}k.prototype.isReactComponent={},k.prototype.setState=function(L,z){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,z,"setState")},k.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function C(){}C.prototype=k.prototype;function P(L,z,oe){this.props=L,this.context=z,this.refs=x,this.updater=oe||w}var A=P.prototype=new C;A.constructor=P,y(A,k.prototype),A.isPureReactComponent=!0;var M=Array.isArray,ee=Object.prototype.hasOwnProperty,q={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function Z(L,z,oe){var ce,he={},me=null,G=null;if(z!=null)for(ce in z.ref!==void 0&&(G=z.ref),z.key!==void 0&&(me=""+z.key),z)ee.call(z,ce)&&!B.hasOwnProperty(ce)&&(he[ce]=z[ce]);var J=arguments.length-2;if(J===1)he.children=oe;else if(1<J){for(var ge=Array(J),Me=0;Me<J;Me++)ge[Me]=arguments[Me+2];he.children=ge}if(L&&L.defaultProps)for(ce in J=L.defaultProps,J)he[ce]===void 0&&(he[ce]=J[ce]);return{$$typeof:e,type:L,key:me,ref:G,props:he,_owner:q.current}}function H(L,z){return{$$typeof:e,type:L.type,key:z,ref:L.ref,props:L.props,_owner:L._owner}}function te(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function K(L){var z={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(oe){return z[oe]})}var T=/\/+/g;function E(L,z){return typeof L=="object"&&L!==null&&L.key!=null?K(""+L.key):z.toString(36)}function j(L,z,oe,ce,he){var me=typeof L;(me==="undefined"||me==="boolean")&&(L=null);var G=!1;if(L===null)G=!0;else switch(me){case"string":case"number":G=!0;break;case"object":switch(L.$$typeof){case e:case t:G=!0}}if(G)return G=L,he=he(G),L=ce===""?"."+E(G,0):ce,M(he)?(oe="",L!=null&&(oe=L.replace(T,"$&/")+"/"),j(he,z,oe,"",function(Me){return Me})):he!=null&&(te(he)&&(he=H(he,oe+(!he.key||G&&G.key===he.key?"":(""+he.key).replace(T,"$&/")+"/")+L)),z.push(he)),1;if(G=0,ce=ce===""?".":ce+":",M(L))for(var J=0;J<L.length;J++){me=L[J];var ge=ce+E(me,J);G+=j(me,z,oe,ge,he)}else if(ge=S(L),typeof ge=="function")for(L=ge.call(L),J=0;!(me=L.next()).done;)me=me.value,ge=ce+E(me,J++),G+=j(me,z,oe,ge,he);else if(me==="object")throw z=String(L),Error("Objects are not valid as a React child (found: "+(z==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":z)+"). If you meant to render a collection of children, use an array instead.");return G}function D(L,z,oe){if(L==null)return L;var ce=[],he=0;return j(L,ce,"","",function(me){return z.call(oe,me,he++)}),ce}function U(L){if(L._status===-1){var z=L._result;z=z(),z.then(function(oe){(L._status===0||L._status===-1)&&(L._status=1,L._result=oe)},function(oe){(L._status===0||L._status===-1)&&(L._status=2,L._result=oe)}),L._status===-1&&(L._status=0,L._result=z)}if(L._status===1)return L._result.default;throw L._result}var re={current:null},I={transition:null},V={ReactCurrentDispatcher:re,ReactCurrentBatchConfig:I,ReactCurrentOwner:q};function $(){throw Error("act(...) is not supported in production builds of React.")}return Je.Children={map:D,forEach:function(L,z,oe){D(L,function(){z.apply(this,arguments)},oe)},count:function(L){var z=0;return D(L,function(){z++}),z},toArray:function(L){return D(L,function(z){return z})||[]},only:function(L){if(!te(L))throw Error("React.Children.only expected to receive a single React element child.");return L}},Je.Component=k,Je.Fragment=i,Je.Profiler=o,Je.PureComponent=P,Je.StrictMode=s,Je.Suspense=p,Je.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,Je.act=$,Je.cloneElement=function(L,z,oe){if(L==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+L+".");var ce=y({},L.props),he=L.key,me=L.ref,G=L._owner;if(z!=null){if(z.ref!==void 0&&(me=z.ref,G=q.current),z.key!==void 0&&(he=""+z.key),L.type&&L.type.defaultProps)var J=L.type.defaultProps;for(ge in z)ee.call(z,ge)&&!B.hasOwnProperty(ge)&&(ce[ge]=z[ge]===void 0&&J!==void 0?J[ge]:z[ge])}var ge=arguments.length-2;if(ge===1)ce.children=oe;else if(1<ge){J=Array(ge);for(var Me=0;Me<ge;Me++)J[Me]=arguments[Me+2];ce.children=J}return{$$typeof:e,type:L.type,key:he,ref:me,props:ce,_owner:G}},Je.createContext=function(L){return L={$$typeof:u,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},L.Provider={$$typeof:a,_context:L},L.Consumer=L},Je.createElement=Z,Je.createFactory=function(L){var z=Z.bind(null,L);return z.type=L,z},Je.createRef=function(){return{current:null}},Je.forwardRef=function(L){return{$$typeof:h,render:L}},Je.isValidElement=te,Je.lazy=function(L){return{$$typeof:_,_payload:{_status:-1,_result:L},_init:U}},Je.memo=function(L,z){return{$$typeof:f,type:L,compare:z===void 0?null:z}},Je.startTransition=function(L){var z=I.transition;I.transition={};try{L()}finally{I.transition=z}},Je.unstable_act=$,Je.useCallback=function(L,z){return re.current.useCallback(L,z)},Je.useContext=function(L){return re.current.useContext(L)},Je.useDebugValue=function(){},Je.useDeferredValue=function(L){return re.current.useDeferredValue(L)},Je.useEffect=function(L,z){return re.current.useEffect(L,z)},Je.useId=function(){return re.current.useId()},Je.useImperativeHandle=function(L,z,oe){return re.current.useImperativeHandle(L,z,oe)},Je.useInsertionEffect=function(L,z){return re.current.useInsertionEffect(L,z)},Je.useLayoutEffect=function(L,z){return re.current.useLayoutEffect(L,z)},Je.useMemo=function(L,z){return re.current.useMemo(L,z)},Je.useReducer=function(L,z,oe){return re.current.useReducer(L,z,oe)},Je.useRef=function(L){return re.current.useRef(L)},Je.useState=function(L){return re.current.useState(L)},Je.useSyncExternalStore=function(L,z,oe){return re.current.useSyncExternalStore(L,z,oe)},Je.useTransition=function(){return re.current.useTransition()},Je.version="18.3.1",Je}var mm;function oh(){return mm||(mm=1,fu.exports=FS()),fu.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 gm;function $S(){if(gm)return to;gm=1;var e=oh(),t=Symbol.for("react.element"),i=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function u(h,p,f){var _,b={},S=null,w=null;f!==void 0&&(S=""+f),p.key!==void 0&&(S=""+p.key),p.ref!==void 0&&(w=p.ref);for(_ in p)s.call(p,_)&&!a.hasOwnProperty(_)&&(b[_]=p[_]);if(h&&h.defaultProps)for(_ in p=h.defaultProps,p)b[_]===void 0&&(b[_]=p[_]);return{$$typeof:t,type:h,key:S,ref:w,props:b,_owner:o.current}}return to.Fragment=i,to.jsx=u,to.jsxs=u,to}var vm;function HS(){return vm||(vm=1,hu.exports=$S()),hu.exports}var c=HS(),R=oh();const WS=sh(R);var Oa={},pu={exports:{}},_i={},mu={exports:{}},gu={};/**
|
|
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 _m;function US(){return _m||(_m=1,(function(e){function t(I,V){var $=I.length;I.push(V);e:for(;0<$;){var L=$-1>>>1,z=I[L];if(0<o(z,V))I[L]=V,I[$]=z,$=L;else break e}}function i(I){return I.length===0?null:I[0]}function s(I){if(I.length===0)return null;var V=I[0],$=I.pop();if($!==V){I[0]=$;e:for(var L=0,z=I.length,oe=z>>>1;L<oe;){var ce=2*(L+1)-1,he=I[ce],me=ce+1,G=I[me];if(0>o(he,$))me<z&&0>o(G,he)?(I[L]=G,I[me]=$,L=me):(I[L]=he,I[ce]=$,L=ce);else if(me<z&&0>o(G,$))I[L]=G,I[me]=$,L=me;else break e}}return V}function o(I,V){var $=I.sortIndex-V.sortIndex;return $!==0?$:I.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,h=u.now();e.unstable_now=function(){return u.now()-h}}var p=[],f=[],_=1,b=null,S=3,w=!1,y=!1,x=!1,k=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(I){for(var V=i(f);V!==null;){if(V.callback===null)s(f);else if(V.startTime<=I)s(f),V.sortIndex=V.expirationTime,t(p,V);else break;V=i(f)}}function M(I){if(x=!1,A(I),!y)if(i(p)!==null)y=!0,U(ee);else{var V=i(f);V!==null&&re(M,V.startTime-I)}}function ee(I,V){y=!1,x&&(x=!1,C(Z),Z=-1),w=!0;var $=S;try{for(A(V),b=i(p);b!==null&&(!(b.expirationTime>V)||I&&!K());){var L=b.callback;if(typeof L=="function"){b.callback=null,S=b.priorityLevel;var z=L(b.expirationTime<=V);V=e.unstable_now(),typeof z=="function"?b.callback=z:b===i(p)&&s(p),A(V)}else s(p);b=i(p)}if(b!==null)var oe=!0;else{var ce=i(f);ce!==null&&re(M,ce.startTime-V),oe=!1}return oe}finally{b=null,S=$,w=!1}}var q=!1,B=null,Z=-1,H=5,te=-1;function K(){return!(e.unstable_now()-te<H)}function T(){if(B!==null){var I=e.unstable_now();te=I;var V=!0;try{V=B(!0,I)}finally{V?E():(q=!1,B=null)}}else q=!1}var E;if(typeof P=="function")E=function(){P(T)};else if(typeof MessageChannel<"u"){var j=new MessageChannel,D=j.port2;j.port1.onmessage=T,E=function(){D.postMessage(null)}}else E=function(){k(T,0)};function U(I){B=I,q||(q=!0,E())}function re(I,V){Z=k(function(){I(e.unstable_now())},V)}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(){y||w||(y=!0,U(ee))},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"):H=0<I?Math.floor(1e3/I):5},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_getFirstCallbackNode=function(){return i(p)},e.unstable_next=function(I){switch(S){case 1:case 2:case 3:var V=3;break;default:V=S}var $=S;S=V;try{return I()}finally{S=$}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(I,V){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var $=S;S=I;try{return V()}finally{S=$}},e.unstable_scheduleCallback=function(I,V,$){var L=e.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?L+$:L):$=L,I){case 1:var z=-1;break;case 2:z=250;break;case 5:z=1073741823;break;case 4:z=1e4;break;default:z=5e3}return z=$+z,I={id:_++,callback:V,priorityLevel:I,startTime:$,expirationTime:z,sortIndex:-1},$>L?(I.sortIndex=$,t(f,I),i(p)===null&&I===i(f)&&(x?(C(Z),Z=-1):x=!0,re(M,$-L))):(I.sortIndex=z,t(p,I),y||w||(y=!0,U(ee))),I},e.unstable_shouldYield=K,e.unstable_wrapCallback=function(I){var V=S;return function(){var $=S;S=V;try{return I.apply(this,arguments)}finally{S=$}}}})(gu)),gu}var ym;function KS(){return ym||(ym=1,mu.exports=US()),mu.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 wm;function qS(){if(wm)return _i;wm=1;var e=oh(),t=KS();function i(n){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+n,l=1;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function a(n,r){u(n,r),u(n+"Capture",r)}function u(n,r){for(o[n]=r,n=0;n<r.length;n++)s.add(r[n])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,f=/^[: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]*$/,_={},b={};function S(n){return p.call(b,n)?!0:p.call(_,n)?!1:f.test(n)?b[n]=!0:(_[n]=!0,!1)}function w(n,r,l,d){if(l!==null&&l.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return d?!1:l!==null?!l.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function y(n,r,l,d){if(r===null||typeof r>"u"||w(n,r,l,d))return!0;if(d)return!1;if(l!==null)switch(l.type){case 3:return!r;case 4:return r===!1;case 5:return isNaN(r);case 6:return isNaN(r)||1>r}return!1}function x(n,r,l,d,m,v,N){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=d,this.attributeNamespace=m,this.mustUseProperty=l,this.propertyName=n,this.type=r,this.sanitizeURL=v,this.removeEmptyString=N}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){k[n]=new x(n,0,!1,n,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var r=n[0];k[r]=new x(r,1,!1,n[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(n){k[n]=new x(n,2,!1,n.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){k[n]=new x(n,2,!1,n,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){k[n]=new x(n,3,!1,n.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(n){k[n]=new x(n,3,!0,n,null,!1,!1)}),["capture","download"].forEach(function(n){k[n]=new x(n,4,!1,n,null,!1,!1)}),["cols","rows","size","span"].forEach(function(n){k[n]=new x(n,6,!1,n,null,!1,!1)}),["rowSpan","start"].forEach(function(n){k[n]=new x(n,5,!1,n.toLowerCase(),null,!1,!1)});var C=/[\-:]([a-z])/g;function P(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var r=n.replace(C,P);k[r]=new x(r,1,!1,n,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var r=n.replace(C,P);k[r]=new x(r,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(n){var r=n.replace(C,P);k[r]=new x(r,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(n){k[n]=new x(n,1,!1,n.toLowerCase(),null,!1,!1)}),k.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(n){k[n]=new x(n,1,!1,n.toLowerCase(),null,!0,!0)});function A(n,r,l,d){var m=k.hasOwnProperty(r)?k[r]:null;(m!==null?m.type!==0:d||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(y(r,l,m,d)&&(l=null),d||m===null?S(r)&&(l===null?n.removeAttribute(r):n.setAttribute(r,""+l)):m.mustUseProperty?n[m.propertyName]=l===null?m.type===3?!1:"":l:(r=m.attributeName,d=m.attributeNamespace,l===null?n.removeAttribute(r):(m=m.type,l=m===3||m===4&&l===!0?"":""+l,d?n.setAttributeNS(d,r,l):n.setAttribute(r,l))))}var M=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,ee=Symbol.for("react.element"),q=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),H=Symbol.for("react.profiler"),te=Symbol.for("react.provider"),K=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),re=Symbol.for("react.offscreen"),I=Symbol.iterator;function V(n){return n===null||typeof n!="object"?null:(n=I&&n[I]||n["@@iterator"],typeof n=="function"?n:null)}var $=Object.assign,L;function z(n){if(L===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);L=r&&r[1]||""}return`
|
|
34
|
+
`+L+n}var oe=!1;function ce(n,r){if(!n||oe)return"";oe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(r)if(r=function(){throw Error()},Object.defineProperty(r.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(r,[])}catch(le){var d=le}Reflect.construct(n,[],r)}else{try{r.call()}catch(le){d=le}n.call(r.prototype)}else{try{throw Error()}catch(le){d=le}n()}}catch(le){if(le&&d&&typeof le.stack=="string"){for(var m=le.stack.split(`
|
|
35
|
+
`),v=d.stack.split(`
|
|
36
|
+
`),N=m.length-1,O=v.length-1;1<=N&&0<=O&&m[N]!==v[O];)O--;for(;1<=N&&0<=O;N--,O--)if(m[N]!==v[O]){if(N!==1||O!==1)do if(N--,O--,0>O||m[N]!==v[O]){var Y=`
|
|
37
|
+
`+m[N].replace(" at new "," at ");return n.displayName&&Y.includes("<anonymous>")&&(Y=Y.replace("<anonymous>",n.displayName)),Y}while(1<=N&&0<=O);break}}}finally{oe=!1,Error.prepareStackTrace=l}return(n=n?n.displayName||n.name:"")?z(n):""}function he(n){switch(n.tag){case 5:return z(n.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return n=ce(n.type,!1),n;case 11:return n=ce(n.type.render,!1),n;case 1:return n=ce(n.type,!0),n;default:return""}}function me(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case B:return"Fragment";case q:return"Portal";case H:return"Profiler";case Z:return"StrictMode";case E:return"Suspense";case j:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case K:return(n.displayName||"Context")+".Consumer";case te:return(n._context.displayName||"Context")+".Provider";case T:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case D:return r=n.displayName||null,r!==null?r:me(n.type)||"Memo";case U:r=n._payload,n=n._init;try{return me(n(r))}catch{}}return null}function G(n){var r=n.type;switch(n.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=r.render,n=n.displayName||n.name||"",r.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return me(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 J(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ge(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Me(n){var r=ge(n)?"checked":"value",l=Object.getOwnPropertyDescriptor(n.constructor.prototype,r),d=""+n[r];if(!n.hasOwnProperty(r)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var m=l.get,v=l.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return m.call(this)},set:function(N){d=""+N,v.call(this,N)}}),Object.defineProperty(n,r,{enumerable:l.enumerable}),{getValue:function(){return d},setValue:function(N){d=""+N},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function Ze(n){n._valueTracker||(n._valueTracker=Me(n))}function Be(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),d="";return n&&(d=ge(n)?n.checked?"true":"false":n.value),n=d,n!==l?(r.setValue(n),!0):!1}function Fe(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function ct(n,r){var l=r.checked;return $({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:l??n._wrapperState.initialChecked})}function Ve(n,r){var l=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;l=J(r.value!=null?r.value:l),n._wrapperState={initialChecked:d,initialValue:l,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function gt(n,r){r=r.checked,r!=null&&A(n,"checked",r,!1)}function ut(n,r){gt(n,r);var l=J(r.value),d=r.type;if(l!=null)d==="number"?(l===0&&n.value===""||n.value!=l)&&(n.value=""+l):n.value!==""+l&&(n.value=""+l);else if(d==="submit"||d==="reset"){n.removeAttribute("value");return}r.hasOwnProperty("value")?nt(n,r.type,l):r.hasOwnProperty("defaultValue")&&nt(n,r.type,J(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(n.defaultChecked=!!r.defaultChecked)}function lt(n,r,l){if(r.hasOwnProperty("value")||r.hasOwnProperty("defaultValue")){var d=r.type;if(!(d!=="submit"&&d!=="reset"||r.value!==void 0&&r.value!==null))return;r=""+n._wrapperState.initialValue,l||r===n.value||(n.value=r),n.defaultValue=r}l=n.name,l!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,l!==""&&(n.name=l)}function nt(n,r,l){(r!=="number"||Fe(n.ownerDocument)!==n)&&(l==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+l&&(n.defaultValue=""+l))}var dt=Array.isArray;function rt(n,r,l,d){if(n=n.options,r){r={};for(var m=0;m<l.length;m++)r["$"+l[m]]=!0;for(l=0;l<n.length;l++)m=r.hasOwnProperty("$"+n[l].value),n[l].selected!==m&&(n[l].selected=m),m&&d&&(n[l].defaultSelected=!0)}else{for(l=""+J(l),r=null,m=0;m<n.length;m++){if(n[m].value===l){n[m].selected=!0,d&&(n[m].defaultSelected=!0);return}r!==null||n[m].disabled||(r=n[m])}r!==null&&(r.selected=!0)}}function ot(n,r){if(r.dangerouslySetInnerHTML!=null)throw Error(i(91));return $({},r,{value:void 0,defaultValue:void 0,children:""+n._wrapperState.initialValue})}function ae(n,r){var l=r.value;if(l==null){if(l=r.children,r=r.defaultValue,l!=null){if(r!=null)throw Error(i(92));if(dt(l)){if(1<l.length)throw Error(i(93));l=l[0]}r=l}r==null&&(r=""),l=r}n._wrapperState={initialValue:J(l)}}function xe(n,r){var l=J(r.value),d=J(r.defaultValue);l!=null&&(l=""+l,l!==n.value&&(n.value=l),r.defaultValue==null&&n.defaultValue!==l&&(n.defaultValue=l)),d!=null&&(n.defaultValue=""+d)}function de(n){var r=n.textContent;r===n._wrapperState.initialValue&&r!==""&&r!==null&&(n.value=r)}function Ne(n){switch(n){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ee(n,r){return n==null||n==="http://www.w3.org/1999/xhtml"?Ne(r):n==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":n}var X,ie=(function(n){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,l,d,m){MSApp.execUnsafeLocalFunction(function(){return n(r,l,d,m)})}:n})(function(n,r){if(n.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in n)n.innerHTML=r;else{for(X=X||document.createElement("div"),X.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=X.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;r.firstChild;)n.appendChild(r.firstChild)}});function F(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var W={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},ue=["Webkit","ms","Moz","O"];Object.keys(W).forEach(function(n){ue.forEach(function(r){r=r+n.charAt(0).toUpperCase()+n.substring(1),W[r]=W[n]})});function ve(n,r,l){return r==null||typeof r=="boolean"||r===""?"":l||typeof r!="number"||r===0||W.hasOwnProperty(n)&&W[n]?(""+r).trim():r+"px"}function Ce(n,r){n=n.style;for(var l in r)if(r.hasOwnProperty(l)){var d=l.indexOf("--")===0,m=ve(l,r[l],d);l==="float"&&(l="cssFloat"),d?n.setProperty(l,m):n[l]=m}}var _e=$({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 Re(n,r){if(r){if(_e[n]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(i(137,n));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(i(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(i(61))}if(r.style!=null&&typeof r.style!="object")throw Error(i(62))}}function Qe(n,r){if(n.indexOf("-")===-1)return typeof r.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zt=null;function ze(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var Di=null,Nt=null,Ke=null;function ei(n){if(n=Fs(n)){if(typeof Di!="function")throw Error(i(280));var r=n.stateNode;r&&(r=Zo(r),Di(n.stateNode,n.type,r))}}function fe(n){Nt?Ke?Ke.push(n):Ke=[n]:Nt=n}function Pe(){if(Nt){var n=Nt,r=Ke;if(Ke=Nt=null,ei(n),r)for(n=0;n<r.length;n++)ei(r[n])}}function qe(n,r){return n(r)}function xt(){}var oi=!1;function _s(n,r,l){if(oi)return n(r,l);oi=!0;try{return qe(n,r,l)}finally{oi=!1,(Nt!==null||Ke!==null)&&(xt(),Pe())}}function Si(n,r){var l=n.stateNode;if(l===null)return null;var d=Zo(l);if(d===null)return null;l=d[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":(d=!d.disabled)||(n=n.type,d=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!d;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(i(231,r,typeof l));return l}var ys=!1;if(h)try{var ws={};Object.defineProperty(ws,"passive",{get:function(){ys=!0}}),window.addEventListener("test",ws,ws),window.removeEventListener("test",ws,ws)}catch{ys=!1}function qy(n,r,l,d,m,v,N,O,Y){var le=Array.prototype.slice.call(arguments,3);try{r.apply(l,le)}catch(we){this.onError(we)}}var Ss=!1,Do=null,Lo=!1,Dl=null,Vy={onError:function(n){Ss=!0,Do=n}};function Yy(n,r,l,d,m,v,N,O,Y){Ss=!1,Do=null,qy.apply(Vy,arguments)}function Xy(n,r,l,d,m,v,N,O,Y){if(Yy.apply(this,arguments),Ss){if(Ss){var le=Do;Ss=!1,Do=null}else throw Error(i(198));Lo||(Lo=!0,Dl=le)}}function ir(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function Ih(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function Bh(n){if(ir(n)!==n)throw Error(i(188))}function Gy(n){var r=n.alternate;if(!r){if(r=ir(n),r===null)throw Error(i(188));return r!==n?null:n}for(var l=n,d=r;;){var m=l.return;if(m===null)break;var v=m.alternate;if(v===null){if(d=m.return,d!==null){l=d;continue}break}if(m.child===v.child){for(v=m.child;v;){if(v===l)return Bh(m),n;if(v===d)return Bh(m),r;v=v.sibling}throw Error(i(188))}if(l.return!==d.return)l=m,d=v;else{for(var N=!1,O=m.child;O;){if(O===l){N=!0,l=m,d=v;break}if(O===d){N=!0,d=m,l=v;break}O=O.sibling}if(!N){for(O=v.child;O;){if(O===l){N=!0,l=v,d=m;break}if(O===d){N=!0,d=v,l=m;break}O=O.sibling}if(!N)throw Error(i(189))}}if(l.alternate!==d)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?n:r}function Oh(n){return n=Gy(n),n!==null?zh(n):null}function zh(n){if(n.tag===5||n.tag===6)return n;for(n=n.child;n!==null;){var r=zh(n);if(r!==null)return r;n=n.sibling}return null}var Fh=t.unstable_scheduleCallback,$h=t.unstable_cancelCallback,Qy=t.unstable_shouldYield,Jy=t.unstable_requestPaint,Rt=t.unstable_now,Zy=t.unstable_getCurrentPriorityLevel,Ll=t.unstable_ImmediatePriority,Hh=t.unstable_UserBlockingPriority,Mo=t.unstable_NormalPriority,ew=t.unstable_LowPriority,Wh=t.unstable_IdlePriority,To=null,Qi=null;function tw(n){if(Qi&&typeof Qi.onCommitFiberRoot=="function")try{Qi.onCommitFiberRoot(To,n,void 0,(n.current.flags&128)===128)}catch{}}var Wi=Math.clz32?Math.clz32:rw,iw=Math.log,nw=Math.LN2;function rw(n){return n>>>=0,n===0?32:31-(iw(n)/nw|0)|0}var Ao=64,Io=4194304;function bs(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Bo(n,r){var l=n.pendingLanes;if(l===0)return 0;var d=0,m=n.suspendedLanes,v=n.pingedLanes,N=l&268435455;if(N!==0){var O=N&~m;O!==0?d=bs(O):(v&=N,v!==0&&(d=bs(v)))}else N=l&~m,N!==0?d=bs(N):v!==0&&(d=bs(v));if(d===0)return 0;if(r!==0&&r!==d&&(r&m)===0&&(m=d&-d,v=r&-r,m>=v||m===16&&(v&4194240)!==0))return r;if((d&4)!==0&&(d|=l&16),r=n.entangledLanes,r!==0)for(n=n.entanglements,r&=d;0<r;)l=31-Wi(r),m=1<<l,d|=n[l],r&=~m;return d}function sw(n,r){switch(n){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ow(n,r){for(var l=n.suspendedLanes,d=n.pingedLanes,m=n.expirationTimes,v=n.pendingLanes;0<v;){var N=31-Wi(v),O=1<<N,Y=m[N];Y===-1?((O&l)===0||(O&d)!==0)&&(m[N]=sw(O,r)):Y<=r&&(n.expiredLanes|=O),v&=~O}}function Ml(n){return n=n.pendingLanes&-1073741825,n!==0?n:n&1073741824?1073741824:0}function Uh(){var n=Ao;return Ao<<=1,(Ao&4194240)===0&&(Ao=64),n}function Tl(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function xs(n,r,l){n.pendingLanes|=r,r!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,r=31-Wi(r),n[r]=l}function aw(n,r){var l=n.pendingLanes&~r;n.pendingLanes=r,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=r,n.mutableReadLanes&=r,n.entangledLanes&=r,r=n.entanglements;var d=n.eventTimes;for(n=n.expirationTimes;0<l;){var m=31-Wi(l),v=1<<m;r[m]=0,d[m]=-1,n[m]=-1,l&=~v}}function Al(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var d=31-Wi(l),m=1<<d;m&r|n[d]&r&&(n[d]|=r),l&=~m}}var st=0;function Kh(n){return n&=-n,1<n?4<n?(n&268435455)!==0?16:536870912:4:1}var qh,Il,Vh,Yh,Xh,Bl=!1,Oo=[],kn=null,En=null,Nn=null,Cs=new Map,ks=new Map,Rn=[],lw="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 Gh(n,r){switch(n){case"focusin":case"focusout":kn=null;break;case"dragenter":case"dragleave":En=null;break;case"mouseover":case"mouseout":Nn=null;break;case"pointerover":case"pointerout":Cs.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":ks.delete(r.pointerId)}}function Es(n,r,l,d,m,v){return n===null||n.nativeEvent!==v?(n={blockedOn:r,domEventName:l,eventSystemFlags:d,nativeEvent:v,targetContainers:[m]},r!==null&&(r=Fs(r),r!==null&&Il(r)),n):(n.eventSystemFlags|=d,r=n.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),n)}function cw(n,r,l,d,m){switch(r){case"focusin":return kn=Es(kn,n,r,l,d,m),!0;case"dragenter":return En=Es(En,n,r,l,d,m),!0;case"mouseover":return Nn=Es(Nn,n,r,l,d,m),!0;case"pointerover":var v=m.pointerId;return Cs.set(v,Es(Cs.get(v)||null,n,r,l,d,m)),!0;case"gotpointercapture":return v=m.pointerId,ks.set(v,Es(ks.get(v)||null,n,r,l,d,m)),!0}return!1}function Qh(n){var r=nr(n.target);if(r!==null){var l=ir(r);if(l!==null){if(r=l.tag,r===13){if(r=Ih(l),r!==null){n.blockedOn=r,Xh(n.priority,function(){Vh(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function zo(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=zl(n.domEventName,n.eventSystemFlags,r[0],n.nativeEvent);if(l===null){l=n.nativeEvent;var d=new l.constructor(l.type,l);zt=d,l.target.dispatchEvent(d),zt=null}else return r=Fs(l),r!==null&&Il(r),n.blockedOn=l,!1;r.shift()}return!0}function Jh(n,r,l){zo(n)&&l.delete(r)}function uw(){Bl=!1,kn!==null&&zo(kn)&&(kn=null),En!==null&&zo(En)&&(En=null),Nn!==null&&zo(Nn)&&(Nn=null),Cs.forEach(Jh),ks.forEach(Jh)}function Ns(n,r){n.blockedOn===r&&(n.blockedOn=null,Bl||(Bl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,uw)))}function Rs(n){function r(m){return Ns(m,n)}if(0<Oo.length){Ns(Oo[0],n);for(var l=1;l<Oo.length;l++){var d=Oo[l];d.blockedOn===n&&(d.blockedOn=null)}}for(kn!==null&&Ns(kn,n),En!==null&&Ns(En,n),Nn!==null&&Ns(Nn,n),Cs.forEach(r),ks.forEach(r),l=0;l<Rn.length;l++)d=Rn[l],d.blockedOn===n&&(d.blockedOn=null);for(;0<Rn.length&&(l=Rn[0],l.blockedOn===null);)Qh(l),l.blockedOn===null&&Rn.shift()}var Lr=M.ReactCurrentBatchConfig,Fo=!0;function dw(n,r,l,d){var m=st,v=Lr.transition;Lr.transition=null;try{st=1,Ol(n,r,l,d)}finally{st=m,Lr.transition=v}}function hw(n,r,l,d){var m=st,v=Lr.transition;Lr.transition=null;try{st=4,Ol(n,r,l,d)}finally{st=m,Lr.transition=v}}function Ol(n,r,l,d){if(Fo){var m=zl(n,r,l,d);if(m===null)ic(n,r,d,$o,l),Gh(n,d);else if(cw(m,n,r,l,d))d.stopPropagation();else if(Gh(n,d),r&4&&-1<lw.indexOf(n)){for(;m!==null;){var v=Fs(m);if(v!==null&&qh(v),v=zl(n,r,l,d),v===null&&ic(n,r,d,$o,l),v===m)break;m=v}m!==null&&d.stopPropagation()}else ic(n,r,d,null,l)}}var $o=null;function zl(n,r,l,d){if($o=null,n=ze(d),n=nr(n),n!==null)if(r=ir(n),r===null)n=null;else if(l=r.tag,l===13){if(n=Ih(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null);return $o=n,null}function Zh(n){switch(n){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Zy()){case Ll:return 1;case Hh:return 4;case Mo:case ew:return 16;case Wh:return 536870912;default:return 16}default:return 16}}var Pn=null,Fl=null,Ho=null;function ef(){if(Ho)return Ho;var n,r=Fl,l=r.length,d,m="value"in Pn?Pn.value:Pn.textContent,v=m.length;for(n=0;n<l&&r[n]===m[n];n++);var N=l-n;for(d=1;d<=N&&r[l-d]===m[v-d];d++);return Ho=m.slice(n,1<d?1-d:void 0)}function Wo(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function Uo(){return!0}function tf(){return!1}function bi(n){function r(l,d,m,v,N){this._reactName=l,this._targetInst=m,this.type=d,this.nativeEvent=v,this.target=N,this.currentTarget=null;for(var O in n)n.hasOwnProperty(O)&&(l=n[O],this[O]=l?l(v):v[O]);return this.isDefaultPrevented=(v.defaultPrevented!=null?v.defaultPrevented:v.returnValue===!1)?Uo:tf,this.isPropagationStopped=tf,this}return $(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Uo)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Uo)},persist:function(){},isPersistent:Uo}),r}var Mr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},$l=bi(Mr),Ps=$({},Mr,{view:0,detail:0}),fw=bi(Ps),Hl,Wl,js,Ko=$({},Ps,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Kl,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==js&&(js&&n.type==="mousemove"?(Hl=n.screenX-js.screenX,Wl=n.screenY-js.screenY):Wl=Hl=0,js=n),Hl)},movementY:function(n){return"movementY"in n?n.movementY:Wl}}),nf=bi(Ko),pw=$({},Ko,{dataTransfer:0}),mw=bi(pw),gw=$({},Ps,{relatedTarget:0}),Ul=bi(gw),vw=$({},Mr,{animationName:0,elapsedTime:0,pseudoElement:0}),_w=bi(vw),yw=$({},Mr,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),ww=bi(yw),Sw=$({},Mr,{data:0}),rf=bi(Sw),bw={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},xw={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"},Cw={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kw(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=Cw[n])?!!r[n]:!1}function Kl(){return kw}var Ew=$({},Ps,{key:function(n){if(n.key){var r=bw[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=Wo(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?xw[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Kl,charCode:function(n){return n.type==="keypress"?Wo(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?Wo(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),Nw=bi(Ew),Rw=$({},Ko,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),sf=bi(Rw),Pw=$({},Ps,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Kl}),jw=bi(Pw),Dw=$({},Mr,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lw=bi(Dw),Mw=$({},Ko,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),Tw=bi(Mw),Aw=[9,13,27,32],ql=h&&"CompositionEvent"in window,Ds=null;h&&"documentMode"in document&&(Ds=document.documentMode);var Iw=h&&"TextEvent"in window&&!Ds,of=h&&(!ql||Ds&&8<Ds&&11>=Ds),af=" ",lf=!1;function cf(n,r){switch(n){case"keyup":return Aw.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function uf(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Tr=!1;function Bw(n,r){switch(n){case"compositionend":return uf(r);case"keypress":return r.which!==32?null:(lf=!0,af);case"textInput":return n=r.data,n===af&&lf?null:n;default:return null}}function Ow(n,r){if(Tr)return n==="compositionend"||!ql&&cf(n,r)?(n=ef(),Ho=Fl=Pn=null,Tr=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return of&&r.locale!=="ko"?null:r.data;default:return null}}var zw={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 df(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!zw[n.type]:r==="textarea"}function hf(n,r,l,d){fe(d),r=Go(r,"onChange"),0<r.length&&(l=new $l("onChange","change",null,l,d),n.push({event:l,listeners:r}))}var Ls=null,Ms=null;function Fw(n){jf(n,0)}function qo(n){var r=zr(n);if(Be(r))return n}function $w(n,r){if(n==="change")return r}var ff=!1;if(h){var Vl;if(h){var Yl="oninput"in document;if(!Yl){var pf=document.createElement("div");pf.setAttribute("oninput","return;"),Yl=typeof pf.oninput=="function"}Vl=Yl}else Vl=!1;ff=Vl&&(!document.documentMode||9<document.documentMode)}function mf(){Ls&&(Ls.detachEvent("onpropertychange",gf),Ms=Ls=null)}function gf(n){if(n.propertyName==="value"&&qo(Ms)){var r=[];hf(r,Ms,n,ze(n)),_s(Fw,r)}}function Hw(n,r,l){n==="focusin"?(mf(),Ls=r,Ms=l,Ls.attachEvent("onpropertychange",gf)):n==="focusout"&&mf()}function Ww(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return qo(Ms)}function Uw(n,r){if(n==="click")return qo(r)}function Kw(n,r){if(n==="input"||n==="change")return qo(r)}function qw(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Ui=typeof Object.is=="function"?Object.is:qw;function Ts(n,r){if(Ui(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),d=Object.keys(r);if(l.length!==d.length)return!1;for(d=0;d<l.length;d++){var m=l[d];if(!p.call(r,m)||!Ui(n[m],r[m]))return!1}return!0}function vf(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function _f(n,r){var l=vf(n);n=0;for(var d;l;){if(l.nodeType===3){if(d=n+l.textContent.length,n<=r&&d>=r)return{node:l,offset:r-n};n=d}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=vf(l)}}function yf(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?yf(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function wf(){for(var n=window,r=Fe();r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=Fe(n.document)}return r}function Xl(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}function Vw(n){var r=wf(),l=n.focusedElem,d=n.selectionRange;if(r!==l&&l&&l.ownerDocument&&yf(l.ownerDocument.documentElement,l)){if(d!==null&&Xl(l)){if(r=d.start,n=d.end,n===void 0&&(n=r),"selectionStart"in l)l.selectionStart=r,l.selectionEnd=Math.min(n,l.value.length);else if(n=(r=l.ownerDocument||document)&&r.defaultView||window,n.getSelection){n=n.getSelection();var m=l.textContent.length,v=Math.min(d.start,m);d=d.end===void 0?v:Math.min(d.end,m),!n.extend&&v>d&&(m=d,d=v,v=m),m=_f(l,v);var N=_f(l,d);m&&N&&(n.rangeCount!==1||n.anchorNode!==m.node||n.anchorOffset!==m.offset||n.focusNode!==N.node||n.focusOffset!==N.offset)&&(r=r.createRange(),r.setStart(m.node,m.offset),n.removeAllRanges(),v>d?(n.addRange(r),n.extend(N.node,N.offset)):(r.setEnd(N.node,N.offset),n.addRange(r)))}}for(r=[],n=l;n=n.parentNode;)n.nodeType===1&&r.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof l.focus=="function"&&l.focus(),l=0;l<r.length;l++)n=r[l],n.element.scrollLeft=n.left,n.element.scrollTop=n.top}}var Yw=h&&"documentMode"in document&&11>=document.documentMode,Ar=null,Gl=null,As=null,Ql=!1;function Sf(n,r,l){var d=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ql||Ar==null||Ar!==Fe(d)||(d=Ar,"selectionStart"in d&&Xl(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),As&&Ts(As,d)||(As=d,d=Go(Gl,"onSelect"),0<d.length&&(r=new $l("onSelect","select",null,r,l),n.push({event:r,listeners:d}),r.target=Ar)))}function Vo(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var Ir={animationend:Vo("Animation","AnimationEnd"),animationiteration:Vo("Animation","AnimationIteration"),animationstart:Vo("Animation","AnimationStart"),transitionend:Vo("Transition","TransitionEnd")},Jl={},bf={};h&&(bf=document.createElement("div").style,"AnimationEvent"in window||(delete Ir.animationend.animation,delete Ir.animationiteration.animation,delete Ir.animationstart.animation),"TransitionEvent"in window||delete Ir.transitionend.transition);function Yo(n){if(Jl[n])return Jl[n];if(!Ir[n])return n;var r=Ir[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in bf)return Jl[n]=r[l];return n}var xf=Yo("animationend"),Cf=Yo("animationiteration"),kf=Yo("animationstart"),Ef=Yo("transitionend"),Nf=new Map,Rf="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 jn(n,r){Nf.set(n,r),a(r,[n])}for(var Zl=0;Zl<Rf.length;Zl++){var ec=Rf[Zl],Xw=ec.toLowerCase(),Gw=ec[0].toUpperCase()+ec.slice(1);jn(Xw,"on"+Gw)}jn(xf,"onAnimationEnd"),jn(Cf,"onAnimationIteration"),jn(kf,"onAnimationStart"),jn("dblclick","onDoubleClick"),jn("focusin","onFocus"),jn("focusout","onBlur"),jn(Ef,"onTransitionEnd"),u("onMouseEnter",["mouseout","mouseover"]),u("onMouseLeave",["mouseout","mouseover"]),u("onPointerEnter",["pointerout","pointerover"]),u("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Is="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(" "),Qw=new Set("cancel close invalid load scroll toggle".split(" ").concat(Is));function Pf(n,r,l){var d=n.type||"unknown-event";n.currentTarget=l,Xy(d,r,void 0,n),n.currentTarget=null}function jf(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var d=n[l],m=d.event;d=d.listeners;e:{var v=void 0;if(r)for(var N=d.length-1;0<=N;N--){var O=d[N],Y=O.instance,le=O.currentTarget;if(O=O.listener,Y!==v&&m.isPropagationStopped())break e;Pf(m,O,le),v=Y}else for(N=0;N<d.length;N++){if(O=d[N],Y=O.instance,le=O.currentTarget,O=O.listener,Y!==v&&m.isPropagationStopped())break e;Pf(m,O,le),v=Y}}}if(Lo)throw n=Dl,Lo=!1,Dl=null,n}function ft(n,r){var l=r[lc];l===void 0&&(l=r[lc]=new Set);var d=n+"__bubble";l.has(d)||(Df(r,n,2,!1),l.add(d))}function tc(n,r,l){var d=0;r&&(d|=4),Df(l,n,d,r)}var Xo="_reactListening"+Math.random().toString(36).slice(2);function Bs(n){if(!n[Xo]){n[Xo]=!0,s.forEach(function(l){l!=="selectionchange"&&(Qw.has(l)||tc(l,!1,n),tc(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Xo]||(r[Xo]=!0,tc("selectionchange",!1,r))}}function Df(n,r,l,d){switch(Zh(r)){case 1:var m=dw;break;case 4:m=hw;break;default:m=Ol}l=m.bind(null,r,l,n),m=void 0,!ys||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(m=!0),d?m!==void 0?n.addEventListener(r,l,{capture:!0,passive:m}):n.addEventListener(r,l,!0):m!==void 0?n.addEventListener(r,l,{passive:m}):n.addEventListener(r,l,!1)}function ic(n,r,l,d,m){var v=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var N=d.tag;if(N===3||N===4){var O=d.stateNode.containerInfo;if(O===m||O.nodeType===8&&O.parentNode===m)break;if(N===4)for(N=d.return;N!==null;){var Y=N.tag;if((Y===3||Y===4)&&(Y=N.stateNode.containerInfo,Y===m||Y.nodeType===8&&Y.parentNode===m))return;N=N.return}for(;O!==null;){if(N=nr(O),N===null)return;if(Y=N.tag,Y===5||Y===6){d=v=N;continue e}O=O.parentNode}}d=d.return}_s(function(){var le=v,we=ze(l),Se=[];e:{var ye=Nf.get(n);if(ye!==void 0){var De=$l,Te=n;switch(n){case"keypress":if(Wo(l)===0)break e;case"keydown":case"keyup":De=Nw;break;case"focusin":Te="focus",De=Ul;break;case"focusout":Te="blur",De=Ul;break;case"beforeblur":case"afterblur":De=Ul;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":De=nf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":De=mw;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":De=jw;break;case xf:case Cf:case kf:De=_w;break;case Ef:De=Lw;break;case"scroll":De=fw;break;case"wheel":De=Tw;break;case"copy":case"cut":case"paste":De=ww;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":De=sf}var Ae=(r&4)!==0,Pt=!Ae&&n==="scroll",ne=Ae?ye!==null?ye+"Capture":null:ye;Ae=[];for(var Q=le,se;Q!==null;){se=Q;var be=se.stateNode;if(se.tag===5&&be!==null&&(se=be,ne!==null&&(be=Si(Q,ne),be!=null&&Ae.push(Os(Q,be,se)))),Pt)break;Q=Q.return}0<Ae.length&&(ye=new De(ye,Te,null,l,we),Se.push({event:ye,listeners:Ae}))}}if((r&7)===0){e:{if(ye=n==="mouseover"||n==="pointerover",De=n==="mouseout"||n==="pointerout",ye&&l!==zt&&(Te=l.relatedTarget||l.fromElement)&&(nr(Te)||Te[hn]))break e;if((De||ye)&&(ye=we.window===we?we:(ye=we.ownerDocument)?ye.defaultView||ye.parentWindow:window,De?(Te=l.relatedTarget||l.toElement,De=le,Te=Te?nr(Te):null,Te!==null&&(Pt=ir(Te),Te!==Pt||Te.tag!==5&&Te.tag!==6)&&(Te=null)):(De=null,Te=le),De!==Te)){if(Ae=nf,be="onMouseLeave",ne="onMouseEnter",Q="mouse",(n==="pointerout"||n==="pointerover")&&(Ae=sf,be="onPointerLeave",ne="onPointerEnter",Q="pointer"),Pt=De==null?ye:zr(De),se=Te==null?ye:zr(Te),ye=new Ae(be,Q+"leave",De,l,we),ye.target=Pt,ye.relatedTarget=se,be=null,nr(we)===le&&(Ae=new Ae(ne,Q+"enter",Te,l,we),Ae.target=se,Ae.relatedTarget=Pt,be=Ae),Pt=be,De&&Te)t:{for(Ae=De,ne=Te,Q=0,se=Ae;se;se=Br(se))Q++;for(se=0,be=ne;be;be=Br(be))se++;for(;0<Q-se;)Ae=Br(Ae),Q--;for(;0<se-Q;)ne=Br(ne),se--;for(;Q--;){if(Ae===ne||ne!==null&&Ae===ne.alternate)break t;Ae=Br(Ae),ne=Br(ne)}Ae=null}else Ae=null;De!==null&&Lf(Se,ye,De,Ae,!1),Te!==null&&Pt!==null&&Lf(Se,Pt,Te,Ae,!0)}}e:{if(ye=le?zr(le):window,De=ye.nodeName&&ye.nodeName.toLowerCase(),De==="select"||De==="input"&&ye.type==="file")var Ie=$w;else if(df(ye))if(ff)Ie=Kw;else{Ie=Ww;var $e=Hw}else(De=ye.nodeName)&&De.toLowerCase()==="input"&&(ye.type==="checkbox"||ye.type==="radio")&&(Ie=Uw);if(Ie&&(Ie=Ie(n,le))){hf(Se,Ie,l,we);break e}$e&&$e(n,ye,le),n==="focusout"&&($e=ye._wrapperState)&&$e.controlled&&ye.type==="number"&&nt(ye,"number",ye.value)}switch($e=le?zr(le):window,n){case"focusin":(df($e)||$e.contentEditable==="true")&&(Ar=$e,Gl=le,As=null);break;case"focusout":As=Gl=Ar=null;break;case"mousedown":Ql=!0;break;case"contextmenu":case"mouseup":case"dragend":Ql=!1,Sf(Se,l,we);break;case"selectionchange":if(Yw)break;case"keydown":case"keyup":Sf(Se,l,we)}var He;if(ql)e:{switch(n){case"compositionstart":var We="onCompositionStart";break e;case"compositionend":We="onCompositionEnd";break e;case"compositionupdate":We="onCompositionUpdate";break e}We=void 0}else Tr?cf(n,l)&&(We="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(We="onCompositionStart");We&&(of&&l.locale!=="ko"&&(Tr||We!=="onCompositionStart"?We==="onCompositionEnd"&&Tr&&(He=ef()):(Pn=we,Fl="value"in Pn?Pn.value:Pn.textContent,Tr=!0)),$e=Go(le,We),0<$e.length&&(We=new rf(We,n,null,l,we),Se.push({event:We,listeners:$e}),He?We.data=He:(He=uf(l),He!==null&&(We.data=He)))),(He=Iw?Bw(n,l):Ow(n,l))&&(le=Go(le,"onBeforeInput"),0<le.length&&(we=new rf("onBeforeInput","beforeinput",null,l,we),Se.push({event:we,listeners:le}),we.data=He))}jf(Se,r)})}function Os(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Go(n,r){for(var l=r+"Capture",d=[];n!==null;){var m=n,v=m.stateNode;m.tag===5&&v!==null&&(m=v,v=Si(n,l),v!=null&&d.unshift(Os(n,v,m)),v=Si(n,r),v!=null&&d.push(Os(n,v,m))),n=n.return}return d}function Br(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5);return n||null}function Lf(n,r,l,d,m){for(var v=r._reactName,N=[];l!==null&&l!==d;){var O=l,Y=O.alternate,le=O.stateNode;if(Y!==null&&Y===d)break;O.tag===5&&le!==null&&(O=le,m?(Y=Si(l,v),Y!=null&&N.unshift(Os(l,Y,O))):m||(Y=Si(l,v),Y!=null&&N.push(Os(l,Y,O)))),l=l.return}N.length!==0&&n.push({event:r,listeners:N})}var Jw=/\r\n?/g,Zw=/\u0000|\uFFFD/g;function Mf(n){return(typeof n=="string"?n:""+n).replace(Jw,`
|
|
38
|
+
`).replace(Zw,"")}function Qo(n,r,l){if(r=Mf(r),Mf(n)!==r&&l)throw Error(i(425))}function Jo(){}var nc=null,rc=null;function sc(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var oc=typeof setTimeout=="function"?setTimeout:void 0,eS=typeof clearTimeout=="function"?clearTimeout:void 0,Tf=typeof Promise=="function"?Promise:void 0,tS=typeof queueMicrotask=="function"?queueMicrotask:typeof Tf<"u"?function(n){return Tf.resolve(null).then(n).catch(iS)}:oc;function iS(n){setTimeout(function(){throw n})}function ac(n,r){var l=r,d=0;do{var m=l.nextSibling;if(n.removeChild(l),m&&m.nodeType===8)if(l=m.data,l==="/$"){if(d===0){n.removeChild(m),Rs(r);return}d--}else l!=="$"&&l!=="$?"&&l!=="$!"||d++;l=m}while(l);Rs(r)}function Dn(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return n}function Af(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"){if(r===0)return n;r--}else l==="/$"&&r++}n=n.previousSibling}return null}var Or=Math.random().toString(36).slice(2),Ji="__reactFiber$"+Or,zs="__reactProps$"+Or,hn="__reactContainer$"+Or,lc="__reactEvents$"+Or,nS="__reactListeners$"+Or,rS="__reactHandles$"+Or;function nr(n){var r=n[Ji];if(r)return r;for(var l=n.parentNode;l;){if(r=l[hn]||l[Ji]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=Af(n);n!==null;){if(l=n[Ji])return l;n=Af(n)}return r}n=l,l=n.parentNode}return null}function Fs(n){return n=n[Ji]||n[hn],!n||n.tag!==5&&n.tag!==6&&n.tag!==13&&n.tag!==3?null:n}function zr(n){if(n.tag===5||n.tag===6)return n.stateNode;throw Error(i(33))}function Zo(n){return n[zs]||null}var cc=[],Fr=-1;function Ln(n){return{current:n}}function pt(n){0>Fr||(n.current=cc[Fr],cc[Fr]=null,Fr--)}function ht(n,r){Fr++,cc[Fr]=n.current,n.current=r}var Mn={},ti=Ln(Mn),fi=Ln(!1),rr=Mn;function $r(n,r){var l=n.type.contextTypes;if(!l)return Mn;var d=n.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var m={},v;for(v in l)m[v]=r[v];return d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=r,n.__reactInternalMemoizedMaskedChildContext=m),m}function pi(n){return n=n.childContextTypes,n!=null}function ea(){pt(fi),pt(ti)}function If(n,r,l){if(ti.current!==Mn)throw Error(i(168));ht(ti,r),ht(fi,l)}function Bf(n,r,l){var d=n.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return l;d=d.getChildContext();for(var m in d)if(!(m in r))throw Error(i(108,G(n)||"Unknown",m));return $({},l,d)}function ta(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Mn,rr=ti.current,ht(ti,n),ht(fi,fi.current),!0}function Of(n,r,l){var d=n.stateNode;if(!d)throw Error(i(169));l?(n=Bf(n,r,rr),d.__reactInternalMemoizedMergedChildContext=n,pt(fi),pt(ti),ht(ti,n)):pt(fi),ht(fi,l)}var fn=null,ia=!1,uc=!1;function zf(n){fn===null?fn=[n]:fn.push(n)}function sS(n){ia=!0,zf(n)}function Tn(){if(!uc&&fn!==null){uc=!0;var n=0,r=st;try{var l=fn;for(st=1;n<l.length;n++){var d=l[n];do d=d(!0);while(d!==null)}fn=null,ia=!1}catch(m){throw fn!==null&&(fn=fn.slice(n+1)),Fh(Ll,Tn),m}finally{st=r,uc=!1}}return null}var Hr=[],Wr=0,na=null,ra=0,Li=[],Mi=0,sr=null,pn=1,mn="";function or(n,r){Hr[Wr++]=ra,Hr[Wr++]=na,na=n,ra=r}function Ff(n,r,l){Li[Mi++]=pn,Li[Mi++]=mn,Li[Mi++]=sr,sr=n;var d=pn;n=mn;var m=32-Wi(d)-1;d&=~(1<<m),l+=1;var v=32-Wi(r)+m;if(30<v){var N=m-m%5;v=(d&(1<<N)-1).toString(32),d>>=N,m-=N,pn=1<<32-Wi(r)+m|l<<m|d,mn=v+n}else pn=1<<v|l<<m|d,mn=n}function dc(n){n.return!==null&&(or(n,1),Ff(n,1,0))}function hc(n){for(;n===na;)na=Hr[--Wr],Hr[Wr]=null,ra=Hr[--Wr],Hr[Wr]=null;for(;n===sr;)sr=Li[--Mi],Li[Mi]=null,mn=Li[--Mi],Li[Mi]=null,pn=Li[--Mi],Li[Mi]=null}var xi=null,Ci=null,vt=!1,Ki=null;function $f(n,r){var l=Bi(5,null,null,0);l.elementType="DELETED",l.stateNode=r,l.return=n,r=n.deletions,r===null?(n.deletions=[l],n.flags|=16):r.push(l)}function Hf(n,r){switch(n.tag){case 5:var l=n.type;return r=r.nodeType!==1||l.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(n.stateNode=r,xi=n,Ci=Dn(r.firstChild),!0):!1;case 6:return r=n.pendingProps===""||r.nodeType!==3?null:r,r!==null?(n.stateNode=r,xi=n,Ci=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(l=sr!==null?{id:pn,overflow:mn}:null,n.memoizedState={dehydrated:r,treeContext:l,retryLane:1073741824},l=Bi(18,null,null,0),l.stateNode=r,l.return=n,n.child=l,xi=n,Ci=null,!0):!1;default:return!1}}function fc(n){return(n.mode&1)!==0&&(n.flags&128)===0}function pc(n){if(vt){var r=Ci;if(r){var l=r;if(!Hf(n,r)){if(fc(n))throw Error(i(418));r=Dn(l.nextSibling);var d=xi;r&&Hf(n,r)?$f(d,l):(n.flags=n.flags&-4097|2,vt=!1,xi=n)}}else{if(fc(n))throw Error(i(418));n.flags=n.flags&-4097|2,vt=!1,xi=n}}}function Wf(n){for(n=n.return;n!==null&&n.tag!==5&&n.tag!==3&&n.tag!==13;)n=n.return;xi=n}function sa(n){if(n!==xi)return!1;if(!vt)return Wf(n),vt=!0,!1;var r;if((r=n.tag!==3)&&!(r=n.tag!==5)&&(r=n.type,r=r!=="head"&&r!=="body"&&!sc(n.type,n.memoizedProps)),r&&(r=Ci)){if(fc(n))throw Uf(),Error(i(418));for(;r;)$f(n,r),r=Dn(r.nextSibling)}if(Wf(n),n.tag===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(i(317));e:{for(n=n.nextSibling,r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"){if(r===0){Ci=Dn(n.nextSibling);break e}r--}else l!=="$"&&l!=="$!"&&l!=="$?"||r++}n=n.nextSibling}Ci=null}}else Ci=xi?Dn(n.stateNode.nextSibling):null;return!0}function Uf(){for(var n=Ci;n;)n=Dn(n.nextSibling)}function Ur(){Ci=xi=null,vt=!1}function mc(n){Ki===null?Ki=[n]:Ki.push(n)}var oS=M.ReactCurrentBatchConfig;function $s(n,r,l){if(n=l.ref,n!==null&&typeof n!="function"&&typeof n!="object"){if(l._owner){if(l=l._owner,l){if(l.tag!==1)throw Error(i(309));var d=l.stateNode}if(!d)throw Error(i(147,n));var m=d,v=""+n;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===v?r.ref:(r=function(N){var O=m.refs;N===null?delete O[v]:O[v]=N},r._stringRef=v,r)}if(typeof n!="string")throw Error(i(284));if(!l._owner)throw Error(i(290,n))}return n}function oa(n,r){throw n=Object.prototype.toString.call(r),Error(i(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n))}function Kf(n){var r=n._init;return r(n._payload)}function qf(n){function r(ne,Q){if(n){var se=ne.deletions;se===null?(ne.deletions=[Q],ne.flags|=16):se.push(Q)}}function l(ne,Q){if(!n)return null;for(;Q!==null;)r(ne,Q),Q=Q.sibling;return null}function d(ne,Q){for(ne=new Map;Q!==null;)Q.key!==null?ne.set(Q.key,Q):ne.set(Q.index,Q),Q=Q.sibling;return ne}function m(ne,Q){return ne=Hn(ne,Q),ne.index=0,ne.sibling=null,ne}function v(ne,Q,se){return ne.index=se,n?(se=ne.alternate,se!==null?(se=se.index,se<Q?(ne.flags|=2,Q):se):(ne.flags|=2,Q)):(ne.flags|=1048576,Q)}function N(ne){return n&&ne.alternate===null&&(ne.flags|=2),ne}function O(ne,Q,se,be){return Q===null||Q.tag!==6?(Q=ou(se,ne.mode,be),Q.return=ne,Q):(Q=m(Q,se),Q.return=ne,Q)}function Y(ne,Q,se,be){var Ie=se.type;return Ie===B?we(ne,Q,se.props.children,be,se.key):Q!==null&&(Q.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===U&&Kf(Ie)===Q.type)?(be=m(Q,se.props),be.ref=$s(ne,Q,se),be.return=ne,be):(be=ja(se.type,se.key,se.props,null,ne.mode,be),be.ref=$s(ne,Q,se),be.return=ne,be)}function le(ne,Q,se,be){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==se.containerInfo||Q.stateNode.implementation!==se.implementation?(Q=au(se,ne.mode,be),Q.return=ne,Q):(Q=m(Q,se.children||[]),Q.return=ne,Q)}function we(ne,Q,se,be,Ie){return Q===null||Q.tag!==7?(Q=pr(se,ne.mode,be,Ie),Q.return=ne,Q):(Q=m(Q,se),Q.return=ne,Q)}function Se(ne,Q,se){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=ou(""+Q,ne.mode,se),Q.return=ne,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case ee:return se=ja(Q.type,Q.key,Q.props,null,ne.mode,se),se.ref=$s(ne,null,Q),se.return=ne,se;case q:return Q=au(Q,ne.mode,se),Q.return=ne,Q;case U:var be=Q._init;return Se(ne,be(Q._payload),se)}if(dt(Q)||V(Q))return Q=pr(Q,ne.mode,se,null),Q.return=ne,Q;oa(ne,Q)}return null}function ye(ne,Q,se,be){var Ie=Q!==null?Q.key:null;if(typeof se=="string"&&se!==""||typeof se=="number")return Ie!==null?null:O(ne,Q,""+se,be);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case ee:return se.key===Ie?Y(ne,Q,se,be):null;case q:return se.key===Ie?le(ne,Q,se,be):null;case U:return Ie=se._init,ye(ne,Q,Ie(se._payload),be)}if(dt(se)||V(se))return Ie!==null?null:we(ne,Q,se,be,null);oa(ne,se)}return null}function De(ne,Q,se,be,Ie){if(typeof be=="string"&&be!==""||typeof be=="number")return ne=ne.get(se)||null,O(Q,ne,""+be,Ie);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case ee:return ne=ne.get(be.key===null?se:be.key)||null,Y(Q,ne,be,Ie);case q:return ne=ne.get(be.key===null?se:be.key)||null,le(Q,ne,be,Ie);case U:var $e=be._init;return De(ne,Q,se,$e(be._payload),Ie)}if(dt(be)||V(be))return ne=ne.get(se)||null,we(Q,ne,be,Ie,null);oa(Q,be)}return null}function Te(ne,Q,se,be){for(var Ie=null,$e=null,He=Q,We=Q=0,Ht=null;He!==null&&We<se.length;We++){He.index>We?(Ht=He,He=null):Ht=He.sibling;var it=ye(ne,He,se[We],be);if(it===null){He===null&&(He=Ht);break}n&&He&&it.alternate===null&&r(ne,He),Q=v(it,Q,We),$e===null?Ie=it:$e.sibling=it,$e=it,He=Ht}if(We===se.length)return l(ne,He),vt&&or(ne,We),Ie;if(He===null){for(;We<se.length;We++)He=Se(ne,se[We],be),He!==null&&(Q=v(He,Q,We),$e===null?Ie=He:$e.sibling=He,$e=He);return vt&&or(ne,We),Ie}for(He=d(ne,He);We<se.length;We++)Ht=De(He,ne,We,se[We],be),Ht!==null&&(n&&Ht.alternate!==null&&He.delete(Ht.key===null?We:Ht.key),Q=v(Ht,Q,We),$e===null?Ie=Ht:$e.sibling=Ht,$e=Ht);return n&&He.forEach(function(Wn){return r(ne,Wn)}),vt&&or(ne,We),Ie}function Ae(ne,Q,se,be){var Ie=V(se);if(typeof Ie!="function")throw Error(i(150));if(se=Ie.call(se),se==null)throw Error(i(151));for(var $e=Ie=null,He=Q,We=Q=0,Ht=null,it=se.next();He!==null&&!it.done;We++,it=se.next()){He.index>We?(Ht=He,He=null):Ht=He.sibling;var Wn=ye(ne,He,it.value,be);if(Wn===null){He===null&&(He=Ht);break}n&&He&&Wn.alternate===null&&r(ne,He),Q=v(Wn,Q,We),$e===null?Ie=Wn:$e.sibling=Wn,$e=Wn,He=Ht}if(it.done)return l(ne,He),vt&&or(ne,We),Ie;if(He===null){for(;!it.done;We++,it=se.next())it=Se(ne,it.value,be),it!==null&&(Q=v(it,Q,We),$e===null?Ie=it:$e.sibling=it,$e=it);return vt&&or(ne,We),Ie}for(He=d(ne,He);!it.done;We++,it=se.next())it=De(He,ne,We,it.value,be),it!==null&&(n&&it.alternate!==null&&He.delete(it.key===null?We:it.key),Q=v(it,Q,We),$e===null?Ie=it:$e.sibling=it,$e=it);return n&&He.forEach(function(zS){return r(ne,zS)}),vt&&or(ne,We),Ie}function Pt(ne,Q,se,be){if(typeof se=="object"&&se!==null&&se.type===B&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case ee:e:{for(var Ie=se.key,$e=Q;$e!==null;){if($e.key===Ie){if(Ie=se.type,Ie===B){if($e.tag===7){l(ne,$e.sibling),Q=m($e,se.props.children),Q.return=ne,ne=Q;break e}}else if($e.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===U&&Kf(Ie)===$e.type){l(ne,$e.sibling),Q=m($e,se.props),Q.ref=$s(ne,$e,se),Q.return=ne,ne=Q;break e}l(ne,$e);break}else r(ne,$e);$e=$e.sibling}se.type===B?(Q=pr(se.props.children,ne.mode,be,se.key),Q.return=ne,ne=Q):(be=ja(se.type,se.key,se.props,null,ne.mode,be),be.ref=$s(ne,Q,se),be.return=ne,ne=be)}return N(ne);case q:e:{for($e=se.key;Q!==null;){if(Q.key===$e)if(Q.tag===4&&Q.stateNode.containerInfo===se.containerInfo&&Q.stateNode.implementation===se.implementation){l(ne,Q.sibling),Q=m(Q,se.children||[]),Q.return=ne,ne=Q;break e}else{l(ne,Q);break}else r(ne,Q);Q=Q.sibling}Q=au(se,ne.mode,be),Q.return=ne,ne=Q}return N(ne);case U:return $e=se._init,Pt(ne,Q,$e(se._payload),be)}if(dt(se))return Te(ne,Q,se,be);if(V(se))return Ae(ne,Q,se,be);oa(ne,se)}return typeof se=="string"&&se!==""||typeof se=="number"?(se=""+se,Q!==null&&Q.tag===6?(l(ne,Q.sibling),Q=m(Q,se),Q.return=ne,ne=Q):(l(ne,Q),Q=ou(se,ne.mode,be),Q.return=ne,ne=Q),N(ne)):l(ne,Q)}return Pt}var Kr=qf(!0),Vf=qf(!1),aa=Ln(null),la=null,qr=null,gc=null;function vc(){gc=qr=la=null}function _c(n){var r=aa.current;pt(aa),n._currentValue=r}function yc(n,r,l){for(;n!==null;){var d=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),n===l)break;n=n.return}}function Vr(n,r){la=n,gc=qr=null,n=n.dependencies,n!==null&&n.firstContext!==null&&((n.lanes&r)!==0&&(mi=!0),n.firstContext=null)}function Ti(n){var r=n._currentValue;if(gc!==n)if(n={context:n,memoizedValue:r,next:null},qr===null){if(la===null)throw Error(i(308));qr=n,la.dependencies={lanes:0,firstContext:n}}else qr=qr.next=n;return r}var ar=null;function wc(n){ar===null?ar=[n]:ar.push(n)}function Yf(n,r,l,d){var m=r.interleaved;return m===null?(l.next=l,wc(r)):(l.next=m.next,m.next=l),r.interleaved=l,gn(n,d)}function gn(n,r){n.lanes|=r;var l=n.alternate;for(l!==null&&(l.lanes|=r),l=n,n=n.return;n!==null;)n.childLanes|=r,l=n.alternate,l!==null&&(l.childLanes|=r),l=n,n=n.return;return l.tag===3?l.stateNode:null}var An=!1;function Sc(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xf(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function vn(n,r){return{eventTime:n,lane:r,tag:0,payload:null,callback:null,next:null}}function In(n,r,l){var d=n.updateQueue;if(d===null)return null;if(d=d.shared,(tt&2)!==0){var m=d.pending;return m===null?r.next=r:(r.next=m.next,m.next=r),d.pending=r,gn(n,l)}return m=d.interleaved,m===null?(r.next=r,wc(d)):(r.next=m.next,m.next=r),d.interleaved=r,gn(n,l)}function ca(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194240)!==0)){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,Al(n,l)}}function Gf(n,r){var l=n.updateQueue,d=n.alternate;if(d!==null&&(d=d.updateQueue,l===d)){var m=null,v=null;if(l=l.firstBaseUpdate,l!==null){do{var N={eventTime:l.eventTime,lane:l.lane,tag:l.tag,payload:l.payload,callback:l.callback,next:null};v===null?m=v=N:v=v.next=N,l=l.next}while(l!==null);v===null?m=v=r:v=v.next=r}else m=v=r;l={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:v,shared:d.shared,effects:d.effects},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}function ua(n,r,l,d){var m=n.updateQueue;An=!1;var v=m.firstBaseUpdate,N=m.lastBaseUpdate,O=m.shared.pending;if(O!==null){m.shared.pending=null;var Y=O,le=Y.next;Y.next=null,N===null?v=le:N.next=le,N=Y;var we=n.alternate;we!==null&&(we=we.updateQueue,O=we.lastBaseUpdate,O!==N&&(O===null?we.firstBaseUpdate=le:O.next=le,we.lastBaseUpdate=Y))}if(v!==null){var Se=m.baseState;N=0,we=le=Y=null,O=v;do{var ye=O.lane,De=O.eventTime;if((d&ye)===ye){we!==null&&(we=we.next={eventTime:De,lane:0,tag:O.tag,payload:O.payload,callback:O.callback,next:null});e:{var Te=n,Ae=O;switch(ye=r,De=l,Ae.tag){case 1:if(Te=Ae.payload,typeof Te=="function"){Se=Te.call(De,Se,ye);break e}Se=Te;break e;case 3:Te.flags=Te.flags&-65537|128;case 0:if(Te=Ae.payload,ye=typeof Te=="function"?Te.call(De,Se,ye):Te,ye==null)break e;Se=$({},Se,ye);break e;case 2:An=!0}}O.callback!==null&&O.lane!==0&&(n.flags|=64,ye=m.effects,ye===null?m.effects=[O]:ye.push(O))}else De={eventTime:De,lane:ye,tag:O.tag,payload:O.payload,callback:O.callback,next:null},we===null?(le=we=De,Y=Se):we=we.next=De,N|=ye;if(O=O.next,O===null){if(O=m.shared.pending,O===null)break;ye=O,O=ye.next,ye.next=null,m.lastBaseUpdate=ye,m.shared.pending=null}}while(!0);if(we===null&&(Y=Se),m.baseState=Y,m.firstBaseUpdate=le,m.lastBaseUpdate=we,r=m.shared.interleaved,r!==null){m=r;do N|=m.lane,m=m.next;while(m!==r)}else v===null&&(m.shared.lanes=0);ur|=N,n.lanes=N,n.memoizedState=Se}}function Qf(n,r,l){if(n=r.effects,r.effects=null,n!==null)for(r=0;r<n.length;r++){var d=n[r],m=d.callback;if(m!==null){if(d.callback=null,d=l,typeof m!="function")throw Error(i(191,m));m.call(d)}}}var Hs={},Zi=Ln(Hs),Ws=Ln(Hs),Us=Ln(Hs);function lr(n){if(n===Hs)throw Error(i(174));return n}function bc(n,r){switch(ht(Us,r),ht(Ws,n),ht(Zi,Hs),n=r.nodeType,n){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:Ee(null,"");break;default:n=n===8?r.parentNode:r,r=n.namespaceURI||null,n=n.tagName,r=Ee(r,n)}pt(Zi),ht(Zi,r)}function Yr(){pt(Zi),pt(Ws),pt(Us)}function Jf(n){lr(Us.current);var r=lr(Zi.current),l=Ee(r,n.type);r!==l&&(ht(Ws,n),ht(Zi,l))}function xc(n){Ws.current===n&&(pt(Zi),pt(Ws))}var yt=Ln(0);function da(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||l.data==="$?"||l.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Cc=[];function kc(){for(var n=0;n<Cc.length;n++)Cc[n]._workInProgressVersionPrimary=null;Cc.length=0}var ha=M.ReactCurrentDispatcher,Ec=M.ReactCurrentBatchConfig,cr=0,wt=null,Tt=null,Ft=null,fa=!1,Ks=!1,qs=0,aS=0;function ii(){throw Error(i(321))}function Nc(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Ui(n[l],r[l]))return!1;return!0}function Rc(n,r,l,d,m,v){if(cr=v,wt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,ha.current=n===null||n.memoizedState===null?dS:hS,n=l(d,m),Ks){v=0;do{if(Ks=!1,qs=0,25<=v)throw Error(i(301));v+=1,Ft=Tt=null,r.updateQueue=null,ha.current=fS,n=l(d,m)}while(Ks)}if(ha.current=ga,r=Tt!==null&&Tt.next!==null,cr=0,Ft=Tt=wt=null,fa=!1,r)throw Error(i(300));return n}function Pc(){var n=qs!==0;return qs=0,n}function en(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ft===null?wt.memoizedState=Ft=n:Ft=Ft.next=n,Ft}function Ai(){if(Tt===null){var n=wt.alternate;n=n!==null?n.memoizedState:null}else n=Tt.next;var r=Ft===null?wt.memoizedState:Ft.next;if(r!==null)Ft=r,Tt=n;else{if(n===null)throw Error(i(310));Tt=n,n={memoizedState:Tt.memoizedState,baseState:Tt.baseState,baseQueue:Tt.baseQueue,queue:Tt.queue,next:null},Ft===null?wt.memoizedState=Ft=n:Ft=Ft.next=n}return Ft}function Vs(n,r){return typeof r=="function"?r(n):r}function jc(n){var r=Ai(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var d=Tt,m=d.baseQueue,v=l.pending;if(v!==null){if(m!==null){var N=m.next;m.next=v.next,v.next=N}d.baseQueue=m=v,l.pending=null}if(m!==null){v=m.next,d=d.baseState;var O=N=null,Y=null,le=v;do{var we=le.lane;if((cr&we)===we)Y!==null&&(Y=Y.next={lane:0,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),d=le.hasEagerState?le.eagerState:n(d,le.action);else{var Se={lane:we,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null};Y===null?(O=Y=Se,N=d):Y=Y.next=Se,wt.lanes|=we,ur|=we}le=le.next}while(le!==null&&le!==v);Y===null?N=d:Y.next=O,Ui(d,r.memoizedState)||(mi=!0),r.memoizedState=d,r.baseState=N,r.baseQueue=Y,l.lastRenderedState=d}if(n=l.interleaved,n!==null){m=n;do v=m.lane,wt.lanes|=v,ur|=v,m=m.next;while(m!==n)}else m===null&&(l.lanes=0);return[r.memoizedState,l.dispatch]}function Dc(n){var r=Ai(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=n;var d=l.dispatch,m=l.pending,v=r.memoizedState;if(m!==null){l.pending=null;var N=m=m.next;do v=n(v,N.action),N=N.next;while(N!==m);Ui(v,r.memoizedState)||(mi=!0),r.memoizedState=v,r.baseQueue===null&&(r.baseState=v),l.lastRenderedState=v}return[v,d]}function Zf(){}function ep(n,r){var l=wt,d=Ai(),m=r(),v=!Ui(d.memoizedState,m);if(v&&(d.memoizedState=m,mi=!0),d=d.queue,Lc(np.bind(null,l,d,n),[n]),d.getSnapshot!==r||v||Ft!==null&&Ft.memoizedState.tag&1){if(l.flags|=2048,Ys(9,ip.bind(null,l,d,m,r),void 0,null),$t===null)throw Error(i(349));(cr&30)!==0||tp(l,r,m)}return m}function tp(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=wt.updateQueue,r===null?(r={lastEffect:null,stores:null},wt.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function ip(n,r,l,d){r.value=l,r.getSnapshot=d,rp(r)&&sp(n)}function np(n,r,l){return l(function(){rp(r)&&sp(n)})}function rp(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Ui(n,l)}catch{return!0}}function sp(n){var r=gn(n,1);r!==null&&Xi(r,n,1,-1)}function op(n){var r=en();return typeof n=="function"&&(n=n()),r.memoizedState=r.baseState=n,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Vs,lastRenderedState:n},r.queue=n,n=n.dispatch=uS.bind(null,wt,n),[r.memoizedState,n]}function Ys(n,r,l,d){return n={tag:n,create:r,destroy:l,deps:d,next:null},r=wt.updateQueue,r===null?(r={lastEffect:null,stores:null},wt.updateQueue=r,r.lastEffect=n.next=n):(l=r.lastEffect,l===null?r.lastEffect=n.next=n:(d=l.next,l.next=n,n.next=d,r.lastEffect=n)),n}function ap(){return Ai().memoizedState}function pa(n,r,l,d){var m=en();wt.flags|=n,m.memoizedState=Ys(1|r,l,void 0,d===void 0?null:d)}function ma(n,r,l,d){var m=Ai();d=d===void 0?null:d;var v=void 0;if(Tt!==null){var N=Tt.memoizedState;if(v=N.destroy,d!==null&&Nc(d,N.deps)){m.memoizedState=Ys(r,l,v,d);return}}wt.flags|=n,m.memoizedState=Ys(1|r,l,v,d)}function lp(n,r){return pa(8390656,8,n,r)}function Lc(n,r){return ma(2048,8,n,r)}function cp(n,r){return ma(4,2,n,r)}function up(n,r){return ma(4,4,n,r)}function dp(n,r){if(typeof r=="function")return n=n(),r(n),function(){r(null)};if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function hp(n,r,l){return l=l!=null?l.concat([n]):null,ma(4,4,dp.bind(null,r,n),l)}function Mc(){}function fp(n,r){var l=Ai();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&Nc(r,d[1])?d[0]:(l.memoizedState=[n,r],n)}function pp(n,r){var l=Ai();r=r===void 0?null:r;var d=l.memoizedState;return d!==null&&r!==null&&Nc(r,d[1])?d[0]:(n=n(),l.memoizedState=[n,r],n)}function mp(n,r,l){return(cr&21)===0?(n.baseState&&(n.baseState=!1,mi=!0),n.memoizedState=l):(Ui(l,r)||(l=Uh(),wt.lanes|=l,ur|=l,n.baseState=!0),r)}function lS(n,r){var l=st;st=l!==0&&4>l?l:4,n(!0);var d=Ec.transition;Ec.transition={};try{n(!1),r()}finally{st=l,Ec.transition=d}}function gp(){return Ai().memoizedState}function cS(n,r,l){var d=Fn(n);if(l={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null},vp(n))_p(r,l);else if(l=Yf(n,r,l,d),l!==null){var m=li();Xi(l,n,d,m),yp(l,r,d)}}function uS(n,r,l){var d=Fn(n),m={lane:d,action:l,hasEagerState:!1,eagerState:null,next:null};if(vp(n))_p(r,m);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=r.lastRenderedReducer,v!==null))try{var N=r.lastRenderedState,O=v(N,l);if(m.hasEagerState=!0,m.eagerState=O,Ui(O,N)){var Y=r.interleaved;Y===null?(m.next=m,wc(r)):(m.next=Y.next,Y.next=m),r.interleaved=m;return}}catch{}finally{}l=Yf(n,r,m,d),l!==null&&(m=li(),Xi(l,n,d,m),yp(l,r,d))}}function vp(n){var r=n.alternate;return n===wt||r!==null&&r===wt}function _p(n,r){Ks=fa=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function yp(n,r,l){if((l&4194240)!==0){var d=r.lanes;d&=n.pendingLanes,l|=d,r.lanes=l,Al(n,l)}}var ga={readContext:Ti,useCallback:ii,useContext:ii,useEffect:ii,useImperativeHandle:ii,useInsertionEffect:ii,useLayoutEffect:ii,useMemo:ii,useReducer:ii,useRef:ii,useState:ii,useDebugValue:ii,useDeferredValue:ii,useTransition:ii,useMutableSource:ii,useSyncExternalStore:ii,useId:ii,unstable_isNewReconciler:!1},dS={readContext:Ti,useCallback:function(n,r){return en().memoizedState=[n,r===void 0?null:r],n},useContext:Ti,useEffect:lp,useImperativeHandle:function(n,r,l){return l=l!=null?l.concat([n]):null,pa(4194308,4,dp.bind(null,r,n),l)},useLayoutEffect:function(n,r){return pa(4194308,4,n,r)},useInsertionEffect:function(n,r){return pa(4,2,n,r)},useMemo:function(n,r){var l=en();return r=r===void 0?null:r,n=n(),l.memoizedState=[n,r],n},useReducer:function(n,r,l){var d=en();return r=l!==void 0?l(r):r,d.memoizedState=d.baseState=r,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:r},d.queue=n,n=n.dispatch=cS.bind(null,wt,n),[d.memoizedState,n]},useRef:function(n){var r=en();return n={current:n},r.memoizedState=n},useState:op,useDebugValue:Mc,useDeferredValue:function(n){return en().memoizedState=n},useTransition:function(){var n=op(!1),r=n[0];return n=lS.bind(null,n[1]),en().memoizedState=n,[r,n]},useMutableSource:function(){},useSyncExternalStore:function(n,r,l){var d=wt,m=en();if(vt){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),$t===null)throw Error(i(349));(cr&30)!==0||tp(d,r,l)}m.memoizedState=l;var v={value:l,getSnapshot:r};return m.queue=v,lp(np.bind(null,d,v,n),[n]),d.flags|=2048,Ys(9,ip.bind(null,d,v,l,r),void 0,null),l},useId:function(){var n=en(),r=$t.identifierPrefix;if(vt){var l=mn,d=pn;l=(d&~(1<<32-Wi(d)-1)).toString(32)+l,r=":"+r+"R"+l,l=qs++,0<l&&(r+="H"+l.toString(32)),r+=":"}else l=aS++,r=":"+r+"r"+l.toString(32)+":";return n.memoizedState=r},unstable_isNewReconciler:!1},hS={readContext:Ti,useCallback:fp,useContext:Ti,useEffect:Lc,useImperativeHandle:hp,useInsertionEffect:cp,useLayoutEffect:up,useMemo:pp,useReducer:jc,useRef:ap,useState:function(){return jc(Vs)},useDebugValue:Mc,useDeferredValue:function(n){var r=Ai();return mp(r,Tt.memoizedState,n)},useTransition:function(){var n=jc(Vs)[0],r=Ai().memoizedState;return[n,r]},useMutableSource:Zf,useSyncExternalStore:ep,useId:gp,unstable_isNewReconciler:!1},fS={readContext:Ti,useCallback:fp,useContext:Ti,useEffect:Lc,useImperativeHandle:hp,useInsertionEffect:cp,useLayoutEffect:up,useMemo:pp,useReducer:Dc,useRef:ap,useState:function(){return Dc(Vs)},useDebugValue:Mc,useDeferredValue:function(n){var r=Ai();return Tt===null?r.memoizedState=n:mp(r,Tt.memoizedState,n)},useTransition:function(){var n=Dc(Vs)[0],r=Ai().memoizedState;return[n,r]},useMutableSource:Zf,useSyncExternalStore:ep,useId:gp,unstable_isNewReconciler:!1};function qi(n,r){if(n&&n.defaultProps){r=$({},r),n=n.defaultProps;for(var l in n)r[l]===void 0&&(r[l]=n[l]);return r}return r}function Tc(n,r,l,d){r=n.memoizedState,l=l(d,r),l=l==null?r:$({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var va={isMounted:function(n){return(n=n._reactInternals)?ir(n)===n:!1},enqueueSetState:function(n,r,l){n=n._reactInternals;var d=li(),m=Fn(n),v=vn(d,m);v.payload=r,l!=null&&(v.callback=l),r=In(n,v,m),r!==null&&(Xi(r,n,m,d),ca(r,n,m))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var d=li(),m=Fn(n),v=vn(d,m);v.tag=1,v.payload=r,l!=null&&(v.callback=l),r=In(n,v,m),r!==null&&(Xi(r,n,m,d),ca(r,n,m))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=li(),d=Fn(n),m=vn(l,d);m.tag=2,r!=null&&(m.callback=r),r=In(n,m,d),r!==null&&(Xi(r,n,d,l),ca(r,n,d))}};function wp(n,r,l,d,m,v,N){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(d,v,N):r.prototype&&r.prototype.isPureReactComponent?!Ts(l,d)||!Ts(m,v):!0}function Sp(n,r,l){var d=!1,m=Mn,v=r.contextType;return typeof v=="object"&&v!==null?v=Ti(v):(m=pi(r)?rr:ti.current,d=r.contextTypes,v=(d=d!=null)?$r(n,m):Mn),r=new r(l,v),n.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=va,n.stateNode=r,r._reactInternals=n,d&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=m,n.__reactInternalMemoizedMaskedChildContext=v),r}function bp(n,r,l,d){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,d),r.state!==n&&va.enqueueReplaceState(r,r.state,null)}function Ac(n,r,l,d){var m=n.stateNode;m.props=l,m.state=n.memoizedState,m.refs={},Sc(n);var v=r.contextType;typeof v=="object"&&v!==null?m.context=Ti(v):(v=pi(r)?rr:ti.current,m.context=$r(n,v)),m.state=n.memoizedState,v=r.getDerivedStateFromProps,typeof v=="function"&&(Tc(n,r,v,l),m.state=n.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(r=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),r!==m.state&&va.enqueueReplaceState(m,m.state,null),ua(n,l,m,d),m.state=n.memoizedState),typeof m.componentDidMount=="function"&&(n.flags|=4194308)}function Xr(n,r){try{var l="",d=r;do l+=he(d),d=d.return;while(d);var m=l}catch(v){m=`
|
|
39
|
+
Error generating stack: `+v.message+`
|
|
40
|
+
`+v.stack}return{value:n,source:r,stack:m,digest:null}}function Ic(n,r,l){return{value:n,source:null,stack:l??null,digest:r??null}}function Bc(n,r){try{console.error(r.value)}catch(l){setTimeout(function(){throw l})}}var pS=typeof WeakMap=="function"?WeakMap:Map;function xp(n,r,l){l=vn(-1,l),l.tag=3,l.payload={element:null};var d=r.value;return l.callback=function(){Ca||(Ca=!0,Jc=d),Bc(n,r)},l}function Cp(n,r,l){l=vn(-1,l),l.tag=3;var d=n.type.getDerivedStateFromError;if(typeof d=="function"){var m=r.value;l.payload=function(){return d(m)},l.callback=function(){Bc(n,r)}}var v=n.stateNode;return v!==null&&typeof v.componentDidCatch=="function"&&(l.callback=function(){Bc(n,r),typeof d!="function"&&(On===null?On=new Set([this]):On.add(this));var N=r.stack;this.componentDidCatch(r.value,{componentStack:N!==null?N:""})}),l}function kp(n,r,l){var d=n.pingCache;if(d===null){d=n.pingCache=new pS;var m=new Set;d.set(r,m)}else m=d.get(r),m===void 0&&(m=new Set,d.set(r,m));m.has(l)||(m.add(l),n=RS.bind(null,n,r,l),r.then(n,n))}function Ep(n){do{var r;if((r=n.tag===13)&&(r=n.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return n;n=n.return}while(n!==null);return null}function Np(n,r,l,d,m){return(n.mode&1)===0?(n===r?n.flags|=65536:(n.flags|=128,l.flags|=131072,l.flags&=-52805,l.tag===1&&(l.alternate===null?l.tag=17:(r=vn(-1,1),r.tag=2,In(l,r,1))),l.lanes|=1),n):(n.flags|=65536,n.lanes=m,n)}var mS=M.ReactCurrentOwner,mi=!1;function ai(n,r,l,d){r.child=n===null?Vf(r,null,l,d):Kr(r,n.child,l,d)}function Rp(n,r,l,d,m){l=l.render;var v=r.ref;return Vr(r,m),d=Rc(n,r,l,d,v,m),l=Pc(),n!==null&&!mi?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~m,_n(n,r,m)):(vt&&l&&dc(r),r.flags|=1,ai(n,r,d,m),r.child)}function Pp(n,r,l,d,m){if(n===null){var v=l.type;return typeof v=="function"&&!su(v)&&v.defaultProps===void 0&&l.compare===null&&l.defaultProps===void 0?(r.tag=15,r.type=v,jp(n,r,v,d,m)):(n=ja(l.type,null,d,r,r.mode,m),n.ref=r.ref,n.return=r,r.child=n)}if(v=n.child,(n.lanes&m)===0){var N=v.memoizedProps;if(l=l.compare,l=l!==null?l:Ts,l(N,d)&&n.ref===r.ref)return _n(n,r,m)}return r.flags|=1,n=Hn(v,d),n.ref=r.ref,n.return=r,r.child=n}function jp(n,r,l,d,m){if(n!==null){var v=n.memoizedProps;if(Ts(v,d)&&n.ref===r.ref)if(mi=!1,r.pendingProps=d=v,(n.lanes&m)!==0)(n.flags&131072)!==0&&(mi=!0);else return r.lanes=n.lanes,_n(n,r,m)}return Oc(n,r,l,d,m)}function Dp(n,r,l){var d=r.pendingProps,m=d.children,v=n!==null?n.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},ht(Qr,ki),ki|=l;else{if((l&1073741824)===0)return n=v!==null?v.baseLanes|l:l,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:n,cachePool:null,transitions:null},r.updateQueue=null,ht(Qr,ki),ki|=n,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=v!==null?v.baseLanes:l,ht(Qr,ki),ki|=d}else v!==null?(d=v.baseLanes|l,r.memoizedState=null):d=l,ht(Qr,ki),ki|=d;return ai(n,r,m,l),r.child}function Lp(n,r){var l=r.ref;(n===null&&l!==null||n!==null&&n.ref!==l)&&(r.flags|=512,r.flags|=2097152)}function Oc(n,r,l,d,m){var v=pi(l)?rr:ti.current;return v=$r(r,v),Vr(r,m),l=Rc(n,r,l,d,v,m),d=Pc(),n!==null&&!mi?(r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~m,_n(n,r,m)):(vt&&d&&dc(r),r.flags|=1,ai(n,r,l,m),r.child)}function Mp(n,r,l,d,m){if(pi(l)){var v=!0;ta(r)}else v=!1;if(Vr(r,m),r.stateNode===null)ya(n,r),Sp(r,l,d),Ac(r,l,d,m),d=!0;else if(n===null){var N=r.stateNode,O=r.memoizedProps;N.props=O;var Y=N.context,le=l.contextType;typeof le=="object"&&le!==null?le=Ti(le):(le=pi(l)?rr:ti.current,le=$r(r,le));var we=l.getDerivedStateFromProps,Se=typeof we=="function"||typeof N.getSnapshotBeforeUpdate=="function";Se||typeof N.UNSAFE_componentWillReceiveProps!="function"&&typeof N.componentWillReceiveProps!="function"||(O!==d||Y!==le)&&bp(r,N,d,le),An=!1;var ye=r.memoizedState;N.state=ye,ua(r,d,N,m),Y=r.memoizedState,O!==d||ye!==Y||fi.current||An?(typeof we=="function"&&(Tc(r,l,we,d),Y=r.memoizedState),(O=An||wp(r,l,O,d,ye,Y,le))?(Se||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||(typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount()),typeof N.componentDidMount=="function"&&(r.flags|=4194308)):(typeof N.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=Y),N.props=d,N.state=Y,N.context=le,d=O):(typeof N.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{N=r.stateNode,Xf(n,r),O=r.memoizedProps,le=r.type===r.elementType?O:qi(r.type,O),N.props=le,Se=r.pendingProps,ye=N.context,Y=l.contextType,typeof Y=="object"&&Y!==null?Y=Ti(Y):(Y=pi(l)?rr:ti.current,Y=$r(r,Y));var De=l.getDerivedStateFromProps;(we=typeof De=="function"||typeof N.getSnapshotBeforeUpdate=="function")||typeof N.UNSAFE_componentWillReceiveProps!="function"&&typeof N.componentWillReceiveProps!="function"||(O!==Se||ye!==Y)&&bp(r,N,d,Y),An=!1,ye=r.memoizedState,N.state=ye,ua(r,d,N,m);var Te=r.memoizedState;O!==Se||ye!==Te||fi.current||An?(typeof De=="function"&&(Tc(r,l,De,d),Te=r.memoizedState),(le=An||wp(r,l,le,d,ye,Te,Y)||!1)?(we||typeof N.UNSAFE_componentWillUpdate!="function"&&typeof N.componentWillUpdate!="function"||(typeof N.componentWillUpdate=="function"&&N.componentWillUpdate(d,Te,Y),typeof N.UNSAFE_componentWillUpdate=="function"&&N.UNSAFE_componentWillUpdate(d,Te,Y)),typeof N.componentDidUpdate=="function"&&(r.flags|=4),typeof N.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof N.componentDidUpdate!="function"||O===n.memoizedProps&&ye===n.memoizedState||(r.flags|=4),typeof N.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&ye===n.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=Te),N.props=d,N.state=Te,N.context=Y,d=le):(typeof N.componentDidUpdate!="function"||O===n.memoizedProps&&ye===n.memoizedState||(r.flags|=4),typeof N.getSnapshotBeforeUpdate!="function"||O===n.memoizedProps&&ye===n.memoizedState||(r.flags|=1024),d=!1)}return zc(n,r,l,d,v,m)}function zc(n,r,l,d,m,v){Lp(n,r);var N=(r.flags&128)!==0;if(!d&&!N)return m&&Of(r,l,!1),_n(n,r,v);d=r.stateNode,mS.current=r;var O=N&&typeof l.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,n!==null&&N?(r.child=Kr(r,n.child,null,v),r.child=Kr(r,null,O,v)):ai(n,r,O,v),r.memoizedState=d.state,m&&Of(r,l,!0),r.child}function Tp(n){var r=n.stateNode;r.pendingContext?If(n,r.pendingContext,r.pendingContext!==r.context):r.context&&If(n,r.context,!1),bc(n,r.containerInfo)}function Ap(n,r,l,d,m){return Ur(),mc(m),r.flags|=256,ai(n,r,l,d),r.child}var Fc={dehydrated:null,treeContext:null,retryLane:0};function $c(n){return{baseLanes:n,cachePool:null,transitions:null}}function Ip(n,r,l){var d=r.pendingProps,m=yt.current,v=!1,N=(r.flags&128)!==0,O;if((O=N)||(O=n!==null&&n.memoizedState===null?!1:(m&2)!==0),O?(v=!0,r.flags&=-129):(n===null||n.memoizedState!==null)&&(m|=1),ht(yt,m&1),n===null)return pc(r),n=r.memoizedState,n!==null&&(n=n.dehydrated,n!==null)?((r.mode&1)===0?r.lanes=1:n.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(N=d.children,n=d.fallback,v?(d=r.mode,v=r.child,N={mode:"hidden",children:N},(d&1)===0&&v!==null?(v.childLanes=0,v.pendingProps=N):v=Da(N,d,0,null),n=pr(n,d,l,null),v.return=r,n.return=r,v.sibling=n,r.child=v,r.child.memoizedState=$c(l),r.memoizedState=Fc,n):Hc(r,N));if(m=n.memoizedState,m!==null&&(O=m.dehydrated,O!==null))return gS(n,r,N,d,O,m,l);if(v){v=d.fallback,N=r.mode,m=n.child,O=m.sibling;var Y={mode:"hidden",children:d.children};return(N&1)===0&&r.child!==m?(d=r.child,d.childLanes=0,d.pendingProps=Y,r.deletions=null):(d=Hn(m,Y),d.subtreeFlags=m.subtreeFlags&14680064),O!==null?v=Hn(O,v):(v=pr(v,N,l,null),v.flags|=2),v.return=r,d.return=r,d.sibling=v,r.child=d,d=v,v=r.child,N=n.child.memoizedState,N=N===null?$c(l):{baseLanes:N.baseLanes|l,cachePool:null,transitions:N.transitions},v.memoizedState=N,v.childLanes=n.childLanes&~l,r.memoizedState=Fc,d}return v=n.child,n=v.sibling,d=Hn(v,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=l),d.return=r,d.sibling=null,n!==null&&(l=r.deletions,l===null?(r.deletions=[n],r.flags|=16):l.push(n)),r.child=d,r.memoizedState=null,d}function Hc(n,r){return r=Da({mode:"visible",children:r},n.mode,0,null),r.return=n,n.child=r}function _a(n,r,l,d){return d!==null&&mc(d),Kr(r,n.child,null,l),n=Hc(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function gS(n,r,l,d,m,v,N){if(l)return r.flags&256?(r.flags&=-257,d=Ic(Error(i(422))),_a(n,r,N,d)):r.memoizedState!==null?(r.child=n.child,r.flags|=128,null):(v=d.fallback,m=r.mode,d=Da({mode:"visible",children:d.children},m,0,null),v=pr(v,m,N,null),v.flags|=2,d.return=r,v.return=r,d.sibling=v,r.child=d,(r.mode&1)!==0&&Kr(r,n.child,null,N),r.child.memoizedState=$c(N),r.memoizedState=Fc,v);if((r.mode&1)===0)return _a(n,r,N,null);if(m.data==="$!"){if(d=m.nextSibling&&m.nextSibling.dataset,d)var O=d.dgst;return d=O,v=Error(i(419)),d=Ic(v,d,void 0),_a(n,r,N,d)}if(O=(N&n.childLanes)!==0,mi||O){if(d=$t,d!==null){switch(N&-N){case 4:m=2;break;case 16:m=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:m=32;break;case 536870912:m=268435456;break;default:m=0}m=(m&(d.suspendedLanes|N))!==0?0:m,m!==0&&m!==v.retryLane&&(v.retryLane=m,gn(n,m),Xi(d,n,m,-1))}return ru(),d=Ic(Error(i(421))),_a(n,r,N,d)}return m.data==="$?"?(r.flags|=128,r.child=n.child,r=PS.bind(null,n),m._reactRetry=r,null):(n=v.treeContext,Ci=Dn(m.nextSibling),xi=r,vt=!0,Ki=null,n!==null&&(Li[Mi++]=pn,Li[Mi++]=mn,Li[Mi++]=sr,pn=n.id,mn=n.overflow,sr=r),r=Hc(r,d.children),r.flags|=4096,r)}function Bp(n,r,l){n.lanes|=r;var d=n.alternate;d!==null&&(d.lanes|=r),yc(n.return,r,l)}function Wc(n,r,l,d,m){var v=n.memoizedState;v===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:l,tailMode:m}:(v.isBackwards=r,v.rendering=null,v.renderingStartTime=0,v.last=d,v.tail=l,v.tailMode=m)}function Op(n,r,l){var d=r.pendingProps,m=d.revealOrder,v=d.tail;if(ai(n,r,d.children,l),d=yt.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&Bp(n,l,r);else if(n.tag===19)Bp(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}d&=1}if(ht(yt,d),(r.mode&1)===0)r.memoizedState=null;else switch(m){case"forwards":for(l=r.child,m=null;l!==null;)n=l.alternate,n!==null&&da(n)===null&&(m=l),l=l.sibling;l=m,l===null?(m=r.child,r.child=null):(m=l.sibling,l.sibling=null),Wc(r,!1,m,l,v);break;case"backwards":for(l=null,m=r.child,r.child=null;m!==null;){if(n=m.alternate,n!==null&&da(n)===null){r.child=m;break}n=m.sibling,m.sibling=l,l=m,m=n}Wc(r,!0,l,null,v);break;case"together":Wc(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function ya(n,r){(r.mode&1)===0&&n!==null&&(n.alternate=null,r.alternate=null,r.flags|=2)}function _n(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),ur|=r.lanes,(l&r.childLanes)===0)return null;if(n!==null&&r.child!==n.child)throw Error(i(153));if(r.child!==null){for(n=r.child,l=Hn(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Hn(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function vS(n,r,l){switch(r.tag){case 3:Tp(r),Ur();break;case 5:Jf(r);break;case 1:pi(r.type)&&ta(r);break;case 4:bc(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,m=r.memoizedProps.value;ht(aa,d._currentValue),d._currentValue=m;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(ht(yt,yt.current&1),r.flags|=128,null):(l&r.child.childLanes)!==0?Ip(n,r,l):(ht(yt,yt.current&1),n=_n(n,r,l),n!==null?n.sibling:null);ht(yt,yt.current&1);break;case 19:if(d=(l&r.childLanes)!==0,(n.flags&128)!==0){if(d)return Op(n,r,l);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),ht(yt,yt.current),d)break;return null;case 22:case 23:return r.lanes=0,Dp(n,r,l)}return _n(n,r,l)}var zp,Uc,Fp,$p;zp=function(n,r){for(var l=r.child;l!==null;){if(l.tag===5||l.tag===6)n.appendChild(l.stateNode);else if(l.tag!==4&&l.child!==null){l.child.return=l,l=l.child;continue}if(l===r)break;for(;l.sibling===null;){if(l.return===null||l.return===r)return;l=l.return}l.sibling.return=l.return,l=l.sibling}},Uc=function(){},Fp=function(n,r,l,d){var m=n.memoizedProps;if(m!==d){n=r.stateNode,lr(Zi.current);var v=null;switch(l){case"input":m=ct(n,m),d=ct(n,d),v=[];break;case"select":m=$({},m,{value:void 0}),d=$({},d,{value:void 0}),v=[];break;case"textarea":m=ot(n,m),d=ot(n,d),v=[];break;default:typeof m.onClick!="function"&&typeof d.onClick=="function"&&(n.onclick=Jo)}Re(l,d);var N;l=null;for(le in m)if(!d.hasOwnProperty(le)&&m.hasOwnProperty(le)&&m[le]!=null)if(le==="style"){var O=m[le];for(N in O)O.hasOwnProperty(N)&&(l||(l={}),l[N]="")}else le!=="dangerouslySetInnerHTML"&&le!=="children"&&le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&le!=="autoFocus"&&(o.hasOwnProperty(le)?v||(v=[]):(v=v||[]).push(le,null));for(le in d){var Y=d[le];if(O=m!=null?m[le]:void 0,d.hasOwnProperty(le)&&Y!==O&&(Y!=null||O!=null))if(le==="style")if(O){for(N in O)!O.hasOwnProperty(N)||Y&&Y.hasOwnProperty(N)||(l||(l={}),l[N]="");for(N in Y)Y.hasOwnProperty(N)&&O[N]!==Y[N]&&(l||(l={}),l[N]=Y[N])}else l||(v||(v=[]),v.push(le,l)),l=Y;else le==="dangerouslySetInnerHTML"?(Y=Y?Y.__html:void 0,O=O?O.__html:void 0,Y!=null&&O!==Y&&(v=v||[]).push(le,Y)):le==="children"?typeof Y!="string"&&typeof Y!="number"||(v=v||[]).push(le,""+Y):le!=="suppressContentEditableWarning"&&le!=="suppressHydrationWarning"&&(o.hasOwnProperty(le)?(Y!=null&&le==="onScroll"&&ft("scroll",n),v||O===Y||(v=[])):(v=v||[]).push(le,Y))}l&&(v=v||[]).push("style",l);var le=v;(r.updateQueue=le)&&(r.flags|=4)}},$p=function(n,r,l,d){l!==d&&(r.flags|=4)};function Xs(n,r){if(!vt)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var d=null;l!==null;)l.alternate!==null&&(d=l),l=l.sibling;d===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:d.sibling=null}}function ni(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,d=0;if(r)for(var m=n.child;m!==null;)l|=m.lanes|m.childLanes,d|=m.subtreeFlags&14680064,d|=m.flags&14680064,m.return=n,m=m.sibling;else for(m=n.child;m!==null;)l|=m.lanes|m.childLanes,d|=m.subtreeFlags,d|=m.flags,m.return=n,m=m.sibling;return n.subtreeFlags|=d,n.childLanes=l,r}function _S(n,r,l){var d=r.pendingProps;switch(hc(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ni(r),null;case 1:return pi(r.type)&&ea(),ni(r),null;case 3:return d=r.stateNode,Yr(),pt(fi),pt(ti),kc(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(n===null||n.child===null)&&(sa(r)?r.flags|=4:n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,Ki!==null&&(tu(Ki),Ki=null))),Uc(n,r),ni(r),null;case 5:xc(r);var m=lr(Us.current);if(l=r.type,n!==null&&r.stateNode!=null)Fp(n,r,l,d,m),n.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(i(166));return ni(r),null}if(n=lr(Zi.current),sa(r)){d=r.stateNode,l=r.type;var v=r.memoizedProps;switch(d[Ji]=r,d[zs]=v,n=(r.mode&1)!==0,l){case"dialog":ft("cancel",d),ft("close",d);break;case"iframe":case"object":case"embed":ft("load",d);break;case"video":case"audio":for(m=0;m<Is.length;m++)ft(Is[m],d);break;case"source":ft("error",d);break;case"img":case"image":case"link":ft("error",d),ft("load",d);break;case"details":ft("toggle",d);break;case"input":Ve(d,v),ft("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!v.multiple},ft("invalid",d);break;case"textarea":ae(d,v),ft("invalid",d)}Re(l,v),m=null;for(var N in v)if(v.hasOwnProperty(N)){var O=v[N];N==="children"?typeof O=="string"?d.textContent!==O&&(v.suppressHydrationWarning!==!0&&Qo(d.textContent,O,n),m=["children",O]):typeof O=="number"&&d.textContent!==""+O&&(v.suppressHydrationWarning!==!0&&Qo(d.textContent,O,n),m=["children",""+O]):o.hasOwnProperty(N)&&O!=null&&N==="onScroll"&&ft("scroll",d)}switch(l){case"input":Ze(d),lt(d,v,!0);break;case"textarea":Ze(d),de(d);break;case"select":case"option":break;default:typeof v.onClick=="function"&&(d.onclick=Jo)}d=m,r.updateQueue=d,d!==null&&(r.flags|=4)}else{N=m.nodeType===9?m:m.ownerDocument,n==="http://www.w3.org/1999/xhtml"&&(n=Ne(l)),n==="http://www.w3.org/1999/xhtml"?l==="script"?(n=N.createElement("div"),n.innerHTML="<script><\/script>",n=n.removeChild(n.firstChild)):typeof d.is=="string"?n=N.createElement(l,{is:d.is}):(n=N.createElement(l),l==="select"&&(N=n,d.multiple?N.multiple=!0:d.size&&(N.size=d.size))):n=N.createElementNS(n,l),n[Ji]=r,n[zs]=d,zp(n,r,!1,!1),r.stateNode=n;e:{switch(N=Qe(l,d),l){case"dialog":ft("cancel",n),ft("close",n),m=d;break;case"iframe":case"object":case"embed":ft("load",n),m=d;break;case"video":case"audio":for(m=0;m<Is.length;m++)ft(Is[m],n);m=d;break;case"source":ft("error",n),m=d;break;case"img":case"image":case"link":ft("error",n),ft("load",n),m=d;break;case"details":ft("toggle",n),m=d;break;case"input":Ve(n,d),m=ct(n,d),ft("invalid",n);break;case"option":m=d;break;case"select":n._wrapperState={wasMultiple:!!d.multiple},m=$({},d,{value:void 0}),ft("invalid",n);break;case"textarea":ae(n,d),m=ot(n,d),ft("invalid",n);break;default:m=d}Re(l,m),O=m;for(v in O)if(O.hasOwnProperty(v)){var Y=O[v];v==="style"?Ce(n,Y):v==="dangerouslySetInnerHTML"?(Y=Y?Y.__html:void 0,Y!=null&&ie(n,Y)):v==="children"?typeof Y=="string"?(l!=="textarea"||Y!=="")&&F(n,Y):typeof Y=="number"&&F(n,""+Y):v!=="suppressContentEditableWarning"&&v!=="suppressHydrationWarning"&&v!=="autoFocus"&&(o.hasOwnProperty(v)?Y!=null&&v==="onScroll"&&ft("scroll",n):Y!=null&&A(n,v,Y,N))}switch(l){case"input":Ze(n),lt(n,d,!1);break;case"textarea":Ze(n),de(n);break;case"option":d.value!=null&&n.setAttribute("value",""+J(d.value));break;case"select":n.multiple=!!d.multiple,v=d.value,v!=null?rt(n,!!d.multiple,v,!1):d.defaultValue!=null&&rt(n,!!d.multiple,d.defaultValue,!0);break;default:typeof m.onClick=="function"&&(n.onclick=Jo)}switch(l){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}}d&&(r.flags|=4)}r.ref!==null&&(r.flags|=512,r.flags|=2097152)}return ni(r),null;case 6:if(n&&r.stateNode!=null)$p(n,r,n.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(i(166));if(l=lr(Us.current),lr(Zi.current),sa(r)){if(d=r.stateNode,l=r.memoizedProps,d[Ji]=r,(v=d.nodeValue!==l)&&(n=xi,n!==null))switch(n.tag){case 3:Qo(d.nodeValue,l,(n.mode&1)!==0);break;case 5:n.memoizedProps.suppressHydrationWarning!==!0&&Qo(d.nodeValue,l,(n.mode&1)!==0)}v&&(r.flags|=4)}else d=(l.nodeType===9?l:l.ownerDocument).createTextNode(d),d[Ji]=r,r.stateNode=d}return ni(r),null;case 13:if(pt(yt),d=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(vt&&Ci!==null&&(r.mode&1)!==0&&(r.flags&128)===0)Uf(),Ur(),r.flags|=98560,v=!1;else if(v=sa(r),d!==null&&d.dehydrated!==null){if(n===null){if(!v)throw Error(i(318));if(v=r.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(i(317));v[Ji]=r}else Ur(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ni(r),v=!1}else Ki!==null&&(tu(Ki),Ki=null),v=!0;if(!v)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=l,r):(d=d!==null,d!==(n!==null&&n.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(n===null||(yt.current&1)!==0?At===0&&(At=3):ru())),r.updateQueue!==null&&(r.flags|=4),ni(r),null);case 4:return Yr(),Uc(n,r),n===null&&Bs(r.stateNode.containerInfo),ni(r),null;case 10:return _c(r.type._context),ni(r),null;case 17:return pi(r.type)&&ea(),ni(r),null;case 19:if(pt(yt),v=r.memoizedState,v===null)return ni(r),null;if(d=(r.flags&128)!==0,N=v.rendering,N===null)if(d)Xs(v,!1);else{if(At!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(N=da(n),N!==null){for(r.flags|=128,Xs(v,!1),d=N.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=l,l=r.child;l!==null;)v=l,n=d,v.flags&=14680066,N=v.alternate,N===null?(v.childLanes=0,v.lanes=n,v.child=null,v.subtreeFlags=0,v.memoizedProps=null,v.memoizedState=null,v.updateQueue=null,v.dependencies=null,v.stateNode=null):(v.childLanes=N.childLanes,v.lanes=N.lanes,v.child=N.child,v.subtreeFlags=0,v.deletions=null,v.memoizedProps=N.memoizedProps,v.memoizedState=N.memoizedState,v.updateQueue=N.updateQueue,v.type=N.type,n=N.dependencies,v.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),l=l.sibling;return ht(yt,yt.current&1|2),r.child}n=n.sibling}v.tail!==null&&Rt()>Jr&&(r.flags|=128,d=!0,Xs(v,!1),r.lanes=4194304)}else{if(!d)if(n=da(N),n!==null){if(r.flags|=128,d=!0,l=n.updateQueue,l!==null&&(r.updateQueue=l,r.flags|=4),Xs(v,!0),v.tail===null&&v.tailMode==="hidden"&&!N.alternate&&!vt)return ni(r),null}else 2*Rt()-v.renderingStartTime>Jr&&l!==1073741824&&(r.flags|=128,d=!0,Xs(v,!1),r.lanes=4194304);v.isBackwards?(N.sibling=r.child,r.child=N):(l=v.last,l!==null?l.sibling=N:r.child=N,v.last=N)}return v.tail!==null?(r=v.tail,v.rendering=r,v.tail=r.sibling,v.renderingStartTime=Rt(),r.sibling=null,l=yt.current,ht(yt,d?l&1|2:l&1),r):(ni(r),null);case 22:case 23:return nu(),d=r.memoizedState!==null,n!==null&&n.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(ki&1073741824)!==0&&(ni(r),r.subtreeFlags&6&&(r.flags|=8192)):ni(r),null;case 24:return null;case 25:return null}throw Error(i(156,r.tag))}function yS(n,r){switch(hc(r),r.tag){case 1:return pi(r.type)&&ea(),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Yr(),pt(fi),pt(ti),kc(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 5:return xc(r),null;case 13:if(pt(yt),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(i(340));Ur()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return pt(yt),null;case 4:return Yr(),null;case 10:return _c(r.type._context),null;case 22:case 23:return nu(),null;case 24:return null;default:return null}}var wa=!1,ri=!1,wS=typeof WeakSet=="function"?WeakSet:Set,Le=null;function Gr(n,r){var l=n.ref;if(l!==null)if(typeof l=="function")try{l(null)}catch(d){Ct(n,r,d)}else l.current=null}function Kc(n,r,l){try{l()}catch(d){Ct(n,r,d)}}var Hp=!1;function SS(n,r){if(nc=Fo,n=wf(),Xl(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var d=l.getSelection&&l.getSelection();if(d&&d.rangeCount!==0){l=d.anchorNode;var m=d.anchorOffset,v=d.focusNode;d=d.focusOffset;try{l.nodeType,v.nodeType}catch{l=null;break e}var N=0,O=-1,Y=-1,le=0,we=0,Se=n,ye=null;t:for(;;){for(var De;Se!==l||m!==0&&Se.nodeType!==3||(O=N+m),Se!==v||d!==0&&Se.nodeType!==3||(Y=N+d),Se.nodeType===3&&(N+=Se.nodeValue.length),(De=Se.firstChild)!==null;)ye=Se,Se=De;for(;;){if(Se===n)break t;if(ye===l&&++le===m&&(O=N),ye===v&&++we===d&&(Y=N),(De=Se.nextSibling)!==null)break;Se=ye,ye=Se.parentNode}Se=De}l=O===-1||Y===-1?null:{start:O,end:Y}}else l=null}l=l||{start:0,end:0}}else l=null;for(rc={focusedElem:n,selectionRange:l},Fo=!1,Le=r;Le!==null;)if(r=Le,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,Le=n;else for(;Le!==null;){r=Le;try{var Te=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if(Te!==null){var Ae=Te.memoizedProps,Pt=Te.memoizedState,ne=r.stateNode,Q=ne.getSnapshotBeforeUpdate(r.elementType===r.type?Ae:qi(r.type,Ae),Pt);ne.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:var se=r.stateNode.containerInfo;se.nodeType===1?se.textContent="":se.nodeType===9&&se.documentElement&&se.removeChild(se.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(be){Ct(r,r.return,be)}if(n=r.sibling,n!==null){n.return=r.return,Le=n;break}Le=r.return}return Te=Hp,Hp=!1,Te}function Gs(n,r,l){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var m=d=d.next;do{if((m.tag&n)===n){var v=m.destroy;m.destroy=void 0,v!==void 0&&Kc(r,l,v)}m=m.next}while(m!==d)}}function Sa(n,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&n)===n){var d=l.create;l.destroy=d()}l=l.next}while(l!==r)}}function qc(n){var r=n.ref;if(r!==null){var l=n.stateNode;switch(n.tag){case 5:n=l;break;default:n=l}typeof r=="function"?r(n):r.current=n}}function Wp(n){var r=n.alternate;r!==null&&(n.alternate=null,Wp(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&(delete r[Ji],delete r[zs],delete r[lc],delete r[nS],delete r[rS])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function Up(n){return n.tag===5||n.tag===3||n.tag===4}function Kp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Up(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function Vc(n,r,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?l.nodeType===8?l.parentNode.insertBefore(n,r):l.insertBefore(n,r):(l.nodeType===8?(r=l.parentNode,r.insertBefore(n,l)):(r=l,r.appendChild(n)),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Jo));else if(d!==4&&(n=n.child,n!==null))for(Vc(n,r,l),n=n.sibling;n!==null;)Vc(n,r,l),n=n.sibling}function Yc(n,r,l){var d=n.tag;if(d===5||d===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(d!==4&&(n=n.child,n!==null))for(Yc(n,r,l),n=n.sibling;n!==null;)Yc(n,r,l),n=n.sibling}var Gt=null,Vi=!1;function Bn(n,r,l){for(l=l.child;l!==null;)qp(n,r,l),l=l.sibling}function qp(n,r,l){if(Qi&&typeof Qi.onCommitFiberUnmount=="function")try{Qi.onCommitFiberUnmount(To,l)}catch{}switch(l.tag){case 5:ri||Gr(l,r);case 6:var d=Gt,m=Vi;Gt=null,Bn(n,r,l),Gt=d,Vi=m,Gt!==null&&(Vi?(n=Gt,l=l.stateNode,n.nodeType===8?n.parentNode.removeChild(l):n.removeChild(l)):Gt.removeChild(l.stateNode));break;case 18:Gt!==null&&(Vi?(n=Gt,l=l.stateNode,n.nodeType===8?ac(n.parentNode,l):n.nodeType===1&&ac(n,l),Rs(n)):ac(Gt,l.stateNode));break;case 4:d=Gt,m=Vi,Gt=l.stateNode.containerInfo,Vi=!0,Bn(n,r,l),Gt=d,Vi=m;break;case 0:case 11:case 14:case 15:if(!ri&&(d=l.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){m=d=d.next;do{var v=m,N=v.destroy;v=v.tag,N!==void 0&&((v&2)!==0||(v&4)!==0)&&Kc(l,r,N),m=m.next}while(m!==d)}Bn(n,r,l);break;case 1:if(!ri&&(Gr(l,r),d=l.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=l.memoizedProps,d.state=l.memoizedState,d.componentWillUnmount()}catch(O){Ct(l,r,O)}Bn(n,r,l);break;case 21:Bn(n,r,l);break;case 22:l.mode&1?(ri=(d=ri)||l.memoizedState!==null,Bn(n,r,l),ri=d):Bn(n,r,l);break;default:Bn(n,r,l)}}function Vp(n){var r=n.updateQueue;if(r!==null){n.updateQueue=null;var l=n.stateNode;l===null&&(l=n.stateNode=new wS),r.forEach(function(d){var m=jS.bind(null,n,d);l.has(d)||(l.add(d),d.then(m,m))})}}function Yi(n,r){var l=r.deletions;if(l!==null)for(var d=0;d<l.length;d++){var m=l[d];try{var v=n,N=r,O=N;e:for(;O!==null;){switch(O.tag){case 5:Gt=O.stateNode,Vi=!1;break e;case 3:Gt=O.stateNode.containerInfo,Vi=!0;break e;case 4:Gt=O.stateNode.containerInfo,Vi=!0;break e}O=O.return}if(Gt===null)throw Error(i(160));qp(v,N,m),Gt=null,Vi=!1;var Y=m.alternate;Y!==null&&(Y.return=null),m.return=null}catch(le){Ct(m,r,le)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)Yp(r,n),r=r.sibling}function Yp(n,r){var l=n.alternate,d=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:if(Yi(r,n),tn(n),d&4){try{Gs(3,n,n.return),Sa(3,n)}catch(Ae){Ct(n,n.return,Ae)}try{Gs(5,n,n.return)}catch(Ae){Ct(n,n.return,Ae)}}break;case 1:Yi(r,n),tn(n),d&512&&l!==null&&Gr(l,l.return);break;case 5:if(Yi(r,n),tn(n),d&512&&l!==null&&Gr(l,l.return),n.flags&32){var m=n.stateNode;try{F(m,"")}catch(Ae){Ct(n,n.return,Ae)}}if(d&4&&(m=n.stateNode,m!=null)){var v=n.memoizedProps,N=l!==null?l.memoizedProps:v,O=n.type,Y=n.updateQueue;if(n.updateQueue=null,Y!==null)try{O==="input"&&v.type==="radio"&&v.name!=null&>(m,v),Qe(O,N);var le=Qe(O,v);for(N=0;N<Y.length;N+=2){var we=Y[N],Se=Y[N+1];we==="style"?Ce(m,Se):we==="dangerouslySetInnerHTML"?ie(m,Se):we==="children"?F(m,Se):A(m,we,Se,le)}switch(O){case"input":ut(m,v);break;case"textarea":xe(m,v);break;case"select":var ye=m._wrapperState.wasMultiple;m._wrapperState.wasMultiple=!!v.multiple;var De=v.value;De!=null?rt(m,!!v.multiple,De,!1):ye!==!!v.multiple&&(v.defaultValue!=null?rt(m,!!v.multiple,v.defaultValue,!0):rt(m,!!v.multiple,v.multiple?[]:"",!1))}m[zs]=v}catch(Ae){Ct(n,n.return,Ae)}}break;case 6:if(Yi(r,n),tn(n),d&4){if(n.stateNode===null)throw Error(i(162));m=n.stateNode,v=n.memoizedProps;try{m.nodeValue=v}catch(Ae){Ct(n,n.return,Ae)}}break;case 3:if(Yi(r,n),tn(n),d&4&&l!==null&&l.memoizedState.isDehydrated)try{Rs(r.containerInfo)}catch(Ae){Ct(n,n.return,Ae)}break;case 4:Yi(r,n),tn(n);break;case 13:Yi(r,n),tn(n),m=n.child,m.flags&8192&&(v=m.memoizedState!==null,m.stateNode.isHidden=v,!v||m.alternate!==null&&m.alternate.memoizedState!==null||(Qc=Rt())),d&4&&Vp(n);break;case 22:if(we=l!==null&&l.memoizedState!==null,n.mode&1?(ri=(le=ri)||we,Yi(r,n),ri=le):Yi(r,n),tn(n),d&8192){if(le=n.memoizedState!==null,(n.stateNode.isHidden=le)&&!we&&(n.mode&1)!==0)for(Le=n,we=n.child;we!==null;){for(Se=Le=we;Le!==null;){switch(ye=Le,De=ye.child,ye.tag){case 0:case 11:case 14:case 15:Gs(4,ye,ye.return);break;case 1:Gr(ye,ye.return);var Te=ye.stateNode;if(typeof Te.componentWillUnmount=="function"){d=ye,l=ye.return;try{r=d,Te.props=r.memoizedProps,Te.state=r.memoizedState,Te.componentWillUnmount()}catch(Ae){Ct(d,l,Ae)}}break;case 5:Gr(ye,ye.return);break;case 22:if(ye.memoizedState!==null){Qp(Se);continue}}De!==null?(De.return=ye,Le=De):Qp(Se)}we=we.sibling}e:for(we=null,Se=n;;){if(Se.tag===5){if(we===null){we=Se;try{m=Se.stateNode,le?(v=m.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none"):(O=Se.stateNode,Y=Se.memoizedProps.style,N=Y!=null&&Y.hasOwnProperty("display")?Y.display:null,O.style.display=ve("display",N))}catch(Ae){Ct(n,n.return,Ae)}}}else if(Se.tag===6){if(we===null)try{Se.stateNode.nodeValue=le?"":Se.memoizedProps}catch(Ae){Ct(n,n.return,Ae)}}else if((Se.tag!==22&&Se.tag!==23||Se.memoizedState===null||Se===n)&&Se.child!==null){Se.child.return=Se,Se=Se.child;continue}if(Se===n)break e;for(;Se.sibling===null;){if(Se.return===null||Se.return===n)break e;we===Se&&(we=null),Se=Se.return}we===Se&&(we=null),Se.sibling.return=Se.return,Se=Se.sibling}}break;case 19:Yi(r,n),tn(n),d&4&&Vp(n);break;case 21:break;default:Yi(r,n),tn(n)}}function tn(n){var r=n.flags;if(r&2){try{e:{for(var l=n.return;l!==null;){if(Up(l)){var d=l;break e}l=l.return}throw Error(i(160))}switch(d.tag){case 5:var m=d.stateNode;d.flags&32&&(F(m,""),d.flags&=-33);var v=Kp(n);Yc(n,v,m);break;case 3:case 4:var N=d.stateNode.containerInfo,O=Kp(n);Vc(n,O,N);break;default:throw Error(i(161))}}catch(Y){Ct(n,n.return,Y)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function bS(n,r,l){Le=n,Xp(n)}function Xp(n,r,l){for(var d=(n.mode&1)!==0;Le!==null;){var m=Le,v=m.child;if(m.tag===22&&d){var N=m.memoizedState!==null||wa;if(!N){var O=m.alternate,Y=O!==null&&O.memoizedState!==null||ri;O=wa;var le=ri;if(wa=N,(ri=Y)&&!le)for(Le=m;Le!==null;)N=Le,Y=N.child,N.tag===22&&N.memoizedState!==null?Jp(m):Y!==null?(Y.return=N,Le=Y):Jp(m);for(;v!==null;)Le=v,Xp(v),v=v.sibling;Le=m,wa=O,ri=le}Gp(n)}else(m.subtreeFlags&8772)!==0&&v!==null?(v.return=m,Le=v):Gp(n)}}function Gp(n){for(;Le!==null;){var r=Le;if((r.flags&8772)!==0){var l=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:ri||Sa(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!ri)if(l===null)d.componentDidMount();else{var m=r.elementType===r.type?l.memoizedProps:qi(r.type,l.memoizedProps);d.componentDidUpdate(m,l.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var v=r.updateQueue;v!==null&&Qf(r,v,d);break;case 3:var N=r.updateQueue;if(N!==null){if(l=null,r.child!==null)switch(r.child.tag){case 5:l=r.child.stateNode;break;case 1:l=r.child.stateNode}Qf(r,N,l)}break;case 5:var O=r.stateNode;if(l===null&&r.flags&4){l=O;var Y=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":Y.autoFocus&&l.focus();break;case"img":Y.src&&(l.src=Y.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var le=r.alternate;if(le!==null){var we=le.memoizedState;if(we!==null){var Se=we.dehydrated;Se!==null&&Rs(Se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(i(163))}ri||r.flags&512&&qc(r)}catch(ye){Ct(r,r.return,ye)}}if(r===n){Le=null;break}if(l=r.sibling,l!==null){l.return=r.return,Le=l;break}Le=r.return}}function Qp(n){for(;Le!==null;){var r=Le;if(r===n){Le=null;break}var l=r.sibling;if(l!==null){l.return=r.return,Le=l;break}Le=r.return}}function Jp(n){for(;Le!==null;){var r=Le;try{switch(r.tag){case 0:case 11:case 15:var l=r.return;try{Sa(4,r)}catch(Y){Ct(r,l,Y)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var m=r.return;try{d.componentDidMount()}catch(Y){Ct(r,m,Y)}}var v=r.return;try{qc(r)}catch(Y){Ct(r,v,Y)}break;case 5:var N=r.return;try{qc(r)}catch(Y){Ct(r,N,Y)}}}catch(Y){Ct(r,r.return,Y)}if(r===n){Le=null;break}var O=r.sibling;if(O!==null){O.return=r.return,Le=O;break}Le=r.return}}var xS=Math.ceil,ba=M.ReactCurrentDispatcher,Xc=M.ReactCurrentOwner,Ii=M.ReactCurrentBatchConfig,tt=0,$t=null,Dt=null,Qt=0,ki=0,Qr=Ln(0),At=0,Qs=null,ur=0,xa=0,Gc=0,Js=null,gi=null,Qc=0,Jr=1/0,yn=null,Ca=!1,Jc=null,On=null,ka=!1,zn=null,Ea=0,Zs=0,Zc=null,Na=-1,Ra=0;function li(){return(tt&6)!==0?Rt():Na!==-1?Na:Na=Rt()}function Fn(n){return(n.mode&1)===0?1:(tt&2)!==0&&Qt!==0?Qt&-Qt:oS.transition!==null?(Ra===0&&(Ra=Uh()),Ra):(n=st,n!==0||(n=window.event,n=n===void 0?16:Zh(n.type)),n)}function Xi(n,r,l,d){if(50<Zs)throw Zs=0,Zc=null,Error(i(185));xs(n,l,d),((tt&2)===0||n!==$t)&&(n===$t&&((tt&2)===0&&(xa|=l),At===4&&$n(n,Qt)),vi(n,d),l===1&&tt===0&&(r.mode&1)===0&&(Jr=Rt()+500,ia&&Tn()))}function vi(n,r){var l=n.callbackNode;ow(n,r);var d=Bo(n,n===$t?Qt:0);if(d===0)l!==null&&$h(l),n.callbackNode=null,n.callbackPriority=0;else if(r=d&-d,n.callbackPriority!==r){if(l!=null&&$h(l),r===1)n.tag===0?sS(em.bind(null,n)):zf(em.bind(null,n)),tS(function(){(tt&6)===0&&Tn()}),l=null;else{switch(Kh(d)){case 1:l=Ll;break;case 4:l=Hh;break;case 16:l=Mo;break;case 536870912:l=Wh;break;default:l=Mo}l=lm(l,Zp.bind(null,n))}n.callbackPriority=r,n.callbackNode=l}}function Zp(n,r){if(Na=-1,Ra=0,(tt&6)!==0)throw Error(i(327));var l=n.callbackNode;if(Zr()&&n.callbackNode!==l)return null;var d=Bo(n,n===$t?Qt:0);if(d===0)return null;if((d&30)!==0||(d&n.expiredLanes)!==0||r)r=Pa(n,d);else{r=d;var m=tt;tt|=2;var v=im();($t!==n||Qt!==r)&&(yn=null,Jr=Rt()+500,hr(n,r));do try{ES();break}catch(O){tm(n,O)}while(!0);vc(),ba.current=v,tt=m,Dt!==null?r=0:($t=null,Qt=0,r=At)}if(r!==0){if(r===2&&(m=Ml(n),m!==0&&(d=m,r=eu(n,m))),r===1)throw l=Qs,hr(n,0),$n(n,d),vi(n,Rt()),l;if(r===6)$n(n,d);else{if(m=n.current.alternate,(d&30)===0&&!CS(m)&&(r=Pa(n,d),r===2&&(v=Ml(n),v!==0&&(d=v,r=eu(n,v))),r===1))throw l=Qs,hr(n,0),$n(n,d),vi(n,Rt()),l;switch(n.finishedWork=m,n.finishedLanes=d,r){case 0:case 1:throw Error(i(345));case 2:fr(n,gi,yn);break;case 3:if($n(n,d),(d&130023424)===d&&(r=Qc+500-Rt(),10<r)){if(Bo(n,0)!==0)break;if(m=n.suspendedLanes,(m&d)!==d){li(),n.pingedLanes|=n.suspendedLanes&m;break}n.timeoutHandle=oc(fr.bind(null,n,gi,yn),r);break}fr(n,gi,yn);break;case 4:if($n(n,d),(d&4194240)===d)break;for(r=n.eventTimes,m=-1;0<d;){var N=31-Wi(d);v=1<<N,N=r[N],N>m&&(m=N),d&=~v}if(d=m,d=Rt()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*xS(d/1960))-d,10<d){n.timeoutHandle=oc(fr.bind(null,n,gi,yn),d);break}fr(n,gi,yn);break;case 5:fr(n,gi,yn);break;default:throw Error(i(329))}}}return vi(n,Rt()),n.callbackNode===l?Zp.bind(null,n):null}function eu(n,r){var l=Js;return n.current.memoizedState.isDehydrated&&(hr(n,r).flags|=256),n=Pa(n,r),n!==2&&(r=gi,gi=l,r!==null&&tu(r)),n}function tu(n){gi===null?gi=n:gi.push.apply(gi,n)}function CS(n){for(var r=n;;){if(r.flags&16384){var l=r.updateQueue;if(l!==null&&(l=l.stores,l!==null))for(var d=0;d<l.length;d++){var m=l[d],v=m.getSnapshot;m=m.value;try{if(!Ui(v(),m))return!1}catch{return!1}}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function $n(n,r){for(r&=~Gc,r&=~xa,n.suspendedLanes|=r,n.pingedLanes&=~r,n=n.expirationTimes;0<r;){var l=31-Wi(r),d=1<<l;n[l]=-1,r&=~d}}function em(n){if((tt&6)!==0)throw Error(i(327));Zr();var r=Bo(n,0);if((r&1)===0)return vi(n,Rt()),null;var l=Pa(n,r);if(n.tag!==0&&l===2){var d=Ml(n);d!==0&&(r=d,l=eu(n,d))}if(l===1)throw l=Qs,hr(n,0),$n(n,r),vi(n,Rt()),l;if(l===6)throw Error(i(345));return n.finishedWork=n.current.alternate,n.finishedLanes=r,fr(n,gi,yn),vi(n,Rt()),null}function iu(n,r){var l=tt;tt|=1;try{return n(r)}finally{tt=l,tt===0&&(Jr=Rt()+500,ia&&Tn())}}function dr(n){zn!==null&&zn.tag===0&&(tt&6)===0&&Zr();var r=tt;tt|=1;var l=Ii.transition,d=st;try{if(Ii.transition=null,st=1,n)return n()}finally{st=d,Ii.transition=l,tt=r,(tt&6)===0&&Tn()}}function nu(){ki=Qr.current,pt(Qr)}function hr(n,r){n.finishedWork=null,n.finishedLanes=0;var l=n.timeoutHandle;if(l!==-1&&(n.timeoutHandle=-1,eS(l)),Dt!==null)for(l=Dt.return;l!==null;){var d=l;switch(hc(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&ea();break;case 3:Yr(),pt(fi),pt(ti),kc();break;case 5:xc(d);break;case 4:Yr();break;case 13:pt(yt);break;case 19:pt(yt);break;case 10:_c(d.type._context);break;case 22:case 23:nu()}l=l.return}if($t=n,Dt=n=Hn(n.current,null),Qt=ki=r,At=0,Qs=null,Gc=xa=ur=0,gi=Js=null,ar!==null){for(r=0;r<ar.length;r++)if(l=ar[r],d=l.interleaved,d!==null){l.interleaved=null;var m=d.next,v=l.pending;if(v!==null){var N=v.next;v.next=m,d.next=N}l.pending=d}ar=null}return n}function tm(n,r){do{var l=Dt;try{if(vc(),ha.current=ga,fa){for(var d=wt.memoizedState;d!==null;){var m=d.queue;m!==null&&(m.pending=null),d=d.next}fa=!1}if(cr=0,Ft=Tt=wt=null,Ks=!1,qs=0,Xc.current=null,l===null||l.return===null){At=1,Qs=r,Dt=null;break}e:{var v=n,N=l.return,O=l,Y=r;if(r=Qt,O.flags|=32768,Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var le=Y,we=O,Se=we.tag;if((we.mode&1)===0&&(Se===0||Se===11||Se===15)){var ye=we.alternate;ye?(we.updateQueue=ye.updateQueue,we.memoizedState=ye.memoizedState,we.lanes=ye.lanes):(we.updateQueue=null,we.memoizedState=null)}var De=Ep(N);if(De!==null){De.flags&=-257,Np(De,N,O,v,r),De.mode&1&&kp(v,le,r),r=De,Y=le;var Te=r.updateQueue;if(Te===null){var Ae=new Set;Ae.add(Y),r.updateQueue=Ae}else Te.add(Y);break e}else{if((r&1)===0){kp(v,le,r),ru();break e}Y=Error(i(426))}}else if(vt&&O.mode&1){var Pt=Ep(N);if(Pt!==null){(Pt.flags&65536)===0&&(Pt.flags|=256),Np(Pt,N,O,v,r),mc(Xr(Y,O));break e}}v=Y=Xr(Y,O),At!==4&&(At=2),Js===null?Js=[v]:Js.push(v),v=N;do{switch(v.tag){case 3:v.flags|=65536,r&=-r,v.lanes|=r;var ne=xp(v,Y,r);Gf(v,ne);break e;case 1:O=Y;var Q=v.type,se=v.stateNode;if((v.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||se!==null&&typeof se.componentDidCatch=="function"&&(On===null||!On.has(se)))){v.flags|=65536,r&=-r,v.lanes|=r;var be=Cp(v,O,r);Gf(v,be);break e}}v=v.return}while(v!==null)}rm(l)}catch(Ie){r=Ie,Dt===l&&l!==null&&(Dt=l=l.return);continue}break}while(!0)}function im(){var n=ba.current;return ba.current=ga,n===null?ga:n}function ru(){(At===0||At===3||At===2)&&(At=4),$t===null||(ur&268435455)===0&&(xa&268435455)===0||$n($t,Qt)}function Pa(n,r){var l=tt;tt|=2;var d=im();($t!==n||Qt!==r)&&(yn=null,hr(n,r));do try{kS();break}catch(m){tm(n,m)}while(!0);if(vc(),tt=l,ba.current=d,Dt!==null)throw Error(i(261));return $t=null,Qt=0,At}function kS(){for(;Dt!==null;)nm(Dt)}function ES(){for(;Dt!==null&&!Qy();)nm(Dt)}function nm(n){var r=am(n.alternate,n,ki);n.memoizedProps=n.pendingProps,r===null?rm(n):Dt=r,Xc.current=null}function rm(n){var r=n;do{var l=r.alternate;if(n=r.return,(r.flags&32768)===0){if(l=_S(l,r,ki),l!==null){Dt=l;return}}else{if(l=yS(l,r),l!==null){l.flags&=32767,Dt=l;return}if(n!==null)n.flags|=32768,n.subtreeFlags=0,n.deletions=null;else{At=6,Dt=null;return}}if(r=r.sibling,r!==null){Dt=r;return}Dt=r=n}while(r!==null);At===0&&(At=5)}function fr(n,r,l){var d=st,m=Ii.transition;try{Ii.transition=null,st=1,NS(n,r,l,d)}finally{Ii.transition=m,st=d}return null}function NS(n,r,l,d){do Zr();while(zn!==null);if((tt&6)!==0)throw Error(i(327));l=n.finishedWork;var m=n.finishedLanes;if(l===null)return null;if(n.finishedWork=null,n.finishedLanes=0,l===n.current)throw Error(i(177));n.callbackNode=null,n.callbackPriority=0;var v=l.lanes|l.childLanes;if(aw(n,v),n===$t&&(Dt=$t=null,Qt=0),(l.subtreeFlags&2064)===0&&(l.flags&2064)===0||ka||(ka=!0,lm(Mo,function(){return Zr(),null})),v=(l.flags&15990)!==0,(l.subtreeFlags&15990)!==0||v){v=Ii.transition,Ii.transition=null;var N=st;st=1;var O=tt;tt|=4,Xc.current=null,SS(n,l),Yp(l,n),Vw(rc),Fo=!!nc,rc=nc=null,n.current=l,bS(l),Jy(),tt=O,st=N,Ii.transition=v}else n.current=l;if(ka&&(ka=!1,zn=n,Ea=m),v=n.pendingLanes,v===0&&(On=null),tw(l.stateNode),vi(n,Rt()),r!==null)for(d=n.onRecoverableError,l=0;l<r.length;l++)m=r[l],d(m.value,{componentStack:m.stack,digest:m.digest});if(Ca)throw Ca=!1,n=Jc,Jc=null,n;return(Ea&1)!==0&&n.tag!==0&&Zr(),v=n.pendingLanes,(v&1)!==0?n===Zc?Zs++:(Zs=0,Zc=n):Zs=0,Tn(),null}function Zr(){if(zn!==null){var n=Kh(Ea),r=Ii.transition,l=st;try{if(Ii.transition=null,st=16>n?16:n,zn===null)var d=!1;else{if(n=zn,zn=null,Ea=0,(tt&6)!==0)throw Error(i(331));var m=tt;for(tt|=4,Le=n.current;Le!==null;){var v=Le,N=v.child;if((Le.flags&16)!==0){var O=v.deletions;if(O!==null){for(var Y=0;Y<O.length;Y++){var le=O[Y];for(Le=le;Le!==null;){var we=Le;switch(we.tag){case 0:case 11:case 15:Gs(8,we,v)}var Se=we.child;if(Se!==null)Se.return=we,Le=Se;else for(;Le!==null;){we=Le;var ye=we.sibling,De=we.return;if(Wp(we),we===le){Le=null;break}if(ye!==null){ye.return=De,Le=ye;break}Le=De}}}var Te=v.alternate;if(Te!==null){var Ae=Te.child;if(Ae!==null){Te.child=null;do{var Pt=Ae.sibling;Ae.sibling=null,Ae=Pt}while(Ae!==null)}}Le=v}}if((v.subtreeFlags&2064)!==0&&N!==null)N.return=v,Le=N;else e:for(;Le!==null;){if(v=Le,(v.flags&2048)!==0)switch(v.tag){case 0:case 11:case 15:Gs(9,v,v.return)}var ne=v.sibling;if(ne!==null){ne.return=v.return,Le=ne;break e}Le=v.return}}var Q=n.current;for(Le=Q;Le!==null;){N=Le;var se=N.child;if((N.subtreeFlags&2064)!==0&&se!==null)se.return=N,Le=se;else e:for(N=Q;Le!==null;){if(O=Le,(O.flags&2048)!==0)try{switch(O.tag){case 0:case 11:case 15:Sa(9,O)}}catch(Ie){Ct(O,O.return,Ie)}if(O===N){Le=null;break e}var be=O.sibling;if(be!==null){be.return=O.return,Le=be;break e}Le=O.return}}if(tt=m,Tn(),Qi&&typeof Qi.onPostCommitFiberRoot=="function")try{Qi.onPostCommitFiberRoot(To,n)}catch{}d=!0}return d}finally{st=l,Ii.transition=r}}return!1}function sm(n,r,l){r=Xr(l,r),r=xp(n,r,1),n=In(n,r,1),r=li(),n!==null&&(xs(n,1,r),vi(n,r))}function Ct(n,r,l){if(n.tag===3)sm(n,n,l);else for(;r!==null;){if(r.tag===3){sm(r,n,l);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(On===null||!On.has(d))){n=Xr(l,n),n=Cp(r,n,1),r=In(r,n,1),n=li(),r!==null&&(xs(r,1,n),vi(r,n));break}}r=r.return}}function RS(n,r,l){var d=n.pingCache;d!==null&&d.delete(r),r=li(),n.pingedLanes|=n.suspendedLanes&l,$t===n&&(Qt&l)===l&&(At===4||At===3&&(Qt&130023424)===Qt&&500>Rt()-Qc?hr(n,0):Gc|=l),vi(n,r)}function om(n,r){r===0&&((n.mode&1)===0?r=1:(r=Io,Io<<=1,(Io&130023424)===0&&(Io=4194304)));var l=li();n=gn(n,r),n!==null&&(xs(n,r,l),vi(n,l))}function PS(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),om(n,l)}function jS(n,r){var l=0;switch(n.tag){case 13:var d=n.stateNode,m=n.memoizedState;m!==null&&(l=m.retryLane);break;case 19:d=n.stateNode;break;default:throw Error(i(314))}d!==null&&d.delete(r),om(n,l)}var am;am=function(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps||fi.current)mi=!0;else{if((n.lanes&l)===0&&(r.flags&128)===0)return mi=!1,vS(n,r,l);mi=(n.flags&131072)!==0}else mi=!1,vt&&(r.flags&1048576)!==0&&Ff(r,ra,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;ya(n,r),n=r.pendingProps;var m=$r(r,ti.current);Vr(r,l),m=Rc(null,r,d,n,m,l);var v=Pc();return r.flags|=1,typeof m=="object"&&m!==null&&typeof m.render=="function"&&m.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,pi(d)?(v=!0,ta(r)):v=!1,r.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,Sc(r),m.updater=va,r.stateNode=m,m._reactInternals=r,Ac(r,d,n,l),r=zc(null,r,d,!0,v,l)):(r.tag=0,vt&&v&&dc(r),ai(null,r,m,l),r=r.child),r;case 16:d=r.elementType;e:{switch(ya(n,r),n=r.pendingProps,m=d._init,d=m(d._payload),r.type=d,m=r.tag=LS(d),n=qi(d,n),m){case 0:r=Oc(null,r,d,n,l);break e;case 1:r=Mp(null,r,d,n,l);break e;case 11:r=Rp(null,r,d,n,l);break e;case 14:r=Pp(null,r,d,qi(d.type,n),l);break e}throw Error(i(306,d,""))}return r;case 0:return d=r.type,m=r.pendingProps,m=r.elementType===d?m:qi(d,m),Oc(n,r,d,m,l);case 1:return d=r.type,m=r.pendingProps,m=r.elementType===d?m:qi(d,m),Mp(n,r,d,m,l);case 3:e:{if(Tp(r),n===null)throw Error(i(387));d=r.pendingProps,v=r.memoizedState,m=v.element,Xf(n,r),ua(r,d,null,l);var N=r.memoizedState;if(d=N.element,v.isDehydrated)if(v={element:d,isDehydrated:!1,cache:N.cache,pendingSuspenseBoundaries:N.pendingSuspenseBoundaries,transitions:N.transitions},r.updateQueue.baseState=v,r.memoizedState=v,r.flags&256){m=Xr(Error(i(423)),r),r=Ap(n,r,d,l,m);break e}else if(d!==m){m=Xr(Error(i(424)),r),r=Ap(n,r,d,l,m);break e}else for(Ci=Dn(r.stateNode.containerInfo.firstChild),xi=r,vt=!0,Ki=null,l=Vf(r,null,d,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling;else{if(Ur(),d===m){r=_n(n,r,l);break e}ai(n,r,d,l)}r=r.child}return r;case 5:return Jf(r),n===null&&pc(r),d=r.type,m=r.pendingProps,v=n!==null?n.memoizedProps:null,N=m.children,sc(d,m)?N=null:v!==null&&sc(d,v)&&(r.flags|=32),Lp(n,r),ai(n,r,N,l),r.child;case 6:return n===null&&pc(r),null;case 13:return Ip(n,r,l);case 4:return bc(r,r.stateNode.containerInfo),d=r.pendingProps,n===null?r.child=Kr(r,null,d,l):ai(n,r,d,l),r.child;case 11:return d=r.type,m=r.pendingProps,m=r.elementType===d?m:qi(d,m),Rp(n,r,d,m,l);case 7:return ai(n,r,r.pendingProps,l),r.child;case 8:return ai(n,r,r.pendingProps.children,l),r.child;case 12:return ai(n,r,r.pendingProps.children,l),r.child;case 10:e:{if(d=r.type._context,m=r.pendingProps,v=r.memoizedProps,N=m.value,ht(aa,d._currentValue),d._currentValue=N,v!==null)if(Ui(v.value,N)){if(v.children===m.children&&!fi.current){r=_n(n,r,l);break e}}else for(v=r.child,v!==null&&(v.return=r);v!==null;){var O=v.dependencies;if(O!==null){N=v.child;for(var Y=O.firstContext;Y!==null;){if(Y.context===d){if(v.tag===1){Y=vn(-1,l&-l),Y.tag=2;var le=v.updateQueue;if(le!==null){le=le.shared;var we=le.pending;we===null?Y.next=Y:(Y.next=we.next,we.next=Y),le.pending=Y}}v.lanes|=l,Y=v.alternate,Y!==null&&(Y.lanes|=l),yc(v.return,l,r),O.lanes|=l;break}Y=Y.next}}else if(v.tag===10)N=v.type===r.type?null:v.child;else if(v.tag===18){if(N=v.return,N===null)throw Error(i(341));N.lanes|=l,O=N.alternate,O!==null&&(O.lanes|=l),yc(N,l,r),N=v.sibling}else N=v.child;if(N!==null)N.return=v;else for(N=v;N!==null;){if(N===r){N=null;break}if(v=N.sibling,v!==null){v.return=N.return,N=v;break}N=N.return}v=N}ai(n,r,m.children,l),r=r.child}return r;case 9:return m=r.type,d=r.pendingProps.children,Vr(r,l),m=Ti(m),d=d(m),r.flags|=1,ai(n,r,d,l),r.child;case 14:return d=r.type,m=qi(d,r.pendingProps),m=qi(d.type,m),Pp(n,r,d,m,l);case 15:return jp(n,r,r.type,r.pendingProps,l);case 17:return d=r.type,m=r.pendingProps,m=r.elementType===d?m:qi(d,m),ya(n,r),r.tag=1,pi(d)?(n=!0,ta(r)):n=!1,Vr(r,l),Sp(r,d,m),Ac(r,d,m,l),zc(null,r,d,!0,n,l);case 19:return Op(n,r,l);case 22:return Dp(n,r,l)}throw Error(i(156,r.tag))};function lm(n,r){return Fh(n,r)}function DS(n,r,l,d){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=d,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Bi(n,r,l,d){return new DS(n,r,l,d)}function su(n){return n=n.prototype,!(!n||!n.isReactComponent)}function LS(n){if(typeof n=="function")return su(n)?1:0;if(n!=null){if(n=n.$$typeof,n===T)return 11;if(n===D)return 14}return 2}function Hn(n,r){var l=n.alternate;return l===null?(l=Bi(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&14680064,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l}function ja(n,r,l,d,m,v){var N=2;if(d=n,typeof n=="function")su(n)&&(N=1);else if(typeof n=="string")N=5;else e:switch(n){case B:return pr(l.children,m,v,r);case Z:N=8,m|=8;break;case H:return n=Bi(12,l,r,m|2),n.elementType=H,n.lanes=v,n;case E:return n=Bi(13,l,r,m),n.elementType=E,n.lanes=v,n;case j:return n=Bi(19,l,r,m),n.elementType=j,n.lanes=v,n;case re:return Da(l,m,v,r);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case te:N=10;break e;case K:N=9;break e;case T:N=11;break e;case D:N=14;break e;case U:N=16,d=null;break e}throw Error(i(130,n==null?n:typeof n,""))}return r=Bi(N,l,r,m),r.elementType=n,r.type=d,r.lanes=v,r}function pr(n,r,l,d){return n=Bi(7,n,d,r),n.lanes=l,n}function Da(n,r,l,d){return n=Bi(22,n,d,r),n.elementType=re,n.lanes=l,n.stateNode={isHidden:!1},n}function ou(n,r,l){return n=Bi(6,n,null,r),n.lanes=l,n}function au(n,r,l){return r=Bi(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}function MS(n,r,l,d,m){this.tag=r,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Tl(0),this.expirationTimes=Tl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Tl(0),this.identifierPrefix=d,this.onRecoverableError=m,this.mutableSourceEagerHydrationData=null}function lu(n,r,l,d,m,v,N,O,Y){return n=new MS(n,r,l,O,Y),r===1?(r=1,v===!0&&(r|=8)):r=0,v=Bi(3,null,null,r),n.current=v,v.stateNode=n,v.memoizedState={element:d,isDehydrated:l,cache:null,transitions:null,pendingSuspenseBoundaries:null},Sc(v),n}function TS(n,r,l){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:q,key:d==null?null:""+d,children:n,containerInfo:r,implementation:l}}function cm(n){if(!n)return Mn;n=n._reactInternals;e:{if(ir(n)!==n||n.tag!==1)throw Error(i(170));var r=n;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(pi(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(i(171))}if(n.tag===1){var l=n.type;if(pi(l))return Bf(n,l,r)}return r}function um(n,r,l,d,m,v,N,O,Y){return n=lu(l,d,!0,n,m,v,N,O,Y),n.context=cm(null),l=n.current,d=li(),m=Fn(l),v=vn(d,m),v.callback=r??null,In(l,v,m),n.current.lanes=m,xs(n,m,d),vi(n,d),n}function La(n,r,l,d){var m=r.current,v=li(),N=Fn(m);return l=cm(l),r.context===null?r.context=l:r.pendingContext=l,r=vn(v,N),r.payload={element:n},d=d===void 0?null:d,d!==null&&(r.callback=d),n=In(m,r,N),n!==null&&(Xi(n,m,N,v),ca(n,m,N)),N}function Ma(n){if(n=n.current,!n.child)return null;switch(n.child.tag){case 5:return n.child.stateNode;default:return n.child.stateNode}}function dm(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function cu(n,r){dm(n,r),(n=n.alternate)&&dm(n,r)}function AS(){return null}var hm=typeof reportError=="function"?reportError:function(n){console.error(n)};function uu(n){this._internalRoot=n}Ta.prototype.render=uu.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(i(409));La(n,r,null,null)},Ta.prototype.unmount=uu.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;dr(function(){La(null,n,null,null)}),r[hn]=null}};function Ta(n){this._internalRoot=n}Ta.prototype.unstable_scheduleHydration=function(n){if(n){var r=Yh();n={blockedOn:null,target:n,priority:r};for(var l=0;l<Rn.length&&r!==0&&r<Rn[l].priority;l++);Rn.splice(l,0,n),l===0&&Qh(n)}};function du(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function Aa(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11&&(n.nodeType!==8||n.nodeValue!==" react-mount-point-unstable "))}function fm(){}function IS(n,r,l,d,m){if(m){if(typeof d=="function"){var v=d;d=function(){var le=Ma(N);v.call(le)}}var N=um(r,d,n,0,null,!1,!1,"",fm);return n._reactRootContainer=N,n[hn]=N.current,Bs(n.nodeType===8?n.parentNode:n),dr(),N}for(;m=n.lastChild;)n.removeChild(m);if(typeof d=="function"){var O=d;d=function(){var le=Ma(Y);O.call(le)}}var Y=lu(n,0,!1,null,null,!1,!1,"",fm);return n._reactRootContainer=Y,n[hn]=Y.current,Bs(n.nodeType===8?n.parentNode:n),dr(function(){La(r,Y,l,d)}),Y}function Ia(n,r,l,d,m){var v=l._reactRootContainer;if(v){var N=v;if(typeof m=="function"){var O=m;m=function(){var Y=Ma(N);O.call(Y)}}La(r,N,n,m)}else N=IS(l,r,n,m,d);return Ma(N)}qh=function(n){switch(n.tag){case 3:var r=n.stateNode;if(r.current.memoizedState.isDehydrated){var l=bs(r.pendingLanes);l!==0&&(Al(r,l|1),vi(r,Rt()),(tt&6)===0&&(Jr=Rt()+500,Tn()))}break;case 13:dr(function(){var d=gn(n,1);if(d!==null){var m=li();Xi(d,n,1,m)}}),cu(n,1)}},Il=function(n){if(n.tag===13){var r=gn(n,134217728);if(r!==null){var l=li();Xi(r,n,134217728,l)}cu(n,134217728)}},Vh=function(n){if(n.tag===13){var r=Fn(n),l=gn(n,r);if(l!==null){var d=li();Xi(l,n,r,d)}cu(n,r)}},Yh=function(){return st},Xh=function(n,r){var l=st;try{return st=n,r()}finally{st=l}},Di=function(n,r,l){switch(r){case"input":if(ut(n,l),r=l.name,l.type==="radio"&&r!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<l.length;r++){var d=l[r];if(d!==n&&d.form===n.form){var m=Zo(d);if(!m)throw Error(i(90));Be(d),ut(d,m)}}}break;case"textarea":xe(n,l);break;case"select":r=l.value,r!=null&&rt(n,!!l.multiple,r,!1)}},qe=iu,xt=dr;var BS={usingClientEntryPoint:!1,Events:[Fs,zr,Zo,fe,Pe,iu]},eo={findFiberByHostInstance:nr,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},OS={bundleType:eo.bundleType,version:eo.version,rendererPackageName:eo.rendererPackageName,rendererConfig:eo.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(n){return n=Oh(n),n===null?null:n.stateNode},findFiberByHostInstance:eo.findFiberByHostInstance||AS,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 Ba=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ba.isDisabled&&Ba.supportsFiber)try{To=Ba.inject(OS),Qi=Ba}catch{}}return _i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=BS,_i.createPortal=function(n,r){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!du(r))throw Error(i(200));return TS(n,r,null,l)},_i.createRoot=function(n,r){if(!du(n))throw Error(i(299));var l=!1,d="",m=hm;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(m=r.onRecoverableError)),r=lu(n,1,!1,null,null,l,!1,d,m),n[hn]=r.current,Bs(n.nodeType===8?n.parentNode:n),new uu(r)},_i.findDOMNode=function(n){if(n==null)return null;if(n.nodeType===1)return n;var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(i(188)):(n=Object.keys(n).join(","),Error(i(268,n)));return n=Oh(r),n=n===null?null:n.stateNode,n},_i.flushSync=function(n){return dr(n)},_i.hydrate=function(n,r,l){if(!Aa(r))throw Error(i(200));return Ia(null,n,r,!0,l)},_i.hydrateRoot=function(n,r,l){if(!du(n))throw Error(i(405));var d=l!=null&&l.hydratedSources||null,m=!1,v="",N=hm;if(l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(N=l.onRecoverableError)),r=um(r,null,n,1,l??null,m,!1,v,N),n[hn]=r.current,Bs(n),d)for(n=0;n<d.length;n++)l=d[n],m=l._getVersion,m=m(l._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[l,m]:r.mutableSourceEagerHydrationData.push(l,m);return new Ta(r)},_i.render=function(n,r,l){if(!Aa(r))throw Error(i(200));return Ia(null,n,r,!1,l)},_i.unmountComponentAtNode=function(n){if(!Aa(n))throw Error(i(40));return n._reactRootContainer?(dr(function(){Ia(null,null,n,!1,function(){n._reactRootContainer=null,n[hn]=null})}),!0):!1},_i.unstable_batchedUpdates=iu,_i.unstable_renderSubtreeIntoContainer=function(n,r,l,d){if(!Aa(l))throw Error(i(200));if(n==null||n._reactInternals===void 0)throw Error(i(38));return Ia(n,r,l,!1,d)},_i.version="18.3.1-next-f1338f8080-20240426",_i}var Sm;function VS(){if(Sm)return pu.exports;Sm=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(),pu.exports=qS(),pu.exports}var bm;function YS(){if(bm)return Oa;bm=1;var e=VS();return Oa.createRoot=e.createRoot,Oa.hydrateRoot=e.hydrateRoot,Oa}var XS=YS();const GS=sh(XS);function Vt(e,t,i={}){return fetch(e,{...i,headers:{...i.headers||{},Authorization:`Bearer ${t}`}})}const Wv=e=>`nc_seen_${e}`;async function Oe(e,t,i={}){const s=await Vt(e,t,{method:i.method||"GET",headers:{"content-type":"application/json"},body:i.body?JSON.stringify(i.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const ui=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",Yt=(e,t)=>`${ui(e)}/fleet/${t}`,Rr=(e,t)=>Oe(Yt(t,"status"),e),ah=(e,t,i)=>Oe(Yt(i,"up"),e,{method:"POST",body:t}),sl=(e,t,i)=>Oe(Yt(i,"down"),e,{method:"POST",body:t}),Uv=(e,t,i)=>Oe(Yt(i,"boot"),e,{method:"POST",body:t}),ho=(e,t,i)=>Oe(Yt(i,"restart"),e,{method:"POST",body:{cell:t}}),lh=(e,t)=>Oe(Yt(t,"definitions"),e),QS=(e,t)=>Oe(Yt(t,"credentials/status"),e),xm=(e,t,i,s)=>Oe(Yt(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:i}}),JS=(e,t,i)=>Oe(Yt(i,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),ZS=(e,t,i)=>Oe(Yt(i,"define-engine"),e,{method:"POST",body:{def:t}}),e0=(e,t,i,s,o)=>Oe(Yt(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:i,envChanges:s}}),t0=(e,t,i)=>Oe(Yt(i,"remove-engine"),e,{method:"POST",body:{id:t}}),i0=(e,t,i)=>Oe(Yt(i,"define-cell"),e,{method:"POST",body:{def:t}}),Kv=(e,t,i,s)=>Oe(Yt(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:i}}),qv=(e,t,i=!1,s)=>Oe(Yt(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:i}}),n0=(e,t,i)=>Oe(Yt(i,"import-cell"),e,{method:"POST",body:t}),r0=(e,t,i)=>Oe(Yt(i,"restore-cells"),e,{method:"POST",body:{cells:t}}),s0=(e,t,i,s)=>Oe(Yt(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!i}}),ch=(e,t,i)=>Oe(`${ui(i)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Vv=(e,t,i,s)=>Oe(`${ui(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!i}}),uh=(e,t,i)=>Oe(`${ui(i)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),Yv=e=>Oe("/api/settings",e),o0=e=>Oe("/api/nodes",e),a0=e=>Oe("/api/peers",e),l0=e=>Oe("/api/topology",e),Xv=(e,t)=>Oe(`${ui(t)}/sessions`,e),dh=(e,t)=>Oe(`${ui(t)}/config`,e),Cm=(e,t)=>Oe(`${ui(t)}/topology`,e),Gv=(e,t)=>Oe("/api/settings/config",e,{method:"POST",body:t}),c0=e=>Oe("/api/settings/token/rotate",e,{method:"POST"}),u0=(e,t)=>Oe("/api/settings/nodes/pair",e,{method:"POST",body:t}),km=(e,t,i=[])=>Oe(`${ui(i)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),Qv=(e,t,i)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:i}}),d0=e=>Oe("/api/settings/node-aliases",e),h0=(e,t,i)=>Oe(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{alias:i}}),Em=(e,t)=>Oe(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"DELETE"}),f0=(e,t,i)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:i}),p0=(e,t)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),hh=(e,t,i)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}/${i}`,e,{method:"POST"}),m0=(e,t,i)=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:i}}),Nm=(e,t,i,s=[])=>Oe(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:i,selected:s}}),g0=e=>Oe("/api/settings/service/regenerate",e,{method:"POST"}),v0=e=>Oe("/api/settings/update/check",e,{method:"POST"}),_0=e=>Oe("/api/settings/update/apply",e,{method:"POST"}),Sl=(e,t)=>`${ui(e)}/diagnostics/${t}`,y0=(e,t=[])=>Oe(Sl(t,"status"),e),w0=(e,{after:t=0,limit:i=200}={},s=[])=>Oe(`${Sl(s,"logs")}?after=${encodeURIComponent(t)}&limit=${encodeURIComponent(i)}`,e),Rm=(e,t,i,s=[])=>Oe(Sl(s,"verbose"),e,{method:"PATCH",body:{enabled:t,durationSeconds:i}}),S0=(e,t=[])=>Oe(Sl(t,"logs"),e,{method:"DELETE"}),b0=(e,t=!0)=>Oe(`/api/asks${t?"?open=1":""}`,e),x0=(e,t,i)=>Oe(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:i}}),za=(e,t=[])=>Oe(`${ui(t)}/decks`,e),Pm=(e,t,i=[])=>Oe(`${ui(i)}/decks`,e,{method:"POST",body:{name:t}}),Fa=(e,t,i,s,o=[])=>Oe(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:i,expectedRevision:s}}),C0=(e,t,i,s,o=[])=>Oe(`${ui(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:i,expectedRevision:s}}),k0=(e,t,i,s=[])=>Oe(`${ui(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:i}}),E0={power:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 3v8"}),c.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:c.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:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),c.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),c.jsx("path",{d:"M12 18v3"})]}),enter:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),c.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),c.jsx("path",{d:"M22 2 11 13"})]}),trash:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M4 7h16"}),c.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),c.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),c.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:c.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),refresh:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),c.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),c.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),c.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M12 16V5"}),c.jsx("polyline",{points:"8 9 12 5 16 9"}),c.jsx("path",{d:"M5 20h14"})]}),chevronLeft:c.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:c.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:c.jsx("polyline",{points:"6 10 12 16 18 10"}),history:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),c.jsx("polyline",{points:"3 3 3 8 8 8"}),c.jsx("path",{d:"M12 7v5l3 2"})]}),attach:c.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:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:c.jsxs(c.Fragment,{children:[c.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"}),c.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),c.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"11",cy:"11",r:"7"}),c.jsx("path",{d:"M21 21l-4.35-4.35"}),c.jsx("path",{d:"M8 11h6"})]}),gear:c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.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:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function et({name:e,size:t=20}){return c.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:E0[e]||null})}const N0=["all","pinned","active","off","technical"],Jv="nc_sidebar_views_v1",Zv="nc_sidebar_order_v1";function e_(e){return N0.includes(e)?e:"all"}function R0(e,t=[],i="all"){const s=e_(i);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function P0(e,t,i=[],s=[]){const o=i.indexOf(e.key),a=i.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,h=a===-1?Number.MAX_SAFE_INTEGER:a,p=s.indexOf(e.key),f=s.indexOf(t.key),_=p===-1?Number.MAX_SAFE_INTEGER:p,b=f===-1?Number.MAX_SAFE_INTEGER:f;return u-h||_-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 j0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Zv));if(!t||typeof t!="object"||Array.isArray(t))return{};const i={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(u=>typeof u=="string"&&u&&u.length<=256))].slice(0,128);a.length&&(i[s]=a)}return i}catch{return{}}}function Jn(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function D0(e,t=globalThis.localStorage){try{t.setItem(Zv,JSON.stringify(e))}catch{}return e}function L0(e,t,i,s,o=[]){if(typeof t!="string"||!t||i===s)return e;const a=[...new Set(o.filter(S=>typeof S=="string"&&S))];if(!a.includes(i)||!a.includes(s))return e;const u=Jn(e,t).filter(S=>a.includes(S)),h=[...u,...a.filter(S=>!u.includes(S))],p=h.indexOf(i),f=h.indexOf(s);h.splice(p,1);const _=h.indexOf(s),b=p<f?_+1:_;return h.splice(b,0,i),{...e,[t]:h}}function M0(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Jv));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function jm(e,t){var i,s;return{open:((i=e==null?void 0:e[t])==null?void 0:i.open)!==!1,filter:e_((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function T0(e,t=globalThis.localStorage){try{t.setItem(Jv,JSON.stringify(e))}catch{}return e}function Dm(e,t=""){const i=String(t||"").trim().toLocaleLowerCase();return i?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(i):!0}function xr(e=[],t=[],i="all",s=[]){return[...e].filter(o=>R0(o,t,i)).sort((o,a)=>P0(o,a,t,s))}const fh=["it","en","es"];function A0(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return fh.includes(t)?t:"en"}catch{return"en"}}const Qa=A0(),t_="nc_lang",od="nc-lang";function i_(){return typeof localStorage<"u"?localStorage:null}const $a={it:{"update-available":"nuova versione {v} disponibile","install-version-mismatch":"installazione incompleta: frontend e server non coincidono (v{v})",reload:"ricarica","grid-empty":"trascina qui una sessione dalla sidebar, o doppio-clic per la vista singola","grid-full":"il deck può mostrare al massimo 9 sessioni",pin:"fissa in cima",reorder:"riordina","reorder-help":"trascina la maniglia; frecce su/giu da tastiera","rename-node":"rinomina nodo","rename-node-prompt":"Nuovo nome del nodo in NexusCrew","rename-node-invalid":"Nome non valido: massimo 64 caratteri, senza a capo.","reorder-deck-help":"trascina il deck; frecce sinistra/destra da tastiera",sessions:"sessioni","new-session":"nuova sessione",new:"nuova",fleet:"Flotta","fleet-tmux":"flotta tmux","other-sessions":"Altre sessioni","view-all":"tutte","view-pinned":"fissate","view-active":"attive","view-off":"spente","view-technical":"tecniche","mark-technical":"nascondi come sessione tecnica","mark-normal":"mostra come sessione normale","position-local":"Locale",files:"file",refresh:"aggiorna","filter-placeholder":"filtra sessioni…","loading-fleet":"carico la flotta…","no-sessions":"nessuna sessione tmux viva — la flotta parte al boot (systemd)","no-match":'nessuna sessione contiene "{q}"',"copy-url":"clicca per copiare l'URL","ssh-only":"solo tunnel SSH/VPN","new-files-outbox":"nuovi file in outbox",terminate:"termina","terminate-confirm":'Terminare la sessione "{name}"?',"cell-on":"tmux vivo","cell-off":"spenta","cell-working":"al lavoro","cell-idle":"in attesa","cell-degraded":"degradata: unit attiva, tmux morto","power-on":"accendi","power-off":"spegni","boot-enable":"attiva al boot","boot-disable":"disattiva al boot","state-on":"accesa","state-off":"spenta",engine:"Engine",model:"Modello","model-default":"Modello predefinito del provider","model-remembered":"Ultimo modello usato con questo engine","boot-persist":"avvia al boot","remove-boot":"togli anche dal boot","power-config-in-settings":"Engine, provider, profilo, modello e permessi si modificano in Impostazioni → Flotta.","no-remote-control":"⚠ engine non-native: niente RC da app claude.ai (da qui la piloti comunque)",cancel:"annulla",name:"nome","name-invalid":"nome non valido: a-zA-Z0-9._- max 64, senza '-' iniziale",cwd:"cartella",browse:"sfoglia","fs-home":"home","fs-parent":".. su",preset:"preset","preset-2x2":"griglia 2×2","preset-columns":"colonne","preset-equalize":"equalizza",collapse:"comprimi",expand:"espandi",create:"crea","auth-prompt":"Incolla il token (stampato dal server):","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande",composer:"composer",windows:"{n} finestre","empty-files":"vuota",upload:"carica","no-sessions-short":"nessuna sessione","composer-placeholder":"scrivi o detta…","composer-history-tools":"cronologia e dimensione input","composer-history":"cronologia della cella","composer-history-empty":"nessun input inviato","composer-history-clear":"cancella cronologia di questa cella","composer-expand":"espandi input","composer-collapse":"riduci input","composer-clear-data":"cancella bozze e cronologia","composer-clear-data-help":"Rimuove da questo browser tutte le bozze e la cronologia input delle celle.","composer-clear-confirm":"Cancellare tutte le bozze e la cronologia input salvate in questo browser?","composer-clear-done":"Bozze e cronologia cancellate.","composer-clear-failed":"Impossibile cancellare i dati del composer in questo browser.",attach:"allega","attach-file":"File","attach-camera":"Fotocamera","attach-gallery":"Galleria","attach-uploading":"carico…","attach-upload-progress":"allegato {n}/{total}…","attach-uploaded":"{n} allegati caricati",voice:"voice",send:"invia","composer-send-failed":"connessione non pronta — testo conservato, riprova",close:"chiudi","lang-label":"lingua",decks:"deck","new-deck":"nuovo deck","deck-name":"nome deck","open-deck-window":"apri in una nuova finestra","detach-deck":"stacca in una nuova finestra","deck-current":"questo deck (finestra corrente)","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","rename-deck":"rinomina deck","delete-deck":"elimina deck","delete-deck-confirm":'Eliminare il deck "{name}"?',"send-to-deck":"manda al deck…","deck-autosave":"salvataggio automatico",saving:"salvataggio…",saved:"salvato","popup-blocked":"popup bloccato: apri qui","select-drag":"trascina per selezionare","copy-manual":"seleziona e copia manualmente","toggle-sidebar":"mostra/nascondi la barra laterale",settings:"impostazioni","tab-roles":"ruoli","tab-nodes":"nodi",local:"Locale",location:"Dove","pairing-link":"link di pairing","pairing-required":"nome, alias SSH e link di pairing sono obbligatori","pairing-connect-help":"Per collegare un nodo servono: nome, Host SSH già funzionante e link/QR creato sull’altra installazione NexusCrew.","pairing-localhost-hint":"127.0.0.1 nel link è corretto: non aprirlo qui. NexusCrew usa invito e porta attraverso l’Host SSH.","scan-qr":"scansiona QR","pairing-qr-invalid":"QR di pairing non valido","invite-node":"invita un nodo","create-pairing-link":"crea link / QR","visibility-network":"tutta la rete","visibility-relay":"solo relay","visibility-selected":"nodi selezionati","hydra-simple":"locale + nodi, una sola rete","local-ready":"Questo dispositivo è pronto. Puoi usarlo da solo o collegarlo a un nodo.","local-only":"solo locale","add-node":"aggiungi nodo",connect:"collega","node-connected":"Nodo collegato. La rete verrà sincronizzata automaticamente.","tab-system":"sistema","tab-fleet":"flotta","tab-diagnostics":"diagnostica","diagnostics-local":"Questo nodo","diagnostics-target":"Nodo da diagnosticare","diagnostics-verbose":"Log verbosi temporanei","diagnostics-duration":"Durata verbose","diagnostics-expires":"Verbose attivo fino alle {time}","diagnostics-off":"Verbose spento; warning ed errori operativi restano disponibili.","diagnostics-level":"Livello","diagnostics-all-levels":"tutti i livelli","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"scorrimento automatico","diagnostics-log":"Log diagnostico sanitizzato","diagnostics-empty":"Nessun evento diagnostico.","diagnostics-export":"esporta JSON","diagnostics-export-failed":"Esportazione non disponibile in questo browser.","diagnostics-clear":"svuota","diagnostics-clear-confirm":"Svuotare il buffer diagnostico di questo nodo?","diagnostics-unsupported":"Questo peer è offline o non supporta la diagnostica strutturata.","fleet-editor-loading":"Caricamento dell'editor Fleet…","fleet-editor-load-error":"Impossibile caricare l'editor Fleet.","fleet-editor-unavailable":"Editor Fleet non disponibile in questa posizione.","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-shell-engine-help":"Shell locale risolta sul dispositivo al momento dell’avvio; nessun percorso viene salvato nel backup.","fleet-shell-command-placeholder":"comando opzionale, es. npm test","fleet-shell-command-help":"Esecuzione one-shot tramite la shell locale con -lc. La cella si ferma quando il comando termina.","fleet-shell-command-metachar":"Pipe, redirect, variabili e altri metacaratteri vengono interpretati dalla shell del dispositivo.","fleet-shell-interactive":"Vuoto: apre una shell interattiva locale e mantiene la cella attiva.","fleet-shell-launch-help":"Il comando Shell si configura nella cella da Impostazioni → Flotta.","fleet-credential-title":"API key su questo dispositivo","fleet-credential-help":"La key resta solo sul nodo selezionato, non viene mostrata, esportata o condivisa con la rete.","fleet-credential-set":"imposta key","fleet-credential-change":"cambia key","fleet-credential-forget":"dimentica","fleet-credential-saved":"Key salvata localmente.","fleet-credential-removed":"Key locale rimossa.","fleet-credential-remove-confirm":"Rimuovere la key locale {key}?","fleet-credential-source-environment":"ambiente","fleet-credential-source-local":"store locale","fleet-credential-source-compatibility":"config compatibile","fleet-credential-source-missing":"mancante","fleet-key-section":"KEY","fleet-key-variable":"Variabile","fleet-key-value":"Valore per {key}","fleet-key-used-by":"Usata da: {engines}","fleet-key-used-by-none":"Non ancora usata da engine configurati su questo nodo.","fleet-key-shared-impact":"Sostituire o rimuovere {key} interessa tutti gli engine elencati: {engines}.","fleet-key-enter":"inserisci la key","fleet-key-blank-keeps":"vuoto = mantieni la fonte attuale","fleet-key-reveal":"mostra","fleet-key-hide":"nascondi","fleet-key-local-help":"Il valore resta write-only sul nodo selezionato e non entra in engine, backup o federazione.","fleet-key-create-missing":"Crea esplicitamente l’engine senza key (resterà “key richiesta”).","fleet-key-partial-create":"Engine creato; la key non è stata salvata. Puoi riprovare senza creare duplicati.","fleet-key-partial-edit":"Engine aggiornato; la key non è stata salvata. Le modifiche all’engine restano applicate.","fleet-provider-notice-claude-openrouter":"Claude Code è ottimizzato per modelli Anthropic: altri provider potrebbero non funzionare correttamente. Fast mode richiede il provider Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses è beta e stateless; Codex-VL non usa fallback Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configurazione Claude isolata con onboarding e fast mode dedicati; la configurazione Claude nativa non viene modificata.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max-preview è il modello predefinito e non viene usato alcun fallback OpenAI/PAYG.","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.',"fleet-cwd-needs-repair":"cartella da riparare","fleet-cwd-repair":"ripara","fleet-cwd-repair-title":"Ripara cartella cella {id}","fleet-cwd-repair-help":"La cartella attuale non è portabile su questo dispositivo: appartiene a un altro dispositivo o non esiste sotto la home. Scegli una cartella home-relative (~) sul dispositivo target; il backend ricalcolerà il percorso assoluto.","fleet-cwd-repair-no-source-path":"Il percorso originale non viene mostrato: è specifico del dispositivo di origine.","fleet-cwd-repair-placeholder":"es. Dev","fleet-cwd-repair-preview":"Nuova cartella: {path}","fleet-cwd-repair-browse":"sfoglia sotto ~","fleet-cwd-repair-fs-empty":"nessuna sottocartella","fleet-cwd-repair-use-current":"usa questa cartella","fleet-cwd-repair-invalid":'percorso non valido: niente assoluto, "..", barra rovesciata o lettera disco',"fleet-cwd-repair-confirm":"Impostare la cartella della cella {id} su {path}? Verrà ricalcolata sul dispositivo target.","fleet-cwd-repair-unportable":"Il percorso scelto non è portabile su questo dispositivo: deve esistere sotto la home.","fleet-cwd-repair-suggestion":"Suggerimento dal dispositivo:","fleet-cwd-repair-use-suggestion":"usa {path}","fleet-cwd-repaired":"Cartella della cella riparata.","settings-readonly":"READONLY attivo: le modifiche sono bloccate dal server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"questa macchina guarda altri nodi via tunnel SSH","role-node":"nodo (raggiungibile)","published-port":"porta pubblicata (opzionale)","no-nodes":"nessun nodo remoto configurato","node-add":"collega installazione NexusCrew","node-connect-help":"La porta SSH serve a raggiungere il server SSH. La porta NexusCrew è invece la porta locale mostrata da `nexuscrew status` sul nodo remoto.","node-name-label":"Nome del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH su questo dispositivo","node-ssh-local-help":"Puoi sostituire l’indirizzo del link con lo stesso alias che funziona usando ssh su questo dispositivo. Alias, agent e chiavi restano locali e non viaggiano nel link.","node-ssh-port-label":"Porta SSH","node-ssh-port-help":"Di solito 22; usa la porta pubblica del server SSH.","node-app-port-label":"Porta NexusCrew sul nodo","node-app-port-help":"È la porta mostrata da `nexuscrew status` sul nodo remoto.","node-name-ph":"nome (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"porta remota (opz.)","node-remove-confirm":'Rimuovere il nodo "{name}"?',"node-remove-warning":"Elimina associazione, credenziali e tunnel locale. Non spegne il dispositivo remoto.","peer-inventory-title":"Nodi collegati al hub","peer-group-hubs":"Hub diretti","peer-group-clients":"Client collegati","peer-group-routed":"Nodi raggiungibili tramite la rete","peer-routed":"instradato","peer-routed-stale":"instradato, non raggiungibile","peer-visibility":"Visibilità nella rete","node-test":"test","tunnel-start":"avvia tunnel","tunnel-stop":"ferma tunnel","tunnel-restart":"riavvia tunnel","share-node":"Condividi questo nodo","share-local-heading":"Condivisione di questo dispositivo","share-local-hub":"Hub di condivisione","share-local-through":"Condividi {device} tramite {hub}","share-local-active":"Condiviso e raggiungibile dalla rete collegata all’hub.","share-local-pending":"Condivisione richiesta, ma il tunnel è giù: questo dispositivo non è ancora raggiungibile.","share-local-private":"Privato: solo questo dispositivo può usare il collegamento all’hub.","share-local-private-down":"Privato, ma il collegamento all’hub è giù. Riconnetti per applicare e verificare la modalità privata.","share-local-reconnect":"Riconnetti e riconcilia","share-node-off-desc":"Privato: resta collegato al nodo hub, ma gli altri client non possono raggiungerlo.","share-node-on-desc":"Condiviso: il nodo hub può mostrarlo e smistare celle e deck autorizzati.","peer-shared":"Nodo client condiviso nella rete Hydra","peer-private":"Nodo client privato: collegato, non pubblicato nella rete Hydra","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","authorized-keys-hint":"incolla questa riga in ~/.ssh/authorized_keys sull'host remoto:",copy:"copia",copied:"copiato","token-rotate":"ruota token","token-rotate-explain":"Il nuovo token NON verrà mostrato: recuperalo con `nexuscrew show token`. La sessione corrente verrà invalidata.","service-regenerate":"rigenera service","npm-auto-update":"aggiornamenti automatici da npm","npm-auto-update-help":"Controlla periodicamente latest e installa solo versioni più recenti. Mai downgrade.","npm-update-current":"installata","npm-update-latest":"npm latest","npm-update-check":"controlla ora","npm-update-install":"aggiorna ora","npm-update-restarting":"Aggiornamento avviato; NexusCrew si riaprirà dopo il riavvio del servizio.","npm-update-idle":"aggiornato","npm-update-checking":"controllo in corso","npm-update-available":"aggiornamento disponibile","npm-update-installing":"installazione in corso","npm-update-installed":"installato, riavvio in corso","npm-update-error":"controllo fallito","npm-update-unsupported":"disponibile solo con installazione npm globale","service-installed":"service installato","service-missing":"service non installato","service-active":"attivo","service-inactive":"non attivo",confirm:"conferma",add:"aggiungi",enable:"attiva","wizard-title":"benvenuto in NexusCrew","wizard-skip":"configura dopo dai settings","wizard-step-roles":"ruoli di questa installazione","wizard-step-node":"primo nodo remoto (opzionale)","wizard-done":"tutto pronto","wizard-done-desc":"setup completato — puoi cambiare tutto dai settings",next:"continua",back:"indietro",skip:"salta",finish:"fine","err-node-name":"nome non valido (a-z, 0-9, -, max 32)","err-local-name":"nome locale non valido: usa uno slug univoco, non “localhost”","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)","routed-node-aliases":"Alias nodi instradati","routed-node-aliases-help":"Visibili solo su questo dispositivo; route e nome remoto non cambiano.","node-local-alias":"Alias su questo dispositivo","alias-on-device":"Alias su questo dispositivo","reset-alias":"Ripristina nome remoto","node-slug-hint":"routing su slug: {slug}","device-name-label":"Nome dispositivo","device-name-hint":"come ti vedono i peer (modificabile)","local-route-name-label":"Nome locale / route","local-route-name-hint":"handle tecnico stabile: label leggibile + suffisso del nodeId; modificabile prima della connessione","err-label":"etichetta non valida (max 64 char, niente a capo)","fleet-inventory":"Celle e sessioni","fleet-inventory-help":"tutte le posizioni (Locale + route Hydra)","fleet-manage-location":"Gestisci posizione","fleet-network-overview":"Panoramica rete","fleet-manage-help":"crea e configura celle nella posizione selezionata","fleet-overview-help":"stato operativo di tutte le posizioni, senza duplicare l’editor","fleet-inventory-empty":"nessuna cella o sessione","fleet-not-available":"fleet non disponibile su questa posizione",start:"avvia",stop:"ferma",restart:"riavvia",delete:"elimina","copy-manual":"copia non riuscita — seleziona e Cmd+C, o copia a mano","copy-empty":"niente selezione: trascina con Shift per selezionare","save-and-start":"salva e avvia",permissions:"Permessi","power-on-hint":"Spegni la cella; puoi anche toglierla dal boot.","launch-engine-help":"Provider, credenziali e nuovi engine si creano in Impostazioni → Flotta. Modello e permessi sono per questa cella.","launch-unavailable-hint":"Configurazione engine non disponibile su questo nodo.","import-as-cell":"Importa come cella","import-help":"Riconcilia una sessione tmux esistente in una cella gestita. Scegli un engine già dichiarato: nessun engine viene inventato.","import-engine-required":"scegli un engine (obbligatorio)","test-and-connect":"testa e collega","pairing-v2-hint":"Incolla o scansiona UN solo link: precompila nome, Host SSH ed etichetta quando il link li include (v2).","invite-v2-hint":"Crea un invito monouso completo. Se sei già collegato a un hub, viene usato automaticamente; altrimenti serve solo il suo indirizzo SSH raggiungibile.","invite-network-hint":"Crea un invito per la rete a cui sei già collegato. Il nuovo dispositivo entrerà attraverso l’hub, non si collegherà direttamente a questo dispositivo.","invite-network-label":"Rete di destinazione","invite-network-via":"Hub","invite-network-route":"Un solo collegamento verso l’hub; nodi, celle e deck vengono smistati internamente.","invite-endpoint-label":"Indirizzo SSH di questo hub visto dagli altri dispositivi","invite-endpoint-auto":"Endpoint già configurato","invite-endpoint-needed":"Inserisci user@host o un alias SSH condiviso. Non è 127.0.0.1 e non è l’URL HTTP NexusCrew.","invite-ssh-hint":"Il target SSH con cui L’ALTRO dispositivo raggiunge QUESTA installazione (user@host o alias). Obbligatorio: viene incluso nel link.","invite-next-steps":"copia questo link, apri NexusCrew sull’altro dispositivo e incollalo in Impostazioni → Nodi (o scansiona il QR): al resto pensa NexusCrew","pair-card-title":"collega con un solo link","pair-card-help":"Incolla il link di pairing generato sull’altro dispositivo (o scansiona il suo QR): NexusCrew decodifica, prova la connessione SSH e collega da solo.","pair-paste-ph":"incolla qui il link di pairing","pair-paste-btn":"incolla","pair-advanced":"avanzate / modifica","pair-progress":"collegamento in corso: SSH → invito → conferma → verifica…","pair-retry":"riprova","pair-invalid-link":"questo non è un link di pairing valido","pair-invalid-hint":"serve il link completo (http://…#pair=…) generato dall’altro NexusCrew: non aprirlo, incollalo qui","pair-missing-ssh":"il link non include il target SSH (formato v1): indica in “avanzate” come questo dispositivo raggiunge l’altro via SSH — non viene mai inventato","pair-missing-name":"manca il nome del nodo: completalo in “avanzate”","pair-clipboard-denied":"lettura degli appunti non consentita: incolla manualmente nel campo","pair-clipboard-empty":"appunti vuoti: copia prima il link di pairing","pair-stage-validation":"dati non validi","pair-stage-conflict":"nome già in uso","pair-stage-ssh-start":"avvio del tunnel SSH fallito","pair-stage-ssh-ready":"peer non raggiungibile via SSH","pair-stage-join":"scambio dell’invito fallito","pair-stage-tunnel-final":"tunnel negoziato fallito","pair-stage-confirm":"conferma del pairing fallita","pair-stage-health":"verifica finale della federazione fallita","pair-stage-internal":"errore interno","pair-stage-generic":"connessione fallita","qr-no-camera":"nessuna camera disponibile su questo dispositivo: usa una foto del QR","qr-permission":"permesso camera negato: consentilo nel browser o usa una foto del QR","qr-unsupported":"scanner live non supportato qui: carica una foto del QR","qr-upload":"usa una foto"},en:{"update-available":"new version {v} available","install-version-mismatch":"incomplete installation: frontend and server do not match (v{v})",reload:"reload","grid-empty":"drag a session here from the sidebar, or double-click for single view","grid-full":"a deck can show at most 9 sessions",pin:"pin to top",reorder:"reorder","reorder-help":"drag the handle; keyboard up/down arrows","rename-node":"rename node","rename-node-prompt":"New node name in NexusCrew","rename-node-invalid":"Invalid name: maximum 64 characters, no line breaks.","reorder-deck-help":"drag the deck; keyboard left/right arrows",sessions:"sessions","new-session":"new session",new:"new",fleet:"Fleet","fleet-tmux":"tmux fleet","other-sessions":"Other sessions","view-all":"all","view-pinned":"pinned","view-active":"active","view-off":"off","view-technical":"technical","mark-technical":"hide as technical session","mark-normal":"show as normal session","position-local":"Local",files:"files",refresh:"refresh","filter-placeholder":"filter sessions…","loading-fleet":"loading fleet…","no-sessions":"no live tmux sessions — the fleet starts at boot (systemd)","no-match":'no session matches "{q}"',"copy-url":"click to copy URL","ssh-only":"SSH/VPN tunnel only","new-files-outbox":"new files in outbox",terminate:"terminate","terminate-confirm":'Terminate session "{name}"?',"cell-on":"tmux alive","cell-off":"off","cell-working":"working","cell-idle":"idle","cell-degraded":"degraded: unit active, tmux dead","power-on":"power on","power-off":"power off","boot-enable":"enable at boot","boot-disable":"disable at boot","state-on":"running","state-off":"stopped",engine:"Engine",model:"Model","model-default":"Provider default model","model-remembered":"Last model used with this engine","boot-persist":"start at boot","remove-boot":"also remove from boot","power-config-in-settings":"Edit engine, provider, profile, model and permissions in Settings → Fleet.","no-remote-control":"⚠ non-native engine: no claude.ai app RC (you can still drive it from here)",cancel:"cancel",name:"name","name-invalid":"invalid name: a-zA-Z0-9._- max 64, no leading '-'",cwd:"folder",browse:"browse","fs-home":"home","fs-parent":".. up",preset:"preset","preset-2x2":"2×2 grid","preset-columns":"columns","preset-equalize":"equalize",collapse:"collapse",expand:"expand",create:"create","auth-prompt":"Paste the token (printed by the server):","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text",composer:"composer",windows:"{n} windows","empty-files":"empty",upload:"upload","no-sessions-short":"no sessions","composer-placeholder":"type or dictate…","composer-history-tools":"input history and size","composer-history":"cell history","composer-history-empty":"no submitted input","composer-history-clear":"clear this cell history","composer-expand":"expand input","composer-collapse":"collapse input","composer-clear-data":"clear drafts and history","composer-clear-data-help":"Removes every saved cell draft and input-history entry from this browser.","composer-clear-confirm":"Clear every saved draft and input-history entry from this browser?","composer-clear-done":"Drafts and history cleared.","composer-clear-failed":"Could not clear composer data in this browser.",attach:"attach","attach-file":"File","attach-camera":"Camera","attach-gallery":"Gallery","attach-uploading":"uploading…","attach-upload-progress":"attachment {n}/{total}…","attach-uploaded":"{n} attachments uploaded",voice:"voice",send:"send","composer-send-failed":"connection not ready — text kept, try again",close:"close","lang-label":"language",decks:"decks","new-deck":"new deck","deck-name":"deck name","open-deck-window":"open in a new window","detach-deck":"detach into a new window","deck-current":"this deck (current window)","deck-owner-unavailable":"owner node is not shared or reachable","rename-deck":"rename deck","delete-deck":"delete deck","delete-deck-confirm":'Delete deck "{name}"?',"send-to-deck":"send to deck…","deck-autosave":"autosave",saving:"saving…",saved:"saved","popup-blocked":"popup blocked: open here","select-drag":"drag to select","copy-manual":"select and copy manually","toggle-sidebar":"show/hide the sidebar",settings:"settings","tab-roles":"roles","tab-nodes":"nodes",local:"Local",location:"Location","pairing-link":"pairing link","pairing-required":"name, SSH alias and pairing link are required","pairing-connect-help":"Connecting a node requires a name, a working SSH Host, and a link/QR created by the other NexusCrew installation.","pairing-localhost-hint":"127.0.0.1 in the link is correct: do not open it here. NexusCrew carries the invite and port through the SSH Host.","scan-qr":"scan QR","pairing-qr-invalid":"invalid pairing QR","invite-node":"invite a node","create-pairing-link":"create link / QR","visibility-network":"whole network","visibility-relay":"relay only","visibility-selected":"selected nodes","hydra-simple":"local + nodes, one network","local-ready":"This device is ready. Use it alone or connect it to a node.","local-only":"local only","add-node":"add node",connect:"connect","node-connected":"Node connected. The network will synchronize automatically.","tab-system":"system","tab-fleet":"fleet","tab-diagnostics":"diagnostics","diagnostics-local":"This node","diagnostics-target":"Node to diagnose","diagnostics-verbose":"Temporary verbose logs","diagnostics-duration":"Verbose duration","diagnostics-expires":"Verbose enabled until {time}","diagnostics-off":"Verbose is off; operational warnings and errors remain available.","diagnostics-level":"Level","diagnostics-all-levels":"all levels","diagnostics-component":"component","diagnostics-pause":"pause","diagnostics-autoscroll":"autoscroll","diagnostics-log":"Sanitized diagnostic log","diagnostics-empty":"No diagnostic events.","diagnostics-export":"export JSON","diagnostics-export-failed":"Export is not available in this browser.","diagnostics-clear":"clear","diagnostics-clear-confirm":"Clear this node diagnostic buffer?","diagnostics-unsupported":"This peer is offline or does not support structured diagnostics.","fleet-editor-loading":"Loading the Fleet editor…","fleet-editor-load-error":"Unable to load the Fleet editor.","fleet-editor-unavailable":"The Fleet editor is unavailable at this location.","fleet-managed":"managed by NexusCrew","fleet-custom":"custom command","fleet-managed-help":"Client, provider and launch are managed internally; secrets are never displayed.","fleet-shell-engine-help":"The local shell is resolved on the device at launch time; no executable path is stored in backups.","fleet-shell-command-placeholder":"optional command, e.g. npm test","fleet-shell-command-help":"One-shot execution through the local shell with -lc. The cell stops when the command finishes.","fleet-shell-command-metachar":"Pipes, redirects, variables, and other metacharacters are interpreted by the device shell.","fleet-shell-interactive":"Empty: opens a local interactive shell and keeps the cell active.","fleet-shell-launch-help":"Configure the Shell command on the cell in Settings → Fleet.","fleet-credential-title":"API key on this device","fleet-credential-help":"The key stays only on the selected node and is never displayed, exported or shared with the network.","fleet-credential-set":"set key","fleet-credential-change":"change key","fleet-credential-forget":"forget","fleet-credential-saved":"Key saved locally.","fleet-credential-removed":"Local key removed.","fleet-credential-remove-confirm":"Remove the local {key} key?","fleet-credential-source-environment":"environment","fleet-credential-source-local":"local store","fleet-credential-source-compatibility":"compatible config","fleet-credential-source-missing":"missing","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Value for {key}","fleet-key-used-by":"Used by: {engines}","fleet-key-used-by-none":"Not yet used by configured engines on this node.","fleet-key-shared-impact":"Replacing or removing {key} affects every listed engine: {engines}.","fleet-key-enter":"enter the key","fleet-key-blank-keeps":"blank = keep the current source","fleet-key-reveal":"reveal","fleet-key-hide":"hide","fleet-key-local-help":"The value stays write-only on the selected node and never enters engines, backups or federation.","fleet-key-create-missing":"Explicitly create the engine without a key (it will remain “key required”).","fleet-key-partial-create":"Engine created; the key was not saved. Retry without creating a duplicate.","fleet-key-partial-edit":"Engine updated; the key was not saved. The engine changes remain applied.","fleet-provider-notice-claude-openrouter":"Claude Code is optimized for Anthropic models; other providers may not work correctly. Fast mode requires the first-party Anthropic provider.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses is beta and stateless; Codex-VL has no Chat Completions fallback.","fleet-provider-notice-claude-kimi-code":"Kimi Code uses isolated Claude configuration with dedicated onboarding and fast-mode flags; native Claude configuration is not modified.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max-preview is the default and no OpenAI/PAYG fallback is used.","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.',"fleet-cwd-needs-repair":"folder needs repair","fleet-cwd-repair":"repair","fleet-cwd-repair-title":"Repair cell folder {id}","fleet-cwd-repair-help":"The current folder is not portable on this device: it belongs to another device or does not exist under the home directory. Choose a home-relative (~) folder on the target device; the backend will recompute the absolute path.","fleet-cwd-repair-no-source-path":"The original path is not shown: it is specific to the source device.","fleet-cwd-repair-placeholder":"e.g. Dev","fleet-cwd-repair-preview":"New folder: {path}","fleet-cwd-repair-browse":"browse under ~","fleet-cwd-repair-fs-empty":"no subfolders","fleet-cwd-repair-use-current":"use this folder","fleet-cwd-repair-invalid":'invalid path: no absolute path, "..", backslash or drive letter',"fleet-cwd-repair-confirm":"Set the folder of cell {id} to {path}? It will be recomputed on the target device.","fleet-cwd-repair-unportable":"The chosen path is not portable on this device: it must exist under the home directory.","fleet-cwd-repair-suggestion":"Suggestion from device:","fleet-cwd-repair-use-suggestion":"use {path}","fleet-cwd-repaired":"Cell folder repaired.","settings-readonly":"READONLY active: changes are blocked by the server (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"this machine watches other nodes via SSH tunnels","role-node":"node (reachable)","published-port":"published port (optional)","no-nodes":"no remote nodes configured","node-add":"connect a NexusCrew installation","node-connect-help":"The SSH port reaches the SSH server. The NexusCrew port is the local port reported by `nexuscrew status` on the remote node.","node-name-label":"Node name","node-ssh-label":"SSH host","pair-ssh-local-label":"SSH host or alias on this device","node-ssh-local-help":"You may replace the link address with the same alias that works with ssh on this device. Aliases, agents and private keys stay local and are never carried in the link.","node-ssh-port-label":"SSH port","node-ssh-port-help":"Usually 22; use the SSH server public port.","node-app-port-label":"NexusCrew port on node","node-app-port-help":"The port reported by `nexuscrew status` on the remote node.","node-name-ph":"name (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"remote port (opt.)","node-remove-confirm":'Remove node "{name}"?',"node-remove-warning":"Deletes the pairing, credentials and local tunnel. It does not power off the remote device.","peer-inventory-title":"Nodes connected to the hub","peer-group-hubs":"Direct hubs","peer-group-clients":"Connected clients","peer-group-routed":"Nodes reachable through the network","peer-routed":"routed","peer-routed-stale":"routed, unreachable","peer-visibility":"Network visibility","node-test":"test","tunnel-start":"start tunnel","tunnel-stop":"stop tunnel","tunnel-restart":"restart tunnel","share-node":"Share this node","share-local-heading":"Share this device","share-local-hub":"Sharing hub","share-local-through":"Share {device} through {hub}","share-local-active":"Shared and reachable by the network connected to the hub.","share-local-pending":"Sharing is requested, but the tunnel is down: this device is not reachable yet.","share-local-private":"Private: only this device can use its hub connection.","share-local-private-down":"Private, but the hub connection is down. Reconnect to apply and verify private mode.","share-local-reconnect":"Reconnect and reconcile","share-node-off-desc":"Private: it stays connected to the hub, but other clients cannot reach it.","share-node-on-desc":"Shared: the hub may advertise it and route authorized cells and decks.","peer-shared":"Client node shared on the Hydra network","peer-private":"Private client node: connected, not published on Hydra","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","authorized-keys-hint":"paste this line into ~/.ssh/authorized_keys on the remote host:",copy:"copy",copied:"copied","token-rotate":"rotate token","token-rotate-explain":"The new token will NOT be shown: retrieve it with `nexuscrew show token`. The current session will be invalidated.","service-regenerate":"regenerate service","npm-auto-update":"automatic updates from npm","npm-auto-update-help":"Periodically checks latest and installs only newer versions. Never downgrades.","npm-update-current":"installed","npm-update-latest":"npm latest","npm-update-check":"check now","npm-update-install":"update now","npm-update-restarting":"Update started; NexusCrew will return after the service restarts.","npm-update-idle":"up to date","npm-update-checking":"checking","npm-update-available":"update available","npm-update-installing":"installing","npm-update-installed":"installed, restarting","npm-update-error":"check failed","npm-update-unsupported":"available only for global npm installations","service-installed":"service installed","service-missing":"service not installed","service-active":"active","service-inactive":"not active",confirm:"confirm",add:"add",enable:"enable","wizard-title":"welcome to NexusCrew","wizard-skip":"configure later from settings","wizard-step-roles":"roles of this install","wizard-step-node":"first remote node (optional)","wizard-done":"all set","wizard-done-desc":"setup complete — you can change everything from settings",next:"continue",back:"back",skip:"skip",finish:"finish","err-node-name":"invalid name (a-z, 0-9, -, max 32)","err-local-name":"invalid local name: use a unique slug, not “localhost”","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)","routed-node-aliases":"Routed node aliases","routed-node-aliases-help":"Visible only on this device; the route and remote name do not change.","node-local-alias":"Alias on this device","alias-on-device":"Alias on this device","reset-alias":"Reset remote name","node-slug-hint":"routing on slug: {slug}","device-name-label":"Device name","device-name-hint":"how peers see you (editable)","local-route-name-label":"Local / route name","local-route-name-hint":"stable technical handle: readable label + nodeId suffix; editable before connecting","err-label":"invalid label (max 64 chars, no line breaks)","fleet-inventory":"Cells and sessions","fleet-inventory-help":"all positions (Local + Hydra routes)","fleet-manage-location":"Manage location","fleet-network-overview":"Network overview","fleet-manage-help":"create and configure cells at the selected location","fleet-overview-help":"operational state of every location, separate from the editor","fleet-inventory-empty":"no cells or sessions","fleet-not-available":"fleet not available on this position",start:"start",stop:"stop",restart:"restart",delete:"delete","copy-manual":"copy failed — select and press Cmd+C, or copy manually","copy-empty":"nothing selected: drag with Shift to select","save-and-start":"save and start",permissions:"Permissions","power-on-hint":"Stop the cell; you can also remove it from boot.","launch-engine-help":"Providers, credentials and new engines are created in Settings → Fleet. Model and permissions are per cell.","launch-unavailable-hint":"Engine configuration is unavailable on this node.","import-as-cell":"Import as cell","import-help":"Reconcile an existing tmux session into a managed cell. Pick an already-declared engine: no engine is invented.","import-engine-required":"pick an engine (required)","test-and-connect":"test and connect","pairing-v2-hint":"Paste or scan ONE link: it prefills name, SSH host and label when the link carries them (v2).","invite-v2-hint":"Create one complete one-time invitation. If this device already joined a hub, that hub is used automatically; otherwise only its reachable SSH address is required.","invite-network-hint":"Create an invitation for the network you already joined. The new device enters through the hub instead of connecting directly to this device.","invite-network-label":"Destination network","invite-network-via":"Hub","invite-network-route":"One connection to the hub; nodes, cells and decks are routed internally.","invite-endpoint-label":"This hub’s SSH address as seen by other devices","invite-endpoint-auto":"Configured endpoint","invite-endpoint-needed":"Enter user@host or a shared SSH alias. This is not 127.0.0.1 and not the NexusCrew HTTP URL.","invite-ssh-hint":"The SSH target the OTHER device uses to reach THIS installation (user@host or alias). Required: it is included in the link.","invite-next-steps":"copy this link, open NexusCrew on the other device and paste it in Settings → Nodes (or scan the QR): NexusCrew does the rest","pair-card-title":"connect with one link","pair-card-help":"Paste the pairing link generated on the other device (or scan its QR): NexusCrew decodes it, tests the SSH connection and connects on its own.","pair-paste-ph":"paste the pairing link here","pair-paste-btn":"paste","pair-advanced":"advanced / edit","pair-progress":"connecting: SSH → invite → confirm → verify…","pair-retry":"retry","pair-invalid-link":"this is not a valid pairing link","pair-invalid-hint":"you need the full link (http://…#pair=…) generated by the other NexusCrew: don’t open it, paste it here","pair-missing-ssh":"the link carries no SSH target (v1 format): set in “advanced” how this device reaches the other one over SSH — it is never invented","pair-missing-name":"the node name is missing: fill it in “advanced”","pair-clipboard-denied":"clipboard read not allowed: paste manually into the field","pair-clipboard-empty":"clipboard is empty: copy the pairing link first","pair-stage-validation":"invalid data","pair-stage-conflict":"name already in use","pair-stage-ssh-start":"SSH tunnel start failed","pair-stage-ssh-ready":"peer unreachable over SSH","pair-stage-join":"invite exchange failed","pair-stage-tunnel-final":"negotiated tunnel failed","pair-stage-confirm":"pairing confirmation failed","pair-stage-health":"final federation check failed","pair-stage-internal":"internal error","pair-stage-generic":"connection failed","qr-no-camera":"no camera available on this device: use a photo of the QR","qr-permission":"camera permission denied: allow it in the browser or use a photo of the QR","qr-unsupported":"live scanner not supported here: upload a photo of the QR","qr-upload":"use a photo"},es:{"update-available":"nueva versión {v} disponible","install-version-mismatch":"instalación incompleta: frontend y servidor no coinciden (v{v})",reload:"recargar","grid-empty":"arrastra aquí una sesión desde la barra lateral, o doble clic para vista única","grid-full":"un deck puede mostrar como máximo 9 sesiones",pin:"fijar arriba",reorder:"reordenar","reorder-help":"arrastra el control; flechas arriba/abajo","rename-node":"renombrar nodo","rename-node-prompt":"Nuevo nombre del nodo en NexusCrew","rename-node-invalid":"Nombre no válido: máximo 64 caracteres, sin saltos de línea.","reorder-deck-help":"arrastra el deck; flechas izquierda/derecha",sessions:"sesiones","new-session":"nueva sesión",new:"nueva",fleet:"Flota","fleet-tmux":"flota tmux","other-sessions":"Otras sesiones","view-all":"todas","view-pinned":"fijadas","view-active":"activas","view-off":"apagadas","view-technical":"técnicas","mark-technical":"ocultar como sesión técnica","mark-normal":"mostrar como sesión normal","position-local":"Local",files:"archivos",refresh:"actualizar","filter-placeholder":"filtrar sesiones…","loading-fleet":"cargando flota…","no-sessions":"sin sesiones tmux vivas — la flota arranca en el boot (systemd)","no-match":"ninguna sesión coincide con «{q}»","copy-url":"clic para copiar la URL","ssh-only":"solo túnel SSH/VPN","new-files-outbox":"archivos nuevos en outbox",terminate:"terminar","terminate-confirm":"¿Terminar la sesión «{name}»?","cell-on":"tmux activo","cell-off":"apagada","cell-working":"trabajando","cell-idle":"en espera","cell-degraded":"degradada: unit activa, tmux muerto","power-on":"encender","power-off":"apagar","boot-enable":"activar al iniciar","boot-disable":"desactivar al iniciar","state-on":"encendida","state-off":"apagada",engine:"Motor",model:"Modelo","model-default":"Modelo predeterminado del proveedor","model-remembered":"Último modelo usado con este motor","boot-persist":"iniciar en el boot","remove-boot":"quitar también del boot","power-config-in-settings":"Modifica motor, proveedor, perfil, modelo y permisos en Ajustes → Flota.","no-remote-control":"⚠ motor no nativo: sin RC de la app claude.ai (aquí puedes pilotarla igual)",cancel:"cancelar",name:"nombre","name-invalid":"nombre inválido: a-zA-Z0-9._- máx 64, sin '-' inicial",cwd:"carpeta",browse:"explorar","fs-home":"home","fs-parent":".. arriba",preset:"preset","preset-2x2":"cuadrícula 2×2","preset-columns":"columnas","preset-equalize":"igualar",collapse:"contraer",expand:"expandir",create:"crear","auth-prompt":"Pega el token (impreso por el servidor):","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande",composer:"composer",windows:"{n} ventanas","empty-files":"vacía",upload:"subir","no-sessions-short":"sin sesiones","composer-placeholder":"escribe o dicta…","composer-history-tools":"historial y tamaño de entrada","composer-history":"historial de la celda","composer-history-empty":"ninguna entrada enviada","composer-history-clear":"borrar historial de esta celda","composer-expand":"ampliar entrada","composer-collapse":"reducir entrada","composer-clear-data":"borrar borradores e historial","composer-clear-data-help":"Elimina de este navegador todos los borradores y el historial de entrada de las celdas.","composer-clear-confirm":"¿Borrar todos los borradores y el historial de entrada guardados en este navegador?","composer-clear-done":"Borradores e historial eliminados.","composer-clear-failed":"No se pudieron borrar los datos del composer en este navegador.",attach:"adjuntar","attach-file":"Archivo","attach-camera":"Cámara","attach-gallery":"Galería","attach-uploading":"subiendo…","attach-upload-progress":"adjunto {n}/{total}…","attach-uploaded":"{n} adjuntos subidos",voice:"voz",send:"enviar","composer-send-failed":"conexión no disponible — texto conservado, inténtalo de nuevo",close:"cerrar","lang-label":"idioma",decks:"decks","new-deck":"nuevo deck","deck-name":"nombre del deck","open-deck-window":"abrir en una ventana nueva","detach-deck":"separar en una ventana nueva","deck-current":"este deck (ventana actual)","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","rename-deck":"renombrar deck","delete-deck":"eliminar deck","delete-deck-confirm":"¿Eliminar el deck «{name}»?","send-to-deck":"enviar al deck…","deck-autosave":"guardado automático",saving:"guardando…",saved:"guardado","popup-blocked":"ventana bloqueada: abrir aquí","select-drag":"arrastra para seleccionar","copy-manual":"selecciona y copia manualmente","toggle-sidebar":"mostrar/ocultar la barra lateral",settings:"ajustes","tab-roles":"roles","tab-nodes":"nodos",local:"Local",location:"Ubicación","pairing-link":"enlace de emparejamiento","pairing-required":"nombre, alias SSH y enlace son obligatorios","pairing-connect-help":"Para conectar un nodo necesitas un nombre, un Host SSH funcional y el enlace/QR creado por la otra instalación NexusCrew.","pairing-localhost-hint":"127.0.0.1 en el enlace es correcto: no lo abras aquí. NexusCrew usa la invitación y el puerto mediante el Host SSH.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","invite-node":"invitar un nodo","create-pairing-link":"crear enlace / QR","visibility-network":"toda la red","visibility-relay":"solo relay","visibility-selected":"nodos seleccionados","hydra-simple":"local + nodos, una red","local-ready":"Este dispositivo está listo. Úsalo solo o conéctalo a un nodo.","local-only":"solo local","add-node":"añadir nodo",connect:"conectar","node-connected":"Nodo conectado. La red se sincronizará automáticamente.","tab-system":"sistema","tab-fleet":"flota","tab-diagnostics":"diagnóstico","diagnostics-local":"Este nodo","diagnostics-target":"Nodo a diagnosticar","diagnostics-verbose":"Logs detallados temporales","diagnostics-duration":"Duración detallada","diagnostics-expires":"Log detallado activo hasta las {time}","diagnostics-off":"El log detallado está apagado; los avisos y errores operativos siguen disponibles.","diagnostics-level":"Nivel","diagnostics-all-levels":"todos los niveles","diagnostics-component":"componente","diagnostics-pause":"pausa","diagnostics-autoscroll":"desplazamiento automático","diagnostics-log":"Log de diagnóstico sanitizado","diagnostics-empty":"No hay eventos de diagnóstico.","diagnostics-export":"exportar JSON","diagnostics-export-failed":"La exportación no está disponible en este navegador.","diagnostics-clear":"vaciar","diagnostics-clear-confirm":"¿Vaciar el búfer de diagnóstico de este nodo?","diagnostics-unsupported":"Este par está desconectado o no admite diagnósticos estructurados.","fleet-editor-loading":"Cargando el editor de Fleet…","fleet-editor-load-error":"No se puede cargar el editor de Fleet.","fleet-editor-unavailable":"El editor de Fleet no está disponible en esta ubicación.","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-shell-engine-help":"La shell local se resuelve en el dispositivo al iniciar; no se guarda ninguna ruta ejecutable en las copias.","fleet-shell-command-placeholder":"comando opcional, p. ej. npm test","fleet-shell-command-help":"Ejecución one-shot mediante la shell local con -lc. La celda se detiene cuando termina el comando.","fleet-shell-command-metachar":"Pipes, redirecciones, variables y otros metacaracteres son interpretados por la shell del dispositivo.","fleet-shell-interactive":"Vacío: abre una shell local interactiva y mantiene la celda activa.","fleet-shell-launch-help":"Configura el comando Shell de la celda en Ajustes → Flota.","fleet-credential-title":"Clave API en este dispositivo","fleet-credential-help":"La clave permanece solo en el nodo seleccionado y nunca se muestra, exporta ni comparte con la red.","fleet-credential-set":"poner clave","fleet-credential-change":"cambiar clave","fleet-credential-forget":"olvidar","fleet-credential-saved":"Clave guardada localmente.","fleet-credential-removed":"Clave local eliminada.","fleet-credential-remove-confirm":"¿Eliminar la clave local {key}?","fleet-credential-source-environment":"entorno","fleet-credential-source-local":"almacén local","fleet-credential-source-compatibility":"config compatible","fleet-credential-source-missing":"ausente","fleet-key-section":"KEY","fleet-key-variable":"Variable","fleet-key-value":"Valor para {key}","fleet-key-used-by":"Usada por: {engines}","fleet-key-used-by-none":"Aún no la usa ningún motor configurado en este nodo.","fleet-key-shared-impact":"Sustituir o eliminar {key} afecta a todos los motores listados: {engines}.","fleet-key-enter":"introduce la clave","fleet-key-blank-keeps":"vacío = mantener la fuente actual","fleet-key-reveal":"mostrar","fleet-key-hide":"ocultar","fleet-key-local-help":"El valor permanece write-only en el nodo seleccionado y nunca entra en motores, copias ni federación.","fleet-key-create-missing":"Crear explícitamente el motor sin clave (seguirá como “clave requerida”).","fleet-key-partial-create":"Motor creado; la clave no se guardó. Puedes reintentar sin crear un duplicado.","fleet-key-partial-edit":"Motor actualizado; la clave no se guardó. Los cambios del motor siguen aplicados.","fleet-provider-notice-claude-openrouter":"Claude Code está optimizado para modelos Anthropic; otros proveedores podrían no funcionar correctamente. Fast mode requiere el proveedor Anthropic first-party.","fleet-provider-notice-codex-openrouter":"OpenRouter Responses es beta y stateless; Codex-VL no usa fallback de Chat Completions.","fleet-provider-notice-claude-kimi-code":"Kimi Code usa una configuración Claude aislada con onboarding y fast mode dedicados; la configuración Claude nativa no se modifica.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max-preview es el modelo predeterminado y no se usa fallback OpenAI/PAYG.","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.',"fleet-cwd-needs-repair":"carpeta a reparar","fleet-cwd-repair":"reparar","fleet-cwd-repair-title":"Reparar carpeta de celda {id}","fleet-cwd-repair-help":"La carpeta actual no es portátil en este dispositivo: pertenece a otro dispositivo o no existe bajo el directorio home. Elige una carpeta relativa a home (~) en el dispositivo destino; el backend recalculará la ruta absoluta.","fleet-cwd-repair-no-source-path":"La ruta original no se muestra: es específica del dispositivo de origen.","fleet-cwd-repair-placeholder":"p. ej. Dev","fleet-cwd-repair-preview":"Nueva carpeta: {path}","fleet-cwd-repair-browse":"examinar bajo ~","fleet-cwd-repair-fs-empty":"sin subcarpetas","fleet-cwd-repair-use-current":"usar esta carpeta","fleet-cwd-repair-invalid":'ruta no válida: nada de ruta absoluta, "..", barra invertida ni letra de unidad',"fleet-cwd-repair-confirm":"¿Establecer la carpeta de la celda {id} a {path}? Se recalculará en el dispositivo destino.","fleet-cwd-repair-unportable":"La ruta elegida no es portátil en este dispositivo: debe existir bajo el directorio home.","fleet-cwd-repair-suggestion":"Sugerencia del dispositivo:","fleet-cwd-repair-use-suggestion":"usar {path}","fleet-cwd-repaired":"Carpeta de la celda reparada.","settings-readonly":"READONLY activo: los cambios están bloqueados por el servidor (NEXUSCREW_READONLY=1)","role-client":"client (hub)","role-client-desc":"esta máquina observa otros nodos vía túneles SSH","role-node":"nodo (alcanzable)","published-port":"puerto publicado (opcional)","no-nodes":"sin nodos remotos configurados","node-add":"conectar una instalación NexusCrew","node-connect-help":"El puerto SSH conecta con el servidor SSH. El puerto NexusCrew es el puerto local indicado por `nexuscrew status` en el nodo remoto.","node-name-label":"Nombre del nodo","node-ssh-label":"Host SSH","pair-ssh-local-label":"Host o alias SSH en este dispositivo","node-ssh-local-help":"Puedes sustituir la dirección del enlace por el mismo alias que funciona con ssh en este dispositivo. Los alias, agentes y claves permanecen locales y nunca viajan en el enlace.","node-ssh-port-label":"Puerto SSH","node-ssh-port-help":"Normalmente 22; usa el puerto público del servidor SSH.","node-app-port-label":"Puerto NexusCrew del nodo","node-app-port-help":"El puerto indicado por `nexuscrew status` en el nodo remoto.","node-name-ph":"nombre (a-z 0-9 -)","node-ssh-ph":"ssh (user@host)","node-port-ph":"puerto remoto (opc.)","node-remove-confirm":"¿Eliminar el nodo «{name}»?","node-remove-warning":"Elimina el emparejamiento, las credenciales y el túnel local. No apaga el dispositivo remoto.","peer-inventory-title":"Nodos conectados al hub","peer-group-hubs":"Hubs directos","peer-group-clients":"Clientes conectados","peer-group-routed":"Nodos accesibles a través de la red","peer-routed":"enrutado","peer-routed-stale":"enrutado, no accesible","peer-visibility":"Visibilidad en la red","node-test":"test","tunnel-start":"iniciar túnel","tunnel-stop":"detener túnel","tunnel-restart":"reiniciar túnel","share-node":"Compartir este nodo","share-local-heading":"Compartir este dispositivo","share-local-hub":"Hub para compartir","share-local-through":"Compartir {device} mediante {hub}","share-local-active":"Compartido y accesible para la red conectada al hub.","share-local-pending":"Se solicitó compartir, pero el túnel está caído: este dispositivo aún no es accesible.","share-local-private":"Privado: solo este dispositivo puede usar la conexión al hub.","share-local-private-down":"Privado, pero la conexión al hub está caída. Reconecta para aplicar y verificar el modo privado.","share-local-reconnect":"Reconectar y reconciliar","share-node-off-desc":"Privado: sigue conectado al hub, pero otros clientes no pueden alcanzarlo.","share-node-on-desc":"Compartido: el hub puede anunciarlo y enrutar celdas y decks autorizados.","peer-shared":"Nodo cliente compartido en la red Hydra","peer-private":"Nodo cliente privado: conectado, no publicado en Hydra","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","authorized-keys-hint":"pega esta línea en ~/.ssh/authorized_keys del host remoto:",copy:"copiar",copied:"copiado","token-rotate":"rotar token","token-rotate-explain":"El nuevo token NO se mostrará: recupéralo con `nexuscrew show token`. La sesión actual quedará invalidada.","service-regenerate":"regenerar service","npm-auto-update":"actualizaciones automáticas desde npm","npm-auto-update-help":"Comprueba latest periódicamente e instala solo versiones más recientes. Nunca baja de versión.","npm-update-current":"instalada","npm-update-latest":"npm latest","npm-update-check":"comprobar ahora","npm-update-install":"actualizar ahora","npm-update-restarting":"Actualización iniciada; NexusCrew volverá después de reiniciar el servicio.","npm-update-idle":"actualizado","npm-update-checking":"comprobando","npm-update-available":"actualización disponible","npm-update-installing":"instalando","npm-update-installed":"instalada, reiniciando","npm-update-error":"comprobación fallida","npm-update-unsupported":"disponible solo con instalación npm global","service-installed":"service instalado","service-missing":"service no instalado","service-active":"activo","service-inactive":"no activo",confirm:"confirmar",add:"añadir",enable:"activar","wizard-title":"bienvenido a NexusCrew","wizard-skip":"configura después desde ajustes","wizard-step-roles":"roles de esta instalación","wizard-step-node":"primer nodo remoto (opcional)","wizard-done":"todo listo","wizard-done-desc":"configuración completa — puedes cambiarlo todo desde ajustes",next:"continuar",back:"atrás",skip:"omitir",finish:"terminar","err-node-name":"nombre inválido (a-z, 0-9, -, máx 32)","err-local-name":"nombre local inválido: usa un slug único, no “localhost”","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)","routed-node-aliases":"Alias de nodos enrutados","routed-node-aliases-help":"Visibles solo en este dispositivo; la ruta y el nombre remoto no cambian.","node-local-alias":"Alias en este dispositivo","alias-on-device":"Alias en este dispositivo","reset-alias":"Restablecer nombre remoto","node-slug-hint":"enrutado por slug: {slug}","device-name-label":"Nombre del dispositivo","device-name-hint":"cómo te ven los pares (editable)","local-route-name-label":"Nombre local / ruta","local-route-name-hint":"identificador técnico estable: etiqueta legible + sufijo del nodeId; editable antes de conectar","err-label":"etiqueta no válida (máx 64 caracteres, sin saltos de línea)","fleet-inventory":"Celdas y sesiones","fleet-inventory-help":"todas las posiciones (Local + rutas Hydra)","fleet-manage-location":"Gestionar ubicación","fleet-network-overview":"Vista de red","fleet-manage-help":"crea y configura celdas en la ubicación seleccionada","fleet-overview-help":"estado operativo de todas las ubicaciones, separado del editor","fleet-inventory-empty":"sin celdas ni sesiones","fleet-not-available":"fleet no disponible en esta posición",start:"iniciar",stop:"detener",restart:"reiniciar",delete:"eliminar","copy-manual":"copia fallida — selecciona y pulsa Cmd+C, o copia a mano","copy-empty":"nada seleccionado: arrastra con Shift para seleccionar","save-and-start":"guardar e iniciar",permissions:"Permisos","power-on-hint":"Detén la celda; también puedes quitarla del boot.","launch-engine-help":"Proveedores, credenciales y nuevos motores se crean en Ajustes → Flota. Modelo y permisos son por celda.","launch-unavailable-hint":"La configuración del motor no está disponible en este nodo.","import-as-cell":"Importar como celda","import-help":"Reconcilia una sesión tmux existente en una celda gestionada. Elige un motor ya declarado: no se inventa ninguno.","import-engine-required":"elige un motor (obligatorio)","test-and-connect":"probar y conectar","pairing-v2-hint":"Pega o escanea UN solo enlace: rellena nombre, Host SSH y etiqueta cuando los incluye (v2).","invite-v2-hint":"Crea una invitación completa de un solo uso. Si este dispositivo ya está unido a un hub, se usa automáticamente; si no, solo hace falta su dirección SSH alcanzable.","invite-network-hint":"Crea una invitación para la red a la que ya estás conectado. El nuevo dispositivo entra por el hub y no se conecta directamente a este dispositivo.","invite-network-label":"Red de destino","invite-network-via":"Hub","invite-network-route":"Una sola conexión al hub; nodos, celdas y decks se enrutan internamente.","invite-endpoint-label":"Dirección SSH de este hub vista por los otros dispositivos","invite-endpoint-auto":"Endpoint ya configurado","invite-endpoint-needed":"Introduce usuario@host o un alias SSH compartido. No es 127.0.0.1 ni la URL HTTP de NexusCrew.","invite-ssh-hint":"El destino SSH con el que el OTRO dispositivo alcanza ESTA instalación (usuario@host o alias). Obligatorio: se incluye en el enlace.","invite-next-steps":"copia este enlace, abre NexusCrew en el otro dispositivo y pégalo en Ajustes → Nodos (o escanea el QR): NexusCrew hace el resto","pair-card-title":"conectar con un solo enlace","pair-card-help":"Pega el enlace de emparejamiento generado en el otro dispositivo (o escanea su QR): NexusCrew lo decodifica, prueba la conexión SSH y conecta solo.","pair-paste-ph":"pega aquí el enlace de emparejamiento","pair-paste-btn":"pegar","pair-advanced":"avanzado / editar","pair-progress":"conectando: SSH → invitación → confirmación → verificación…","pair-retry":"reintentar","pair-invalid-link":"esto no es un enlace de emparejamiento válido","pair-invalid-hint":"se necesita el enlace completo (http://…#pair=…) generado por el otro NexusCrew: no lo abras, pégalo aquí","pair-missing-ssh":"el enlace no incluye el destino SSH (formato v1): indica en “avanzado” cómo este dispositivo alcanza al otro por SSH — nunca se inventa","pair-missing-name":"falta el nombre del nodo: complétalo en “avanzado”","pair-clipboard-denied":"lectura del portapapeles no permitida: pega manualmente en el campo","pair-clipboard-empty":"portapapeles vacío: copia primero el enlace","pair-stage-validation":"datos no válidos","pair-stage-conflict":"nombre ya en uso","pair-stage-ssh-start":"fallo al iniciar el túnel SSH","pair-stage-ssh-ready":"peer inaccesible por SSH","pair-stage-join":"intercambio de invitación fallido","pair-stage-tunnel-final":"túnel negociado fallido","pair-stage-confirm":"confirmación de emparejamiento fallida","pair-stage-health":"verificación final de la federación fallida","pair-stage-internal":"error interno","pair-stage-generic":"conexión fallida","qr-no-camera":"no hay cámara disponible en este dispositivo: usa una foto del QR","qr-permission":"permiso de cámara denegado: permítelo en el navegador o usa una foto del QR","qr-unsupported":"escáner en vivo no soportado aquí: sube una foto del QR","qr-upload":"usar una foto"}};function ad(){const e=i_(),t=e?e.getItem(t_):null;return fh.includes(t)?t:Qa}function I0(e){const t=i_();if(t)try{t.setItem(t_,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(od))}function g(e){const t=ad(),i=$a[t]||$a[Qa];return Object.prototype.hasOwnProperty.call(i,e)?i[e]:Object.prototype.hasOwnProperty.call($a[Qa],e)?$a[Qa][e]:e}function B0(e){return typeof window>"u"?()=>{}:(window.addEventListener(od,e),()=>window.removeEventListener(od,e))}const n_=fh;function ji(){return[R.useSyncExternalStore(B0,ad,ad),I0]}function ol({cell:e,token:t,route:i=[],onConfirm:s,onClose:o}){var U,re;ji();const a=!!(e&&e.active),u=Array.isArray(i)?i.join("/"):"",[h,p]=R.useState([]),[f,_]=R.useState(!1);R.useEffect(()=>{let I=!0;return(async()=>{if(t)try{const V=await Rr(t,u?u.split("/"):[]);if(!I)return;if(_(V.provider==="builtin"&&(V.capabilities||[]).includes("edit")),V.provider==="builtin"&&(V.capabilities||[]).includes("definitions")){const $=await lh(t,u?u.split("/"):[]);if(!I)return;const L=new Map((V.engines||[]).map(z=>[z.id,z]));p(($.engines||[]).map(z=>{var oe,ce,he,me,G,J,ge;return{id:z.id,label:z.label||z.id,client:((oe=z.managed)==null?void 0:oe.client)||"",models:[...new Set([...((ce=L.get(z.id))==null?void 0:ce.models)||[],...((he=z.managedInfo)==null?void 0:he.models)||[]])].filter(Boolean),defaultModel:((me=z.managed)==null?void 0:me.model)||((G=z.managedInfo)==null?void 0:G.defaultModel)||"",policyDefault:((J=z.managed)==null?void 0:J.permissionPolicy)||((ge=z.managed)!=null&&ge.client&&z.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{I=!1}},[t,u]);const b=(e==null?void 0:e.engine)||((U=h[0])==null?void 0:U.id)||"",S=I=>(e==null?void 0:e.models)&&e.models[I]||"",w=I=>{const V=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[I];if(V==="standard"||V==="unsafe")return V;const $=h.find(L=>L.id===I);return $?$.policyDefault:"standard"},[y,x]=R.useState(b),[k,C]=R.useState((e==null?void 0:e.model)||""),P=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((re=e==null?void 0:e.permissionPolicies)==null?void 0:re[e==null?void 0:e.engine])||"",[A,M]=R.useState(P),[ee,q]=R.useState((e==null?void 0:e.boot)??!0),[B,Z]=R.useState(!1),[H,te]=R.useState(null);R.useEffect(()=>{h.length&&(x(I=>I||b),C(I=>I||S((e==null?void 0:e.engine)||b)||""),M(I=>I==="standard"||I==="unsafe"?I:w((e==null?void 0:e.engine)||b)))},[h.length]);const K=R.useMemo(()=>h.find(I=>I.id===y)||null,[h,y]),T=!!(K&&["claude","codex","codex-vl"].includes(K.client)),E=(K==null?void 0:K.client)==="shell";function j(I){x(I);const V=h.find($=>$.id===I);C(S(I)||(V==null?void 0:V.defaultModel)||""),M(w(I))}async function D(I){I.preventDefault(),Z(!0),te(null);try{if(a)await s({action:"down",boot:ee});else{const V=A==="standard"||A==="unsafe"?A:(K==null?void 0:K.policyDefault)||"standard";await s({action:"up",...f?{engine:y,model:k||"",...T?{permissionPolicy:V}:(K==null?void 0:K.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:ee})}o()}catch(V){te(String(V&&V.message||V)),Z(!1)}}return c.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:c.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:I=>I.stopPropagation(),onSubmit:D,children:[c.jsxs("div",{className:"nc-sheet-head",children:[c.jsx("b",{children:e==null?void 0:e.cell}),c.jsx("span",{className:"nc-sheet-state",children:g(a?"state-on":"state-off")})]}),a?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:g("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[g("model"),": ",e.model]}),c.jsx("small",{children:g("power-on-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:ee,onChange:I=>q(I.target.checked)}),g("remove-boot")]})]}):c.jsxs(c.Fragment,{children:[f&&h.length>0?c.jsxs("div",{className:"nc-launch-fields",children:[c.jsxs("label",{className:"nc-field",children:[g("engine"),c.jsx("select",{value:y,onChange:I=>j(I.target.value),children:h.map(I=>c.jsx("option",{value:I.id,children:I.label},I.id))})]}),!E&&c.jsxs("label",{className:"nc-field",children:[g("model"),c.jsx("input",{value:k,list:"nc-launch-models",placeholder:g("model-default"),onChange:I=>C(I.target.value)}),c.jsx("datalist",{id:"nc-launch-models",children:((K==null?void 0:K.models)||[]).map(I=>c.jsx("option",{value:I},I))})]}),T?c.jsxs("label",{className:"nc-field",children:[g("permissions"),c.jsxs("select",{value:A,onChange:I=>M(I.target.value),children:[c.jsx("option",{value:"standard",children:g("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:g("fleet-unsafe-permissions")})]})]}):c.jsx("small",{className:"nc-note",children:g("fleet-standard-permissions")}),T&&A==="unsafe"&&c.jsx("small",{className:"nc-err",children:g("fleet-unsafe-warning")}),c.jsx("small",{className:"nc-note",children:g(E?"fleet-shell-launch-help":"launch-engine-help")})]}):c.jsxs("div",{className:"nc-power-config",children:[c.jsx("span",{children:g("engine")}),c.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&c.jsxs("small",{children:[g("model"),": ",e.model]}),c.jsx("small",{children:g("launch-unavailable-hint")})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:ee,onChange:I=>q(I.target.checked)}),g("boot-persist")]})]}),H&&c.jsx("div",{className:"nc-err",children:H}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:B,children:g("cancel")}),c.jsx("button",{type:"submit",className:"nc-btn primary",disabled:B,children:g(a?"power-off":"save-and-start")})]})]})})}const Lm=/^[a-z0-9-]{1,32}$/;function al(e,t){const i=Array.isArray(e)?e:[];return i.length?`${i.map(encodeURIComponent).join("/")}:${t}`:String(t)}function O0(e,t,i){const s={};for(const o of Array.isArray(t)?t:[]){const a=Array.isArray(o==null?void 0:o.route)?o.route:typeof(o==null?void 0:o.name)=="string"?[o.name]:[];if(!a.length)continue;const u=a.join("/"),h=o.status==="up"||o.tunnel&&o.tunnel.status==="up",p=o.status==="passive"||o.tunnel&&o.tunnel.status==="passive";!h&&!p&&(s[u]=e&&e[u]||i)}return s}function Mm(e,t,i){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${i}:${s.tmuxSession||s.cell}`}))}function Tm({nodes:e,topology:t,remote:i,down:s,fleet:o,aliases:a}={}){var f,_,b,S;const u=[],h=new Set,p=new Set;for(const w of Array.isArray(e)?e:[]){if(!w||typeof w.name!="string"||!Lm.test(w.name)||w.direction==="inbound"&&w.shared!==!0)continue;const y=[w.name],x=w.name;h.add(x);const k=((f=w.tunnel)==null?void 0:f.status)||"unknown",C=k==="up",P={name:w.name,label:w.label||w.name,originalLabel:w.label||w.name,alias:null,route:y,direct:!0,instanceId:w.nodeId||null,shared:w.shared===!0,tunnelStatus:k,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:w.health||null,direction:w.direction||"outbound",roles:w.roles||null,rolesKnown:w.rolesKnown===!0};if(w.nodeId&&p.add(w.nodeId),!w.nodeId&&w.paired===!1){u.push({...P,status:"needs-repair",downSince:s&&s[x]||null});continue}if(((_=w.health)==null?void 0:_.auth)==="failed"||k==="degraded"&&((b=w.health)==null?void 0:b.status)==="degraded"){u.push({...P,status:"needs-repair",downSince:s&&s[x]||null});continue}if(k==="passive"||((S=w.health)==null?void 0:S.status)==="passive"){u.push({...P,status:"passive",downSince:null});continue}if(!C){u.push({...P,status:"down",downSince:s&&s[x]||null});continue}const A=i&&(i[x]||i[w.name])||null,M=o&&(o[x]||o[w.name]),ee=!!(A&&!A.error&&Array.isArray(A.sessions)),q=!!(M&&M.available===!0&&Array.isArray(M.cells));if(!ee&&!q){u.push({...P,status:"unreachable"});continue}const B=(ee?A.sessions:[]).filter(te=>te&&typeof te.name=="string"&&te.name).map(te=>({...te,node:x,route:y,key:`${x}:${te.name}`})),Z=Mm(M,y,x),H=new Set(Z.map(te=>te.tmuxSession).filter(Boolean));u.push({...P,status:"up",sessions:B,cells:Z,unmanaged:B.filter(te=>!H.has(te.name)),fleetAvailable:!!(M&&M.available),capabilities:M&&M.capabilities||[],engines:M&&M.engines||[],fleetProvider:M&&M.provider||null,sessionsAvailable:ee,inventoryPartial:!ee})}for(const w of Array.isArray(t)?t:[]){if(!w||!Array.isArray(w.route)||w.route.length<1||w.route.some(H=>!Lm.test(H)))continue;const y=w.route.join("/");if(h.has(y)||w.instanceId&&p.has(w.instanceId))continue;w.instanceId&&p.add(w.instanceId);const x=w.label||w.route.join(" › "),k=w.instanceId&&a&&typeof a[w.instanceId]=="string"?a[w.instanceId]:null,C={name:w.name,label:k||x,originalLabel:x,alias:k,route:[...w.route],direct:!1,instanceId:w.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:w.health||null,lastSeen:w.lastSeen||null};if(w.stale){u.push({...C,status:"offline",downSince:s&&s[y]||w.lastSeen||null});continue}const P=i&&i[y]||null,A=o&&o[y],M=!!(P&&!P.error&&Array.isArray(P.sessions)),ee=!!(A&&A.available===!0&&Array.isArray(A.cells));if(!M&&!ee){u.push({...C,status:"unreachable",downSince:s&&s[y]||null});continue}const q=(M?P.sessions:[]).filter(H=>H&&typeof H.name=="string"&&H.name).map(H=>({...H,node:y,route:w.route,key:`${y}:${H.name}`})),B=Mm(A,w.route,y),Z=new Set(B.map(H=>H.tmuxSession).filter(Boolean));u.push({...C,status:"up",sessions:q,cells:B,unmanaged:q.filter(H=>!Z.has(H.name)),fleetAvailable:!!(A&&A.available),capabilities:A&&A.capabilities||[],engines:A&&A.engines||[],fleetProvider:A&&A.provider||null,lastSeen:w.lastSeen||null,sessionsAvailable:M,inventoryPartial:!M})}return u.sort((w,y)=>w.label.localeCompare(y.label))}const z0=4e3;function ph(e,t=!0,i=0){const[s,o]=R.useState([]),a=R.useRef({});return R.useEffect(()=>{if(!t||!e){o([]);return}let u=!0;async function h(){var C;let f=[],_=[],b={};if(await Promise.all([o0(e).then(P=>{f=Array.isArray(P.nodes)?P.nodes:[]}).catch(()=>{}),l0(e).then(P=>{_=Array.isArray(P.nodes)?P.nodes:[]}).catch(()=>{}),d0(e).then(P=>{b=P&&typeof P.aliasesByInstanceId=="object"?P.aliasesByInstanceId:{}}).catch(()=>{})]),!u)return;const S={},w={},y=new Set(f.map(P=>P.name)),x=[];for(const P of f)((C=P.tunnel)==null?void 0:C.status)==="up"&&(P.nodeId||P.paired!==!1)&&(P.direction!=="inbound"||P.shared===!0)&&x.push([P.name]);for(const P of _)!P.stale&&Array.isArray(P.route)&&!(P.route.length===1&&y.has(P.route[0]))&&x.push(P.route);if(await Promise.all(x.map(async P=>{const A=P.join("/");try{S[A]=await Xv(e,P)}catch{S[A]={error:"unreachable"}}try{w[A]=await Rr(e,P)}catch{w[A]={available:!1}}})),!u)return;const k=Tm({nodes:f,topology:_,remote:S,fleet:w,aliases:b,down:a.current});a.current=O0(a.current,k,Math.floor(Date.now()/1e3)),o(Tm({nodes:f,topology:_,remote:S,fleet:w,aliases:b,down:a.current}))}h();const p=setInterval(h,z0);return()=>{u=!1,clearInterval(p)}},[e,t,i]),s}const Am=52,Im=14;function Gn({position:e,itemKey:t,label:i,onMove:s,onStep:o,canMove:a=()=>!0,scope:u="roster"}){const h=R.useRef(null),p=R.useRef(0),[f,_]=R.useState(!1),b=()=>{var C,P,A,M;const k=h.current;(P=(C=k==null?void 0:k.over)==null?void 0:C.classList)==null||P.remove("nc-roster-over"),(M=(A=k==null?void 0:k.source)==null?void 0:A.classList)==null||M.remove("nc-roster-dragging"),p.current&&cancelAnimationFrame(p.current),p.current=0},S=(k=!1)=>{const C=h.current;if(!C)return;const P=C.target;b(),h.current=null,_(!1);try{C.handle.releasePointerCapture(C.pointerId)}catch{}k&&P&&P!==t&&a(t,P)&&s(t,P)},w=(k,C)=>{var Z,H,te,K,T,E,j,D,U;const P=h.current;if(!P)return;P.x=k,P.y=C;const A=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",M=(H=(Z=document.elementFromPoint(k,C))==null?void 0:Z.closest)==null?void 0:H.call(Z,A),ee=u==="node"?(te=M==null?void 0:M.dataset)==null?void 0:te.nodeOrderKey:(K=M==null?void 0:M.dataset)==null?void 0:K.rosterKey,B=(u==="node"||((T=M==null?void 0:M.dataset)==null?void 0:T.position)===e)&&ee&&ee!==t&&a(t,ee);P.over!==(B?M:null)&&((j=(E=P.over)==null?void 0:E.classList)==null||j.remove("nc-roster-over"),P.over=B?M:null,(U=(D=P.over)==null?void 0:D.classList)==null||U.add("nc-roster-over")),P.target=B?ee:null},y=()=>{const k=h.current;if(!k){p.current=0;return}const C=k.container;if(C){const P=C.getBoundingClientRect(),A=k.y<P.top+Am?-Im:k.y>P.bottom-Am?Im:0;A&&(C.scrollTop+=A,w(k.x,k.y))}p.current=requestAnimationFrame(y)};R.useEffect(()=>{const k=P=>{P.key==="Escape"&&h.current&&(P.preventDefault(),S(!1))},C=()=>S(!1);return window.addEventListener("keydown",k),window.addEventListener("blur",C),()=>{window.removeEventListener("keydown",k),window.removeEventListener("blur",C),b(),h.current=null}},[t,e,u]);const x=k=>{var M;if(k.pointerType==="mouse"&&k.button!==0)return;k.preventDefault(),k.stopPropagation(),k.currentTarget.focus({preventScroll:!0});const C=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",P=k.currentTarget.closest(C),A=k.currentTarget.closest(".nc-side-scroll, .nc-home-scroll");h.current={pointerId:k.pointerId,handle:k.currentTarget,source:P,container:A,target:null,over:null,x:k.clientX,y:k.clientY},(M=P==null?void 0:P.classList)==null||M.add("nc-roster-dragging");try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}_(!0),p.current=requestAnimationFrame(y)};return c.jsx("button",{type:"button",className:`nc-roster-handle${f?" active":""}`,"aria-label":`${g("reorder")} ${i}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:g("reorder-help"),onClick:k=>{k.preventDefault(),k.stopPropagation()},onDragStart:k=>k.preventDefault(),onKeyDown:k=>{k.key!=="ArrowUp"&&k.key!=="ArrowDown"||(k.preventDefault(),k.stopPropagation(),o(k.key==="ArrowUp"?-1:1))},onPointerDown:x,onPointerMove:k=>{!h.current||k.pointerId!==h.current.pointerId||(k.preventDefault(),k.stopPropagation(),w(k.clientX,k.clientY))},onPointerUp:k=>{!h.current||k.pointerId!==h.current.pointerId||(k.preventDefault(),k.stopPropagation(),S(!0))},onPointerCancel:()=>S(!1),onLostPointerCapture:()=>{h.current&&S(!1)},children:"↕"})}const mh="nc_pins";function F0(){try{const e=JSON.parse(localStorage.getItem(mh));return Array.isArray(e)?e:[]}catch{return[]}}function $0(e,t){const i=e.includes(t)?e.filter(s=>s!==t):[...e,t];try{localStorage.setItem(mh,JSON.stringify(i))}catch{}return i}function H0(e,t,i){if(!e.includes(t)||!e.includes(i)||t===i)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(i);s.splice(o,1);const u=s.indexOf(i);s.splice(o<a?u+1:u,0,t);try{localStorage.setItem(mh,JSON.stringify(s))}catch{}return s}function W0(e,t,i){const s=e.indexOf(t);return[s===-1?1e9:s,-(i||0)]}function U0(e,t){return e[0]-t[0]||e[1]-t[1]}function r_(){const[e,t]=R.useState(F0),[i,s]=R.useState(M0),[o,a]=R.useState(j0),u=S=>t(w=>$0(w,S)),h=S=>jm(i,S),p=(S,w)=>s(y=>{const x={...y,[S]:{...jm(y,S),...w}};return T0(x)}),f=(S,w)=>e.includes(S)===e.includes(w);function _(S,w,y,x){const k=e.includes(w),C=e.includes(y);if(k===C){if(k){t(P=>H0(P,w,y));return}a(P=>{var ee;const A=((ee=x.find(q=>q.key===w))==null?void 0:ee.technical)===!0,M=xr(x,e,A?"technical":"all",Jn(P,S)).map(q=>q.key);return D0(L0(P,S,w,y,M))})}}function b(S,w,y,x){var ee;const k=((ee=x.find(q=>q.key===w))==null?void 0:ee.technical)===!0,C=e.includes(w),P=xr(x,e,k?"technical":"all",Jn(o,S)).map(q=>q.key).filter(q=>e.includes(q)===C),A=P.indexOf(w),M=P[A+y];A>=0&&M&&_(S,w,M,x)}return{pins:e,views:i,orders:o,togglePin:u,viewFor:h,updateView:p,canMoveRoster:f,moveRoster:_,stepRoster:b}}const s_="nc_node_order_v1",K0=/^[a-f0-9]{16,64}$/;function Sr(e){if(K0.test(String((e==null?void 0:e.instanceId)||"")))return`id:${e.instanceId}`;const t=Array.isArray(e==null?void 0:e.route)?e.route.filter(i=>typeof i=="string"&&i):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function Bm(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(s_));return Array.isArray(t)?[...new Set(t.filter(i=>typeof i=="string"&&i&&i.length<=192))].slice(0,128):[]}catch{return[]}}function q0(e,t=globalThis.localStorage){try{t.setItem(s_,JSON.stringify(e))}catch{}return e}function Om(e=[],t=[]){const i=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=i.has(Sr(s.group))?i.get(Sr(s.group)):Number.MAX_SAFE_INTEGER,u=i.has(Sr(o.group))?i.get(Sr(o.group)):Number.MAX_SAFE_INTEGER;return a-u||s.index-o.index}).map(({group:s})=>s)}function V0(e,t,i,s=[]){if(!t||!i||t===i)return e;const o=s.map(Sr).filter(Boolean);if(!o.includes(t)||!o.includes(i))return e;const a=[...e.filter(f=>o.includes(f)),...o.filter(f=>!e.includes(f))],u=a.indexOf(t),h=a.indexOf(i);a.splice(u,1);const p=a.indexOf(i);return a.splice(u<h?p+1:p,0,t),a}const ld="nexuscrew-node-preferences";function Y0(){try{window.dispatchEvent(new Event(ld))}catch{}}function o_(){const[e,t]=R.useState(Bm);R.useEffect(()=>{const a=()=>t(Bm());return window.addEventListener("storage",a),window.addEventListener(ld,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(ld,a)}},[]);const i=a=>Om(a,e),s=(a,u,h)=>t(p=>{const f=V0(p,a,u,h);return q0(f),Y0(),f});return{order:e,groupsFor:i,moveNode:s,stepNode:(a,u,h)=>{const p=Om(h,e).map(Sr),f=p.indexOf(a),_=p[f+u];f>=0&&_&&s(a,_,h)},nodeKey:Sr}}function cs(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const i=t-e;return i<0||i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function os(e){return e.status==="passive"?g("node-passive"):e.status==="down"?e.downSince?g("tunnel-down-since").replace("{t}",cs(e.downSince)):g("tunnel-down"):e.status==="unreachable"?g("node-unreachable"):e.status==="offline"?e.lastSeen?g("node-offline-seen").replace("{t}",cs(e.lastSeen)):g("node-offline"):e.status==="needs-repair"?g("node-needs-repair"):""}function a_(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function ll(e){return e&&(e.detail||e.status)||""}function cl(e,t,i=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(i.getItem(Wv(t))||0);return e.outbox.latest>s}function l_(e,t={}){const i=e||{};if(!i.tmux){const s=`${i.engine||""}${i.key?`·${i.key}`:""}`,o=[s,i.model&&i.model!==s?i.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||g("cell-off")).trim()}}if(t.working===!0){const s=g("cell-working"),o=String(t.status||"").trim();return{working:!0,subtitle:!o||/^working(?:\.{3}|…)?$/i.test(o)?s:`${s} · ${o}`}}return t.working===!1?{working:!1,subtitle:g("cell-idle")}:{working:!1,subtitle:String(t.preview||i.preview||g("cell-on")).trim()}}function c_(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function u_(e,t,i,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=i.get(o.tmuxSession)||{},u=al([],o.tmuxSession),h=l_(o,a);return{type:"cell",value:o,key:u,label:o.cell,live:!!o.tmux,fresh:cl(a,u,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:c_(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=al([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:cl(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function cd(e,t=globalThis.localStorage){const i=e||{},s=Array.isArray(i.route)?i.route:[],o=new Map((i.sessions||[]).map(u=>[u.name,u])),a=[...(i.cells||[]).map(u=>{const h=o.get(u.tmuxSession)||{},p=al(s,u.tmuxSession||u.cell),f=l_(u,h);return{type:"cell",value:u,key:p,label:u.cell,live:!!u.tmux,fresh:cl(h,p,t),activity:h.activity||u.activity||0,working:f.working,subtitle:f.subtitle,searchText:c_(u,h)}}),...(i.unmanaged||[]).map(u=>{const h=al(s,u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:cl(u,h,t),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})];return{route:s,rawItems:a}}const gh=9,ul=.2,X0=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,us=/^[a-f0-9]{16,64}$/,ud=e=>X0.test(e)&&new Set(e.split("/")).size===e.split("/").length;function tr(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const i=e.slice(0,t),s=e.slice(t+1);return!ud(i)||!s?null:{session:s,node:i}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&us.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"&&ud(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function Ri(e){const t=tr(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const d_=9,h_=24,Co=11,G0=e=>{const t=Number(e);return t>=d_&&t<=h_?t:Co};function as(){return{columns:[]}}function ln(e){return e.columns.flatMap(t=>t.tiles.map(i=>Ri(i)))}function Q0(e){const t=[],i=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<i;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(Ri(o.tiles[s]));return t}const ps=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))});function vh(e,t,i,s){const o=tr(t);if(!o||ln(e).includes(Ri(o))||ln(e).length>=gh)return e;const a=ps(e),u={session:o.session,height:1,fontSize:Co,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),i==="end")return a.columns.push({width:1,tiles:[u]}),a;if(i&&typeof i.col=="number"&&typeof i.row=="number"&&a.columns[i.col])return a.columns[i.col].tiles.splice(i.row,0,u),a;if(i&&typeof i.col=="number"){const h=Math.max(0,Math.min(a.columns.length,i.col));return a.columns.splice(h,0,{width:1,tiles:[u]}),a}return a.columns.push({width:1,tiles:[u]}),a}function f_(e,t){const i=Ri(t);if(!i||ln(e).includes(i)||ln(e).length>=gh)return e;const s=ln(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let _=0;for(let b=1;b<e.columns.length;b+=1)e.columns[b].tiles.length<e.columns[_].tiles.length&&(_=b);return vh(e,t,{col:_,row:e.columns[_].tiles.length})}const a=[...Q0(e),i],u=new Map(e.columns.flatMap(_=>_.tiles.map(b=>[Ri(b),b]))),h=tr(t),p=e.columns.length?e.columns.reduce((_,b)=>_+(Number(b.width)||1),0)/e.columns.length:1,f=Array.from({length:o},(_,b)=>{var S;return{width:((S=e.columns[b])==null?void 0:S.width)||p,tiles:[]}});return a.forEach((_,b)=>{const S=tr(_);if(!S)return;const w=u.get(_)||(_===i?h:{})||{},y={session:S.session,height:w.height||1,fontSize:w.fontSize||Co};S.node&&(y.node=S.node),w.ownerId&&(y.ownerId=w.ownerId),w.unavailable===!0&&(y.unavailable=!0),f[b%o].tiles.push(y)}),{columns:f.filter(_=>_.tiles.length)}}function dl(e,t){const i=Ri(t),s=ps(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>Ri(a)!==i);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function J0(e,t,i){const s=Ri(t);if(!ln(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>Ri(a)===s);return vh(dl(e,s),s,i,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function Z0(e,t){if(!(t instanceof Map)||t.size===0)return e;let i=!1;const s=ps(e);for(const o of s.columns)for(const a of o.tiles){const u=t.get(Ri(a));if(!u)continue;const h=tr(u);h&&(a.session=h.session,h.node?a.node=h.node:delete a.node,h.ownerId&&(a.ownerId=h.ownerId),i=!0)}return i?Cr(s):e}function eb(e,t,i){const s=ps(e);return s.columns[t]&&(s.columns[t].width=Math.max(ul,Number(i)||1)),s}function tb(e,t,i,s){const o=ps(e),a=o.columns[t]&&o.columns[t].tiles[i];return a&&(a.height=Math.max(ul,Number(s)||1)),o}function ib(e,t,i,s){if(!(e.columns[t]&&e.columns[t].tiles[i]))return e;const a=ps(e),u=a.columns[t].tiles[i],h=Number(u.fontSize)||Co;return u.fontSize=Math.max(d_,Math.min(h_,h+(Number(s)||0))),a}function nb(e,t,i,s){const o=e.columns[t];if(!o||!o.tiles[i])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:i};case"bottom":return{col:t,row:i+1};default:return null}}function zm(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 as();const t=e.columns.map(s=>({width:Math.max(ul,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"&&ud(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&us.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(ul,Number(o.height)||1),fontSize:G0(o.fontSize)};return o.node!=null&&(a.node=o.node),o.ownerId!=null&&(a.ownerId=o.ownerId),o.unavailable===!0&&(a.unavailable=!0),a})})).filter(s=>s.tiles.length>0),i=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!i.has(Ri(o))&&i.add(Ri(o))&&i.size<=gh);return{columns:t.filter(s=>s.tiles.length>0)}}const p_=/^[a-z0-9-]{1,32}$/,rb=/^[A-Za-z0-9._-]{1,32}$/,sb=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,ob=320;function dd(e){return typeof e=="string"&&p_.test(e)}const ab=64;function ds(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=ab&&!/[\x00-\x1f\x7f]/.test(t)}function Zn(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function m_(e){if(typeof e!="string"||!e||e.length>ob||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:rb.test(e.slice(0,t))&&sb.test(e.slice(t+1))}function Fm(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const i=Number(t);return Number.isInteger(i)&&i>=1&&i<=65535?i:void 0}function $m({name:e,ssh:t,sshPort:i,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!dd(o))return{ok:!1,error:"err-node-name"};if(!m_(a))return{ok:!1,error:"err-ssh"};const u=Fm(i);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const h=Fm(s);if(h===void 0)return{ok:!1,error:"err-node-port"};const p={name:o,ssh:a};return u!==null&&(p.sshPort=u),h!==null&&(p.remotePort=h),{ok:!0,value:p}}function lb(e,t){if(!e||!t||t<e)return null;const i=Math.floor((t-e)/1e3);return i<60?"ora":i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}g`}function Hm(e,t){const i=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:i,...s?{passive:!0}:{},label:i?"tunnel-up":s?"node-passive":"tunnel-down",since:i?lb(e.since,t):null}}const cb=new Set(["v","instanceId","port","label","invite"]),ub=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function db(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),i=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(i):Buffer.from(i,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function hb(e){let t="";try{const u=new URL(String(e));t=new URLSearchParams(u.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!t)return{ok:!1};let i;try{i=JSON.parse(db(t))}catch{return{ok:!1}}if(!i||typeof i!="object"||Array.isArray(i))return{ok:!1};const s=i.v===1?cb:i.v===2?ub:null;if(!s)return{ok:!1};for(const u of Object.keys(i))if(!s.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(i.instanceId)))return{ok:!1};const o=Number(i.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof i.label!="string")return{ok:!1};if(typeof i.invite!="string"||!i.invite)return{ok:!1};const a={ok:!0,version:i.v,label:i.label,invite:i.invite,instanceId:i.instanceId,port:o};if(i.v===2){if(i.name!==void 0){if(typeof i.name!="string"||!p_.test(i.name))return{ok:!1};a.name=i.name}if(i.ssh!==void 0){if(!m_(i.ssh))return{ok:!1};a.ssh=String(i.ssh).trim()}if(i.sshPort!==void 0){const u=Number(i.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};a.sshPort=u}}return a}function fb(e,t,i=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,u)=>{u==null||u===""||i.has(a)||(s[a]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Zn(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const es=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function pb({onPick:e,token:t,onSettings:i}){const[s,o]=ji(),a=ph(t),[u,h]=R.useState(null),[p,f]=R.useState(null),[_,b]=R.useState(""),[S,w]=R.useState(""),[y,x]=R.useState({bind:"127.0.0.1",port:""}),[k,C]=R.useState(""),[P,A]=R.useState([]),[M,ee]=R.useState([]),[q,B]=R.useState({}),[Z,H]=R.useState(new Set),[te,K]=R.useState(null),[T,E]=R.useState(null),{pins:j,orders:D,togglePin:U,viewFor:re,updateView:I,canMoveRoster:V,moveRoster:$,stepRoster:L}=r_(),{groupsFor:z,moveNode:oe,stepNode:ce,nodeKey:he}=o_(),me=z(a);R.useEffect(()=>{const F=new Map;for(const W of P)F.set(es(W.cell),!!W.boot);for(const W of a){const ue=W.route||[W.name];for(const ve of W.cells||[])F.set(es(ve.cell,ue),!!ve.boot)}B(W=>{let ue=!1;const ve={...W};for(const[Ce,_e]of Object.entries(W))F.has(Ce)&&F.get(Ce)===_e&&(delete ve[Ce],ue=!0);return ue?ve:W})},[P,a]);async function G(){try{const W=await(await Vt("/api/sessions",t)).json();W.error?(f(W.error),h([])):(f(null),h(W.sessions||[]))}catch(F){f(String(F)),h([])}try{const F=await Rr(t);A(F.available?F.cells||[]:[]),ee(F.available?F.capabilities||[]:[])}catch{A([]),ee([])}}R.useEffect(()=>{G(),Vt("/api/config",t).then(W=>W.json()).then(W=>{w(W.version||""),x({bind:W.bind||"127.0.0.1",port:W.port||""}),C(us.test(String(W.instanceId||""))?W.instanceId:"")}).catch(()=>{});const F=setInterval(G,4e3);return()=>clearInterval(F)},[]);async function J(){if(!y.port)return;const F=`http://${y.bind}:${y.port}/#token=${t}`;try{await navigator.clipboard.writeText(F)}catch{}}function ge(F,W,ue){const ve=es(F,W);B(Ce=>({...Ce,[ve]:!!ue}))}function Me(F,W=[]){const ue=es(F.cell,W);return Object.prototype.hasOwnProperty.call(q,ue)?q[ue]:!!F.boot}async function Ze(F,W,ue=[]){F.stopPropagation();const ve=es(W.cell,ue),Ce=!Me(W,ue);ge(W.cell,ue,Ce),H(_e=>new Set(_e).add(ve));try{await Uv(t,{cell:W.cell,enabled:Ce},ue),ue.length||A(_e=>_e.map(Re=>Re.cell===W.cell?{...Re,boot:Ce}:Re))}catch(_e){B(Re=>{const Qe={...Re};return delete Qe[ve],Qe}),f(String((_e==null?void 0:_e.message)||_e))}finally{H(_e=>{const Re=new Set(_e);return Re.delete(ve),Re})}}async function Be(F){if(!te)return;const{cell:W}=te,ue=Array.isArray(te.route)?te.route:[];F.action==="up"?(await ah(t,{cell:W,boot:!!F.boot,...F.engine?{engine:F.engine}:{},...F.model!==void 0?{model:F.model}:{},...F.permissionPolicy?{permissionPolicy:F.permissionPolicy}:{}},ue),ge(W,ue,!!F.boot)):(await sl(t,{cell:W,boot:!!F.boot},ue),F.boot&&ge(W,ue,!1)),G()}async function Fe(F,W=[]){try{await ch(t,F,W)}catch{return}G()}async function ct(F,W,ue=[]){try{await Vv(t,F,W,ue)}catch{return}G()}async function Ve(F){if(!(!(F!=null&&F.direct)||T)){E(F.name);try{await hh(t,F.name,F.tunnelStatus==="up"?"down":"up")}catch{}E(null)}}async function gt(F){if(!(F!=null&&F.direct))return;const W=window.prompt(g("rename-node-prompt"),F.label||F.name);if(W===null)return;const ue=String(W).trim();if(!ds(ue)){window.alert(g("rename-node-invalid"));return}try{await Qv(t,F.name,ue)}catch(ve){window.alert(String((ve==null?void 0:ve.message)||ve))}}const ut=R.useMemo(()=>new Map((u||[]).map(F=>[F.name,F])),[u]),lt=R.useMemo(()=>new Set(P.map(F=>F.tmuxSession)),[P]),nt=R.useMemo(()=>(u||[]).filter(F=>!lt.has(F.name)),[u,lt]),dt=R.useMemo(()=>u_(P,nt,ut),[P,nt,ut]),rt=re("local"),ot=R.useMemo(()=>xr(dt,j,rt.filter,Jn(D,"local")).filter(F=>Dm(F,_)),[dt,j,rt.filter,_,D]),ae=me.reduce((F,W)=>F+(W.cells||[]).length+(W.unmanaged||[]).filter(ue=>!ue.technical).length,0),xe=xr(dt,j,"all",Jn(D,"local")).length+ae,de=dt.filter(F=>F.live).length+me.reduce((F,W)=>F+cd(W).rawItems.filter(ue=>ue.live).length,0),Ne=(u||[]).filter(F=>F.attached).length+me.reduce((F,W)=>F+(W.sessions||[]).filter(ue=>ue.attached).length,0),Ee=Math.min(Ne,de),X=y.port?`${y.bind}:${y.port}`:y.bind;function ie(F,W=null,ue=dt){var Di,Nt;const ve=Array.isArray(W==null?void 0:W.route)?W.route:[],Ce=ve.join("/"),_e=Ce||"local",Re=ve.length?W==null?void 0:W.instanceId:k,Qe=(Ke,ei)=>e({session:Ke,...Ce?{node:Ce}:{},...us.test(String(Re||""))?{ownerId:Re}:{},...typeof ei=="string"&&ei?{cellName:ei}:{}}),zt=V;if(F.type==="cell"){const Ke=F.value,ei=ve.length?((W==null?void 0:W.sessions)||[]).find(Si=>Si.name===Ke.tmuxSession):ut.get(Ke.tmuxSession),fe=Ke.degraded?g("cell-degraded"):F.working?F.subtitle:Ke.tmux?g("cell-idle"):g("cell-off"),Pe=ve.length===0||((W==null?void 0:W.capabilities)||[]).includes(Ke.active?"down":"up"),qe=ve.length===0?M.includes("boot"):((W==null?void 0:W.capabilities)||[]).includes("boot"),xt=Me(Ke,ve),oi=es(Ke.cell,ve),_s=`${g(xt?"boot-disable":"boot-enable")} ${Ke.cell}`;return c.jsxs("div",{className:"nc-mcard","data-roster-key":F.key,"data-position":_e,children:[c.jsx(Gn,{position:_e,itemKey:F.key,label:Ke.cell,canMove:zt,onMove:(Si,ys)=>$(_e,Si,ys,ue),onStep:Si=>L(_e,F.key,Si,ue)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ke.tmux&&Qe(Ke.tmuxSession,Ke.cell),title:fe,"aria-label":`${Ke.cell}, ${fe}`,children:[c.jsx("span",{className:`dot ${Ke.degraded?"warn":Ke.tmux?`on${F.working?" working":""}`:""}`}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:Ke.cell}),c.jsx("small",{title:F.subtitle,children:F.subtitle})]})]}),F.activity?c.jsx("span",{className:"nc-rel",children:cs(F.activity)}):null,F.fresh&&((Di=ei==null?void 0:ei.outbox)==null?void 0:Di.count)>0&&c.jsx("span",{className:"nc-badge",title:g("new-files-outbox"),children:ei.outbox.count}),c.jsx("button",{className:`nc-act pin${j.includes(F.key)?" on":""}`,"aria-label":`${g("pin")} ${Ke.cell}`,title:g("pin"),onClick:()=>U(F.key),children:j.includes(F.key)?"★":"☆"}),qe&&c.jsx("button",{className:`nc-act boot${xt?" on":""}`,disabled:Z.has(oi),onClick:Si=>Ze(Si,Ke,ve),title:_s,"aria-label":_s,children:c.jsx(et,{name:"boot",size:16})}),Pe&&c.jsx("button",{className:`nc-act power${Ke.tmux?" on":""}${Ke.degraded?" warn":""}`,onClick:()=>K(ve.length?{...Ke,boot:xt,route:ve,availableEngines:(W==null?void 0:W.engines)||[]}:{...Ke,boot:xt}),title:Ke.active?g("power-off"):g("power-on"),"aria-label":`${Ke.active?g("power-off"):g("power-on")} ${Ke.cell}`,children:c.jsx(et,{name:"power",size:16})})]},F.key)}const ze=F.value;return c.jsxs("div",{className:"nc-mcard","data-roster-key":F.key,"data-position":_e,children:[c.jsx(Gn,{position:_e,itemKey:F.key,label:ze.name,canMove:zt,onMove:(Ke,ei)=>$(_e,Ke,ei,ue),onStep:Ke=>L(_e,F.key,Ke,ue)}),c.jsxs("button",{className:"nc-mcard-main",onClick:()=>Qe(ze.name),children:[c.jsx("span",{className:ze.attached?"dot on":"dot"}),c.jsxs("span",{className:"nc-mcard-text",children:[c.jsx("b",{children:ze.name}),c.jsx("small",{children:ze.preview?ze.preview:ze.cmd?ze.cmd:g("windows").replace("{n}",String(ze.windows||0))})]})]}),F.activity?c.jsx("span",{className:"nc-rel",children:cs(F.activity)}):null,F.fresh&&((Nt=ze.outbox)==null?void 0:Nt.count)>0&&c.jsx("span",{className:"nc-badge",title:g("new-files-outbox"),children:ze.outbox.count}),c.jsx("button",{className:`nc-act pin${j.includes(F.key)?" on":""}`,"aria-label":`${g("pin")} ${ze.name}`,title:g("pin"),onClick:()=>U(F.key),children:j.includes(F.key)?"★":"☆"}),c.jsx("button",{className:`nc-act technical${ze.technical?" on":""}`,title:ze.technical?g("mark-normal"):g("mark-technical"),"aria-label":`${ze.technical?g("mark-normal"):g("mark-technical")} ${ze.name}`,onClick:()=>ct(ze.name,!ze.technical,ve),children:"T"}),c.jsx("button",{className:"nc-menu",title:g("terminate"),"aria-label":`${g("terminate")} ${ze.name}`,onClick:()=>{window.confirm(g("terminate-confirm").replace("{name}",ze.name))&&Fe(ze.name,ve)},children:"⋯"})]},F.key)}return c.jsxs("div",{className:"nc-home",children:[c.jsxs("header",{className:"nc-home-head",children:[c.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",c.jsx("span",{className:"nc-cursor"})]}),c.jsxs("div",{className:"nc-home-sub",children:[g("fleet-tmux")," · ",de," ",g("sessions"),Ee>0&&` · ${Ee} attached`]}),c.jsxs("span",{className:"nc-head-actions",children:[c.jsx("button",{className:"nc-refresh",onClick:()=>i("nodes",!1),title:g("settings"),children:c.jsx(et,{name:"gear",size:18})}),c.jsx("button",{className:"nc-refresh",onClick:G,title:g("refresh"),children:c.jsx(et,{name:"refresh",size:18})})]})]}),c.jsxs("main",{className:"nc-home-scroll",children:[xe>8&&c.jsx("input",{className:"nc-filter",type:"search",placeholder:g("filter-placeholder"),"aria-label":g("filter-placeholder"),value:_,onChange:F=>b(F.target.value)}),p&&c.jsx("div",{className:"nc-err",children:p}),c.jsxs("section",{className:"nc-group","data-position":"local",children:[c.jsx(Wm,{label:g("position-local"),count:ot.length,state:rt,dotClass:"on",onToggle:()=>I("local",{open:!rt.open}),onFilter:F=>I("local",{filter:F})}),rt.open&&ot.map(F=>ie(F,null,dt)),rt.open&&u===null&&c.jsx("div",{className:"nc-empty",children:g("loading-fleet")}),rt.open&&u!==null&&ot.length===0&&!p&&c.jsx("div",{className:"nc-empty",children:_?g("no-match").replace("{q}",_):g("no-sessions-short")})]}),me.map(F=>{const ue=a_(F.health,{passive:"warn"})||(F.status==="up"?"on":F.status==="passive"?"":"warn"),ve=F.health?ll(F.health):F.status==="up"?"":os(F),_e=(F.route||[F.name]).join("/"),Re=re(_e),{rawItems:Qe}=cd(F),zt=xr(Qe,j,Re.filter,Jn(D,_e)).filter(Nt=>Dm(Nt,_)),ze=F.direct&&F.health&&F.health.managed!==!1?c.jsx("button",{type:"button",className:`nc-act power${F.tunnelStatus==="up"?" on":""}`,disabled:T===F.name,title:F.tunnelStatus==="up"?g("power-off"):g("power-on"),"aria-label":`${F.tunnelStatus==="up"?g("power-off"):g("power-on")} ${F.label||F.name}`,onClick:()=>Ve(F),children:c.jsx(et,{name:"power",size:15})}):null,Di=c.jsxs("span",{className:"nc-node-actions",children:[c.jsx(Gn,{scope:"node",position:"nodes",itemKey:he(F),label:F.label||F.name,onMove:(Nt,Ke)=>oe(Nt,Ke,a),onStep:Nt=>ce(he(F),Nt,a)}),F.direct&&c.jsx("button",{type:"button",className:"nc-node-rename",title:g("rename-node"),"aria-label":`${g("rename-node")} ${F.label||F.name}`,onClick:()=>gt(F),children:"✎"}),ze]});return c.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":_e,"data-node-order-key":he(F),children:[c.jsx(Wm,{label:F.label||F.name,count:zt.length,state:Re,dotClass:ue,dotTitle:ve,detail:F.status==="up"?"":F.health&&ll(F.health)||os(F),onToggle:()=>I(_e,{open:!Re.open}),onFilter:Nt=>I(_e,{filter:Nt}),onRename:F.direct?()=>gt(F):null,action:Di}),F.status==="up"&&Re.open&&zt.map(Nt=>ie(Nt,F,Qe)),F.status==="up"&&Re.open&&zt.length===0&&c.jsx("div",{className:"nc-empty",children:_?g("no-match").replace("{q}",_):g("no-sessions-short")})]},`nodo-${_e}`)}),c.jsxs("footer",{className:"nc-home-foot",onClick:J,title:g("copy-url"),children:[c.jsxs("span",{className:"nc-home-meta",children:[S&&c.jsxs("span",{className:"nc-home-version",children:["v",S]}),c.jsxs("span",{className:"nc-home-endpoint",children:[X," · ",g("ssh-only")]})]}),c.jsx("span",{className:"nc-lang",onClick:F=>F.stopPropagation(),children:n_.map((F,W)=>c.jsxs("span",{children:[W>0&&" · ",c.jsx("button",{className:`nc-lang-btn${s===F?" on":""}`,onClick:()=>o(F),title:F,children:F.toUpperCase()})]},F))})]})]}),c.jsx("button",{className:"nc-fab",onClick:()=>i("fleet",!0),title:g("fleet-new-cell"),"aria-label":g("fleet-new-cell"),children:"+"}),te&&c.jsx(ol,{cell:te,token:t,route:Array.isArray(te.route)?te.route:[],onConfirm:Be,onClose:()=>K(null)})]})}function Wm({label:e,count:t,state:i,dotClass:s="",dotTitle:o="",detail:a="",onToggle:u,onFilter:h,onRename:p=null,action:f=null}){return c.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:p?_=>{_.preventDefault(),p()}:void 0,children:[c.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":i.open,"aria-label":`${e} · ${g("node-sessions").replace("{n}",String(t))}`,children:[c.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:i.open?"⌄":"›"}),c.jsx("span",{className:`dot ${s}`,title:o}),c.jsxs("span",{className:"nc-mobile-position-copy",children:[c.jsx("b",{children:e}),c.jsx("small",{children:a||g("node-sessions").replace("{n}",String(t))})]})]}),c.jsxs("select",{className:"nc-mobile-position-filter",value:i.filter,"aria-label":`${e} · ${g("filter-placeholder")}`,title:g(`view-${i.filter}`),onChange:_=>h(_.target.value),children:[c.jsx("option",{value:"all",children:g("view-all")}),c.jsx("option",{value:"pinned",children:g("view-pinned")}),c.jsx("option",{value:"active",children:g("view-active")}),c.jsx("option",{value:"off",children:g("view-off")}),c.jsx("option",{value:"technical",children:g("view-technical")})]}),f]})}/**
|
|
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 g_=Object.defineProperty,mb=Object.getOwnPropertyDescriptor,gb=(e,t)=>{for(var i in t)g_(e,i,{get:t[i],enumerable:!0})},Et=(e,t,i,s)=>{for(var o=s>1?void 0:s?mb(t,i):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(o=(s?u(t,i,o):u(o))||o);return s&&o&&g_(t,i,o),o},je=(e,t)=>(i,s)=>t(i,s,e),Um="Terminal input",hd={get:()=>Um,set:e=>Um=e},Km="Too much output to announce, navigate to rows manually to read",fd={get:()=>Km,set:e=>Km=e};function vb(e){return e.replace(/\r?\n/g,"\r")}function _b(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function yb(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function wb(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");v_(o,t,i,s)}}function v_(e,t,i,s){e=vb(e),e=_b(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function __(e,t,i){let s=i.getBoundingClientRect(),o=e.clientX-s.left-10,a=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${a}px`,t.style.zIndex="1000",t.focus()}function qm(e,t,i,s,o){__(e,t,i),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Yn(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function bl(e,t=0,i=e.length){let s="";for(let o=t;o<i;++o){let a=e[o];a>65535?(a-=65536,s+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):s+=String.fromCharCode(a)}return s}var Sb=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o=0;if(this._interim){let a=e.charCodeAt(o++);56320<=a&&a<=57343?t[s++]=(this._interim-55296)*1024+a-56320+65536:(t[s++]=this._interim,t[s++]=a),this._interim=0}for(let a=o;a<i;++a){let u=e.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=i)return this._interim=u,s;let h=e.charCodeAt(a);56320<=h&&h<=57343?t[s++]=(u-55296)*1024+h-56320+65536:(t[s++]=u,t[s++]=h);continue}u!==65279&&(t[s++]=u)}return s}},bb=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,o,a,u,h,p=0,f=0;if(this.interim[0]){let S=!1,w=this.interim[0];w&=(w&224)===192?31:(w&240)===224?15:7;let y=0,x;for(;(x=this.interim[++y]&63)&&y<4;)w<<=6,w|=x;let k=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,C=k-y;for(;f<C;){if(f>=i)return 0;if(x=e[f++],(x&192)!==128){f--,S=!0;break}else this.interim[y++]=x,w<<=6,w|=x&63}S||(k===2?w<128?f--:t[s++]=w:k===3?w<2048||w>=55296&&w<=57343||w===65279||(t[s++]=w):w<65536||w>1114111||(t[s++]=w)),this.interim.fill(0)}let _=i-4,b=f;for(;b<i;){for(;b<_&&!((o=e[b])&128)&&!((a=e[b+1])&128)&&!((u=e[b+2])&128)&&!((h=e[b+3])&128);)t[s++]=o,t[s++]=a,t[s++]=u,t[s++]=h,b+=4;if(o=e[b++],o<128)t[s++]=o;else if((o&224)===192){if(b>=i)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(p=(o&31)<<6|a&63,p<128){b--;continue}t[s++]=p}else if((o&240)===224){if(b>=i)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(b>=i)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[b++],(u&192)!==128){b--;continue}if(p=(o&15)<<12|(a&63)<<6|u&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((o&248)===240){if(b>=i)return this.interim[0]=o,s;if(a=e[b++],(a&192)!==128){b--;continue}if(b>=i)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[b++],(u&192)!==128){b--;continue}if(b>=i)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=u,s;if(h=e[b++],(h&192)!==128){b--;continue}if(p=(o&7)<<18|(a&63)<<12|(u&63)<<6|h&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},y_="",Qn=" ",ko=class w_{constructor(){this.fg=0,this.bg=0,this.extended=new hl}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 w_;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}},hl=class S_{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new S_(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},$i=class b_ extends ko{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new hl,this.combinedData=""}static fromCharData(t){let i=new b_;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Yn(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Vm="di$target",pd="di$dependencies",vu=new Map;function xb(e){return e[pd]||[]}function Xt(e){if(vu.has(e))return vu.get(e);let t=function(i,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Cb(t,i,o)};return t._id=e,vu.set(e,t),t}function Cb(e,t,i){t[Vm]===t?t[pd].push({id:e,index:i}):(t[pd]=[{id:e,index:i}],t[Vm]=t)}var di=Xt("BufferService"),x_=Xt("CoreMouseService"),Pr=Xt("CoreService"),kb=Xt("CharsetService"),_h=Xt("InstantiationService"),C_=Xt("LogService"),hi=Xt("OptionsService"),k_=Xt("OscLinkService"),Eb=Xt("UnicodeService"),Eo=Xt("DecorationService"),md=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var _;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new $i,u=i.getTrimmedLength(),h=-1,p=-1,f=!1;for(let b=0;b<u;b++)if(!(p===-1&&!i.hasContent(b))){if(i.loadCell(b,a),a.hasExtendedAttrs()&&a.extended.urlId)if(p===-1){p=b,h=a.extended.urlId;continue}else f=a.extended.urlId!==h;else p!==-1&&(f=!0);if(f||p!==-1&&b===u-1){let S=(_=this._oscLinkService.getLinkData(h))==null?void 0:_.uri;if(S){let w={start:{x:p+1,y:e},end:{x:b+(!f&&b===u-1?1:0),y:e}},y=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let x=new URL(S);["http:","https:"].includes(x.protocol)||(y=!0)}catch{y=!0}y||s.push({text:S,range:w,activate:(x,k)=>o?o.activate(x,k,w):Nb(x,k),hover:(x,k)=>{var C;return(C=o==null?void 0:o.hover)==null?void 0:C.call(o,x,k,w)},leave:(x,k)=>{var C;return(C=o==null?void 0:o.leave)==null?void 0:C.call(o,x,k,w)}})}f=!1,a.hasExtendedAttrs()&&a.extended.urlId?(p=b,h=a.extended.urlId):(p=-1,h=-1)}}t(s)}};md=Et([je(0,di),je(1,hi),je(2,k_)],md);function Nb(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
52
|
+
|
|
53
|
+
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var xl=Xt("CharSizeService"),xn=Xt("CoreBrowserService"),yh=Xt("MouseService"),Cn=Xt("RenderService"),Rb=Xt("SelectionService"),E_=Xt("CharacterJoinerService"),ms=Xt("ThemeService"),N_=Xt("LinkProviderService"),Pb=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Ym.isErrorNoTelemetry(e)?new Ym(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)}},jb=new Pb;function Ja(e){Db(e)||jb.onUnexpectedError(e)}var gd="Canceled";function Db(e){return e instanceof Lb?!0:e instanceof Error&&e.name===gd&&e.message===gd}var Lb=class extends Error{constructor(){super(gd),this.name=this.message}};function Mb(e){return new Error(`Illegal argument: ${e}`)}var Ym=class vd extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof vd)return t;let i=new vd;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},_d=class R_ extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,R_.prototype)}};function Ei(e,t=0){return e[e.length-(1+t)]}var Tb;(e=>{function t(a){return a<0}e.isLessThan=t;function i(a){return a<=0}e.isLessThanOrEqual=i;function s(a){return a>0}e.isGreaterThan=s;function o(a){return a===0}e.isNeitherLessOrGreaterThan=o,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Tb||(Tb={}));function Ab(e,t){let i=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(i,arguments))),o}}var P_;(e=>{function t(M){return M&&typeof M=="object"&&typeof M[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*o(M){yield M}e.single=o;function a(M){return t(M)?M:o(M)}e.wrap=a;function u(M){return M||i}e.from=u;function*h(M){for(let ee=M.length-1;ee>=0;ee--)yield M[ee]}e.reverse=h;function p(M){return!M||M[Symbol.iterator]().next().done===!0}e.isEmpty=p;function f(M){return M[Symbol.iterator]().next().value}e.first=f;function _(M,ee){let q=0;for(let B of M)if(ee(B,q++))return!0;return!1}e.some=_;function b(M,ee){for(let q of M)if(ee(q))return q}e.find=b;function*S(M,ee){for(let q of M)ee(q)&&(yield q)}e.filter=S;function*w(M,ee){let q=0;for(let B of M)yield ee(B,q++)}e.map=w;function*y(M,ee){let q=0;for(let B of M)yield*ee(B,q++)}e.flatMap=y;function*x(...M){for(let ee of M)yield*ee}e.concat=x;function k(M,ee,q){let B=q;for(let Z of M)B=ee(B,Z);return B}e.reduce=k;function*C(M,ee,q=M.length){for(ee<0&&(ee+=M.length),q<0?q+=M.length:q>M.length&&(q=M.length);ee<q;ee++)yield M[ee]}e.slice=C;function P(M,ee=Number.POSITIVE_INFINITY){let q=[];if(ee===0)return[q,M];let B=M[Symbol.iterator]();for(let Z=0;Z<ee;Z++){let H=B.next();if(H.done)return[q,e.empty()];q.push(H.value)}return[q,{[Symbol.iterator](){return B}}]}e.consume=P;async function A(M){let ee=[];for await(let q of M)ee.push(q);return Promise.resolve(ee)}e.asyncToArray=A})(P_||(P_={}));function Er(e){if(P_.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Ib(...e){return _t(()=>Er(e))}function _t(e){return{dispose:Ab(()=>{e()})}}var j_=class D_{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{Er(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?D_.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)}};j_.DISABLE_DISPOSED_WARNING=!1;var er=j_,Ge=class{constructor(){this._store=new er,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)}};Ge.None=Object.freeze({dispose(){}});var hs=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}},bn=typeof window=="object"?window:globalThis,yd=class wd{constructor(t){this.element=t,this.next=wd.Undefined,this.prev=wd.Undefined}};yd.Undefined=new yd(void 0);var St=yd,Xm=class{constructor(){this._first=St.Undefined,this._last=St.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===St.Undefined}clear(){let e=this._first;for(;e!==St.Undefined;){let t=e.next;e.prev=St.Undefined,e.next=St.Undefined,e=t}this._first=St.Undefined,this._last=St.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new St(e);if(this._first===St.Undefined)this._first=i,this._last=i;else if(t){let o=this._last;this._last=i,i.prev=o,o.next=i}else{let o=this._first;this._first=i,i.next=o,o.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==St.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==St.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==St.Undefined&&e.next!==St.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===St.Undefined&&e.next===St.Undefined?(this._first=St.Undefined,this._last=St.Undefined):e.next===St.Undefined?(this._last=this._last.prev,this._last.next=St.Undefined):e.prev===St.Undefined&&(this._first=this._first.next,this._first.prev=St.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==St.Undefined;)yield e.element,e=e.next}},Bb=globalThis.performance&&typeof globalThis.performance.now=="function",Ob=class L_{static create(t){return new L_(t)}constructor(t){this._now=Bb&&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}},Zt;(e=>{e.None=()=>Ge.None;function t(T,E){return b(T,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function i(T){return(E,j=null,D)=>{let U=!1,re;return re=T(I=>{if(!U)return re?re.dispose():U=!0,E.call(j,I)},null,D),U&&re.dispose(),re}}e.once=i;function s(T,E,j){return f((D,U=null,re)=>T(I=>D.call(U,E(I)),null,re),j)}e.map=s;function o(T,E,j){return f((D,U=null,re)=>T(I=>{E(I),D.call(U,I)},null,re),j)}e.forEach=o;function a(T,E,j){return f((D,U=null,re)=>T(I=>E(I)&&D.call(U,I),null,re),j)}e.filter=a;function u(T){return T}e.signal=u;function h(...T){return(E,j=null,D)=>{let U=Ib(...T.map(re=>re(I=>E.call(j,I))));return _(U,D)}}e.any=h;function p(T,E,j,D){let U=j;return s(T,re=>(U=E(U,re),U),D)}e.reduce=p;function f(T,E){let j,D={onWillAddFirstListener(){j=T(U.fire,U)},onDidRemoveLastListener(){j==null||j.dispose()}},U=new ke(D);return E==null||E.add(U),U.event}function _(T,E){return E instanceof Array?E.push(T):E&&E.add(T),T}function b(T,E,j=100,D=!1,U=!1,re,I){let V,$,L,z=0,oe,ce={leakWarningThreshold:re,onWillAddFirstListener(){V=T(me=>{z++,$=E($,me),D&&!L&&(he.fire($),$=void 0),oe=()=>{let G=$;$=void 0,L=void 0,(!D||z>1)&&he.fire(G),z=0},typeof j=="number"?(clearTimeout(L),L=setTimeout(oe,j)):L===void 0&&(L=0,queueMicrotask(oe))})},onWillRemoveListener(){U&&z>0&&(oe==null||oe())},onDidRemoveLastListener(){oe=void 0,V.dispose()}},he=new ke(ce);return I==null||I.add(he),he.event}e.debounce=b;function S(T,E=0,j){return e.debounce(T,(D,U)=>D?(D.push(U),D):[U],E,void 0,!0,void 0,j)}e.accumulate=S;function w(T,E=(D,U)=>D===U,j){let D=!0,U;return a(T,re=>{let I=D||!E(re,U);return D=!1,U=re,I},j)}e.latch=w;function y(T,E,j){return[e.filter(T,E,j),e.filter(T,D=>!E(D),j)]}e.split=y;function x(T,E=!1,j=[],D){let U=j.slice(),re=T($=>{U?U.push($):V.fire($)});D&&D.add(re);let I=()=>{U==null||U.forEach($=>V.fire($)),U=null},V=new ke({onWillAddFirstListener(){re||(re=T($=>V.fire($)),D&&D.add(re))},onDidAddFirstListener(){U&&(E?setTimeout(I):I())},onDidRemoveLastListener(){re&&re.dispose(),re=null}});return D&&D.add(V),V.event}e.buffer=x;function k(T,E){return(j,D,U)=>{let re=E(new P);return T(function(I){let V=re.evaluate(I);V!==C&&j.call(D,V)},void 0,U)}}e.chain=k;let C=Symbol("HaltChainable");class P{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(j=>(E(j),j)),this}filter(E){return this.steps.push(j=>E(j)?j:C),this}reduce(E,j){let D=j;return this.steps.push(U=>(D=E(D,U),D)),this}latch(E=(j,D)=>j===D){let j=!0,D;return this.steps.push(U=>{let re=j||!E(U,D);return j=!1,D=U,re?U:C}),this}evaluate(E){for(let j of this.steps)if(E=j(E),E===C)break;return E}}function A(T,E,j=D=>D){let D=(...V)=>I.fire(j(...V)),U=()=>T.on(E,D),re=()=>T.removeListener(E,D),I=new ke({onWillAddFirstListener:U,onDidRemoveLastListener:re});return I.event}e.fromNodeEventEmitter=A;function M(T,E,j=D=>D){let D=(...V)=>I.fire(j(...V)),U=()=>T.addEventListener(E,D),re=()=>T.removeEventListener(E,D),I=new ke({onWillAddFirstListener:U,onDidRemoveLastListener:re});return I.event}e.fromDOMEventEmitter=M;function ee(T){return new Promise(E=>i(T)(E))}e.toPromise=ee;function q(T){let E=new ke;return T.then(j=>{E.fire(j)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=q;function B(T,E){return T(j=>E.fire(j))}e.forward=B;function Z(T,E,j){return E(j),T(D=>E(D))}e.runAndSubscribe=Z;class H{constructor(E,j){this._observable=E,this._counter=0,this._hasChanged=!1;let D={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new ke(D),j&&j.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,j){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 te(T,E){return new H(T,E).emitter.event}e.fromObservable=te;function K(T){return(E,j,D)=>{let U=0,re=!1,I={beginUpdate(){U++},endUpdate(){U--,U===0&&(T.reportChanges(),re&&(re=!1,E.call(j)))},handlePossibleChange(){},handleChange(){re=!0}};T.addObserver(I),T.reportChanges();let V={dispose(){T.removeObserver(I)}};return D instanceof er?D.add(V):Array.isArray(D)&&D.push(V),V}}e.fromObservableLight=K})(Zt||(Zt={}));var Sd=class bd{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${bd._idPool++}`,bd.all.add(this)}start(t){this._stopWatch=new Ob,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}}};Sd.all=new Set,Sd._idPool=0;var zb=Sd,Fb=-1,M_=class T_{constructor(t,i,s=(T_._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,u]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${u}):`;console.warn(h),console.warn(a);let p=new Wb(h,a);this._errorHandler(p)}return()=>{let a=this._stacks.get(t.value)||0;this._stacks.set(t.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,o]of this._stacks)(!t||i<o)&&(t=[s,o],i=o);return t}};M_._idPool=1;var $b=M_,Hb=class A_{constructor(t){this.value=t}static create(){let t=new Error;return new A_(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
+
`).slice(2).join(`
|
|
59
|
+
`))}},Wb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Ub=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Kb=0,_u=class{constructor(e){this.value=e,this.id=Kb++}},qb=2,Vb,ke=class{constructor(e){var t,i,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new $b((e==null?void 0:e.onListenerError)??Ja,((i=this._options)==null?void 0:i.leakWarningThreshold)??Fb):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new zb(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var u,h,p,f,_;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 S=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],w=new Ub(`${b}. HINT: Stack shows most frequent listener (${S[1]}-times)`,S[0]);return(((u=this._options)==null?void 0:u.onListenerError)||Ja)(w),Ge.None}if(this._disposed)return Ge.None;t&&(e=e.bind(t));let s=new _u(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Hb.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof _u?(this._deliveryQueue??(this._deliveryQueue=new Yb),this._listeners=[this._listeners,s]):this._listeners.push(s):((p=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||p.call(h,this),this._listeners=s,(_=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||_.call(f,this)),this._size++;let a=_t(()=>{o==null||o(),this._removeListener(s)});return i instanceof er?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(e){var o,a,u,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(u=this._options)==null?void 0:u.onDidRemoveLastListener)==null||h.call(u,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*qb<=t.length){let p=0;for(let f=0;f<t.length;f++)t[f]?t[p++]=t[f]:s&&(this._deliveryQueue.end--,p<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=p}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Ja;if(!i){e.value(t);return}try{e.value(t)}catch(o){i(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof _u)this._deliver(this._listeners,e);else{let a=this._deliveryQueue;a.enqueue(this,e,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},Yb=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},xd=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ke,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ke,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};xd.INSTANCE=new xd;var wh=xd;function Xb(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}wh.INSTANCE.onDidChangeZoomLevel;function Gb(e){return wh.INSTANCE.getZoomFactor(e)}wh.INSTANCE.onDidChangeFullscreen;var gs=typeof navigator=="object"?navigator.userAgent:"",Cd=gs.indexOf("Firefox")>=0,Qb=gs.indexOf("AppleWebKit")>=0,Sh=gs.indexOf("Chrome")>=0,Jb=!Sh&&gs.indexOf("Safari")>=0;gs.indexOf("Electron/")>=0;gs.indexOf("Android")>=0;var yu=!1;if(typeof bn.matchMedia=="function"){let e=bn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=bn.matchMedia("(display-mode: fullscreen)");yu=e.matches,Xb(bn,e,({matches:i})=>{yu&&t.matches||(yu=i)})}var ss="en",kd=!1,Ed=!1,Za=!1,I_=!1,Ha,el=ss,Gm=ss,Zb,Gi,kr=globalThis,Jt,Fv;typeof kr.vscode<"u"&&typeof kr.vscode.process<"u"?Jt=kr.vscode.process:typeof process<"u"&&typeof((Fv=process==null?void 0:process.versions)==null?void 0:Fv.node)=="string"&&(Jt=process);var $v,e1=typeof(($v=Jt==null?void 0:Jt.versions)==null?void 0:$v.electron)=="string",t1=e1&&(Jt==null?void 0:Jt.type)==="renderer",Hv;if(typeof Jt=="object"){kd=Jt.platform==="win32",Ed=Jt.platform==="darwin",Za=Jt.platform==="linux",Za&&Jt.env.SNAP&&Jt.env.SNAP_REVISION,Jt.env.CI||Jt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ha=ss,el=ss;let e=Jt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ha=t.userLocale,Gm=t.osLocale,el=t.resolvedLanguage||ss,Zb=(Hv=t.languagePack)==null?void 0:Hv.translationsConfigFile}catch{}I_=!0}else typeof navigator=="object"&&!t1?(Gi=navigator.userAgent,kd=Gi.indexOf("Windows")>=0,Ed=Gi.indexOf("Macintosh")>=0,(Gi.indexOf("Macintosh")>=0||Gi.indexOf("iPad")>=0||Gi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Za=Gi.indexOf("Linux")>=0,(Gi==null?void 0:Gi.indexOf("Mobi"))>=0,el=globalThis._VSCODE_NLS_LANGUAGE||ss,Ha=navigator.language.toLowerCase(),Gm=Ha):console.error("Unable to resolve platform.");var B_=kd,cn=Ed,i1=Za,Qm=I_,dn=Gi,Un=el,n1;(e=>{function t(){return Un}e.value=t;function i(){return Un.length===2?Un==="en":Un.length>=3?Un[0]==="e"&&Un[1]==="n"&&Un[2]==="-":!1}e.isDefaultVariant=i;function s(){return Un==="en"}e.isDefault=s})(n1||(n1={}));var r1=typeof kr.postMessage=="function"&&!kr.importScripts;(()=>{if(r1){let e=[];kr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),kr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var s1=!!(dn&&dn.indexOf("Chrome")>=0);dn&&dn.indexOf("Firefox")>=0;!s1&&dn&&dn.indexOf("Safari")>=0;dn&&dn.indexOf("Edg/")>=0;dn&&dn.indexOf("Android")>=0;var ts=typeof navigator=="object"?navigator:{};Qm||document.queryCommandSupported&&document.queryCommandSupported("copy")||ts&&ts.clipboard&&ts.clipboard.writeText,Qm||ts&&ts.clipboard&&ts.clipboard.readText;var bh=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}},wu=new bh,Jm=new bh,Zm=new bh,o1=new Array(230),O_;(e=>{function t(h){return wu.keyCodeToStr(h)}e.toString=t;function i(h){return wu.strToKeyCode(h)}e.fromString=i;function s(h){return Jm.keyCodeToStr(h)}e.toUserSettingsUS=s;function o(h){return Zm.keyCodeToStr(h)}e.toUserSettingsGeneral=o;function a(h){return Jm.strToKeyCode(h)||Zm.strToKeyCode(h)}e.fromUserSettings=a;function u(h){if(h>=98&&h<=113)return null;switch(h){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return wu.keyCodeToStr(h)}e.toElectronAccelerator=u})(O_||(O_={}));var a1=class z_{constructor(t,i,s,o,a){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof z_&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${i}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new l1([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},l1=class{constructor(e){if(e.length===0)throw Mb("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function c1(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return O_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Cd)switch(t){case 59:return 85;case 60:if(i1)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(cn)return 57;break}else if(Qb&&(cn&&t===93||!cn&&t===92))return 57;return o1[t]||0}var u1=cn?256:2048,d1=512,h1=1024,f1=cn?2048:256,eg=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=c1(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|=u1),this.altKey&&(t|=d1),this.shiftKey&&(t|=h1),this.metaKey&&(t|=f1),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new a1(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},tg=new WeakMap;function p1(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var m1=class{static getSameOriginWindowChain(e){let t=tg.get(e);if(!t){t=[],tg.set(e,t);let i=e,s;do s=p1(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let u=a.window.deref();if(i+=(u==null?void 0:u.scrollY)??0,s+=(u==null?void 0:u.scrollX)??0,u===t||!a.iframeElement)break;let h=a.iframeElement.getBoundingClientRect();i+=h.top,s+=h.left}return{top:i,left:s}}},Wa=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=m1.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},ig=class{constructor(e,t=0,i=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Sh){let a=navigator.userAgent.match(/Chrome\/(\d+)/);s=(a?parseInt(a[1]):123)<=122}if(e){let a=e,u=e,h=((o=e.view)==null?void 0:o.devicePixelRatio)||1;if(typeof a.wheelDeltaY<"u")s?this.deltaY=a.wheelDeltaY/(120*h):this.deltaY=a.wheelDeltaY/120;else if(typeof u.VERTICAL_AXIS<"u"&&u.axis===u.VERTICAL_AXIS)this.deltaY=-u.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Cd&&!cn?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")Jb&&B_?this.deltaX=-(a.wheelDeltaX/120):s?this.deltaX=a.wheelDeltaX/(120*h):this.deltaX=a.wheelDeltaX/120;else if(typeof u.HORIZONTAL_AXIS<"u"&&u.axis===u.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Cd&&!cn?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},F_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),g1;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof v1?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Zt.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:F_})})(g1||(g1={}));var v1=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?F_:(this._emitter||(this._emitter=new ke),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},xh=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 _d("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new _d("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},_1=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new _d("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=_t(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},y1;(e=>{async function t(s){let o,a=await Promise.all(s.map(u=>u.then(h=>h,h=>{o||(o=h)})));if(typeof o<"u")throw o;return a}e.settled=t;function i(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(u){a(u)}})}e.withAsyncBody=i})(y1||(y1={}));var ng=class zi{static fromArray(t){return new zi(i=>{i.emitMany(t)})}static fromPromise(t){return new zi(async i=>{i.emitMany(await t)})}static fromPromises(t){return new zi(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new zi(async i=>{await Promise.all(t.map(async s=>{for await(let o of s)i.emitOne(o)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ke,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 Zt.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new zi(async s=>{for await(let o of t)s.emitOne(i(o))})}map(t){return zi.map(this,t)}static filter(t,i){return new zi(async s=>{for await(let o of t)i(o)&&s.emitOne(o)})}filter(t){return zi.filter(this,t)}static coalesce(t){return zi.filter(t,i=>!!i)}coalesce(){return zi.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return zi.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())}};ng.EMPTY=ng.fromArray([]);var{getWindow:an,getWindowId:w1,onDidRegisterWindow:S1}=(function(){let e=new Map,t={window:bn,disposables:new er};e.set(bn.vscodeWindowId,t);let i=new ke,s=new ke,o=new ke;function a(u,h){return(typeof u=="number"?e.get(u):void 0)??(h?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return Ge.None;let h=new er,p={window:u,disposables:h.add(new er)};return e.set(u.vscodeWindowId,p),h.add(_t(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),h.add(Ue(u,Wt.BEFORE_UNLOAD,()=>{o.fire(u)})),i.fire(p),h},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(u){return u.vscodeWindowId},hasWindow(u){return e.has(u)},getWindowById:a,getWindow(u){var f;let h=u;if((f=h==null?void 0:h.ownerDocument)!=null&&f.defaultView)return h.ownerDocument.defaultView.window;let p=u;return p!=null&&p.view?p.view.window:bn},getDocument(u){return an(u).document}}})(),b1=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ue(e,t,i,s){return new b1(e,t,i,s)}var rg=function(e,t,i,s){return Ue(e,t,i,s)},Ch,x1=class extends _1{constructor(e){super(),this.defaultTarget=e&&an(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},sg=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){Ja(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,o=a=>{i.set(a,!1);let u=e.get(a)??[];for(t.set(a,u),e.set(a,[]),s.set(a,!0);u.length>0;)u.sort(sg.sort),u.shift().execute();s.set(a,!1)};Ch=(a,u,h=0)=>{let p=w1(a),f=new sg(u,h),_=e.get(p);return _||(_=[],e.set(p,_)),_.push(f),i.get(p)||(i.set(p,!0),a.requestAnimationFrame(()=>o(p))),f}})();function C1(e){let t=e.getBoundingClientRect(),i=an(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Wt={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"},k1=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let i=yi(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let i=yi(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){let i=yi(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){let i=yi(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){let i=yi(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){let i=yi(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){let i=yi(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(t){let i=yi(t);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let i=yi(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let i=yi(t);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let i=yi(t);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let i=yi(t);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let i=yi(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let i=yi(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function yi(e){return typeof e=="number"?`${e}px`:e}function _o(e){return new k1(e)}var $_=class{constructor(){this._hooks=new er,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(_t(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=an(e)}this._hooks.add(Ue(a,Wt.POINTER_MOVE,u=>{if(u.buttons!==i){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Ue(a,Wt.POINTER_UP,u=>this.stopMonitoring(!0)))}};function E1(e,t,i){let s=null,o=null;if(typeof i.value=="function"?(s="value",o=i.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",o=i.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;i[s]=function(...u){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:o.apply(this,u)}),this[a]}}var on;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(on||(on={}));var fo=class si extends Ge{constructor(){super(),this.dispatched=!1,this.targets=new Xm,this.ignoreTargets=new Xm,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Zt.runAndSubscribe(S1,({window:t,disposables:i})=>{i.add(Ue(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ue(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ue(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:bn,disposables:this._store}))}static addTarget(t){if(!si.isTouchDevice())return Ge.None;si.INSTANCE||(si.INSTANCE=new si);let i=si.INSTANCE.targets.push(t);return _t(i)}static ignoreTarget(t){if(!si.isTouchDevice())return Ge.None;si.INSTANCE||(si.INSTANCE=new si);let i=si.INSTANCE.ignoreTargets.push(t);return _t(i)}static isTouchDevice(){return"ontouchstart"in bn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let a=t.targetTouches.item(s);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:i,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[i],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let u=this.newGestureEvent(on.Start,a.target);u.pageX=a.pageX,u.pageY=a.pageY,this.dispatchEvent(u)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,u=i.changedTouches.length;a<u;a++){let h=i.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let p=this.activeTouches[h.identifier],f=Date.now()-p.initialTimeStamp;if(f<si.HOLD_DELAY&&Math.abs(p.initialPageX-Ei(p.rollingPageX))<30&&Math.abs(p.initialPageY-Ei(p.rollingPageY))<30){let _=this.newGestureEvent(on.Tap,p.initialTarget);_.pageX=Ei(p.rollingPageX),_.pageY=Ei(p.rollingPageY),this.dispatchEvent(_)}else if(f>=si.HOLD_DELAY&&Math.abs(p.initialPageX-Ei(p.rollingPageX))<30&&Math.abs(p.initialPageY-Ei(p.rollingPageY))<30){let _=this.newGestureEvent(on.Contextmenu,p.initialTarget);_.pageX=Ei(p.rollingPageX),_.pageY=Ei(p.rollingPageY),this.dispatchEvent(_)}else if(o===1){let _=Ei(p.rollingPageX),b=Ei(p.rollingPageY),S=Ei(p.rollingTimestamps)-p.rollingTimestamps[0],w=_-p.rollingPageX[0],y=b-p.rollingPageY[0],x=[...this.targets].filter(k=>p.initialTarget instanceof Node&&k.contains(p.initialTarget));this.inertia(t,x,s,Math.abs(w)/S,w>0?1:-1,_,Math.abs(y)/S,y>0?1:-1,b)}this.dispatchEvent(this.newGestureEvent(on.End,p.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===on.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>si.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===on.Change||t.type===on.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;i.push([o,s])}i.sort((s,o)=>s[0]-o[0]);for(let[s,o]of i)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,o,a,u,h,p,f){this.handle=Ch(t,()=>{let _=Date.now(),b=_-s,S=0,w=0,y=!0;o+=si.SCROLL_FRICTION*b,h+=si.SCROLL_FRICTION*b,o>0&&(y=!1,S=a*o*b),h>0&&(y=!1,w=p*h*b);let x=this.newGestureEvent(on.Change);x.translationX=S,x.translationY=w,i.forEach(k=>k.dispatchEvent(x)),y||this.inertia(t,i,_,o,a,u+S,h,p,f+w)})}onTouchMove(t){let i=Date.now();for(let s=0,o=t.changedTouches.length;s<o;s++){let a=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let u=this.activeTouches[a.identifier],h=this.newGestureEvent(on.Change,u.initialTarget);h.translationX=a.pageX-Ei(u.rollingPageX),h.translationY=a.pageY-Ei(u.rollingPageY),h.pageX=a.pageX,h.pageY=a.pageY,this.dispatchEvent(h),u.rollingPageX.length>3&&(u.rollingPageX.shift(),u.rollingPageY.shift(),u.rollingTimestamps.shift()),u.rollingPageX.push(a.pageX),u.rollingPageY.push(a.pageY),u.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};fo.SCROLL_FRICTION=-.005,fo.HOLD_DELAY=700,fo.CLEAR_TAP_COUNT_TIME=400,Et([E1],fo,"isTouchDevice",1);var N1=fo,kh=class extends Ge{onclick(e,t){this._register(Ue(e,Wt.CLICK,i=>t(new Wa(an(e),i))))}onmousedown(e,t){this._register(Ue(e,Wt.MOUSE_DOWN,i=>t(new Wa(an(e),i))))}onmouseover(e,t){this._register(Ue(e,Wt.MOUSE_OVER,i=>t(new Wa(an(e),i))))}onmouseleave(e,t){this._register(Ue(e,Wt.MOUSE_LEAVE,i=>t(new Wa(an(e),i))))}onkeydown(e,t){this._register(Ue(e,Wt.KEY_DOWN,i=>t(new eg(i))))}onkeyup(e,t){this._register(Ue(e,Wt.KEY_UP,i=>t(new eg(i))))}oninput(e,t){this._register(Ue(e,Wt.INPUT,t))}onblur(e,t){this._register(Ue(e,Wt.BLUR,t))}onfocus(e,t){this._register(Ue(e,Wt.FOCUS,t))}onchange(e,t){this._register(Ue(e,Wt.CHANGE,t))}ignoreGesture(e){return N1.ignoreTarget(e)}},og=11,R1=class extends kh{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=og+"px",this.domNode.style.height=og+"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 $_),this._register(rg(this.bgDomNode,Wt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(rg(this.domNode,Wt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new x1),this._pointerdownScheduleRepeatTimer=this._register(new xh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,an(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},P1=class Nd{constructor(t,i,s,o,a,u,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,o=o|0,a=a|0,u=u|0,h=h|0),this.rawScrollLeft=o,this.rawScrollTop=h,i<0&&(i=0),o+i>s&&(o=s-i),o<0&&(o=0),a<0&&(a=0),h+a>u&&(h=u-a),h<0&&(h=0),this.width=i,this.scrollWidth=s,this.scrollLeft=o,this.height=a,this.scrollHeight=u,this.scrollTop=h}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Nd(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Nd(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:a,heightChanged:u,scrollHeightChanged:h,scrollTopChanged:p}}},j1=class extends Ge{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new P1(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new lg(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=lg.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},ag=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Su(e,t){let i=t-e;return function(s){return e+i*M1(s)}}function D1(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var lg=class Rd{constructor(t,i,s,o){this.from=t,this.to=i,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let o,a;return t<i?(o=t+.75*s,a=i-.75*s):(o=t-.75*s,a=i+.75*s),D1(Su(t,o),Su(a,i),.33)}return Su(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),o=this.scrollTop(i);return new ag(s,o,!1)}return new ag(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Rd.start(t,i,s)}static start(t,i,s){s=s+10;let o=Date.now()-10;return new Rd(t,i,o,s)}};function L1(e){return Math.pow(e,3)}function M1(e){return 1-L1(1-e)}var T1=class extends Ge{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new xh)}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":"")))}},A1=140,H_=class extends kh{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 T1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new $_),this._shouldRender=!0,this.domNode=_o(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ue(this.domNode.domNode,Wt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new R1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=_o(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ue(this.slider.domNode,Wt.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);i<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let o=C1(this.domNode.domNode);t=e.pageX-o.left,i=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),u=Math.abs(a-i);if(B_&&u>A1){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(o)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h))},()=>{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()}},W_=class Pd{constructor(t,i,s,o,a,u){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=o,this._scrollSize=a,this._scrollPosition=u,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Pd(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,o,a){let u=Math.max(0,s-t),h=Math.max(0,u-2*i),p=o>0&&o>s;if(!p)return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*h/o))),_=(h-f)/(o-s),b=a*_;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:_,computedSliderPosition:Math.round(b)}}_refreshComputedValues(){let t=Pd._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},I1=class extends H_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new W_(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}},B1=class extends H_{constructor(e,t,i){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new W_(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}},O1=500,cg=50,z1=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},jd=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,i+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Sh){let i=an(t.browserEvent),s=Gb(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let o=null,a=new z1(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(o=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=a),a.score=this._computeScore(a,o)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),u=Math.abs(i.deltaX),h=Math.abs(i.deltaY),p=Math.max(Math.min(o,u),1),f=Math.max(Math.min(a,h),1),_=Math.max(o,u),b=Math.max(a,h);_%p===0&&b%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};jd.INSTANCE=new jd;var F1=jd,$1=class extends kh{constructor(e,t,i){super(),this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ke),this.onWillScroll=this._onWillScroll.event,this._options=W1(t),this._scrollable=i,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new B1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new I1(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=_o(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=_o(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=_o(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 xh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Er(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,cn&&(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 ig(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Er(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new ig(i))};this._mouseWheelToDispose.push(Ue(this._listenOnDomNode,Wt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=F1.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,u=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&u+a===0?u=a=0:Math.abs(a)>=Math.abs(u)?u=0:a=0),this._options.flipAxes&&([a,u]=[u,a]);let h=!cn&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!u&&(u=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(u=u*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),f={};if(a){let _=cg*a,b=p.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(f,b)}if(u){let _=cg*u,b=p.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(f,b)}f=this._scrollable.validateScrollPosition(f),(p.scrollLeft!==f.scrollLeft||p.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",o=t?" top":"",a=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${o}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${o}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),O1)}},H1=class extends $1{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function W1(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,cn&&(t.className+=" mac"),t}var Dd=class extends Ge{constructor(e,t,i,s,o,a,u,h){super(),this._bufferService=i,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new j1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>Ch(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new H1(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(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Zt.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(_t(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(_t(()=>this._styleElement.remove())),this._register(Zt.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${a.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${a.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${a.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
60
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(f=>this._handleScroll(f)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Dd=Et([je(2,di),je(3,xn),je(4,x_),je(5,ms),je(6,hi),je(7,Cn)],Dd);var Ld=class extends Ge{constructor(e,t,i,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(a=>this._removeDecoration(a))),this._register(_t(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Ld=Et([je(1,di),je(2,xn),je(3,Eo),je(4,Cn)],Ld);var U1=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},nn={full:0,left:0,center:0,right:0},Kn={full:0,left:0,center:0,right:0},io={full:0,left:0,center:0,right:0},fl=class extends Ge{constructor(e,t,i,s,o,a,u,h){var f;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=u,this._coreBrowserService=h,this._colorZoneStore=new U1,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(),(f=this._viewportElement.parentElement)==null||f.insertBefore(this._canvas,this._viewportElement),this._register(_t(()=>{var _;return(_=this._canvas)==null?void 0:_.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);Kn.full=this._canvas.width,Kn.left=e,Kn.center=t,Kn.right=e,this._refreshDrawHeightConstants(),io.full=1,io.left=1,io.center=1+Kn.left,io.right=1+Kn.left+Kn.center}_refreshDrawHeightConstants(){nn.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);nn.left=t,nn.center=t,nn.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*nn.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(io[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-nn[e.position||"full"]/2),Kn[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+nn[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}))}};fl=Et([je(2,di),je(3,Eo),je(4,Cn),je(5,hi),je(6,ms),je(7,xn)],fl);var pe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
61
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(pe||(pe={}));var tl;(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=""))(tl||(tl={}));var U_;(e=>e.ST=`${pe.ESC}\\`)(U_||(U_={}));var Md=class{constructor(e,t,i,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=o,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${pe.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let a=this._compositionView.getBoundingClientRect();this._textarea.style.left=o+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(a.width,1)+"px",this._textarea.style.height=Math.max(a.height,1)+"px",this._textarea.style.lineHeight=a.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Md=Et([je(2,di),je(3,hi),je(4,Pr),je(5,Cn)],Md);var Ut=0,Kt=0,qt=0,kt=0,ug={css:"#00000000",rgba:0},Mt;(e=>{function t(o,a,u,h){return h!==void 0?`#${mr(o)}${mr(a)}${mr(u)}${mr(h)}`:`#${mr(o)}${mr(a)}${mr(u)}`}e.toCss=t;function i(o,a,u,h=255){return(o<<24|a<<16|u<<8|h)>>>0}e.toRgba=i;function s(o,a,u,h){return{css:e.toCss(o,a,u,h),rgba:e.toRgba(o,a,u,h)}}e.toColor=s})(Mt||(Mt={}));var mt;(e=>{function t(p,f){if(kt=(f.rgba&255)/255,kt===1)return{css:f.css,rgba:f.rgba};let _=f.rgba>>24&255,b=f.rgba>>16&255,S=f.rgba>>8&255,w=p.rgba>>24&255,y=p.rgba>>16&255,x=p.rgba>>8&255;Ut=w+Math.round((_-w)*kt),Kt=y+Math.round((b-y)*kt),qt=x+Math.round((S-x)*kt);let k=Mt.toCss(Ut,Kt,qt),C=Mt.toRgba(Ut,Kt,qt);return{css:k,rgba:C}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,f,_){let b=il.ensureContrastRatio(p.rgba,f.rgba,_);if(b)return Mt.toColor(b>>24&255,b>>16&255,b>>8&255)}e.ensureContrastRatio=s;function o(p){let f=(p.rgba|255)>>>0;return[Ut,Kt,qt]=il.toChannels(f),{css:Mt.toCss(Ut,Kt,qt),rgba:f}}e.opaque=o;function a(p,f){return kt=Math.round(f*255),[Ut,Kt,qt]=il.toChannels(p.rgba),{css:Mt.toCss(Ut,Kt,qt,kt),rgba:Mt.toRgba(Ut,Kt,qt,kt)}}e.opacity=a;function u(p,f){return kt=p.rgba&255,a(p,kt*f/255)}e.multiplyOpacity=u;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(mt||(mt={}));var bt;(e=>{let t,i;try{let o=document.createElement("canvas");o.width=1,o.height=1;let a=o.getContext("2d",{willReadFrequently:!0});a&&(t=a,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Ut=parseInt(o.slice(1,2).repeat(2),16),Kt=parseInt(o.slice(2,3).repeat(2),16),qt=parseInt(o.slice(3,4).repeat(2),16),Mt.toColor(Ut,Kt,qt);case 5:return Ut=parseInt(o.slice(1,2).repeat(2),16),Kt=parseInt(o.slice(2,3).repeat(2),16),qt=parseInt(o.slice(3,4).repeat(2),16),kt=parseInt(o.slice(4,5).repeat(2),16),Mt.toColor(Ut,Kt,qt,kt);case 7:return{css:o,rgba:(parseInt(o.slice(1),16)<<8|255)>>>0};case 9:return{css:o,rgba:parseInt(o.slice(1),16)>>>0}}let a=o.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(a)return Ut=parseInt(a[1]),Kt=parseInt(a[2]),qt=parseInt(a[3]),kt=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),Mt.toColor(Ut,Kt,qt,kt);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ut,Kt,qt,kt]=t.getImageData(0,0,1,1).data,kt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Mt.toRgba(Ut,Kt,qt,kt),css:o}}e.toColor=s})(bt||(bt={}));var ci;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,o,a){let u=s/255,h=o/255,p=a/255,f=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),b=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return f*.2126+_*.7152+b*.0722}e.relativeLuminance2=i})(ci||(ci={}));var il;(e=>{function t(u,h){if(kt=(h&255)/255,kt===1)return h;let p=h>>24&255,f=h>>16&255,_=h>>8&255,b=u>>24&255,S=u>>16&255,w=u>>8&255;return Ut=b+Math.round((p-b)*kt),Kt=S+Math.round((f-S)*kt),qt=w+Math.round((_-w)*kt),Mt.toRgba(Ut,Kt,qt)}e.blend=t;function i(u,h,p){let f=ci.relativeLuminance(u>>8),_=ci.relativeLuminance(h>>8);if(wn(f,_)<p){if(_<f){let w=s(u,h,p),y=wn(f,ci.relativeLuminance(w>>8));if(y<p){let x=o(u,h,p),k=wn(f,ci.relativeLuminance(x>>8));return y>k?w:x}return w}let b=o(u,h,p),S=wn(f,ci.relativeLuminance(b>>8));if(S<p){let w=s(u,h,p),y=wn(f,ci.relativeLuminance(w>>8));return S>y?b:w}return b}}e.ensureContrastRatio=i;function s(u,h,p){let f=u>>24&255,_=u>>16&255,b=u>>8&255,S=h>>24&255,w=h>>16&255,y=h>>8&255,x=wn(ci.relativeLuminance2(S,w,y),ci.relativeLuminance2(f,_,b));for(;x<p&&(S>0||w>0||y>0);)S-=Math.max(0,Math.ceil(S*.1)),w-=Math.max(0,Math.ceil(w*.1)),y-=Math.max(0,Math.ceil(y*.1)),x=wn(ci.relativeLuminance2(S,w,y),ci.relativeLuminance2(f,_,b));return(S<<24|w<<16|y<<8|255)>>>0}e.reduceLuminance=s;function o(u,h,p){let f=u>>24&255,_=u>>16&255,b=u>>8&255,S=h>>24&255,w=h>>16&255,y=h>>8&255,x=wn(ci.relativeLuminance2(S,w,y),ci.relativeLuminance2(f,_,b));for(;x<p&&(S<255||w<255||y<255);)S=Math.min(255,S+Math.ceil((255-S)*.1)),w=Math.min(255,w+Math.ceil((255-w)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),x=wn(ci.relativeLuminance2(S,w,y),ci.relativeLuminance2(f,_,b));return(S<<24|w<<16|y<<8|255)>>>0}e.increaseLuminance=o;function a(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=a})(il||(il={}));function mr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function wn(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var K1=class extends ko{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pl=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new $i}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),o=0,a=0,u=0,h=t.getFg(0),p=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==p){if(f-o>1){let _=this._getJoinedRanges(s,u,a,t,o);for(let b=0;b<_.length;b++)i.push(_[b])}o=f,u=a,h=this._workCell.fg,p=this._workCell.bg}a+=this._workCell.getChars().length||Qn.length}if(this._bufferService.cols-o>1){let f=this._getJoinedRanges(s,u,a,t,o);for(let _=0;_<f.length;_++)i.push(f[_])}return i}_getJoinedRanges(e,t,i,s,o){let a=e.substring(t,i),u=[];try{u=this._characterJoiners[0].handler(a)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let p=this._characterJoiners[h].handler(a);for(let f=0;f<p.length;f++)pl._mergeRanges(u,p[f])}catch(p){console.error(p)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,i){let s=0,o=!1,a=0,u=e[s];if(u){for(let h=i;h<this._bufferService.cols;h++){let p=t.getWidth(h),f=t.getString(h).length||Qn.length;if(p!==0){if(!o&&u[0]<=a&&(u[0]=h,o=!0),u[1]<=a){if(u[1]=h,u=e[++s],!u)break;u[0]<=a?(u[0]=h,o=!0):o=!1}a+=f}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let o=e[s];if(i){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};pl=Et([je(0,di)],pl);function q1(e){return 57508<=e&&e<=57558}function V1(e){return 9472<=e&&e<=9631}function Y1(e){return q1(e)||V1(e)}function X1(){return{css:{canvas:Ua(),cell:Ua()},device:{canvas:Ua(),cell:Ua(),char:{width:0,height:0,left:0,top:0}}}}function Ua(){return{width:0,height:0}}var Td=class{constructor(e,t,i,s,o,a,u){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=u,this._workCell=new $i,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,o,a,u,h,p,f,_){let b=[],S=this._characterJoinerService.getJoinedCharacters(t),w=this._themeService.colors,y=e.getNoBgTrimmedLength();i&&y<a+1&&(y=a+1);let x,k=0,C="",P=0,A=0,M=0,ee=0,q=!1,B=0,Z=!1,H=0,te=0,K=[],T=f!==-1&&_!==-1;for(let E=0;E<y;E++){e.loadCell(E,this._workCell);let j=this._workCell.getWidth();if(j===0)continue;let D=!1,U=E>=te,re=E,I=this._workCell;if(S.length>0&&E===S[0][0]&&U){let Fe=S.shift(),ct=this._isCellInSelection(Fe[0],t);for(P=Fe[0]+1;P<Fe[1];P++)U&&(U=ct===this._isCellInSelection(P,t));U&&(U=!i||a<Fe[0]||a>=Fe[1]),U?(D=!0,I=new K1(this._workCell,e.translateToString(!0,Fe[0],Fe[1]),Fe[1]-Fe[0]),re=Fe[1]-1,j=I.getWidth()):te=Fe[1]}let V=this._isCellInSelection(E,t),$=i&&E===a,L=T&&E>=f&&E<=_,z=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,Fe=>{z=!0});let oe=I.getChars()||Qn;if(oe===" "&&(I.isUnderline()||I.isOverline())&&(oe=" "),H=j*h-p.get(oe,I.isBold(),I.isItalic()),!x)x=this._document.createElement("span");else if(k&&(V&&Z||!V&&!Z&&I.bg===A)&&(V&&Z&&w.selectionForeground||I.fg===M)&&I.extended.ext===ee&&L===q&&H===B&&!$&&!D&&!z&&U){I.isInvisible()?C+=Qn:C+=oe,k++;continue}else k&&(x.textContent=C),x=this._document.createElement("span"),k=0,C="";if(A=I.bg,M=I.fg,ee=I.extended.ext,q=L,B=H,Z=V,D&&a>=E&&a<=re&&(a=E),!this._coreService.isCursorHidden&&$&&this._coreService.isCursorInitialized){if(K.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&K.push("xterm-cursor-blink"),K.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":K.push("xterm-cursor-outline");break;case"block":K.push("xterm-cursor-block");break;case"bar":K.push("xterm-cursor-bar");break;case"underline":K.push("xterm-cursor-underline");break}}if(I.isBold()&&K.push("xterm-bold"),I.isItalic()&&K.push("xterm-italic"),I.isDim()&&K.push("xterm-dim"),I.isInvisible()?C=Qn:C=I.getChars()||Qn,I.isUnderline()&&(K.push(`xterm-underline-${I.extended.underlineStyle}`),C===" "&&(C=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${ko.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let Fe=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&Fe<8&&(Fe+=8),x.style.textDecorationColor=w.ansi[Fe].css}I.isOverline()&&(K.push("xterm-overline"),C===" "&&(C=" ")),I.isStrikethrough()&&K.push("xterm-strikethrough"),L&&(x.style.textDecoration="underline");let ce=I.getFgColor(),he=I.getFgColorMode(),me=I.getBgColor(),G=I.getBgColorMode(),J=!!I.isInverse();if(J){let Fe=ce;ce=me,me=Fe;let ct=he;he=G,G=ct}let ge,Me,Ze=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,Fe=>{Fe.options.layer!=="top"&&Ze||(Fe.backgroundColorRGB&&(G=50331648,me=Fe.backgroundColorRGB.rgba>>8&16777215,ge=Fe.backgroundColorRGB),Fe.foregroundColorRGB&&(he=50331648,ce=Fe.foregroundColorRGB.rgba>>8&16777215,Me=Fe.foregroundColorRGB),Ze=Fe.options.layer==="top")}),!Ze&&V&&(ge=this._coreBrowserService.isFocused?w.selectionBackgroundOpaque:w.selectionInactiveBackgroundOpaque,me=ge.rgba>>8&16777215,G=50331648,Ze=!0,w.selectionForeground&&(he=50331648,ce=w.selectionForeground.rgba>>8&16777215,Me=w.selectionForeground)),Ze&&K.push("xterm-decoration-top");let Be;switch(G){case 16777216:case 33554432:Be=w.ansi[me],K.push(`xterm-bg-${me}`);break;case 50331648:Be=Mt.toColor(me>>16,me>>8&255,me&255),this._addStyle(x,`background-color:#${dg((me>>>0).toString(16),"0",6)}`);break;case 0:default:J?(Be=w.foreground,K.push("xterm-bg-257")):Be=w.background}switch(ge||I.isDim()&&(ge=mt.multiplyOpacity(Be,.5)),he){case 16777216:case 33554432:I.isBold()&&ce<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ce+=8),this._applyMinimumContrast(x,Be,w.ansi[ce],I,ge,void 0)||K.push(`xterm-fg-${ce}`);break;case 50331648:let Fe=Mt.toColor(ce>>16&255,ce>>8&255,ce&255);this._applyMinimumContrast(x,Be,Fe,I,ge,Me)||this._addStyle(x,`color:#${dg(ce.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,Be,w.foreground,I,ge,Me)||J&&K.push("xterm-fg-257")}K.length&&(x.className=K.join(" "),K.length=0),!$&&!D&&!z&&U?k++:x.textContent=C,H!==this.defaultSpacing&&(x.style.letterSpacing=`${H}px`),b.push(x),E=re}return x&&k&&(x.textContent=C),b}_applyMinimumContrast(e,t,i,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Y1(s.getCode()))return!1;let u=this._getContrastCache(s),h;if(!o&&!a&&(h=u.getColor(t.rgba,i.rgba)),h===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=mt.ensureContrastRatio(o||t,a||i,p),u.setColor((o||t).rgba,(a||i).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Td=Et([je(1,E_),je(2,hi),je(3,xn),je(4,Pr),je(5,Eo),je(6,ms)],Td);function dg(e,t,i){for(;e.length<i;)e=t+e;return e}var G1=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[i,s,o,a],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(o),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let u=this._measure(e,0);return u>0&&(this._flat[s]=u),u}let o=e;t&&(o+="B"),i&&(o+="I");let a=this._holey.get(o);if(a===void 0){let u=0;t&&(u|=1),i&&(u|=2),a=this._measure(e,u),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Q1=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,u=i[1]-o,h=Math.max(a,0),p=Math.min(u,e.rows-1);if(h>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=u,this.viewportCappedStartRow=h,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function J1(){return new Q1}var bu="xterm-dom-renderer-owner-",Oi="xterm-rows",Ka="xterm-fg-",hg="xterm-bg-",no="xterm-focus",qa="xterm-selection",Z1=1,Ad=class extends Ge{constructor(e,t,i,s,o,a,u,h,p,f,_,b,S,w){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=u,this._charSizeService=p,this._optionsService=f,this._bufferService=_,this._coreService=b,this._coreBrowserService=S,this._themeService=w,this._terminalClass=Z1++,this._rowElements=[],this._selectionRenderModel=J1(),this.onRequestRedraw=this._register(new ke).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Oi),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(qa),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=X1(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(y=>this._injectCss(y))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(Td,document),this._element.classList.add(bu+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(y=>this._handleLinkHover(y))),this._register(this._linkifier2.onHideLinkUnderline(y=>this._handleLinkLeave(y))),this._register(_t(()=>{this._element.classList.remove(bu+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new G1(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Oi} 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} .${Oi} { 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} .${Oi} .xterm-dim { color: ${mt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Oi}.${no} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Oi}.${no} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Oi}.${no} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Oi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${qa} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${qa} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${qa} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,u]of e.ansi.entries())t+=`${this._terminalSelector} .${Ka}${a} { color: ${u.css}; }${this._terminalSelector} .${Ka}${a}.xterm-dim { color: ${mt.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${hg}${a} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${Ka}257 { color: ${mt.opaque(e.background).css}; }${this._terminalSelector} .${Ka}257.xterm-dim { color: ${mt.multiplyOpacity(mt.opaque(e.background),.5).css}; }${this._terminalSelector} .${hg}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(no),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(no),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(i){let p=e[0]>t[0];h.appendChild(this._createSelectionElement(a,p?t[0]:e[0],p?e[0]:t[0],u-a+1))}else{let p=s===a?e[0]:0,f=a===o?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(a,p,f));let _=u-a-1;if(h.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,_)),a!==u){let b=o===u?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(u,0,b))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,i,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(i-t);return a+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-a),o.style.height=`${s*this.dimensions.css.cell.height}px`,o.style.top=`${e*this.dimensions.css.cell.height}px`,o.style.left=`${a}px`,o.style.width=`${u}px`,o}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,o=Math.min(i.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let f=p+i.ydisp,_=this._rowElements[p],b=i.lines.get(f);if(!_||!b)break;_.replaceChildren(...this._rowFactory.createRow(b,f,f===s,u,h,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${bu}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,o,a){i<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;i=Math.max(Math.min(i,u),0),s=Math.max(Math.min(s,u),0),o=Math.min(o,this._bufferService.cols);let h=this._bufferService.buffer,p=h.ybase+h.y,f=Math.min(h.x,o-1),_=this._optionsService.rawOptions.cursorBlink,b=this._optionsService.rawOptions.cursorStyle,S=this._optionsService.rawOptions.cursorInactiveStyle;for(let w=i;w<=s;++w){let y=w+h.ydisp,x=this._rowElements[w],k=h.lines.get(y);if(!x||!k)break;x.replaceChildren(...this._rowFactory.createRow(k,y,y===p,b,S,f,_,this.dimensions.css.cell.width,this._widthCache,a?w===i?e:0:-1,a?(w===s?t:o)-1:-1))}}};Ad=Et([je(7,_h),je(8,xl),je(9,hi),je(10,di),je(11,Pr),je(12,xn),je(13,ms)],Ad);var Id=class extends Ge{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ke),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new tx(this._optionsService))}catch{this._measureStrategy=this._register(new ex(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())}};Id=Et([je(2,hi)],Id);var K_=class extends Ge{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)}},ex=class extends K_{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},tx=class extends K_{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}},ix=class extends Ge{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new nx(this._window)),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ke),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Zt.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ue(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ue(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},nx=class extends Ge{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new hs),this._onDprChange=this._register(new ke),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_t(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ue(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},rx=class extends Ge{constructor(){super(),this.linkProviders=[],this._register(_t(()=>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 Eh(e,t,i){let s=i.getBoundingClientRect(),o=e.getComputedStyle(i),a=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-u]}function sx(e,t,i,s,o,a,u,h,p){if(!a)return;let f=Eh(e,t,i);if(f)return f[0]=Math.ceil((f[0]+(p?u/2:0))/u),f[1]=Math.ceil(f[1]/h),f[0]=Math.min(Math.max(f[0],1),s+(p?1:0)),f[1]=Math.min(Math.max(f[1],1),o),f}var Bd=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,o){return sx(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let i=Eh(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};Bd=Et([je(0,Cn),je(1,xl)],Bd);var ox=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},q_={};gb(q_,{getSafariVersion:()=>lx,isChromeOS:()=>G_,isFirefox:()=>V_,isIpad:()=>cx,isIphone:()=>ux,isLegacyEdge:()=>ax,isLinux:()=>Nh,isMac:()=>ml,isNode:()=>Cl,isSafari:()=>Y_,isWindows:()=>X_});var Cl=typeof process<"u"&&"title"in process,No=Cl?"node":navigator.userAgent,Ro=Cl?"node":navigator.platform,V_=No.includes("Firefox"),ax=No.includes("Edge"),Y_=/^((?!chrome|android).)*safari/i.test(No);function lx(){if(!Y_)return 0;let e=No.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ml=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ro),cx=Ro==="iPad",ux=Ro==="iPhone",X_=["Windows","Win16","Win32","WinCE"].includes(Ro),Nh=Ro.indexOf("Linux")>=0,G_=/\bCrOS\b/.test(No),Q_=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),o=e.timeRemaining(),i*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},dx=class extends Q_{_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())}}},hx=class extends Q_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},gl=!Cl&&"requestIdleCallback"in window?hx:dx,fx=class{constructor(){this._queue=new gl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Od=class extends Ge{constructor(e,t,i,s,o,a,u,h,p){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=o,this._coreBrowserService=h,this._renderer=this._register(new hs),this._pausedResizeTask=new fx,this._observerDisposable=this._register(new hs),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 ke),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ke),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ke),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new ox((f,_)=>this._renderRows(f,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new px(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_t(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var f;return(f=this._renderer.value)==null?void 0:f.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=_t(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Od=Et([je(2,hi),je(3,xl),je(4,Pr),je(5,Eo),je(6,di),je(7,xn),je(8,ms)],Od);var px=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function mx(e,t,i,s){let o=i.buffer.x,a=i.buffer.y;if(!i.buffer.hasScrollback)return _x(o,a,e,t,i,s)+kl(a,t,i,s)+yx(o,a,e,t,i,s);let u;if(a===t)return u=o>e?"D":"C",So(Math.abs(o-e),wo(u,s));u=a>t?"D":"C";let h=Math.abs(a-t),p=vx(a>t?e:o,i)+(h-1)*i.cols+1+gx(a>t?o:e);return So(p,wo(u,s))}function gx(e,t){return e-1}function vx(e,t){return t.cols-e}function _x(e,t,i,s,o,a){return kl(t,s,o,a).length===0?"":So(Z_(e,t,e,t-Nr(t,o),!1,o).length,wo("D",a))}function kl(e,t,i,s){let o=e-Nr(e,i),a=t-Nr(t,i),u=Math.abs(o-a)-wx(e,t,i);return So(u,wo(J_(e,t),s))}function yx(e,t,i,s,o,a){let u;kl(t,s,o,a).length>0?u=s-Nr(s,o):u=t;let h=s,p=Sx(e,t,i,s,o,a);return So(Z_(e,u,i,h,p==="C",o).length,wo(p,a))}function wx(e,t,i){var u;let s=0,o=e-Nr(e,i),a=t-Nr(t,i);for(let h=0;h<Math.abs(o-a);h++){let p=J_(e,t)==="A"?-1:1;(u=i.buffer.lines.get(o+p*h))!=null&&u.isWrapped&&s++}return s}function Nr(e,t){let i=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return i}function Sx(e,t,i,s,o,a){let u;return kl(i,s,o,a).length>0?u=s-Nr(s,o):u=t,e<i&&u<=s||e>=i&&u<s?"C":"D"}function J_(e,t){return e>t?"A":"B"}function Z_(e,t,i,s,o,a){let u=e,h=t,p="";for(;(u!==i||h!==s)&&h>=0&&h<a.buffer.lines.length;)u+=o?1:-1,o&&u>a.cols-1?(p+=a.buffer.translateBufferLineToString(h,!1,e,u),u=0,e=0,h++):!o&&u<0&&(p+=a.buffer.translateBufferLineToString(h,!1,0,e+1),u=a.cols-1,e=u,h--);return p+a.buffer.translateBufferLineToString(h,!1,e,u)}function wo(e,t){let i=t?"O":"[";return pe.ESC+i+e}function So(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var bx=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 fg(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 xu=50,xx=15,Cx=50,kx=500,Ex=" ",Nx=new RegExp(Ex,"g"),zd=class extends Ge{constructor(e,t,i,s,o,a,u,h,p){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=o,this._mouseService=a,this._optionsService=u,this._renderService=h,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new $i,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ke),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ke),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ke),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new bx(this._bufferService),this._activeSelectionMode=0,this._register(_t(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let h=i.translateBufferLineToString(u,!0,o,a);s.push(h)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let u=i.lines.get(a),h=i.translateBufferLineToString(a,!0);u!=null&&u.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let a=i.lines.get(t[1]),u=i.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(Nx," ")).join(X_?`\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())),Nh&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let i=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=fg(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Eh(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-xu),xu),t/=xu,t/Math.abs(t)+Math.round(t*(xx-1)))}shouldForceSelection(e){return ml?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(),Cx)}_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&&!(ml&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<kx&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=mx(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:o>1&&t!==s&&(i+=o-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let u=o.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(a,e[0]),p=h,f=e[0]-h,_=0,b=0,S=0,w=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let k=e[0],C=e[0];a.getWidth(k)===0&&(_++,k--),a.getWidth(C)===2&&(b++,C++);let P=a.getString(C).length;for(P>1&&(w+=P-1,p+=P-1);k>0&&h>0&&!this._isCharWordSeparator(a.loadCell(k-1,this._workCell));){a.loadCell(k-1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,k--):A>1&&(S+=A-1,h-=A-1),h--,k--}for(;C<a.length&&p+1<u.length&&!this._isCharWordSeparator(a.loadCell(C+1,this._workCell));){a.loadCell(C+1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===2?(b++,C++):A>1&&(w+=A-1,p+=A-1),p++,C++}}p++;let y=h+f-_+S,x=Math.min(this._bufferService.cols,p-h+_+b-S-w);if(!(!t&&u.slice(h,p).trim()==="")){if(i&&y===0&&a.getCodePoint(0)!==32){let k=o.lines.get(e[1]-1);if(k&&a.isWrapped&&k.getCodePoint(this._bufferService.cols-1)!==32){let C=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(C){let P=this._bufferService.cols-C.start;y-=P,x+=P}}}if(s&&y+x===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let k=o.lines.get(e[1]+1);if(k!=null&&k.isWrapped&&k.getCodePoint(0)!==32){let C=this._getWordAt([0,e[1]+1],!1,!1,!0);C&&(x+=C.length)}}return{start:y,length:x}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=fg(i,this._bufferService.cols)}};zd=Et([je(3,di),je(4,Pr),je(5,yh),je(6,hi),je(7,Cn),je(8,xn)],zd);var pg=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},mg=class{constructor(){this._color=new pg,this._css=new pg}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},It=Object.freeze((()=>{let e=[bt.toColor("#2e3436"),bt.toColor("#cc0000"),bt.toColor("#4e9a06"),bt.toColor("#c4a000"),bt.toColor("#3465a4"),bt.toColor("#75507b"),bt.toColor("#06989a"),bt.toColor("#d3d7cf"),bt.toColor("#555753"),bt.toColor("#ef2929"),bt.toColor("#8ae234"),bt.toColor("#fce94f"),bt.toColor("#729fcf"),bt.toColor("#ad7fa8"),bt.toColor("#34e2e2"),bt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],o=t[i/6%6|0],a=t[i%6];e.push({css:Mt.toCss(s,o,a),rgba:Mt.toRgba(s,o,a)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:Mt.toCss(s,s,s),rgba:Mt.toRgba(s,s,s)})}return e})()),_r=bt.toColor("#ffffff"),po=bt.toColor("#000000"),gg=bt.toColor("#ffffff"),vg=po,ro={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Rx=_r,Fd=class extends Ge{constructor(e){super(),this._optionsService=e,this._contrastCache=new mg,this._halfContrastCache=new mg,this._onChangeColors=this._register(new ke),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:_r,background:po,cursor:gg,cursorAccent:vg,selectionForeground:void 0,selectionBackgroundTransparent:ro,selectionBackgroundOpaque:mt.blend(po,ro),selectionInactiveBackgroundTransparent:ro,selectionInactiveBackgroundOpaque:mt.blend(po,ro),scrollbarSliderBackground:mt.opacity(_r,.2),scrollbarSliderHoverBackground:mt.opacity(_r,.4),scrollbarSliderActiveBackground:mt.opacity(_r,.5),overviewRulerBorder:_r,ansi:It.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=at(e.foreground,_r),t.background=at(e.background,po),t.cursor=mt.blend(t.background,at(e.cursor,gg)),t.cursorAccent=mt.blend(t.background,at(e.cursorAccent,vg)),t.selectionBackgroundTransparent=at(e.selectionBackground,ro),t.selectionBackgroundOpaque=mt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=at(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=mt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?at(e.selectionForeground,ug):void 0,t.selectionForeground===ug&&(t.selectionForeground=void 0),mt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=mt.opacity(t.selectionBackgroundTransparent,.3)),mt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=mt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=at(e.scrollbarSliderBackground,mt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=at(e.scrollbarSliderHoverBackground,mt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=at(e.scrollbarSliderActiveBackground,mt.opacity(t.foreground,.5)),t.overviewRulerBorder=at(e.overviewRulerBorder,Rx),t.ansi=It.slice(),t.ansi[0]=at(e.black,It[0]),t.ansi[1]=at(e.red,It[1]),t.ansi[2]=at(e.green,It[2]),t.ansi[3]=at(e.yellow,It[3]),t.ansi[4]=at(e.blue,It[4]),t.ansi[5]=at(e.magenta,It[5]),t.ansi[6]=at(e.cyan,It[6]),t.ansi[7]=at(e.white,It[7]),t.ansi[8]=at(e.brightBlack,It[8]),t.ansi[9]=at(e.brightRed,It[9]),t.ansi[10]=at(e.brightGreen,It[10]),t.ansi[11]=at(e.brightYellow,It[11]),t.ansi[12]=at(e.brightBlue,It[12]),t.ansi[13]=at(e.brightMagenta,It[13]),t.ansi[14]=at(e.brightCyan,It[14]),t.ansi[15]=at(e.brightWhite,It[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=at(e.extendedAnsi[s],It[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()}}};Fd=Et([je(0,hi)],Fd);function at(e,t){if(e!==void 0)try{return bt.toColor(e)}catch{}return t}var Px=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},jx=class{constructor(){this._services=new Px,this._services.set(_h,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=xb(e).sort((a,u)=>a.index-u.index),s=[];for(let a of i){let u=this._services.get(a.id);if(!u)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${a.id._id}.`);s.push(u)}let o=i.length>0?i[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},Dx={trace:0,debug:1,info:2,warn:3,error:4,off:5},Lx="xterm.js: ",$d=class extends Ge{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=Dx[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":Lx)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};$d=Et([je(0,hi)],$d);var _g=class extends Ge{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ke),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ke),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ke),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let o=t-1;o>=0;o--)this.set(e+o+i,this.get(e+o));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Xe=3,Lt=Object.freeze(new ko),Va=0,Cu=2,mo=class ey{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Xe);let o=i||$i.fromCharData([0,y_,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let i=this._data[t*Xe+0],s=i&2097151;return[this._data[t*Xe+1],i&2097152?this._combined[t]:s?Yn(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Xe+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Xe+0]=t|2097152|i[2]<<22):this._data[t*Xe+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Xe+0]>>22}hasWidth(t){return this._data[t*Xe+0]&12582912}getFg(t){return this._data[t*Xe+1]}getBg(t){return this._data[t*Xe+2]}hasContent(t){return this._data[t*Xe+0]&4194303}getCodePoint(t){let i=this._data[t*Xe+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Xe+0]&2097152}getString(t){let i=this._data[t*Xe+0];return i&2097152?this._combined[t]:i&2097151?Yn(i&2097151):""}isProtected(t){return this._data[t*Xe+2]&536870912}loadCell(t,i){return Va=t*Xe,i.content=this._data[Va+0],i.fg=this._data[Va+1],i.bg=this._data[Va+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Xe+0]=i.content,this._data[t*Xe+1]=i.fg,this._data[t*Xe+2]=i.bg}setCellFromCodepoint(t,i,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*Xe+0]=i|s<<22,this._data[t*Xe+1]=o.fg,this._data[t*Xe+2]=o.bg}addCodepointToCell(t,i,s){let o=this._data[t*Xe+0];o&2097152?this._combined[t]+=Yn(i):o&2097151?(this._combined[t]=Yn(o&2097151)+Yn(i),o&=-2097152,o|=2097152):o=i|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*Xe+0]=o}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let o=new $i;for(let a=this.length-t-i-1;a>=0;--a)this.setCell(t+i+a,this.loadCell(t+a,o));for(let a=0;a<i;++a)this.setCell(t+a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let o=new $i;for(let a=0;a<this.length-t-i;++a)this.setCell(t+a,this.loadCell(t+i+a,o));for(let a=this.length-i;a<this.length;++a)this.setCell(a,s)}else for(let o=t;o<this.length;++o)this.setCell(o,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Cu<this._data.buffer.byteLength;let s=t*Xe;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,i)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let u=0;u<o.length;u++){let h=parseInt(o[u],10);h>=t&&delete this._combined[h]}let a=Object.keys(this._extendedAttrs);for(let u=0;u<a.length;u++){let h=parseInt(a[u],10);h>=t&&delete this._extendedAttrs[h]}}return this.length=t,s*4*Cu<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Cu<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new ey(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Xe+0]&4194303)return t+(this._data[t*Xe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Xe+0]&4194303||this._data[t*Xe+2]&50331648)return t+(this._data[t*Xe+0]>>22);return 0}copyCellsFrom(t,i,s,o,a){let u=t._data;if(a)for(let p=o-1;p>=0;p--){for(let f=0;f<Xe;f++)this._data[(s+p)*Xe+f]=u[(i+p)*Xe+f];u[(i+p)*Xe+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[i+p])}else for(let p=0;p<o;p++){for(let f=0;f<Xe;f++)this._data[(s+p)*Xe+f]=u[(i+p)*Xe+f];u[(i+p)*Xe+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[i+p])}let h=Object.keys(t._combined);for(let p=0;p<h.length;p++){let f=parseInt(h[p],10);f>=i&&(this._combined[f-i+s]=t._combined[f])}}translateToString(t,i,s,o){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;i<s;){let u=this._data[i*Xe+0],h=u&2097151,p=u&2097152?this._combined[i]:h?Yn(h):Qn;if(a+=p,o)for(let f=0;f<p.length;++f)o.push(i);i+=u>>22||1}return o&&o.push(i),a}};function Mx(e,t,i,s,o,a){let u=[];for(let h=0;h<e.length-1;h++){let p=h,f=e.get(++p);if(!f.isWrapped)continue;let _=[e.get(h)];for(;p<e.length&&f.isWrapped;)_.push(f),f=e.get(++p);if(!a&&s>=h&&s<p){h+=_.length-1;continue}let b=0,S=bo(_,b,t),w=1,y=0;for(;w<_.length;){let k=bo(_,w,t),C=k-y,P=i-S,A=Math.min(C,P);_[b].copyCellsFrom(_[w],y,S,A,!1),S+=A,S===i&&(b++,S=0),y+=A,y===k&&(w++,y=0),S===0&&b!==0&&_[b-1].getWidth(i-1)===2&&(_[b].copyCellsFrom(_[b-1],i-1,S++,1,!1),_[b-1].setCell(i-1,o))}_[b].replaceCells(S,i,o);let x=0;for(let k=_.length-1;k>0&&(k>b||_[k].getTrimmedLength()===0);k--)x++;x>0&&(u.push(h+_.length-x),u.push(x)),h+=_.length-1}return u}function Tx(e,t){let i=[],s=0,o=t[s],a=0;for(let u=0;u<e.length;u++)if(o===u){let h=t[++s];e.onDeleteEmitter.fire({index:u-a,amount:h}),u+=h-1,a+=h,o=t[++s]}else i.push(u);return{layout:i,countRemoved:a}}function Ax(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function Ix(e,t,i){let s=[],o=e.map((p,f)=>bo(e,f,t)).reduce((p,f)=>p+f),a=0,u=0,h=0;for(;h<o;){if(o-h<i){s.push(o-h);break}a+=i;let p=bo(e,u,t);a>p&&(a-=p,u++);let f=e[u].getWidth(a-1)===2;f&&a--;let _=f?i-1:i;s.push(_),h+=_}return s}function bo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?i-1:i}var ty=class iy{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=iy._nextId++,this._onDispose=this.register(new ke),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Er(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ty._nextId=1;var Bx=ty,Ot={},yr=Ot.B;Ot[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ot.A={"#":"£"};Ot.B=void 0;Ot[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ot.C=Ot[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ot.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ot.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ot.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ot.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ot.E=Ot[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ot.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ot.H=Ot[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ot["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var yg=4294967295,wg=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Lt.clone(),this.savedCharset=yr,this.markers=[],this._nullCell=$i.fromCharData([0,y_,1,0]),this._whitespaceCell=$i.fromCharData([0,Qn,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new gl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new _g(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 hl),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 hl),this._whitespaceCell}getBlankLine(e,t){return new mo(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>yg?yg:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Lt);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 _g(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Lt),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 u=0;u<this.lines.length;u++)s+=+this.lines.get(u).resize(e,i);let a=0;if(this._rows<t)for(let u=this._rows;u<t;u++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new mo(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new mo(e,i)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=Mx(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Lt),i);if(s.length>0){let o=Tx(this.lines,s);Ax(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Lt),o=i;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new mo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Lt),o=[],a=0;for(let u=this.lines.length-1;u>=0;u--){let h=this.lines.get(u);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let p=[h];for(;h.isWrapped&&u>0;)h=this.lines.get(--u),p.unshift(h);if(!i){let A=this.ybase+this.y;if(A>=u&&A<u+p.length)continue}let f=p[p.length-1].getTrimmedLength(),_=Ix(p,this._cols,e),b=_.length-p.length,S;this.ybase===0&&this.y!==this.lines.length-1?S=Math.max(0,this.y-this.lines.maxLength+b):S=Math.max(0,this.lines.length-this.lines.maxLength+b);let w=[];for(let A=0;A<b;A++){let M=this.getBlankLine(Lt,!0);w.push(M)}w.length>0&&(o.push({start:u+p.length+a,newLines:w}),a+=w.length),p.push(...w);let y=_.length-1,x=_[y];x===0&&(y--,x=_[y]);let k=p.length-b-1,C=f;for(;k>=0;){let A=Math.min(C,x);if(p[y]===void 0)break;if(p[y].copyCellsFrom(p[k],C-A,x-A,A,!0),x-=A,x===0&&(y--,x=_[y]),C-=A,C===0){k--;let M=Math.max(k,0);C=bo(p,M,this._cols)}}for(let A=0;A<p.length;A++)_[A]<e&&p[A].setCell(_[A],s);let P=b-S;for(;P-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+b,this.ybase+t-1)}if(o.length>0){let u=[],h=[];for(let x=0;x<this.lines.length;x++)h.push(this.lines.get(x));let p=this.lines.length,f=p-1,_=0,b=o[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let S=0;for(let x=Math.min(this.lines.maxLength-1,p+a-1);x>=0;x--)if(b&&b.start>f+S){for(let k=b.newLines.length-1;k>=0;k--)this.lines.set(x--,b.newLines[k]);x++,u.push({index:f+1,amount:b.newLines.length}),S+=b.newLines.length,b=o[++_]}else this.lines.set(x,h[f--]);let w=0;for(let x=u.length-1;x>=0;x--)u[x].index+=w,this.lines.onInsertEmitter.fire(u[x]),w+=u[x].amount;let y=Math.max(0,p+a-this.lines.maxLength);y>0&&this.lines.onTrimEmitter.fire(y)}}translateBufferLineToString(e,t,i=0,s){let o=this.lines.get(e);return o?o.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new Bx(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Ox=class extends Ge{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ke),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 wg(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new wg(!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)}},ny=2,ry=1,Hd=class extends Ge{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,ny),this.rows=Math.max(e.rawOptions.rows||0,ry),this.buffers=this._register(new Ox(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=i.ybase+i.scrollTop,a=i.ybase+i.scrollBottom;if(i.scrollTop===0){let u=i.lines.isFull;a===i.lines.length-1?u?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(a+1,0,s.clone()),u?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let u=a-o+1;i.lines.shiftElements(o+1,u-1,-1),i.lines.set(a,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Hd=Et([je(0,hi)],Hd);var is={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:ml,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},zx=["normal","bold","100","200","300","400","500","600","700","800","900"],Fx=class extends Ge{constructor(e){super(),this._onOptionChange=this._register(new ke),this.onOptionChange=this._onOptionChange.event;let t={...is};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(_t(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in is))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in is))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=is[e]),!$x(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=is[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=zx.includes(t)?t:is[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 $x(e){return e==="block"||e==="underline"||e==="bar"}function go(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&go(e[s],t-1);return i}var Sg=Object.freeze({insertMode:!1}),bg=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Wd=class extends Ge{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new ke),this.onData=this._onData.event,this._onUserInput=this._register(new ke),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ke),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=go(Sg),this.decPrivateModes=go(bg)}reset(){this.modes=go(Sg),this.decPrivateModes=go(bg)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Wd=Et([je(0,di),je(1,C_),je(2,hi)],Wd);var xg={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 ku(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var Eu=String.fromCharCode,Cg={DEFAULT:e=>{let t=[ku(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Eu(t[0])}${Eu(t[1])}${Eu(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ku(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ku(e,!0)};${e.x};${e.y}${t}`}},Ud=class extends Ge{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new ke),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(xg))this.addProtocol(s,xg[s]);for(let s of Object.keys(Cg))this.addEncoding(s,Cg[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Ud=Et([je(0,di),je(1,Pr),je(2,hi)],Ud);var Nu=[[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]],Hx=[[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]],Bt;function Wx(e,t){let i=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(o=i+s>>1,e>t[o][1])i=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var Ux=class{constructor(){if(this.version="6",!Bt){Bt=new Uint8Array(65536),Bt.fill(1),Bt[0]=0,Bt.fill(0,1,32),Bt.fill(0,127,160),Bt.fill(2,4352,4448),Bt[9001]=2,Bt[9002]=2,Bt.fill(2,11904,42192),Bt[12351]=1,Bt.fill(2,44032,55204),Bt.fill(2,63744,64256),Bt.fill(2,65040,65050),Bt.fill(2,65072,65136),Bt.fill(2,65280,65377),Bt.fill(2,65504,65511);for(let e=0;e<Nu.length;++e)Bt.fill(0,Nu[e][0],Nu[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Bt[e]:Wx(e,Hx)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let o=br.extractWidth(t);o===0?s=!1:o>i&&(i=o)}return br.createPropertyValue(0,i,s)}},br=class nl{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ke,this.onChange=this._onChange.event;let t=new Ux;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,o=t.length;for(let a=0;a<o;++a){let u=t.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=o)return i+this.wcwidth(u);let f=t.charCodeAt(a);56320<=f&&f<=57343?u=(u-55296)*1024+f-56320+65536:i+=this.wcwidth(f)}let h=this.charProperties(u,s),p=nl.extractWidth(h);nl.extractShouldJoin(h)&&(p-=nl.extractWidth(s)),i+=p,s=h}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Kx=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 kg(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var so=2147483647,qx=256,sy=class Kd{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>qx)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Kd;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)i.addSubParam(o[a]);else i.addParam(o)}return i}clone(){let t=new Kd(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>so?so: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>so?so:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,o=this._subParamsIdx[i]&255;o-s>0&&(t[i]=this._subParams.slice(s,o))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[i-1];s[i-1]=~o?Math.min(o*10+t,so):t}},oo=[],Vx=class{constructor(){this._state=0,this._active=oo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=oo}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=oo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||oo,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",bl(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=oo,this._id=-1,this._state=0}}},Ni=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=bl(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},ao=[],Yx=class{constructor(){this._handlers=Object.create(null),this._active=ao,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ao}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=ao,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ao,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",bl(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=ao,this._ident=0}},vo=new sy;vo.addParam(0);var Eg=class{constructor(e){this._handler=e,this._data="",this._params=vo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():vo,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=bl(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=vo,this._data="",this._hitLimit=!1,i));return this._params=vo,this._data="",this._hitLimit=!1,t}},Xx=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=i<<4|s}},Fi=160,Gx=(function(){let e=new Xx(4095),t=Array.apply(null,Array(256)).map((h,p)=>p),i=(h,p)=>t.slice(h,p),s=i(32,127),o=i(0,24);o.push(25),o.push.apply(o,i(28,32));let a=i(0,14),u;e.setDefault(1,0),e.addMany(s,0,2,0);for(u in a)e.addMany([24,26,153,154],u,3,0),e.addMany(i(128,144),u,3,0),e.addMany(i(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Fi,0,2,0),e.add(Fi,8,5,8),e.add(Fi,6,0,6),e.add(Fi,11,0,11),e.add(Fi,13,13,13),e})(),Qx=class extends Ge{constructor(e=Gx){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 sy,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(_t(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Vx),this._dcsParser=this._register(new Yx),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,i){let s=0,o=0,a=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&p>-1){for(;p>=0&&(u=h[p](this._params),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 4:if(i===!1&&p>-1){for(;p>=0&&(u=h[p](),u!==!0);p--)if(u instanceof Promise)return this._parseStack.handlerPos=p,u}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(s!==24&&s!==26,i),u)return u;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],u=this._oscParser.end(s!==24&&s!==26,i),u)return u;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=a;h<t;++h){switch(s=e[h],o=this._transitions.table[this.currentState<<8|(s<160?s:Fi)],o>>4){case 2:for(let S=h+1;;++S){if(S>=t||(s=e[S])<32||s>126&&s<Fi){this._printHandler(e,h,S),h=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Fi){this._printHandler(e,h,S),h=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Fi){this._printHandler(e,h,S),h=S-1;break}if(++S>=t||(s=e[S])<32||s>126&&s<Fi){this._printHandler(e,h,S),h=S-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,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],f=p?p.length-1:-1;for(;f>=0&&(u=p[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._preserveStack(3,p,f,o,h),u;f<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let _=this._escHandlers[this._collect<<8|s],b=_?_.length-1:-1;for(;b>=0&&(u=_[b](),u!==!0);b--)if(u instanceof Promise)return this._preserveStack(4,_,b,o,h),u;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 S=h+1;;++S)if(S>=t||(s=e[S])===24||s===26||s===27||s>127&&s<Fi){this._dcsParser.put(e,h,S),h=S-1;break}break;case 14:if(u=this._dcsParser.unhook(s!==24&&s!==26),u)return this._preserveStack(6,[],0,o,h),u;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 S=h+1;;S++)if(S>=t||(s=e[S])<32||s>127&&s<Fi){this._oscParser.put(e,h,S),h=S-1;break}break;case 6:if(u=this._oscParser.end(s!==24&&s!==26),u)return this._preserveStack(5,[],0,o,h),u;s===27&&(o|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=o&15}}},Jx=/^([\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})$/,Zx=/^[\da-f]+$/;function Ng(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=Jx.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Zx.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(i*o,i*o+i),16);s[o]=i===1?a<<4:i===2?a:i===3?a>>4:a>>8}return s}}function Ru(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function eC(e,t=16){let[i,s,o]=e;return`rgb:${Ru(i,t)}/${Ru(s,t)}/${Ru(o,t)}`}var tC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},qn=131072,Rg=10;function Pg(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 jg=5e3,Dg=0,iC=class extends Ge{constructor(e,t,i,s,o,a,u,h,p=new Qx){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=o,this._oscLinkService=a,this._coreMouseService=u,this._unicodeService=h,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Sb,this._utf8Decoder=new bb,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Lt.clone(),this._eraseAttrDataInternal=Lt.clone(),this._onRequestBell=this._register(new ke),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ke),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ke),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ke),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ke),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ke),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ke),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ke),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ke),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ke),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 qd(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:_.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,_,b)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:_,data:b})}),this._parser.setDcsHandlerFallback((f,_,b)=>{_==="HOOK"&&(b=b.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:_,payload:b})}),this._parser.setPrintHandler((f,_,b)=>this.print(f,_,b)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(pe.BEL,()=>this.bell()),this._parser.setExecuteHandler(pe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(pe.BS,()=>this.backspace()),this._parser.setExecuteHandler(pe.HT,()=>this.tab()),this._parser.setExecuteHandler(pe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(pe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(tl.IND,()=>this.index()),this._parser.setExecuteHandler(tl.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(tl.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ni(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Ni(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Ni(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Ni(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Ni(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Ni(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Ni(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Ni(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Ni(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Ni(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Ni(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Ni(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Ot)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Eg((f,_)=>this.requestStatusString(f,_)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),jg))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${jg} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,u=this._parseStack.paused;if(u){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>qn&&(a=this._parseStack.position+qn)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<qn&&(this._parseBuffer=new Uint32Array(Math.min(e.length,qn))),u||this._dirtyRowTracker.clearRange(),e.length>qn)for(let f=a;f<e.length;f+=qn){let _=f+qn<e.length?f+qn:e.length,b=typeof e=="string"?this._stringDecoder.decode(e.substring(f,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,_),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,b))return this._preserveStack(s,o,b,f),this._logSlowResolvingAsync(i),i}else if(!u){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,o,f,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let h=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(h,this._bufferService.rows-1)})}print(e,t,i){let s,o,a=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,_=this._curAttrData,b=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&b.getWidth(this._activeBuffer.x-1)===2&&b.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let S=this._parser.precedingJoinState;for(let w=t;w<i;++w){if(s=e[w],s<127&&a){let C=a[String.fromCharCode(s)];C&&(s=C.charCodeAt(0))}let y=this._unicodeService.charProperties(s,S);o=br.extractWidth(y);let x=br.extractShouldJoin(y),k=x?br.extractWidth(S):0;if(S=y,u&&this._onA11yChar.fire(Yn(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-k>h){if(p){let C=b,P=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 mo&&b.copyCellsFrom(C,P,0,k,!1);P<h;)C.setCellFromCodepoint(P++,0,1,_)}else if(this._activeBuffer.x=h-1,o===2)continue}if(x&&this._activeBuffer.x){let C=b.getWidth(this._activeBuffer.x-1)?1:2;b.addCodepointToCell(this._activeBuffer.x-C,s,o);for(let P=o-k;--P>=0;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(f&&(b.insertCells(this._activeBuffer.x,o-k,this._activeBuffer.getNullCell(_)),b.getWidth(h-1)===2&&b.setCellFromCodepoint(h-1,0,1,_)),b.setCellFromCodepoint(this._activeBuffer.x++,s,o,_),o>0)for(;--o;)b.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=S,this._activeBuffer.x<h&&i-t>0&&b.getWidth(this._activeBuffer.x)===0&&!b.hasContent(this._activeBuffer.x)&&b.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Pg(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Eg(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ni(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Lt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=br.extractWidth(t),o=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(o),u=new Uint32Array(a.length*i),h=0;for(let f=0;f<a.length;){let _=a.codePointAt(f)||0;u[h++]=_,f+=_>65535?2:1}let p=h;for(let f=1;f<i;++f)u.copyWithin(p,0,h),p+=h;return this.print(u,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(pe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(pe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(pe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(pe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(pe.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,yr),this._charsetService.setgCharset(1,yr),this._charsetService.setgCharset(2,yr),this._charsetService.setgCharset(3,yr);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(x=>(x[x.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",x[x.SET=1]="SET",x[x.RESET=2]="RESET",x[x.PERMANENTLY_SET=3]="PERMANENTLY_SET",x[x.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,u=this._coreService,{buffers:h,cols:p}=this._bufferService,{active:f,alt:_}=h,b=this._optionsService.rawOptions,S=(x,k)=>(u.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${x};${k}$y`),!0),w=x=>x?1:2,y=e.params[0];return t?y===2?S(y,4):y===4?S(y,w(u.modes.insertMode)):y===12?S(y,3):y===20?S(y,w(b.convertEol)):S(y,0):y===1?S(y,w(s.applicationCursorKeys)):y===3?S(y,b.windowOptions.setWinLines?p===80?2:p===132?1:0:0):y===6?S(y,w(s.origin)):y===7?S(y,w(s.wraparound)):y===8?S(y,3):y===9?S(y,w(o==="X10")):y===12?S(y,w(b.cursorBlink)):y===25?S(y,w(!u.isCursorHidden)):y===45?S(y,w(s.reverseWraparound)):y===66?S(y,w(s.applicationKeypad)):y===67?S(y,4):y===1e3?S(y,w(o==="VT200")):y===1002?S(y,w(o==="DRAG")):y===1003?S(y,w(o==="ANY")):y===1004?S(y,w(s.sendFocus)):y===1005?S(y,4):y===1006?S(y,w(a==="SGR")):y===1015?S(y,4):y===1016?S(y,w(a==="SGR_PIXELS")):y===1048?S(y,1):y===47||y===1047||y===1049?S(y,w(f===_)):y===2004?S(y,w(s.bracketedPasteMode)):y===2026?S(y,w(s.synchronizedOutput)):S(y,0)}_updateAttrColor(e,t,i,s,o){return t===2?(e|=50331648,e&=-16777216,e|=ko.fromColorRGB([i,s,o])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],o=0,a=0;do{if(s[a+o]=e.params[t+a],e.hasSubParams(t+a)){let u=e.getSubParams(t+a),h=0;do s[1]===5&&(o=1),s[a+h+1+o]=u[h];while(++h<u.length&&h+a+1+o<s.length);break}if(s[1]===5&&a+o>=2||s[1]===2&&a+o>=5)break;s[1]&&(o=1)}while(++a+t<e.length&&a+o<s.length);for(let u=2;u<s.length;++u)s[u]===-1&&(s[u]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Lt.fg,e.bg=Lt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let o=0;o<t;o++)i=e.params[o],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Lt.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Lt.bg&16777215):i===38||i===48||i===58?o+=this._extractColor(e,o,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Lt.fg&16777215,s.bg&=-67108864,s.bg|=Lt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${pe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Lt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Pg(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${pe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Rg&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Rg&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),o=i.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(Lg(a))if(o==="?")t.push({type:0,index:a});else{let u=Ng(o);u&&t.push({type:1,index:a,color:u})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,o=i.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=i[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=Ng(i[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let o=parseInt(i[s]);Lg(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,yr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(tC[e[0]],Ot[e[1]]||yr),!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=Lt.clone(),this._eraseAttrDataInternal=Lt.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 $i;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=u=>(this._coreService.triggerDataEvent(`${pe.ESC}${u}${pe.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},qd=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&&(Dg=e,e=t,t=Dg),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};qd=Et([je(0,di)],qd);function Lg(e){return 0<=e&&e<256}var nC=5e7,Mg=12,rC=50,sC=class extends Ge{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 ke),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>nC)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=h=>performance.now()-i>=Mg?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(i,h);o.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(u);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Mg)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>rC&&(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()}},Vd=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 h=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(p,h)),this._dataByLinkId.set(p.id,p),p.id}let i=e,s=this._getEntryIdKey(i),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(u,a)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Vd=Et([je(0,di)],Vd);var Tg=!1,oC=class extends Ge{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new hs),this._onBinary=this._register(new ke),this.onBinary=this._onBinary.event,this._onData=this._register(new ke),this.onData=this._onData.event,this._onLineFeed=this._register(new ke),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ke),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ke),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ke),this._instantiationService=new jx,this.optionsService=this._register(new Fx(e)),this._instantiationService.setService(hi,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Hd)),this._instantiationService.setService(di,this._bufferService),this._logService=this._register(this._instantiationService.createInstance($d)),this._instantiationService.setService(C_,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Wd)),this._instantiationService.setService(Pr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ud)),this._instantiationService.setService(x_,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(br)),this._instantiationService.setService(Eb,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Kx),this._instantiationService.setService(kb,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Vd),this._instantiationService.setService(k_,this._oscLinkService),this._inputHandler=this._register(new iC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Zt.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Zt.forward(this._bufferService.onResize,this._onResize)),this._register(Zt.forward(this.coreService.onData,this._onData)),this._register(Zt.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 sC((t,i)=>this._inputHandler.parse(t,i))),this._register(Zt.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ke),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&&!Tg&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Tg=!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,ny),t=Math.max(t,ry),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(kg.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(kg(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_t(()=>{for(let t of e)t.dispose()})}}},aC={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 lC(e,t,i,s){var u;let o={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=pe.ESC+"OB":o.key=pe.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":pe.DEL,e.altKey&&(o.key=pe.ESC+o.key);break;case 9:if(e.shiftKey){o.key=pe.ESC+"[Z";break}o.key=pe.HT,o.cancel=!0;break;case 13:o.key=e.altKey?pe.ESC+pe.CR:pe.CR,o.cancel=!0;break;case 27:o.key=pe.ESC,e.altKey&&(o.key=pe.ESC+pe.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=pe.ESC+"[1;"+(a+1)+"D":t?o.key=pe.ESC+"OD":o.key=pe.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=pe.ESC+"[1;"+(a+1)+"C":t?o.key=pe.ESC+"OC":o.key=pe.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=pe.ESC+"[1;"+(a+1)+"A":t?o.key=pe.ESC+"OA":o.key=pe.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=pe.ESC+"[1;"+(a+1)+"B":t?o.key=pe.ESC+"OB":o.key=pe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=pe.ESC+"[2~");break;case 46:a?o.key=pe.ESC+"[3;"+(a+1)+"~":o.key=pe.ESC+"[3~";break;case 36:a?o.key=pe.ESC+"[1;"+(a+1)+"H":t?o.key=pe.ESC+"OH":o.key=pe.ESC+"[H";break;case 35:a?o.key=pe.ESC+"[1;"+(a+1)+"F":t?o.key=pe.ESC+"OF":o.key=pe.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=pe.ESC+"[5;"+(a+1)+"~":o.key=pe.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=pe.ESC+"[6;"+(a+1)+"~":o.key=pe.ESC+"[6~";break;case 112:a?o.key=pe.ESC+"[1;"+(a+1)+"P":o.key=pe.ESC+"OP";break;case 113:a?o.key=pe.ESC+"[1;"+(a+1)+"Q":o.key=pe.ESC+"OQ";break;case 114:a?o.key=pe.ESC+"[1;"+(a+1)+"R":o.key=pe.ESC+"OR";break;case 115:a?o.key=pe.ESC+"[1;"+(a+1)+"S":o.key=pe.ESC+"OS";break;case 116:a?o.key=pe.ESC+"[15;"+(a+1)+"~":o.key=pe.ESC+"[15~";break;case 117:a?o.key=pe.ESC+"[17;"+(a+1)+"~":o.key=pe.ESC+"[17~";break;case 118:a?o.key=pe.ESC+"[18;"+(a+1)+"~":o.key=pe.ESC+"[18~";break;case 119:a?o.key=pe.ESC+"[19;"+(a+1)+"~":o.key=pe.ESC+"[19~";break;case 120:a?o.key=pe.ESC+"[20;"+(a+1)+"~":o.key=pe.ESC+"[20~";break;case 121:a?o.key=pe.ESC+"[21;"+(a+1)+"~":o.key=pe.ESC+"[21~";break;case 122:a?o.key=pe.ESC+"[23;"+(a+1)+"~":o.key=pe.ESC+"[23~";break;case 123:a?o.key=pe.ESC+"[24;"+(a+1)+"~":o.key=pe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?o.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?o.key=pe.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=pe.DEL:e.keyCode===219?o.key=pe.ESC:e.keyCode===220?o.key=pe.FS:e.keyCode===221&&(o.key=pe.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let h=(u=aC[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(h)o.key=pe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,f=String.fromCharCode(p);e.shiftKey&&(f=f.toUpperCase()),o.key=pe.ESC+f}else if(e.keyCode===32)o.key=pe.ESC+(e.ctrlKey?pe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=pe.ESC+p,o.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=pe.US),e.key==="@"&&(o.key=pe.NUL));break}return o}var jt=0,cC=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new gl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new gl,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((o,a)=>this._getKey(o)-this._getKey(a)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[o]=e[t],t++):s[o]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(jt=this._search(t),jt===-1)||this._getKey(this._array[jt])!==t)return!1;do if(this._array[jt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(jt),!0;while(++jt<this._array.length&&this._getKey(this._array[jt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,i=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:i[s++]=this._array[o];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do yield this._array[jt];while(++jt<this._array.length&&this._getKey(this._array[jt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jt=this._search(e),!(jt<0||jt>=this._array.length)&&this._getKey(this._array[jt])===e))do t(this._array[jt]);while(++jt<this._array.length&&this._getKey(this._array[jt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,o=this._getKey(this._array[s]);if(o>e)i=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Pu=0,Ag=0,uC=class extends Ge{constructor(){super(),this._decorations=new cC(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ke),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ke),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_t(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new dC(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!i||(a.options.layer??"bottom")===i)&&(yield a)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,o=>{Pu=o.options.x??0,Ag=Pu+(o.options.width??1),e>=Pu&&e<Ag&&(!i||(o.options.layer??"bottom")===i)&&s(o)})}},dC=class extends er{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ke),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ke),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=bt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=bt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},hC=1e3,fC=class{constructor(e,t=hC){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,a=this._debounceThresholdMS-o;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Ig=20,vl=class extends Ge{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=o.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new fC(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
64
|
+
`))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ue(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(_t(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Ig+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Ig+1&&(this._liveRegion.textContent+=fd.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let o=e;o<=t;o++){let a=i.lines.get(i.ydisp+o),u=[],h=(a==null?void 0:a.translateToString(!0,void 0,void 0,u))||"",p=(i.ydisp+o+1).toString(),f=this._rowElements[o];f&&(h.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=h,this._rowColumns.set(f,u)),f.setAttribute("aria-posinset",p),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=i.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let u,h;if(t===0?(u=i,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(u=this._rowElements.shift(),h=i,this._rowContainer.removeChild(u)),u.removeEventListener("focus",this._topBoundaryFocusListener),h.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 h;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(i.node))return;let o=({node:p,offset:f})=>{let _=p instanceof Text?p.parentNode:p,b=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(b))return console.warn("row is invalid. Race condition?"),null;let S=this._rowColumns.get(_);if(!S)return console.warn("columns is null. Race condition?"),null;let w=f<S.length?S[f]:S.slice(-1)[0]+1;return w>=this._terminal.cols&&(++b,w=0),{row:b,column:w}},a=o(t),u=o(i);if(!(!a||!u)){if(a.row>u.row||a.row===u.row&&a.column>=u.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(u.row-a.row)*this._terminal.cols-a.column+u.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var o,a;e.style.transform="";let t=e.getBoundingClientRect().width,i=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};vl=Et([je(1,_h),je(2,xn),je(3,Cn)],vl);var Yd=class extends Ge{constructor(e,t,i,s,o){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ke),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ke),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(_t(()=>{var a;Er(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(a=this._activeProviderReplies)==null||a.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ue(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ue(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ue(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ue(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let o=i[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[a,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(i=this._checkLinkProviderResult(a,e,i)):u.provideLinks(e.y,h=>{var f,_;if(this._isMouseOut)return;let p=h==null?void 0:h.map(b=>({link:b}));(f=this._activeProviderReplies)==null||f.set(a,p),i=this._checkLinkProviderResult(a,e,i),((_=this._activeProviderReplies)==null?void 0:_.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let a=0;a<o.length;a++){let u=o[a],h=u.link.range.start.y<e?0:u.link.range.start.x,p=u.link.range.end.y>e?this._bufferService.cols:u.link.range.end.x;for(let f=h;f<=p;f++){if(i.has(f)){o.splice(a--,1);break}i.add(f)}}}}_checkLinkProviderResult(e,t,i){var a;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),o=!1;for(let u=0;u<e;u++)(!this._activeProviderReplies.has(u)||this._activeProviderReplies.get(u))&&(o=!0);if(!o&&s){let u=s.find(h=>this._linkAtPosition(h.link,t));u&&(i=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let u=0;u<this._activeProviderReplies.size;u++){let h=(a=this._activeProviderReplies.get(u))==null?void 0:a.find(p=>this._linkAtPosition(p.link,t));if(h){i=!0,this._handleNewLink(h);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&pC(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,Er(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,o,a;(s=this._currentLink)!=null&&s.state&&((a=(o=this._currentLink)==null?void 0:o.state)==null?void 0:a.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return i<=o&&o<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,o){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:o}}};Yd=Et([je(1,yh),je(2,Cn),je(3,di),je(4,N_)],Yd);function pC(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 mC=class extends oC{constructor(e={}){super(e),this._linkifier=this._register(new hs),this.browser=q_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new hs),this._onCursorMove=this._register(new ke),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ke),this.onKey=this._onKey.event,this._onRender=this._register(new ke),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ke),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ke),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ke),this.onBell=this._onBell.event,this._onFocus=this._register(new ke),this._onBlur=this._register(new ke),this._onA11yCharEmitter=this._register(new ke),this._onA11yTabEmitter=this._register(new ke),this._onWillOpen=this._register(new ke),this._setup(),this._decorationService=this._instantiationService.createInstance(uC),this._instantiationService.setService(Eo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(rx),this._instantiationService.setService(N_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(md)),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(Zt.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Zt.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Zt.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Zt.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(_t(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let o=mt.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${pe.ESC}]${s};${eC(o)}${U_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=Mt.toColor(...t.color));else{let a=i;this._themeService.modifyColors(u=>u[a]=Mt.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(vl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(i),a=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=u+"px",this.textarea.style.width=a+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ue(this.element,"copy",t=>{this.hasSelection()&&yb(t,this._selectionService)}));let e=t=>wb(t,this.textarea,this.coreService,this.optionsService);this._register(Ue(this.textarea,"paste",e)),this._register(Ue(this.element,"paste",e)),V_?this._register(Ue(this.element,"mousedown",t=>{t.button===2&&qm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ue(this.element,"contextmenu",t=>{qm(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Nh&&this._register(Ue(this.element,"auxclick",t=>{t.button===1&&__(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ue(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ue(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ue(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ue(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ue(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ue(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ue(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var o;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((o=this.element)==null?void 0:o.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ue(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",hd.get()),G_||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(ix,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(xn,this._coreBrowserService),this._register(Ue(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(Ue(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Id,this._document,this._helperContainer),this._instantiationService.setService(xl,this._charSizeService),this._themeService=this._instantiationService.createInstance(Fd),this._instantiationService.setService(ms,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(pl),this._instantiationService.setService(E_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Od,this.rows,this.screenElement)),this._instantiationService.setService(Cn,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Md,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Bd),this._instantiationService.setService(yh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(Yd,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(Dd,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(zd,this.element,this.screenElement,s)),this._instantiationService.setService(Rb,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()})),this._register(Zt.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(Ld,this.screenElement)),this._register(Ue(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(vl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fl,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(fl,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Ad,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(a){var f,_,b,S,w;let u=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!u)return!1;let h,p;switch(a.overrideType||a.type){case"mousemove":p=32,a.buttons===void 0?(h=3,a.button!==void 0&&(h=a.button<3?a.button:3)):h=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":p=0,h=a.button<3?a.button:3;break;case"mousedown":p=1,h=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let y=a.deltaY;if(y===0||e.coreMouseService.consumeWheelEvent(a,(S=(b=(_=(f=e._renderService)==null?void 0:f.dimensions)==null?void 0:_.device)==null?void 0:b.cell)==null?void 0:S.height,(w=e._coreBrowserService)==null?void 0:w.dpr)===0)return!1;p=y<0?0:1,h=4;break;default:return!1}return p===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:u.col,row:u.row,x:u.x,y:u.y,button:h,action:p,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},o={mouseup:a=>(i(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(i(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&i(a)},mousemove:a=>{a.buttons||i(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),a&8?s.mousemove||(t.addEventListener("mousemove",o.mousemove),s.mousemove=o.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),a&16?s.wheel||(t.addEventListener("wheel",o.wheel,{passive:!1}),s.wheel=o.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),a&2?s.mouseup||(s.mouseup=o.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),a&4?s.mousedrag||(s.mousedrag=o.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ue(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return i(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(Ue(t,"wheel",a=>{var u,h,p,f,_;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,(f=(p=(h=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(a,!0);let b=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(b,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){v_(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=lC(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===pe.ETX||i.key===pe.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(gC(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Lt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(pe.ESC+"[I"):this.coreService.triggerDataEvent(pe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function gC(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var vC=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},_C=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 $i)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Bg=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 _C(t)}getNullCell(){return new $i}},yC=class extends Ge{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ke),this.onBufferChange=this._onBufferChange.event,this._normal=new Bg(this._core.buffers.normal,"normal"),this._alternate=new Bg(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)}},wC=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},SC=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}},bC=["cols","rows"],rn=0,xC=class extends Ge{constructor(e){super(),this._core=this._register(new mC(e)),this._addonManager=this._register(new vC),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(bC.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 wC(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new SC(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 yC(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
66
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return hd.get()},set promptLabel(e){hd.set(e)},get tooMuchOutput(){return fd.get()},set tooMuchOutput(e){fd.set(e)}}}_verifyIntegers(...e){for(rn of e)if(rn===1/0||isNaN(rn)||rn%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(rn of e)if(rn&&(rn===1/0||isNaN(rn)||rn%1!==0||rn<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 CC=2,kC=1,EC=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,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),o=Math.max(0,parseInt(i.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),u={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},h=u.top+u.bottom,p=u.right+u.left,f=s-h,_=o-p-t;return{cols:Math.max(CC,Math.floor(_/e.css.cell.width)),rows:Math.max(kC,Math.floor(f/e.css.cell.height))}}};function NC(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function RC({session:e,node:t,token:i,cols:s,rows:o,readonly:a=!1,takeSize:u,focused:h,onData:p,onExit:f,onFiles:_,retryBaseMs:b=250}){const S=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!S)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const y=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${NC(t,i)}`;let x=null,k=!1,C=!1,P=null,A=0,M=h;const ee=()=>{if(k||C||P)return;const B=Math.min(5e3,Math.max(0,b)*2**Math.min(A++,5));P=setTimeout(()=>{P=null,q()},B)},q=()=>{if(k||C)return;const B=new WebSocket(y);x=B,B.binaryType="arraybuffer",B.onopen=()=>{if(x!==B||k)return;A=0;const Z={type:"attach",session:e,token:i,cols:s,rows:o,readonly:a};u!==void 0&&(Z.takeSize=u),B.send(JSON.stringify(Z)),M!==void 0&&B.send(JSON.stringify({type:"focus",on:!!M}))},B.onmessage=Z=>{if(!(x!==B||k))if(typeof Z.data=="string"){let H;try{H=JSON.parse(Z.data)}catch{return}H.type==="exit"&&(C=!0,f&&f(H.code)),H.type==="files"&&_&&_(H)}else p&&p(new Uint8Array(Z.data))},B.onerror=()=>{if(x===B)try{B.close()}catch{}},B.onclose=Z=>{x!==B||k||C||[1e3,1002,4401,4404].includes(Z==null?void 0:Z.code)||ee()}};return q(),{sendInput:B=>{if(!x||x.readyState!==1)return!1;try{return x.send(typeof B=="string"?new TextEncoder().encode(B):B),!0}catch{try{x.close()}catch{}return!1}},isReady:()=>!!x&&x.readyState===1,resize:(B,Z)=>{s=B,o=Z,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"resize",cols:B,rows:Z}))},action:B=>{(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"action",name:B}))},focus:B=>{M=B,(x==null?void 0:x.readyState)===1&&x.send(JSON.stringify({type:"focus",on:!!B}))},close:()=>{if(k=!0,P&&clearTimeout(P),P=null,x)try{x.close()}catch{}},get raw(){return x}}}async function Og(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const i=document.createElement("textarea");i.value=t,i.readOnly=!0,i.style.position="fixed",i.style.opacity="0",i.style.pointerEvents="none",document.body.appendChild(i),i.select();const s=document.execCommand&&document.execCommand("copy");if(i.remove(),s)return!0}catch{}return!1}const PC="\r";function jC(e){const t=String(e||"");let i=t.length;for(;i>0;){const s=t.charCodeAt(i-1);if(s===10||s===13)i-=1;else break}return t.slice(0,i)}function DC({isReady:e,paste:t,send:i}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:i(PC)!==!1}catch{return!1}}}function LC(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 TC=450,zg=8;function AC(e,t,i,s){return Math.abs(Number(i)-Number(e))>zg||Math.abs(Number(s)-Number(t))>zg}const IC=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function ju(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 Fg(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(i=>i&&i.kind==="file"&&typeof i.getAsFile=="function").map(i=>i.getAsFile()).filter(Boolean)}function BC(e,t=0,i=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=IC.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${i}-${t+1}.${o}`}async function oy({files:e,token:t,session:i,node:s="",paste:o=!0,fetchImpl:a=Vt,onProgress:u=()=>{},now:h=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),f=[],_=[];if(!i||!p.length)return{paths:f,errors:_};const b=ui(s?String(s).split("/"):[]);for(let S=0;S<p.length;S+=1){const w=p[S],y=BC(w,S,h);u({index:S,total:p.length,name:y,state:"uploading"});try{const x=new FormData;x.append("session",i),x.append("paste",o?"true":"false"),x.append("file",w,y);const k=await a(`${b}/files/upload`,t,{method:"POST",body:x}),C=await k.json().catch(()=>({}));if(!k.ok||C.error)throw new Error(C.error||`HTTP ${k.status}`);f.push(C.path),u({index:S,total:p.length,name:y,state:"done",path:C.path})}catch(x){const k=String((x==null?void 0:x.message)||x);_.push({name:y,message:k}),u({index:S,total:p.length,name:y,state:"error",error:k})}}return{paths:f,errors:_}}function ay({session:e,node:t,token:i,readonly:s,takeSize:o,focused:a,sendRef:u,composerRef:h,actionRef:p,ctrlRef:f,setCtrlArmed:_,onFiles:b,fontSize:S=13,selectionMode:w=!1,onSelectionModeChange:y}){const x=R.useRef(null),k=R.useRef(null),C=R.useRef(S);C.current=S;const P=R.useRef(a);P.current=a;const A=R.useRef(w);A.current=w;const[M,ee]=R.useState(""),[q,B]=R.useState(""),[Z,H]=R.useState(null),te=async()=>{var j,D,U,re;const T=((D=(j=k.current)==null?void 0:j.term)==null?void 0:D.getSelection())||M;if(!T){B(g("copy-empty")),setTimeout(()=>B(""),1500);return}const E=await Og(T);B(g(E?"copied":"copy-manual")),E&&((re=(U=k.current)==null?void 0:U.term)==null||re.clearSelection(),y==null||y(!1)),setTimeout(()=>B(""),1800)},K=R.useRef(te);return K.current=te,R.useEffect(()=>{const T=k.current;T&&T.sock&&T.sock.focus&&T.sock.focus(!!a)},[a]),R.useEffect(()=>{const T=k.current;T&&(T.term.options.fontSize=S,T.fit.fit(),T.sock.resize(T.term.cols,T.term.rows))},[S]),R.useEffect(()=>{const T=new xC({cursorBlink:!0,fontSize:C.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),E=new EC;T.loadAddon(E),T.open(x.current),E.fit();const j=new TextDecoder;let D;try{D=RC({session:e,node:t,token:i,readonly:s,takeSize:o,focused:P.current,onFiles:b,cols:T.cols,rows:T.rows,onData:W=>T.write(j.decode(W)),onExit:()=>T.write(`\r
|
|
78
|
+
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
+
`)})}catch(W){return T.write(`\r
|
|
80
|
+
\x1B[31m${W.message}\x1B[0m\r
|
|
81
|
+
`),()=>T.dispose()}k.current={term:T,fit:E,sock:D};let U=null;const re=T.onData(W=>{if(s){U&&(U.ok=!1);return}if(!U&&f&&f.current&&W.length===1){const ve=W.charCodeAt(0);let Ce=ve;ve>=97&&ve<=122?Ce=ve-96:ve>=64&&ve<=95?Ce=ve-64:ve===32&&(Ce=0),W=String.fromCharCode(Ce),f.current=!1,_&&_(!1)}const ue=D.sendInput(W);U&&(U.seen=!0,U.ok=U.ok&&ue)});u&&(u.current=W=>D.sendInput(W)),p&&(p.current=W=>D.action(W)),h&&(h.current=DC({isReady:()=>!s&&D.isReady(),paste:W=>{const ue={seen:!1,ok:!0};U=ue;try{T.paste(W)}catch{ue.ok=!1}finally{U=null}return ue.seen&&ue.ok},send:W=>D.sendInput(W)}));const I=T.onSelectionChange(()=>ee(T.getSelection()));T.attachCustomKeyEventHandler(W=>(W.ctrlKey||W.metaKey)&&W.key.toLowerCase()==="c"&&T.getSelection()?(W.type==="keydown"&&Og(T.getSelection()),!1):!0);const V=x.current;let $=!1;const L=async W=>{if(!W.length||$)return;if(s){H({error:g("settings-readonly")});return}$=!0,H({current:0,total:W.length,name:""});const ue=await oy({files:W,token:i,session:e,node:t,paste:!0,onProgress:({index:ve,total:Ce,name:_e,state:Re,error:Qe})=>H({current:ve+1,total:Ce,name:_e,...Re==="error"?{error:Qe}:{}})});$=!1,ue.errors.length?H({error:ue.errors.map(ve=>`${ve.name}: ${ve.message}`).join(" · ")}):(H({done:!0,total:ue.paths.length}),setTimeout(()=>H(null),1600))},z=W=>{const ue=W.clipboardData;if(!ju(ue))return;const ve=Fg(ue);ve.length&&(W.preventDefault(),W.stopPropagation(),L(ve))},oe=W=>{ju(W.dataTransfer)&&(W.preventDefault(),W.stopPropagation())},ce=W=>{ju(W.dataTransfer)&&(W.preventDefault(),W.stopPropagation(),L(Fg(W.dataTransfer)))};V.addEventListener("paste",z,!0),V.addEventListener("dragenter",oe,!0),V.addEventListener("dragover",oe,!0),V.addEventListener("drop",ce,!0);const he=24;let me=null,G=null,J=0,ge=null,Me=null,Ze=null,Be=!1;const Fe=()=>{Ze&&clearTimeout(Ze),Ze=null},ct=(W,ue)=>{const Ce=(V.querySelector(".xterm-screen")||V).getBoundingClientRect(),_e=Math.max(0,Math.min(T.cols-1,Math.floor((W-Ce.left)/Math.max(1,Ce.width)*T.cols))),Re=Math.max(0,Math.min(T.rows-1,Math.floor((ue-Ce.top)/Math.max(1,Ce.height)*T.rows)));return{col:_e,row:T.buffer.active.viewportY+Re}},Ve=W=>ct(W.clientX,W.clientY),gt=W=>{if(Fe(),Be=!1,W.touches.length!==1){me=null;return}if(A.current){W.preventDefault(),W.stopPropagation(),Me=Ve(W.touches[0]),T.clearSelection();return}me=W.touches[0].clientY,G=W.touches[0].clientX,J=0,ge=null;const ue={x:G,y:me};Ze=setTimeout(()=>{Ze=null,Be=!0,A.current=!0,y==null||y(!0),Me=ct(ue.x,ue.y),T.clearSelection(),T.select(Me.col,Me.row,1),me=null,G=null,ge=null,J=0},TC)},ut=W=>{if((A.current||Be)&&Me&&W.touches.length===1){W.preventDefault(),W.stopPropagation();const ve=Ve(W.touches[0]),Ce=Me.row*T.cols+Me.col,_e=ve.row*T.cols+ve.col,Re=Ce<=_e?Me:ve;T.select(Re.col,Re.row,Math.abs(_e-Ce)+1);return}if(me===null||W.touches.length!==1)return;W.preventDefault(),W.stopPropagation();const ue=W.touches[0];if(Ze&&AC(G,me,ue.clientX,ue.clientY)&&Fe(),ge===null&&(Math.abs(ue.clientY-me)>8||Math.abs(ue.clientX-G)>8)&&(ge=Math.abs(ue.clientY-me)>Math.abs(ue.clientX-G)),!!ge){for(J+=ue.clientY-me,me=ue.clientY;J>=he;)D.action("scroll-up"),J-=he;for(;J<=-he;)D.action("scroll-down"),J+=he}},lt=()=>{Fe(),me=null,G=null,Me=null,Be=!1};let nt=0;const dt=W=>{for(W.preventDefault(),W.stopPropagation(),nt+=W.deltaY;nt<=-he;)D.action("scroll-up"),nt+=he;for(;nt>=he;)D.action("scroll-down"),nt-=he};V.addEventListener("touchstart",gt,{passive:!1}),V.addEventListener("touchmove",ut,{passive:!1,capture:!0}),V.addEventListener("touchend",lt,{passive:!0}),V.addEventListener("touchcancel",lt,{passive:!0});const rt=W=>{(A.current||Be)&&(W.preventDefault(),W.stopPropagation())};V.addEventListener("contextmenu",rt,!0),V.addEventListener("wheel",dt,{passive:!1,capture:!0});let ot=null;const ae=W=>{LC(W)&&(W.preventDefault(),W.stopPropagation(),ot=ct(W.clientX,W.clientY),T.clearSelection())},xe=W=>{if(!ot)return;W.preventDefault(),W.stopPropagation();const ue=ct(W.clientX,W.clientY),ve=ot.row*T.cols+ot.col,Ce=ue.row*T.cols+ue.col,_e=ve<=Ce?ot:ue;T.select(_e.col,_e.row,Math.abs(Ce-ve)+1)},de=W=>{ot&&(W.stopPropagation(),ot=null)};V.addEventListener("mousedown",ae,!0),V.addEventListener("mousemove",xe,!0),V.addEventListener("mouseup",de,!0);const Ne=W=>{!MC(W)||!(k.current&&k.current.term&&k.current.term.getSelection())||(W.preventDefault(),W.stopPropagation(),K.current&&K.current())};V.addEventListener("keydown",Ne,!0);const Ee=()=>{E.fit(),D.resize(T.cols,T.rows)};window.addEventListener("resize",Ee);const X=window.visualViewport;X&&(X.addEventListener("resize",Ee),X.addEventListener("scroll",Ee));let ie=null,F=0;return typeof ResizeObserver<"u"&&(ie=new ResizeObserver(()=>{F&&cancelAnimationFrame(F),F=requestAnimationFrame(Ee)}),ie.observe(V)),()=>{k.current=null,u&&(u.current=()=>!1),h&&(h.current=()=>!1),p&&(p.current=()=>!1),re.dispose(),I.dispose(),V.removeEventListener("touchstart",gt),V.removeEventListener("touchmove",ut,{capture:!0}),V.removeEventListener("touchend",lt),V.removeEventListener("touchcancel",lt),V.removeEventListener("contextmenu",rt,!0),Fe(),V.removeEventListener("wheel",dt,{capture:!0}),V.removeEventListener("mousedown",ae,!0),V.removeEventListener("mousemove",xe,!0),V.removeEventListener("mouseup",de,!0),V.removeEventListener("keydown",Ne,!0),V.removeEventListener("paste",z,!0),V.removeEventListener("dragenter",oe,!0),V.removeEventListener("dragover",oe,!0),V.removeEventListener("drop",ce,!0),window.removeEventListener("resize",Ee),X&&(X.removeEventListener("resize",Ee),X.removeEventListener("scroll",Ee)),ie&&ie.disconnect(),F&&cancelAnimationFrame(F),D.close(),T.dispose()}},[e,t,i,s,o,u,h,p,f,_,b]),c.jsxs("div",{className:`nc-terminal${w?" selecting":""}`,children:[c.jsx("div",{className:"nc-terminal-host",ref:x}),Z&&c.jsx("div",{className:`nc-upload-state${Z.error?" error":""}`,role:"status",children:Z.error?Z.error:Z.done?g("attach-uploaded").replace("{n}",String(Z.total||0)):g("attach-upload-progress").replace("{n}",String(Z.current||0)).replace("{total}",String(Z.total||0))}),(M||w)&&c.jsxs("div",{className:"nc-selection-tools",children:[M?c.jsx("button",{type:"button",onClick:te,children:q||g("copy")}):c.jsx("span",{children:g("select-drag")}),c.jsx("button",{type:"button",onClick:()=>{var T,E;(E=(T=k.current)==null?void 0:T.term)==null||E.clearSelection(),ee(""),y==null||y(!1)},children:g("cancel")}),q===g("copy-manual")&&c.jsx("textarea",{readOnly:!0,value:M,onFocus:T=>T.target.select()})]})]})}const $g="",wi="\x1B",OC=[{label:"↑",seq:wi+"[A"},{label:"↓",seq:wi+"[B"},{label:"PGUP",seq:wi+"[5~"},{label:"PGDN",seq:wi+"[6~"}];function zC({send:e,action:t,ctrlArmed:i=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:u}){const[h,p]=R.useState(!1),[f,_]=R.useState(!1),[b,S]=R.useState(!1),w=k=>{b?(e(wi+k),S(!1)):e(k)},y=(k,C,P)=>c.jsx("button",{onMouseDown:A=>{A.preventDefault(),w(C),P&&P()},children:k},k),x=(k,C)=>c.jsx("button",{onMouseDown:P=>{P.preventDefault(),t(C),_(!1)},children:k},k);return h?c.jsxs("div",{className:"nc-keybar copy",children:[c.jsx("span",{className:"tag",children:"copy-mode"}),OC.map(k=>y(k.label,k.seq)),y("ESCI (q)","q",()=>p(!1))]}):c.jsxs("div",{className:"nc-keybar termux",children:[f&&c.jsxs("div",{className:"nc-keymenu",children:[x("←WIN","prev-window"),x("WIN→","next-window"),x("⬅PANE","pane-left"),x("PANE➡","pane-right"),y("SCROLL",$g+"[",()=>{p(!0),_(!1)}),c.jsx("button",{className:a?"armed":"",onMouseDown:k=>{k.preventDefault(),u==null||u(!a),_(!1)},children:"SELECT"}),y("⌃C","",()=>_(!1)),y("DETACH",$g+"d",()=>_(!1))]}),c.jsxs("div",{className:"row",children:[y("ESC",wi),c.jsx("button",{className:f?"armed":"",onMouseDown:k=>{k.preventDefault(),_(C=>!C)},children:"☰"},"menu"),y("/","/"),y("—","-"),y("HOME",wi+"[H"),y("↑",wi+"[A"),y("END",wi+"[F"),y("PGUP",wi+"[5~")]}),c.jsxs("div",{className:"row",children:[y("⇥"," "),c.jsx("button",{onMouseDown:k=>{k.preventDefault(),o&&o()},children:"⌨"},"kbd"),c.jsx("button",{className:i?"armed":"",onMouseDown:k=>{k.preventDefault(),s&&s()},children:"CTRL"},"ctrl"),c.jsx("button",{className:b?"armed":"",onMouseDown:k=>{k.preventDefault(),S(C=>!C)},children:"ALT"},"alt"),y("←",wi+"[D"),y("↓",wi+"[B"),y("→",wi+"[C"),y("PGDN",wi+"[6~")]})]})}const FC=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function ly({session:e,node:t,token:i,filesEvent:s,onClose:o}){ji();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[h,p]=R.useState("outbox"),[f,_]=R.useState({inbox:[],outbox:[]}),[b,S]=R.useState(""),w=R.useRef(null);async function y(){try{const A=await(await Vt(`${a}/files?session=${encodeURIComponent(e)}`,i)).json();if(A.error){S(A.error);return}_(A);const M=A.outbox[0]?A.outbox[0].mtime:0;localStorage.setItem(Wv(u),String(M))}catch(P){S(String(P))}}R.useEffect(()=>{y()},[e,t]),R.useEffect(()=>{s&&s.session===e&&y()},[s]);async function x(P){for(const A of P){S(`carico ${A.name}…`);const M=new FormData;M.append("session",e),M.append("file",A);try{const q=await(await Vt(`${a}/files/upload`,i,{method:"POST",body:M})).json();S(q.error?`errore: ${q.error}`:"")}catch(ee){S(String(ee))}}y()}async function k(P){const A=await Vt(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(P)}`,i);if(!A.ok){S("errore download");return}const M=await A.blob(),ee=URL.createObjectURL(M),q=document.createElement("a");q.href=ee,q.download=P,q.click(),URL.revokeObjectURL(ee)}async function C(P){await Vt(`${a}/files?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(P)}`,i,{method:"DELETE"}),y()}return c.jsxs("div",{className:"nc-files",children:[c.jsxs("header",{children:[c.jsx("b",{children:t?`${t}:${e}`:e}),c.jsx("button",{onClick:o,title:g("close"),children:c.jsx(et,{name:"x",size:20})})]}),c.jsxs("nav",{children:[c.jsx("button",{className:h==="outbox"?"on":"",onClick:()=>p("outbox"),children:"outbox"}),c.jsx("button",{className:h==="inbox"?"on":"",onClick:()=>p("inbox"),children:"inbox"}),c.jsxs("button",{className:"up",onClick:()=>w.current&&w.current.click(),children:[c.jsx(et,{name:"upload",size:18})," ",g("upload")]}),c.jsx("input",{type:"file",multiple:!0,ref:w,style:{display:"none"},onChange:P=>{x(Array.from(P.target.files||[])),P.target.value=""}})]}),b&&c.jsx("div",{className:"nc-busy",children:b}),c.jsxs("ul",{children:[f[h].map(P=>c.jsxs("li",{children:[c.jsx("span",{className:"name",onClick:()=>k(P.name),children:P.name}),c.jsx("small",{children:FC(P.size)}),c.jsx("button",{onClick:()=>C(P.name),title:"elimina",children:c.jsx(et,{name:"trash",size:18})})]},P.name)),f[h].length===0&&c.jsx("li",{className:"empty",children:g("empty-files")})]})]})}const El="nc_composer_v1",Xd="nc-composer-reset",$C=50,cy=256*1024,uy=512*1024,HC=768*1024,Hg=2*1024*1024,dy=720*60*60*1e3,Gd=1;function hy(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function Rh(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function _l(){return{version:Gd,cells:{}}}function fy(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=hy(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>cy)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=$C))break}let i=0;return t.filter(s=>i+s.text.length>HC?!1:(i+=s.text.length,!0))}function yl(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=uy?e.draft:"",i=fy(e.history),s=hy(e.updatedAt),o=e.expanded===!0;return!t&&!i.length&&!o?null:{draft:t,history:i,expanded:o,updatedAt:s}}function WC(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return _l()}if(!t||typeof t!="object"||t.version!==Gd||!t.cells||typeof t.cells!="object")return _l();const i=Object.create(null);for(const[s,o]of Object.entries(t.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=yl(o);a&&(i[s]=a)}return{version:Gd,cells:i}}function py(e){const t=Rh(e);if(!t)return _l();try{return WC(t.getItem(El))}catch{return _l()}}function Wg(e){try{return JSON.stringify(e).length}catch{return 1/0}}function UC(e,t,i){for(const[s,o]of Object.entries(e.cells))s!==i&&o.updatedAt>0&&t-o.updatedAt>dy&&delete e.cells[s]}function my(e,t){return Object.entries(e.cells).filter(([i])=>i!==t).sort((i,s)=>i[1].updatedAt-s[1].updatedAt).map(([i])=>i)}function KC(e,t){for(;Wg(e)>Hg;){const i=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!i.length)break;i[0][1].history.pop()}for(const i of my(e,t)){if(Wg(e)<=Hg)break;delete e.cells[i]}}function gy(e,t,i){const s=Rh(e);if(!s)return!1;KC(t,i);const o=()=>(s.setItem(El,JSON.stringify(t)),!0);try{return o()}catch{for(const u of my(t,i)){delete t.cells[u];try{return o()}catch{}}return!1}}function Po(e,t,i,s){const o=py(t);UC(o,i,e);const a=yl(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},u=s({...a,history:[...a.history]}),h=yl(u);return h?o.cells[e]={...h,updatedAt:i}:delete o.cells[e],{ok:gy(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:i}}}function qC({ownerId:e,node:t,session:i}){const s=String(i||"");if(!s)return"";const o=us.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function lo(e,t,i=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=py(t),o=yl(s.cells[e]);return!o||o.updatedAt>0&&i-o.updatedAt>dy?(s.cells[e]&&(delete s.cells[e],gy(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function Ug(e,t,i,s=Date.now()){const o=String(t||"");return!e||o.length>uy?!1:Po(e,i,s,a=>({...a,draft:o})).ok}function Kg(e,t,i=Date.now()){return e?Po(e,t,i,s=>({...s,draft:""})).ok:!1}function VC(e,t,i,s=Date.now()){return e?Po(e,i,s,o=>({...o,expanded:!!t})).ok:!1}function YC(e,t,i,s=Date.now()){const o=String(t||"");return!e||!o||o.length>cy?!1:Po(e,i,s,a=>{const u=a.history.filter(h=>h.text!==o);return u.unshift({text:o,at:s}),{...a,history:fy(u)}}).ok}function XC(e,t,i=Date.now()){return e?Po(e,t,i,s=>({...s,history:[]})).ok:!1}function GC(e){const t=Rh(e);if(!t)return!1;try{return t.removeItem(El),!0}catch{return!1}}const QC=300;function JC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function ZC({ownerId:e,node:t,session:i,storage:s=JC()}){const o=R.useMemo(()=>qC({ownerId:e,node:t,session:i}),[e,t,i]),a=R.useMemo(()=>lo(o,s),[]),[u,h]=R.useState(a.draft),[p,f]=R.useState(a.expanded),[_,b]=R.useState(a.history),[S,w]=R.useState(-1),y=R.useRef(o),x=R.useRef(a.draft),k=R.useRef(null),C=R.useRef(a.updatedAt||0),P=R.useRef(a.draft),A=R.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=null},[]),M=R.useCallback(()=>{A(),Ug(y.current,x.current,s)},[A,s]),ee=R.useCallback(()=>{A(),k.current=setTimeout(()=>{k.current=null,Ug(y.current,x.current,s)},QC)},[A,s]),q=R.useCallback(j=>{const D=String(typeof j=="function"?j(x.current):j||"");x.current=D,C.current=Date.now(),P.current=D,w(-1),h(D),ee()},[ee]),B=R.useCallback((j,D)=>{A(),x.current=j,C.current=Date.now(),h(j),w(D),ee()},[A,ee]),Z=R.useCallback(()=>{if(!_.length)return!1;const j=Math.min(S+1,_.length-1);return S<0&&(P.current=x.current),B(_[j].text,j),!0},[B,_,S]),H=R.useCallback(()=>{if(S<0)return!1;const j=S-1;return B(j<0?P.current:_[j].text,j),!0},[B,_,S]),te=R.useCallback(j=>{P.current=x.current;const D=_.findIndex(U=>U.text===j);B(String(j||""),D)},[B,_]),K=R.useCallback(()=>{f(j=>{const D=!j;return VC(y.current,D,s),D})},[s]),T=R.useCallback((j,D,U)=>{if(!j)return;if(YC(j,U,s),!(y.current===j)){lo(j,s).draft===D&&Kg(j,s);return}b(lo(j,s).history),P.current="",w(-1),x.current===D?(A(),x.current="",C.current=Date.now(),h(""),Kg(j,s)):ee()},[A,ee,s]),E=R.useCallback(()=>{XC(y.current,s),b([]),w(-1),P.current=x.current},[s]);return R.useEffect(()=>{if(y.current===o)return;M(),y.current=o;const j=lo(o,s);x.current=j.draft,C.current=j.updatedAt||0,P.current=j.draft,h(j.draft),f(j.expanded),b(j.history),w(-1)},[o,M,s]),R.useEffect(()=>{const j=()=>M(),D=()=>{document.visibilityState==="hidden"&&M()};return window.addEventListener("pagehide",j),document.addEventListener("visibilitychange",D),()=>{window.removeEventListener("pagehide",j),document.removeEventListener("visibilitychange",D),M()}},[M]),R.useEffect(()=>{const j=()=>{A(),x.current="",C.current=0,P.current="",h(""),f(!1),b([]),w(-1)},D=re=>{if(re.key!==El)return;if(re.newValue==null){j();return}const I=lo(y.current,s);I.updatedAt<C.current||(A(),x.current=I.draft,C.current=I.updatedAt,P.current=I.draft,h(I.draft),f(I.expanded),b(I.history),w(-1))},U=()=>j();return window.addEventListener("storage",D),window.addEventListener(Xd,U),()=>{window.removeEventListener("storage",D),window.removeEventListener(Xd,U)}},[A,s]),{cellKey:o,text:u,setText:q,expanded:p,toggleExpanded:K,history:_,historyCursor:S,recallPrevious:Z,recallNext:H,selectHistory:te,confirmSubmitted:T,clearHistory:E,flush:M}}function vy({submitText:e,token:t,session:i,node:s,ownerId:o}){ji();const a=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:u,text:h,setText:p,expanded:f,toggleExpanded:_,history:b,historyCursor:S,recallPrevious:w,recallNext:y,selectHistory:x,confirmSubmitted:k,clearHistory:C,flush:P}=ZC({ownerId:o,node:s,session:i}),[A,M]=R.useState(!1),[ee,q]=R.useState(""),[B,Z]=R.useState(!1),H=R.useRef(null),te=R.useRef(null),K=R.useRef(null),[T,E]=R.useState(!1),[j,D]=R.useState({left:0,bottom:0}),[U,re]=R.useState(!1),[I,V]=R.useState(!1),$=R.useRef(null),L=R.useRef(null),z=R.useRef(null),oe=R.useRef(null),ce=R.useRef(null),he=R.useRef(null),me=R.useRef(null),G=R.useRef(!1),[J,ge]=R.useState(!1),[Me,Ze]=R.useState({left:0,bottom:0,width:320}),Be=R.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);R.useEffect(()=>{let de=!1;if(s){Z(!1);return}return Vt(`${a}/voice/status`,t).then(Ne=>Ne.json()).then(Ne=>{de||Z(!!Ne.serverSttConfigured)}).catch(()=>{de||Z(!1)}),()=>{de=!0}},[t,a]);const ct=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||B);async function Ve(){const de=h,Ne=jC(de);if(!Ne||I)return;V(!0),q("");let Ee=!1;try{Ee=!!await e(Ne)}catch{Ee=!1}Ee?k(u,de,Ne):q(g("composer-send-failed")),V(!1),requestAnimationFrame(()=>{var X;return(X=K.current)==null?void 0:X.focus({preventScroll:!0})})}function gt(){const de=$.current&&$.current.getBoundingClientRect();de&&D({left:Math.max(6,Math.min(de.left,window.innerWidth-186)),bottom:window.innerHeight-de.top+6}),E(!0)}function ut(de){E(!1),de&&$.current&&$.current.focus()}function lt(){const de=z.current&&z.current.getBoundingClientRect();if(de){const Ne=Math.max(220,Math.min(360,window.innerWidth-12));Ze({left:Math.max(6,Math.min(de.right-Ne,window.innerWidth-Ne-6)),bottom:window.innerHeight-de.top+6,width:Ne})}ge(!0)}function nt(de){ge(!1),de&&z.current&&z.current.focus()}R.useEffect(()=>{if(!T)return;const de=Ee=>{Ee.key==="Escape"&&ut(!0)},Ne=Ee=>{const X=L.current&&L.current.contains(Ee.target),ie=$.current&&$.current.contains(Ee.target);!X&&!ie&&ut(!1)};return document.addEventListener("keydown",de),document.addEventListener("pointerdown",Ne),()=>{document.removeEventListener("keydown",de),document.removeEventListener("pointerdown",Ne)}},[T]),R.useEffect(()=>{if(!J)return;const de=Ee=>{Ee.key==="Escape"&&nt(!0)},Ne=Ee=>{const X=oe.current&&oe.current.contains(Ee.target),ie=z.current&&z.current.contains(Ee.target);!X&&!ie&&nt(!1)};return document.addEventListener("keydown",de),document.addEventListener("pointerdown",Ne),()=>{document.removeEventListener("keydown",de),document.removeEventListener("pointerdown",Ne)}},[J]);function dt(de){if(!(de.isComposing||G.current||de.altKey||de.ctrlKey||de.metaKey)){if(de.key==="ArrowUp"&&de.currentTarget.selectionStart===0&&de.currentTarget.selectionEnd===0){w()&&de.preventDefault();return}de.key==="ArrowDown"&&S>=0&&de.currentTarget.selectionStart===h.length&&de.currentTarget.selectionEnd===h.length&&y()&&de.preventDefault()}}function rt(de){ut(!1),de.current&&de.current.click()}async function ot(de){if(!de.length||!i)return;re(!0),q("");const{paths:Ne,errors:Ee}=await oy({files:de,token:t,session:i,node:s,paste:!1});Ee.length&&q(Ee.map(X=>`${X.name}: ${X.message}`).join(" · ")),Ne.length&&p(X=>X+(X&&!X.endsWith(" ")?" ":"")+Ne.join(" ")),re(!1)}function ae(){H.current&&H.current.stop(),te.current&&te.current.stop(),M(!1)}async function xe(){q("");const de=window.SpeechRecognition||window.webkitSpeechRecognition;if(de){const Ne=new de;Ne.lang="it-IT",Ne.continuous=!1,Ne.interimResults=!0;const Ee=h?`${h} `:"";Ne.onresult=X=>{const ie=Array.from(X.results).map(F=>F[0].transcript).join("");p(Ee+ie)},Ne.onend=()=>M(!1),Ne.onerror=X=>{q(`voice: ${X.error||"errore"}`),M(!1)},H.current=Ne,Ne.start(),M(!0);return}try{const Ne=await navigator.mediaDevices.getUserMedia({audio:!0}),Ee=new MediaRecorder(Ne),X=[];Ee.ondataavailable=ie=>X.push(ie.data),Ee.onstop=async()=>{Ne.getTracks().forEach(ie=>ie.stop()),M(!1),q("trascrivo…");try{const ie=new Blob(X,{type:Ee.mimeType||"audio/webm"}),W=await(await Vt(`${a}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:ie})).json();W.error?q(W.error):(q(""),p(ue=>ue+(ue?" ":"")+(W.text||"")))}catch(ie){q(String(ie))}},te.current={stop:()=>Ee.state!=="inactive"&&Ee.stop()},Ee.start(),M(!0)}catch{q("microfono non disponibile"),M(!1)}}return c.jsxs("div",{className:"nc-composer",children:[ee&&c.jsx("div",{className:"nc-composer-err",children:ee}),c.jsxs("div",{className:"nc-composer-row",children:[i&&c.jsx("button",{ref:$,className:U?"attach busy":"attach",disabled:U,onClick:()=>T?ut(!1):gt(),title:g(U?"attach-uploading":"attach"),"aria-label":g("attach"),"aria-haspopup":"menu","aria-expanded":T,"aria-controls":Be.current,children:c.jsx(et,{name:"attach",size:22})}),T&&c.jsxs("div",{ref:L,id:Be.current,role:"menu",className:"nc-attach-menu",style:{left:j.left,bottom:j.bottom},children:[c.jsxs("button",{role:"menuitem",onClick:()=>rt(ce),children:[c.jsx(et,{name:"file",size:18})," ",g("attach-file")]}),c.jsxs("button",{role:"menuitem",onClick:()=>rt(he),children:[c.jsx(et,{name:"camera",size:18})," ",g("attach-camera")]}),c.jsxs("button",{role:"menuitem",onClick:()=>rt(me),children:[c.jsx(et,{name:"image",size:18})," ",g("attach-gallery")]})]}),c.jsx("button",{ref:z,type:"button",className:"history",onPointerDown:de=>de.preventDefault(),onClick:()=>J?nt(!1):lt(),title:g("composer-history-tools"),"aria-label":g("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":J,children:c.jsx(et,{name:"history",size:21})}),J&&c.jsxs("div",{ref:oe,role:"menu",className:"nc-composer-history-menu",style:{left:Me.left,bottom:Me.bottom,width:Me.width},children:[c.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:de=>de.preventDefault(),onClick:()=>{_(),nt(!1),requestAnimationFrame(()=>{var de;return(de=K.current)==null?void 0:de.focus({preventScroll:!0})})},children:[c.jsx(et,{name:f?"chevronDown":"chevronUp",size:18}),g(f?"composer-collapse":"composer-expand")]}),c.jsx("div",{className:"nc-composer-history-title",children:g("composer-history")}),b.length===0&&c.jsx("div",{className:"nc-composer-history-empty",children:g("composer-history-empty")}),b.map((de,Ne)=>c.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Ee=>Ee.preventDefault(),onClick:()=>{x(de.text),nt(!1),requestAnimationFrame(()=>{var Ee;return(Ee=K.current)==null?void 0:Ee.focus({preventScroll:!0})})},children:[c.jsx("span",{children:de.text.replace(/\s+/g," ").slice(0,180)}),de.at>0&&c.jsx("small",{children:new Date(de.at).toLocaleString()})]},`${de.at}:${Ne}`)),b.length>0&&c.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:de=>de.preventDefault(),onClick:()=>{C(),nt(!1)},children:g("composer-history-clear")})]}),c.jsx("input",{ref:ce,type:"file",multiple:!0,hidden:!0,onChange:de=>{ot(Array.from(de.target.files||[])),de.target.value=""}}),c.jsx("input",{ref:he,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:de=>{ot(Array.from(de.target.files||[])),de.target.value=""}}),c.jsx("input",{ref:me,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:de=>{ot(Array.from(de.target.files||[])),de.target.value=""}}),c.jsx("textarea",{ref:K,className:f?"expanded":"",rows:f?8:2,value:h,placeholder:g("composer-placeholder"),onChange:de=>p(de.target.value),onKeyDown:dt,onCompositionStart:()=>{G.current=!0},onCompositionEnd:()=>{G.current=!1},onBlur:P}),ct&&c.jsx("button",{className:A?"mic on":"mic",onClick:A?ae:xe,title:g("voice"),children:c.jsx(et,{name:"mic",size:22})}),c.jsx("button",{type:"button",className:"go",disabled:I,onPointerDown:de=>de.preventDefault(),onClick:Ve,title:g("send"),children:c.jsx(et,{name:"enter",size:22})})]})]})}function qg(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const ek=180,tk=480,ns=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function ik({sessions:e=[],cells:t=[],activeSessions:i=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:u,onBoot:h,onNodePower:p,onKill:f,onVisibility:_,onNew:b,onNodeRename:S,onSettings:w,onBootError:y,localNodeId:x,fleetCapabilities:k=[],bootSettlement:C=null,onBootSettlementApplied:P,width:A=240,collapsed:M=!1,onResize:ee,onToggleCollapse:q}){const[B,Z]=ji(),{pins:H,orders:te,togglePin:K,viewFor:T,updateView:E,canMoveRoster:j,moveRoster:D,stepRoster:U}=r_(),{groupsFor:re,moveNode:I,stepNode:V,nodeKey:$}=o_(),L=new Set((t||[]).map(X=>X.tmuxSession)),z=new Map((e||[]).map(X=>[X.name,X])),oe=(X,ie)=>W0(H,X,ie),ce=U0,he=[...t||[]].sort((X,ie)=>ce(oe(X.tmuxSession,(z.get(X.tmuxSession)||{}).activity),oe(ie.tmuxSession,(z.get(ie.tmuxSession)||{}).activity))),me=(e||[]).filter(X=>!L.has(X.name)).sort((X,ie)=>ce(oe(X.name,X.activity),oe(ie.name,ie.activity))||X.name.localeCompare(ie.name)),G=new Set(i||[]),J=u_(he,me,z),ge=xr(J,H,T("local").filter,Jn(te,"local")),Ze=re(s||[]).map(X=>{const ie=(X.route||[X.name]).join("/"),F=T(ie),{rawItems:W}=cd(X),ue=xr(W,H,F.filter,Jn(te,ie));return{g:X,nodeRoute:ie,groupView:F,rawItems:W,items:ue}}),Be=(X,ie,F)=>o&&o({session:X,...ie?{node:ie}:{},...us.test(String(F||""))?{ownerId:F}:{}}),Fe=async X=>{if(!(X!=null&&X.direct)||!S)return;const ie=window.prompt(g("rename-node-prompt"),X.label||X.name);if(ie!==null)try{await S(X,ie)||window.alert(g("rename-node-invalid"))}catch(F){window.alert(String((F==null?void 0:F.message)||F))}},[ct,Ve]=R.useState({}),[gt,ut]=R.useState(new Set);R.useEffect(()=>{const X=new Map;for(const ie of t||[])X.set(ns(ie.cell),!!ie.boot);for(const ie of s||[]){const F=ie.route||[ie.name];for(const W of ie.cells||[])X.set(ns(W.cell,F),!!W.boot)}Ve(ie=>{let F=!1;const W={...ie};for(const[ue,ve]of Object.entries(ie))X.has(ue)&&X.get(ue)===ve&&(delete W[ue],F=!0);return F?W:ie})},[t,s]),R.useEffect(()=>{if(!(C!=null&&C.cell))return;const X=Array.isArray(C.route)?C.route:[],ie=ns(C.cell,X);Ve(F=>({...F,[ie]:!!C.enabled})),P&&P(C.id)},[C,P]);const lt=(X,ie=[])=>{const F=ns(X.cell,ie);return Object.prototype.hasOwnProperty.call(ct,F)?ct[F]:!!X.boot},nt=async(X,ie,F=[])=>{if(X.stopPropagation(),!h)return;const W=ns(ie.cell,F),ue=!lt(ie,F);Ve(ve=>({...ve,[W]:ue})),ut(ve=>new Set(ve).add(W));try{await h(ie.cell,ue,F)}catch(ve){Ve(Ce=>{const _e={...Ce};return delete _e[W],_e}),y&&y(ve)}finally{ut(ve=>{const Ce=new Set(ve);return Ce.delete(W),Ce})}},dt=(X,ie=[])=>{const F=ns(X.cell,ie),W=lt(X,ie),ue=`${g(W?"boot-disable":"boot-enable")} ${X.cell}`;return c.jsx("button",{className:`nc-boot${W?" on":""}`,disabled:gt.has(F),onClick:ve=>nt(ve,X,ie),title:ue,"aria-label":ue,children:c.jsx(et,{name:"boot",size:14})})},[rt,ot]=R.useState(null),ae=(X,ie)=>{const F=X.currentTarget.getBoundingClientRect();ot({text:ie,y:F.top+F.height/2})},xe=()=>ot(null),de=R.useRef(null);R.useEffect(()=>()=>{de.current&&de.current()},[]);function Ne(X){X.preventDefault(),X.stopPropagation();const ie=X.clientX,F=A,W=ve=>{const Ce=Math.max(ek,Math.min(tk,F+(ve.clientX-ie)));ee&&ee(Ce)},ue=()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",ue),window.removeEventListener("pointercancel",ue),window.removeEventListener("blur",ue),de.current=null};window.addEventListener("pointermove",W),window.addEventListener("pointerup",ue),window.addEventListener("pointercancel",ue),window.addEventListener("blur",ue),de.current=ue}const Ee=M?{width:48,flex:"0 0 48px"}:{width:A,flex:`0 0 ${A}px`};return M?c.jsxs("aside",{className:"nc-sidebar mini",style:Ee,children:[c.jsx("div",{className:"nc-side-head mini",children:c.jsx("button",{className:"nc-collapse-btn",onClick:q,title:g("expand"),children:"⟩"})}),c.jsx("button",{className:"nc-side-gear mini",onClick:()=>w&&w("nodes",!1),title:g("settings"),onMouseEnter:X=>ae(X,g("settings")),onMouseLeave:xe,children:c.jsx(et,{name:"gear",size:16})}),c.jsx("div",{className:"nc-side-scroll mini",children:c.jsxs("div",{className:"nc-side-group mini",children:[T("local").open&&ge.map(X=>X.type==="cell"?(()=>{const ie=X.value,F=ie.degraded?"warn":ie.tmux?"on":"",W=!!ie.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${G.has(ie.tmuxSession)?" active":""}`,onMouseEnter:ue=>ae(ue,`${ie.cell}: ${X.subtitle}`),onMouseLeave:xe,draggable:W,onDragStart:W?ue=>ue.dataTransfer.setData("text/nc-session",ie.tmuxSession):void 0,onClick:W?()=>a&&a(ie.tmuxSession):()=>u&&u(ie),onDoubleClick:W?()=>Be(ie.tmuxSession,"",x):void 0,children:c.jsx("span",{className:`nc-dot ${F}${X.working?" working":""}`})},X.key)})():(()=>{const ie=X.value;return c.jsx("button",{type:"button",className:`nc-mini-init${G.has(ie.name)?" active":""}`,onMouseEnter:F=>ae(F,ie.name),onMouseLeave:xe,draggable:!0,onDragStart:F=>F.dataTransfer.setData("text/nc-session",ie.name),onClick:()=>a&&a(ie.name),onDoubleClick:()=>Be(ie.name,"",x),children:qg(ie.name)},X.key)})()),Ze.flatMap(({g:X,nodeRoute:ie,groupView:F,items:W})=>X.status==="up"?F.open?W.map(ue=>ue.type==="cell"?(()=>{const ve=ue.value,Ce=!!ve.tmux;return c.jsx("button",{type:"button",className:`nc-mini-dot${G.has(ue.key)?" active":""}`,onMouseEnter:_e=>ae(_e,`${X.label||ie}: ${ve.cell} · ${ue.subtitle}`),onMouseLeave:xe,draggable:Ce,onDragStart:Ce?_e=>_e.dataTransfer.setData("text/nc-session",ue.key):void 0,onClick:Ce?()=>a&&a(ue.key):()=>u&&u({...ve,route:X.route,availableEngines:X.engines||[]}),onDoubleClick:Ce?()=>Be(ve.tmuxSession,ie,X.instanceId):void 0,children:c.jsx("span",{className:`nc-dot ${ve.degraded?"warn":Ce?`on${ue.working?" working":""}`:""}`})},ue.key)})():(()=>{const ve=ue.value;return c.jsx("button",{type:"button",className:`nc-mini-init${G.has(ue.key)?" active":""}`,onMouseEnter:Ce=>ae(Ce,`${X.label||ie}: ${ve.name}`),onMouseLeave:xe,draggable:!0,onDragStart:Ce=>Ce.dataTransfer.setData("text/nc-session",ue.key),onClick:()=>a&&a(ue.key),onDoubleClick:()=>Be(ve.name,ie,X.instanceId),children:qg(ve.name)},ue.key)})()):[]:[c.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:ue=>ae(ue,`${X.label||(X.route||[X.name]).join(" › ")}: ${os(X)}`),onMouseLeave:xe,children:c.jsx("span",{className:`nc-dot${X.status==="passive"?"":" warn"}`})},`nodo-${(X.route||[X.name]).join("/")}`)])]})}),rt&&c.jsx("div",{className:"nc-mini-tip",style:{top:rt.y},children:rt.text})]}):c.jsxs("aside",{className:"nc-sidebar",style:Ee,children:[c.jsxs("div",{className:"nc-side-head",children:[c.jsx("button",{className:"nc-collapse-btn",onClick:q,title:g("collapse"),children:"⟨"}),c.jsx("span",{className:"nc-side-title",children:g("fleet")}),c.jsxs("button",{className:"nc-new-btn",onClick:b,title:g("fleet-new-cell"),children:["+ ",g("new")]})]}),c.jsxs("button",{className:"nc-side-gear",onClick:()=>w&&w("nodes",!1),title:g("settings"),children:[c.jsx(et,{name:"gear",size:15})," ",g("settings")]}),c.jsxs("div",{className:"nc-side-scroll",children:[c.jsx(nk,{label:g("position-local"),count:ge.length,state:T("local"),onToggle:()=>E("local",{open:!T("local").open}),onFilter:X=>E("local",{filter:X})}),T("local").open&&c.jsxs("div",{className:"nc-side-group",children:[ge.map(X=>X.type==="cell"?(()=>{const ie=X.value,F=ie.degraded?"warn":ie.tmux?"on":"",W=ie.degraded?g("cell-degraded"):X.working?X.subtitle:ie.tmux?g("cell-idle"):g("cell-off"),ue=!!ie.tmux;return c.jsxs("div",{"data-roster-key":X.key,"data-position":"local",className:`nc-cell${ue?" live":""}${G.has(ie.tmuxSession)?" active":""}`,title:`${ie.cell} · ${X.subtitle}${W===X.subtitle?"":` · ${W}`}`,"aria-label":`${ie.cell}, ${X.subtitle}${W===X.subtitle?"":`, ${W}`}`,draggable:ue,onDragStart:ue?ve=>ve.dataTransfer.setData("text/nc-session",ie.tmuxSession):void 0,onClick:ue?()=>a&&a(ie.tmuxSession):void 0,onDoubleClick:ue?()=>Be(ie.tmuxSession,"",x):void 0,children:[c.jsx(Gn,{position:"local",itemKey:X.key,label:ie.cell,canMove:j,onMove:(ve,Ce)=>D("local",ve,Ce,J),onStep:ve=>U("local",X.key,ve,J)}),c.jsx("span",{className:`nc-dot ${F}${X.working?" working":""}`}),c.jsxs("span",{className:"nc-cell-main",children:[c.jsx("b",{title:ie.cell,children:ie.cell}),c.jsx("small",{title:X.subtitle,children:X.subtitle})]}),c.jsx("button",{className:`nc-pin${H.includes(X.key)?" on":""}`,title:g("pin"),onClick:ve=>{ve.stopPropagation(),K(X.key)},children:H.includes(X.key)?"★":"☆"}),h&&k.includes("boot")&&dt(ie),c.jsx("button",{className:`nc-power${ie.tmux?" on":""}${ie.degraded?" warn":""}`,onClick:ve=>{ve.stopPropagation(),u&&u({...ie,boot:lt(ie)})},title:ie.active?g("power-off"):g("power-on"),children:c.jsx(et,{name:"power",size:14})})]},X.key)})():(()=>{var F;const ie=X.value;return c.jsxs("div",{"data-roster-key":X.key,"data-position":"local",className:`nc-side-card${G.has(ie.name)?" active":""}`,draggable:!0,onDragStart:W=>W.dataTransfer.setData("text/nc-session",ie.name),onClick:()=>a&&a(ie.name),onDoubleClick:()=>Be(ie.name,"",x),children:[c.jsx(Gn,{position:"local",itemKey:X.key,label:ie.name,canMove:j,onMove:(W,ue)=>D("local",W,ue,J),onStep:W=>U("local",X.key,W,J)}),c.jsx("span",{className:ie.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:ie.name}),c.jsxs("small",{children:[ie.preview||ie.cmd||g("windows").replace("{n}",String(ie.windows||0)),((F=ie.outbox)==null?void 0:F.count)>0?` · 📦${ie.outbox.count}`:""]})]}),ie.activity?c.jsx("span",{className:"nc-rel",children:cs(ie.activity)}):null,c.jsx("button",{className:`nc-pin${H.includes(X.key)?" on":""}`,title:g("pin"),onClick:W=>{W.stopPropagation(),K(X.key)},children:H.includes(X.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${ie.technical?" on":""}`,title:ie.technical?g("mark-normal"):g("mark-technical"),"aria-label":`${ie.technical?g("mark-normal"):g("mark-technical")} ${ie.name}`,onClick:W=>{W.stopPropagation(),_&&_(ie.name,!ie.technical,[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:g("terminate"),onClick:W=>{W.stopPropagation(),window.confirm(g("terminate-confirm").replace("{name}",ie.name))&&f&&f(ie.name)},children:"⋯"})]},X.key)})()),ge.length===0&&c.jsx("div",{className:"nc-empty",children:g("no-sessions-short")})]}),Ze.map(({g:X,nodeRoute:ie,groupView:F,rawItems:W,items:ue})=>{const Ce=a_(X.health)||(X.status==="up"?"on":X.status==="passive"?"":"warn");return c.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":$(X),children:[c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:X.direct&&S?_e=>{_e.preventDefault(),Fe(X)}:void 0,onClick:()=>E(ie,{open:!F.open}),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),E(ie,{open:!F.open}))},children:[c.jsx(Gn,{scope:"node",position:"nodes",itemKey:$(X),label:X.label||X.name,onMove:(_e,Re)=>I(_e,Re,s||[]),onStep:_e=>V($(X),_e,s||[])}),c.jsx("span",{className:"nc-node-chevron",children:F.open?"⌄":"›"}),c.jsx("span",{className:`nc-dot ${Ce}`,title:X.health?ll(X.health):""}),c.jsx("b",{children:X.label||X.name}),c.jsxs("small",{children:[" · ",X.status==="up"?g("node-sessions").replace("{n}",String(ue.length)):X.health&&ll(X.health)||os(X)]}),c.jsxs("select",{className:"nc-node-filter",value:F.filter,title:g(`view-${F.filter}`),onClick:_e=>_e.stopPropagation(),onChange:_e=>E(ie,{filter:_e.target.value}),children:[c.jsx("option",{value:"all",children:g("view-all")}),c.jsx("option",{value:"pinned",children:g("view-pinned")}),c.jsx("option",{value:"active",children:g("view-active")}),c.jsx("option",{value:"off",children:g("view-off")}),c.jsx("option",{value:"technical",children:g("view-technical")})]}),X.direct&&S&&c.jsx("button",{type:"button",className:"nc-node-rename",title:g("rename-node"),"aria-label":`${g("rename-node")} ${X.label||X.name}`,onClick:_e=>{_e.stopPropagation(),Fe(X)},children:"✎"}),X.direct&&X.health&&X.health.managed!==!1&&c.jsx("button",{type:"button",className:`nc-power${X.tunnelStatus==="up"?" on":""}`,title:X.tunnelStatus==="up"?g("power-off"):g("power-on"),onClick:_e=>{_e.stopPropagation(),p&&p(X)},children:c.jsx(et,{name:"power",size:14})})]}),X.status==="up"&&F.open&&c.jsxs("div",{className:"nc-side-group",children:[ue.map(_e=>_e.type==="cell"?(()=>{const Re=_e.value,Qe=!!Re.tmux,zt=Re.degraded?"warn":Re.tmux?"on":"";return c.jsxs("div",{"data-roster-key":_e.key,"data-position":ie,className:`nc-side-card nc-cell${Qe?" live":""}${G.has(Re.key)?" active":""}`,title:_e.working?_e.subtitle:Re.tmux?g("cell-idle"):g("cell-off"),draggable:Qe,onDragStart:Qe?ze=>ze.dataTransfer.setData("text/nc-session",Re.key):void 0,onClick:Qe?()=>a&&a(Re.key):void 0,onDoubleClick:Qe?()=>Be(Re.tmuxSession,ie,X.instanceId):void 0,children:[c.jsx(Gn,{position:ie,itemKey:_e.key,label:Re.cell,canMove:j,onMove:(ze,Di)=>D(ie,ze,Di,W),onStep:ze=>U(ie,_e.key,ze,W)}),c.jsx("span",{className:`nc-dot ${zt}${_e.working?" working":""}`}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Re.cell}),c.jsx("small",{title:_e.subtitle,children:_e.subtitle})]}),c.jsx("button",{className:`nc-pin${H.includes(_e.key)?" on":""}`,title:g("pin"),onClick:ze=>{ze.stopPropagation(),K(_e.key)},children:H.includes(_e.key)?"★":"☆"}),h&&(X.capabilities||[]).includes("boot")&&dt(Re,X.route||[]),(X.capabilities||[]).includes(Re.active?"down":"up")&&c.jsx("button",{className:`nc-power${Re.active?" on":""}${Re.degraded?" warn":""}`,onClick:ze=>{ze.stopPropagation(),u&&u({...Re,boot:lt(Re,X.route||[]),route:X.route,availableEngines:X.engines||[]})},title:Re.active?g("power-off"):g("power-on"),children:c.jsx(et,{name:"power",size:14})})]},_e.key)})():(()=>{const Re=_e.value;return c.jsxs("div",{"data-roster-key":_e.key,"data-position":ie,className:`nc-side-card${G.has(Re.key)?" active":""}`,draggable:!0,onDragStart:Qe=>Qe.dataTransfer.setData("text/nc-session",Re.key),onClick:()=>a&&a(Re.key),onDoubleClick:()=>Be(Re.name,Re.node||ie,X.instanceId),children:[c.jsx(Gn,{position:ie,itemKey:_e.key,label:Re.name,canMove:j,onMove:(Qe,zt)=>D(ie,Qe,zt,W),onStep:Qe=>U(ie,_e.key,Qe,W)}),c.jsx("span",{className:Re.attached?"nc-dot on":"nc-dot"}),c.jsxs("span",{className:"nc-card-main",children:[c.jsx("b",{children:Re.name}),c.jsx("small",{children:Re.preview?Re.preview:Re.cmd?Re.cmd:g("windows").replace("{n}",String(Re.windows||0))})]}),Re.activity?c.jsx("span",{className:"nc-rel",children:cs(Re.activity)}):null,c.jsx("button",{className:`nc-pin${H.includes(_e.key)?" on":""}`,title:g("pin"),onClick:Qe=>{Qe.stopPropagation(),K(_e.key)},children:H.includes(_e.key)?"★":"☆"}),c.jsx("button",{className:`nc-technical${Re.technical?" on":""}`,title:Re.technical?g("mark-normal"):g("mark-technical"),"aria-label":`${Re.technical?g("mark-normal"):g("mark-technical")} ${Re.name}`,onClick:Qe=>{Qe.stopPropagation(),_&&_(Re.name,!Re.technical,X.route||[])},children:"T"}),c.jsx("button",{className:"nc-menu",title:g("terminate"),onClick:Qe=>{Qe.stopPropagation(),window.confirm(g("terminate-confirm").replace("{name}",Re.name))&&f&&f(Re.name,X.route)},children:"⋯"})]},_e.key)})()),ue.length===0&&c.jsx("div",{className:"nc-empty",children:g("no-sessions-short")})]})]},`nodo-${(X.route||[X.name]).join("/")}`)})]}),c.jsx("div",{className:"nc-side-lang",children:n_.map((X,ie)=>c.jsxs("span",{children:[ie>0&&" · ",c.jsx("button",{className:`nc-lang-btn${B===X?" on":""}`,onClick:()=>Z(X),title:X,children:X.toUpperCase()})]},X))}),c.jsx("div",{className:"nc-side-resize",onPointerDown:Ne,title:""})]})}function nk({label:e,count:t,state:i,onToggle:s,onFilter:o}){return c.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:s,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),s())},children:[c.jsx("span",{className:"nc-node-chevron",children:i.open?"⌄":"›"}),c.jsx("span",{className:"nc-dot on"}),c.jsx("b",{children:e}),c.jsxs("small",{children:[" · ",g("node-sessions").replace("{n}",String(t))]}),c.jsxs("select",{className:"nc-node-filter",value:i.filter,title:g(`view-${i.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[c.jsx("option",{value:"all",children:g("view-all")}),c.jsx("option",{value:"pinned",children:g("view-pinned")}),c.jsx("option",{value:"active",children:g("view-active")}),c.jsx("option",{value:"off",children:g("view-off")}),c.jsx("option",{value:"technical",children:g("view-technical")})]})]})}function rk(e,t,i){return!e&&t?i+1:i}function sk({session:e,node:t,ownerId:i,cellName:s,token:o,readonly:a=!1,focused:u,onFocus:h,onClose:p,onOpenSingle:f,alive:_=!0,available:b=!0,fontSize:S=Co,onZoom:w,decks:y=[],currentDeck:x,onSendToDeck:k}){const C=s||e,P=R.useRef(()=>{}),A=R.useRef(()=>!1),M=R.useRef(()=>{}),ee=R.useRef(!1),[q,B]=R.useState(!1),[Z,H]=R.useState(!1),[te,K]=R.useState(!1),[T,E]=R.useState(null),[j,D]=R.useState(0),U=R.useRef(_),re=t?`${t}:${e}`:e,I=y.filter(V=>V.id!==x&&V.available!==!1);return R.useEffect(()=>{const V=U.current;!V&&_&&D($=>rk(V,_,$)),U.current=_},[_]),c.jsxs("div",{className:`nc-tile${u?" focused":""}`,onMouseDown:()=>h&&h(re),children:[c.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:V=>{V.dataTransfer.setData("text/nc-session",re),V.dataTransfer.effectAllowed="move"},children:[c.jsxs("button",{className:"nc-tile-name",onClick:()=>h&&h(re),title:t?`${C} · ${t}`:C,children:[c.jsx("span",{className:_?"nc-dot on":"nc-dot"}),c.jsx("b",{children:C})]}),c.jsxs("span",{className:"nc-tile-actions",children:[w&&c.jsx("button",{onClick:()=>w(-1),title:g("zoom-out"),children:c.jsx(et,{name:"zoomOut",size:14})}),w&&c.jsx("button",{onClick:()=>w(1),title:g("zoom-in"),children:c.jsx(et,{name:"zoomIn",size:14})}),k&&I.length>0&&c.jsxs("select",{className:"nc-tile-deck",title:g("send-to-deck"),value:"",onMouseDown:V=>V.stopPropagation(),onChange:V=>{const $=V.target.value;$&&k(re,$),V.target.value=""},children:[c.jsx("option",{value:"",children:g("send-to-deck")}),I.map(V=>c.jsxs("option",{value:V.id,children:[V.ownerLabel," · ",V.name]},V.id))]}),c.jsx("button",{onClick:()=>H(V=>!V),title:"composer",children:"⌨"}),c.jsx("button",{onClick:()=>K(V=>!V),title:"file",children:"📁"}),f&&c.jsx("button",{onClick:()=>f({session:e,node:t,ownerId:i}),title:"vista singola",children:"↗"}),p&&c.jsx("button",{className:"nc-tile-close",onClick:()=>p(re),title:"chiudi",children:"✕"})]})]}),c.jsxs("div",{className:"nc-tile-body",children:[b?c.jsx(ay,{session:e,node:t,token:o,readonly:a,takeSize:!1,focused:u,sendRef:P,composerRef:A,actionRef:M,ctrlRef:ee,setCtrlArmed:B,onFiles:E,fontSize:S},`${re}:${j}`):c.jsx("div",{className:"nc-tile-unavailable",children:g("deck-owner-unavailable")}),b&&te&&c.jsx("div",{className:"nc-tile-files",onMouseDown:V=>V.stopPropagation(),children:c.jsx(ly,{session:e,node:t,token:o,filesEvent:T,onClose:()=>K(!1)})})]}),b&&Z&&c.jsx("div",{className:"nc-tile-composer",onMouseDown:V=>V.stopPropagation(),children:c.jsx(vy,{submitText:V=>A.current(V),token:o,session:e,node:t,ownerId:i})})]})}function ok({session:e,node:t,ownerId:i,cells:s,nodeGroups:o}={}){const a=typeof e=="string"?e:"";if(!a)return null;if(t){const h=Array.isArray(o)?o:[];for(const p of h){if(!p||(Array.isArray(p.route)?p.route:[]).join("/")!==t||i&&p.instanceId&&String(i)!==String(p.instanceId))continue;const _=(Array.isArray(p.cells)?p.cells:[]).find(b=>b&&b.tmuxSession===a);if(_)return _}return null}return(Array.isArray(s)?s:[]).find(h=>h&&h.tmuxSession===a)||null}function Ph({session:e,cell:t,node:i,ownerId:s,cells:o,nodeGroups:a}={}){const u=typeof e=="string"?e:"";if(t&&typeof t.cell=="string"&&t.cell)return t.cell;const h=ok({session:u,node:i,ownerId:s,cells:o,nodeGroups:a});return h&&h.cell?h.cell:u}const Vg=.2,Yg=.28,_y=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),Du=e=>_y(e,"text/nc-session"),Xg=e=>{var t;return _y(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function ak(e,t,i){const s=(e-i.left)/(i.width||1),o=(t-i.top)/(i.height||1);return s<Yg?"left":s>1-Yg?"right":o<.5?"top":"bottom"}function lk({layout:e,onLayoutChange:t,token:i,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:u,onOpenSingle:h,decks:p=[],currentDeck:f,onSendToDeck:_,cells:b=[],nodeGroups:S=[]}){ji();const[w,y]=R.useState(null),x=R.useRef(null),k=R.useRef([]),C=R.useRef(null);function P(K,T){const E=()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E),window.removeEventListener("blur",E),C.current=null};window.addEventListener("pointermove",K),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E),window.addEventListener("blur",E),C.current=E}R.useEffect(()=>()=>{C.current&&C.current()},[]),R.useEffect(()=>{const K=()=>y(null);return window.addEventListener("dragend",K),window.addEventListener("drop",K),()=>{window.removeEventListener("dragend",K),window.removeEventListener("drop",K)}},[]);const A=e.columns.length,M=K=>w&&w.col===K&&w.row===void 0,ee=!!w&&w.col===A,q=(K,T)=>w&&w.col===K&&w.row===T&&w.quadrant?` drop-${w.quadrant}`:"";function B(K){if(K.preventDefault(),Xg(K.dataTransfer)){y(null);return}const T=K.dataTransfer.getData("text/nc-session"),E=w;if(y(null),!T||!E)return;let j;if(E.quadrant){if(j=nb(e,E.col,E.row,E.quadrant),!j)return}else j={col:E.col};t(ln(e).includes(T)?J0(e,T,j):vh(e,T,j))}function Z(K,T){K.preventDefault(),K.stopPropagation();const E=K.clientX,j=e.columns[T].width,D=x.current&&x.current.clientWidth||1,U=e.columns[T+1];P(I=>{let V=Math.max(Vg,j+(I.clientX-E)/D);if(U){const $=zm(V/(V+U.width));V=$/(1-$)*U.width}t(eb(e,T,V))})}function H(K,T,E){K.preventDefault(),K.stopPropagation();const j=K.clientY,D=e.columns[T].tiles[E].height,U=k.current[T],re=U&&U.clientHeight||1,I=e.columns[T].tiles[E+1];P($=>{let L=Math.max(Vg,D+($.clientY-j)/re);if(I){const z=zm(L/(L+I.height));L=z/(1-z)*I.height}t(tb(e,T,E,L))})}function te(K){t(dl(e,K))}return c.jsxs("div",{className:"nc-grid",ref:x,onDragOver:K=>{if(Xg(K.dataTransfer)){K.preventDefault(),y(null);return}Du(K.dataTransfer)&&(K.preventDefault(),w&&w.col===A||y({col:A}))},onDrop:B,onDragLeave:K=>{const T=K.relatedTarget;(!T||!(x.current&&x.current.contains(T)))&&y(null)},children:[e.columns.flatMap((K,T)=>{const E=[];return E.push(c.jsx("div",{className:`nc-col${M(T)?" drop-newcol":""}`,ref:j=>{k.current[T]=j},style:{flexGrow:K.width,flexBasis:0},onDragOver:j=>{Du(j.dataTransfer)&&(j.preventDefault(),j.stopPropagation(),w&&w.col===T&&w.row===void 0||y({col:T}))},children:K.tiles.flatMap((j,D)=>{const U=[],re=Ri(j),I=Ph({session:j.session,node:j.node,ownerId:j.ownerId,cells:b,nodeGroups:S});return U.push(c.jsx("div",{className:`nc-tile-slot${q(T,D)}`,style:{flexGrow:j.height,flexBasis:0},onDragOver:V=>{if(!Du(V.dataTransfer))return;V.preventDefault(),V.stopPropagation();const $=ak(V.clientX,V.clientY,V.currentTarget.getBoundingClientRect());w&&w.col===T&&w.row===D&&w.quadrant===$||y({col:T,row:D,quadrant:$})},children:c.jsx(sk,{session:j.session,node:j.node,ownerId:j.ownerId,cellName:I,token:i,readonly:s,focused:a===re,onFocus:u,onClose:te,onOpenSingle:h,available:j.unavailable!==!0,alive:j.unavailable!==!0&&(!o||o.has(re)),fontSize:j.fontSize,onZoom:V=>t(ib(e,T,D,V)),decks:p,currentDeck:f,onSendToDeck:_})},re)),D<K.tiles.length-1&&U.push(c.jsx("div",{className:"nc-divider-h",onPointerDown:V=>H(V,T,D)},`h${D}`)),U})},`c${T}`)),T<A-1&&E.push(c.jsx("div",{className:"nc-divider-v",onPointerDown:j=>Z(j,T)},`v${T}`)),E}),ee&&c.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),A===0&&c.jsx("div",{className:"nc-grid-empty",children:g("grid-empty")})]})}const Sn="local",Hi=/^[a-f0-9]{16,64}$/;function ls(e,t){return`${e&&Hi.test(e)?e:Sn}:${t}`}function jh(e){const t=String(e||""),i=t.indexOf(":");if(i<1)return null;const s=t.slice(0,i),o=t.slice(i+1);return s!==Sn&&!Hi.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===Sn?null:s,name:o}}function Nl(e){return Array.isArray(e)&&e.length?e.join("/"):""}function Dh(e){return{columns:Cr(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(i=>({...i}))}))}}function ck(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Hi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(Nl(i.route),i.instanceId);return t}function uk(e){const t=new Map;for(const i of Array.isArray(e)?e:[])i&&Hi.test(String(i.instanceId||""))&&Array.isArray(i.route)&&t.set(i.instanceId,[...i.route]);return t}function Qd(e,t,i=[]){const s=Dh(e),o=ck(i);for(const a of s.columns)for(const u of a.tiles)u.ownerId||(!u.node&&Hi.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function Jd(e,t,i=[]){const s=Dh(e),o=new Map;for(const a of i)a&&Hi.test(String(a.instanceId||""))&&Array.isArray(a.route)&&o.set(a.instanceId,[...a.route]);for(const a of s.columns)for(const u of a.tiles)u.ownerId&&(u.ownerId===t?(delete u.node,delete u.unavailable):o.has(u.ownerId)?(u.node=Nl(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function Gg(e,t,i=[]){const s=Dh(e),o=uk(i);for(const a of s.columns)for(const u of a.tiles)delete u.unavailable,u.ownerId&&(u.ownerId===t?delete u.node:o.has(u.ownerId)&&(u.node=Nl(o.get(u.ownerId))));return s}function yy(e,t,i=[]){const s=tr(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Hi.test(String(t||""))?{ownerId:t}:{}};const o=i.find(a=>Nl(a&&a.route)===s.node);return{...s,...o&&Hi.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const dk=/^[a-z0-9-]{1,32}$/,Pi="main",wy="nc_decks",Sy="nc_deck_order_v1",by=24;function Qg(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function fs(e){return typeof e=="string"&&dk.test(e)}function hk(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let i;try{i=decodeURIComponent(t[1])}catch{i=t[1]}return fs(i)?i:Pi}return Pi}function fk(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:ls(null,Pi),ownerId:null,name:Pi}}if(Hi.test(s)&&fs(o))return{id:ls(s,o),ownerId:s,name:o}}const i=hk(e);return{id:ls(null,i),ownerId:null,name:i}}function Lu(e,t){const i=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:jh(e)||{ownerId:null,name:e},s=fs(i.name)?i.name:Pi,o=i.ownerId?`/deck/${encodeURIComponent(i.ownerId)}/${encodeURIComponent(s)}`:s===Pi?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function xy(e){return e===Pi?"nc_grid_v1":`nc_grid_v1__${e}`}function Cy(e){const t=[Pi];if(Array.isArray(e)){for(const i of e)if(fs(i)&&i!==Pi&&!t.includes(i)&&t.push(i),t.length>=by)break}return t}function vs(){return typeof localStorage<"u"?localStorage:null}function pk(){const e=vs();if(!e)return[Pi];try{return Cy(JSON.parse(e.getItem(wy)||"null"))}catch{return[Pi]}}function mk(e){const t=vs();if(t)try{t.setItem(wy,JSON.stringify(Cy(e)))}catch{}}function jo(e){return e==="local"||Hi.test(String(e||""))}function Rl(e,t){const i=jh(e);return!!i&&(i.ownerId||"local")===t}function un(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[i,s]of Object.entries(e).slice(0,64)){if(!jo(i)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&Rl(a,i)))].slice(0,by);o.length&&(t[i]=o)}return t}function Ya(e=vs()){if(!e)return{};try{return un(JSON.parse(e.getItem(Sy)||"null"))}catch{return{}}}function Mu(e,t=vs()){const i=un(e);if(t)try{t.setItem(Sy,JSON.stringify(i))}catch{}return i}function Pl(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function gk(e,t,i,s,o=[]){if(!jo(t)||i===s)return un(e);const a=[...new Set(o.filter(b=>Rl(b,t)))];if(!a.includes(i)||!a.includes(s))return un(e);const u=Pl(e,t).filter(b=>a.includes(b)),h=[...u,...a.filter(b=>!u.includes(b))],p=h.indexOf(i),f=h.indexOf(s);h.splice(p,1);const _=h.indexOf(s);return h.splice(p<f?_+1:_,0,i),un({...e,[t]:h})}function vk(e,t,i,s){if(!jo(t)||!Rl(s,t))return un(e);const o=Pl(e,t);return o.includes(i)?un({...e,[t]:o.map(a=>a===i?s:a)}):un(e)}function _k(e,t,i){return jo(t)?un({...e,[t]:Pl(e,t).filter(s=>s!==i)}):un(e)}function Jg(e,t={}){const i=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!jo(a)||!Rl(o==null?void 0:o.id,a)||(i.has(a)||i.set(a,[]),i.get(a).push(o))}const s=[];for(const[,o]of i){const a=o[0].local?"local":o[0].ownerId,u=Pl(t,a),h=new Map(u.map((p,f)=>[p,f]));o.sort((p,f)=>{const _=h.has(p.id)?h.get(p.id):Number.MAX_SAFE_INTEGER,b=h.has(f.id)?h.get(f.id):Number.MAX_SAFE_INTEGER;return _-b}),s.push(...o)}return s}function Zd(e){const t=vs();if(!t)return null;try{return JSON.parse(t.getItem(xy(e))||"null")}catch{return null}}function yk(e,t){const i=vs();if(i)try{i.setItem(xy(e),JSON.stringify(t))}catch{}}const Zg=52,ev=18;function wk({ownerKey:e,deckId:t,label:i,onMove:s,onStep:o}){const a=R.useRef(null),u=R.useRef(0),[h,p]=R.useState(!1),f=()=>{var x,k,C,P;const y=a.current;(k=(x=y==null?void 0:y.over)==null?void 0:x.classList)==null||k.remove("nc-deck-over"),(P=(C=y==null?void 0:y.source)==null?void 0:C.classList)==null||P.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},_=(y=!1)=>{const x=a.current;if(!x)return;const k=x.target;f(),a.current=null,p(!1);try{x.handle.releasePointerCapture(x.pointerId)}catch{}y&&k&&k!==t&&s(t,k)},b=(y,x)=>{var M,ee,q,B,Z,H,te,K;const k=a.current;if(!k)return;k.x=y,k.y=x;const C=(ee=(M=document.elementFromPoint(y,x))==null?void 0:M.closest)==null?void 0:ee.call(M,"[data-deck-id][data-owner-key]"),P=(q=C==null?void 0:C.dataset)==null?void 0:q.deckId,A=((B=C==null?void 0:C.dataset)==null?void 0:B.ownerKey)===e&&P&&P!==t;k.over!==(A?C:null)&&((H=(Z=k.over)==null?void 0:Z.classList)==null||H.remove("nc-deck-over"),k.over=A?C:null,(K=(te=k.over)==null?void 0:te.classList)==null||K.add("nc-deck-over")),k.target=A?P:null},S=()=>{var k,C;const y=a.current;if(!y){u.current=0;return}const x=(C=(k=y.container)==null?void 0:k.getBoundingClientRect)==null?void 0:C.call(k);if(x){const P=y.x<x.left+Zg?-ev:y.x>x.right-Zg?ev:0;P&&(y.container.scrollLeft+=P,b(y.x,y.y))}u.current=requestAnimationFrame(S)};R.useEffect(()=>{const y=k=>{k.key==="Escape"&&a.current&&(k.preventDefault(),_(!1))},x=()=>_(!1);return window.addEventListener("keydown",y),window.addEventListener("blur",x),()=>{window.removeEventListener("keydown",y),window.removeEventListener("blur",x),f(),a.current=null}},[t,e]);const w=y=>{var C;if(y.pointerType==="mouse"&&y.button!==0)return;y.preventDefault(),y.stopPropagation(),y.currentTarget.focus({preventScroll:!0});const x=y.currentTarget.closest("[data-deck-id][data-owner-key]"),k=y.currentTarget.closest(".nc-deckbar");a.current={pointerId:y.pointerId,handle:y.currentTarget,source:x,container:k,target:null,over:null,x:y.clientX,y:y.clientY},(C=x==null?void 0:x.classList)==null||C.add("nc-deck-dragging");try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}p(!0),u.current=requestAnimationFrame(S)};return c.jsx("button",{type:"button",className:`nc-deck-handle${h?" active":""}`,"aria-label":`${g("reorder")} ${i}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:g("reorder-deck-help"),onClick:y=>{y.preventDefault(),y.stopPropagation()},onDragStart:y=>y.preventDefault(),onKeyDown:y=>{y.key!=="ArrowLeft"&&y.key!=="ArrowRight"||(y.preventDefault(),y.stopPropagation(),o(y.key==="ArrowLeft"?-1:1))},onPointerDown:w,onPointerMove:y=>{!a.current||y.pointerId!==a.current.pointerId||(y.preventDefault(),y.stopPropagation(),b(y.clientX,y.clientY))},onPointerUp:y=>{!a.current||y.pointerId!==a.current.pointerId||(y.preventDefault(),y.stopPropagation(),_(!0))},onPointerCancel:()=>_(!1),onLostPointerCapture:()=>{a.current&&_(!1)},children:"↔"})}function Sk({decks:e=[],currentDeck:t="local:main",onCreate:i,onRename:s,onDelete:o,onReorder:a,onOpenWindow:u,onNavigate:h,saveState:p="idle",error:f="",sidebarVisible:_,onToggleSidebar:b}){ji();const[S,w]=R.useState(null),[y,x]=R.useState(""),[k,C]=R.useState(!1),[P,A]=R.useState(""),[M,ee]=R.useState(""),q=Qg(y),B=fs(q),Z=[];for(const E of e){const j=E.local?"local":E.ownerId;let D=Z.find(U=>U.key===j);D||(D={key:j,label:E.ownerLabel||(E.local?"Local":j),local:!!E.local,decks:[]},Z.push(D)),D.decks.push(E)}const H=async()=>{if(B){C(!0),A("");try{i&&await i(q,S),x(""),w(null)}catch(E){A(String(E.message||E))}C(!1)}},te=E=>{ee(""),u&&u(E.id)||ee(E.id)},K=async E=>{if(!(E.id===t||!h||k||E.available===!1)){C(!0),A("");try{await h(E.id)}catch(j){A(String((j==null?void 0:j.message)||j))}C(!1)}},T=(E,j,D)=>{const U=E.decks.findIndex(I=>I.id===j.id),re=E.decks[U+D];U>=0&&re&&a&&!k&&a(j.id,re.id)};return c.jsxs("div",{className:"nc-deckbar",children:[b&&c.jsx("button",{className:"nc-deck-sidebar-toggle",title:g("toggle-sidebar"),onClick:b,children:_?"◀":"☰"}),c.jsx("span",{className:"nc-deckbar-label",children:g("decks")}),c.jsx("div",{className:"nc-deck-chips",children:Z.map(E=>c.jsxs("span",{className:"nc-deck-owner-group",children:[c.jsx("span",{className:"nc-deck-owner",children:E.local?"Local":E.label}),E.decks.map(j=>c.jsxs("span",{"data-deck-id":j.id,"data-owner-key":E.key,className:`nc-deck-chip${j.id===t?" current":""}${j.available===!1?" offline":""}`,children:[c.jsx(wk,{ownerKey:E.key,deckId:j.id,label:`${E.label} · ${j.name}`,onMove:(D,U)=>{a&&!k&&a(D,U)},onStep:D=>T(E,j,D)}),c.jsxs("button",{className:"nc-deck-open",title:j.available===!1?`${j.ownerLabel} offline`:j.id===t?g("deck-current"):`${j.ownerLabel} · ${j.name}`,disabled:k||j.available===!1,onClick:()=>K(j),children:[j.name,j.id===t?" •":""]}),c.jsx("button",{className:"nc-deck-mini",disabled:j.available===!1,title:g("detach-deck"),onClick:()=>te(j),children:"↗"}),j.name!==Pi&&c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"nc-deck-mini",disabled:j.available===!1,title:g("rename-deck"),onClick:()=>{const D=(typeof window<"u"?window.prompt(g("rename-deck"),j.name):"")||"",U=Qg(D);fs(U)&&U!==j.name&&s&&s(j.id,U).catch(re=>A(String(re.message||re)))},children:"✎"}),c.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:j.available===!1,title:g("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(g("delete-deck-confirm").replace("{name}",`${j.ownerLabel} · ${j.name}`)))&&o&&o(j.id).catch(D=>A(String(D.message||D)))},children:"✕"})]})]},j.id)),S===E.key?c.jsxs("span",{className:"nc-deck-add",children:[c.jsx("input",{autoFocus:!0,className:B||!y?"":"invalid",placeholder:g("deck-name"),value:y,onChange:j=>x(j.target.value),onKeyDown:j=>{j.key==="Enter"&&H(),j.key==="Escape"&&(x(""),w(null))}}),y&&B&&q!==y&&c.jsxs("span",{className:"nc-deck-slug",children:["→ ",q]}),c.jsx("button",{className:"nc-deck-ok",disabled:!B||k,onClick:H,children:g("create")}),c.jsx("button",{className:"nc-deck-cancel",onClick:()=>{x(""),w(null)},children:g("cancel")})]}):c.jsxs("button",{className:"nc-deck-newbtn",disabled:k||E.decks.every(j=>j.available===!1),title:`${g("new-deck")} · ${E.label}`,onClick:()=>{x(""),w(E.key)},children:["+ ",g("new")]})]},E.key))}),c.jsx("span",{className:`nc-deck-state ${p}`,title:g("deck-autosave"),children:g(p==="saving"?"saving":p==="saved"?"saved":"deck-autosave")}),(P||f)&&c.jsx("span",{className:"nc-deck-error",children:P||f}),M&&c.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(M),children:g("popup-blocked")})]})}var rs={},Tu,tv;function bk(){return tv||(tv=1,Tu=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Tu}var Au={},Vn={},iv;function jr(){if(iv)return Vn;iv=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 Vn.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},Vn.getSymbolTotalCodewords=function(s){return t[s]},Vn.getBCHDigit=function(i){let s=0;for(;i!==0;)s++,i>>>=1;return s},Vn.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},Vn.isKanjiModeEnabled=function(){return typeof e<"u"},Vn.toSJIS=function(s){return e(s)},Vn}var Iu={},nv;function Lh(){return nv||(nv=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(Iu)),Iu}var Bu,rv;function xk(){if(rv)return Bu;rv=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const i=Math.floor(t/8);return(this.buffer[i]>>>7-t%8&1)===1},put:function(t,i){for(let s=0;s<i;s++)this.putBit((t>>>i-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),t&&(this.buffer[i]|=128>>>this.length%8),this.length++}},Bu=e,Bu}var Ou,sv;function Ck(){if(sv)return Ou;sv=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,i,s,o){const a=t*this.size+i;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,i){return this.data[t*this.size+i]},e.prototype.xor=function(t,i,s){this.data[t*this.size+i]^=s},e.prototype.isReserved=function(t,i){return this.reservedBit[t*this.size+i]},Ou=e,Ou}var zu={},ov;function kk(){return ov||(ov=1,(function(e){const t=jr().getSymbolSize;e.getRowColCoords=function(s){if(s===1)return[];const o=Math.floor(s/7)+2,a=t(s),u=a===145?26:Math.ceil((a-13)/(2*o-2))*2,h=[a-7];for(let p=1;p<o-1;p++)h[p]=h[p-1]-u;return h.push(6),h.reverse()},e.getPositions=function(s){const o=[],a=e.getRowColCoords(s),u=a.length;for(let h=0;h<u;h++)for(let p=0;p<u;p++)h===0&&p===0||h===0&&p===u-1||h===u-1&&p===0||o.push([a[h],a[p]]);return o}})(zu)),zu}var Fu={},av;function Ek(){if(av)return Fu;av=1;const e=jr().getSymbolSize,t=7;return Fu.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Fu}var $u={},lv;function Nk(){return lv||(lv=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.getPenaltyN1=function(o){const a=o.size;let u=0,h=0,p=0,f=null,_=null;for(let b=0;b<a;b++){h=p=0,f=_=null;for(let S=0;S<a;S++){let w=o.get(b,S);w===f?h++:(h>=5&&(u+=t.N1+(h-5)),f=w,h=1),w=o.get(S,b),w===_?p++:(p>=5&&(u+=t.N1+(p-5)),_=w,p=1)}h>=5&&(u+=t.N1+(h-5)),p>=5&&(u+=t.N1+(p-5))}return u},e.getPenaltyN2=function(o){const a=o.size;let u=0;for(let h=0;h<a-1;h++)for(let p=0;p<a-1;p++){const f=o.get(h,p)+o.get(h,p+1)+o.get(h+1,p)+o.get(h+1,p+1);(f===4||f===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const a=o.size;let u=0,h=0,p=0;for(let f=0;f<a;f++){h=p=0;for(let _=0;_<a;_++)h=h<<1&2047|o.get(f,_),_>=10&&(h===1488||h===93)&&u++,p=p<<1&2047|o.get(_,f),_>=10&&(p===1488||p===93)&&u++}return u*t.N3},e.getPenaltyN4=function(o){let a=0;const u=o.data.length;for(let p=0;p<u;p++)a+=o.data[p];return Math.abs(Math.ceil(a*100/u/5)-10)*t.N4};function i(s,o,a){switch(s){case e.Patterns.PATTERN000:return(o+a)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return a%3===0;case e.Patterns.PATTERN011:return(o+a)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(a/3))%2===0;case e.Patterns.PATTERN101:return o*a%2+o*a%3===0;case e.Patterns.PATTERN110:return(o*a%2+o*a%3)%2===0;case e.Patterns.PATTERN111:return(o*a%3+(o+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}e.applyMask=function(o,a){const u=a.size;for(let h=0;h<u;h++)for(let p=0;p<u;p++)a.isReserved(p,h)||a.xor(p,h,i(o,p,h))},e.getBestMask=function(o,a){const u=Object.keys(e.Patterns).length;let h=0,p=1/0;for(let f=0;f<u;f++){a(f),e.applyMask(f,o);const _=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(f,o),_<p&&(p=_,h=f)}return h}})($u)),$u}var Xa={},cv;function ky(){if(cv)return Xa;cv=1;const e=Lh(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Xa.getBlocksCount=function(o,a){switch(a){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Xa.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return i[(o-1)*4+0];case e.M:return i[(o-1)*4+1];case e.Q:return i[(o-1)*4+2];case e.H:return i[(o-1)*4+3];default:return}},Xa}var Hu={},co={},uv;function Rk(){if(uv)return co;uv=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]})(),co.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},co.exp=function(s){return e[s]},co.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},co}var dv;function Pk(){return dv||(dv=1,(function(e){const t=Rk();e.mul=function(s,o){const a=new Uint8Array(s.length+o.length-1);for(let u=0;u<s.length;u++)for(let h=0;h<o.length;h++)a[u+h]^=t.mul(s[u],o[h]);return a},e.mod=function(s,o){let a=new Uint8Array(s);for(;a.length-o.length>=0;){const u=a[0];for(let p=0;p<o.length;p++)a[p]^=t.mul(o[p],u);let h=0;for(;h<a.length&&a[h]===0;)h++;a=a.slice(h)}return a},e.generateECPolynomial=function(s){let o=new Uint8Array([1]);for(let a=0;a<s;a++)o=e.mul(o,new Uint8Array([1,t.exp(a)]));return o}})(Hu)),Hu}var Wu,hv;function jk(){if(hv)return Wu;hv=1;const e=Pk();function t(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const a=e.mod(o,this.genPoly),u=this.degree-a.length;if(u>0){const h=new Uint8Array(this.degree);return h.set(a,u),h}return a},Wu=t,Wu}var Uu={},Ku={},qu={},fv;function Ey(){return fv||(fv=1,qu.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),qu}var sn={},pv;function Ny(){if(pv)return sn;pv=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
82
|
+
]))+`;sn.KANJI=new RegExp(i,"g"),sn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),sn.BYTE=new RegExp(s,"g"),sn.NUMERIC=new RegExp(e,"g"),sn.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+i+"$"),a=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return sn.testKanji=function(p){return o.test(p)},sn.testNumeric=function(p){return a.test(p)},sn.testAlphanumeric=function(p){return u.test(p)},sn}var mv;function Dr(){return mv||(mv=1,(function(e){const t=Ey(),i=Ny();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(a,u){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?a.ccBits[0]:u<27?a.ccBits[1]:a.ccBits[2]},e.getBestModeForData=function(a){return i.testNumeric(a)?e.NUMERIC:i.testAlphanumeric(a)?e.ALPHANUMERIC:i.testKanji(a)?e.KANJI:e.BYTE},e.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},e.isValid=function(a){return a&&a.bit&&a.ccBits};function s(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(a,u){if(e.isValid(a))return a;try{return s(a)}catch{return u}}})(Ku)),Ku}var gv;function Dk(){return gv||(gv=1,(function(e){const t=jr(),i=ky(),s=Lh(),o=Dr(),a=Ey(),u=7973,h=t.getBCHDigit(u);function p(S,w,y){for(let x=1;x<=40;x++)if(w<=e.getCapacity(x,y,S))return x}function f(S,w){return o.getCharCountIndicator(S,w)+4}function _(S,w){let y=0;return S.forEach(function(x){const k=f(x.mode,w);y+=k+x.getBitsLength()}),y}function b(S,w){for(let y=1;y<=40;y++)if(_(S,y)<=e.getCapacity(y,w,o.MIXED))return y}e.from=function(w,y){return a.isValid(w)?parseInt(w,10):y},e.getCapacity=function(w,y,x){if(!a.isValid(w))throw new Error("Invalid QR Code version");typeof x>"u"&&(x=o.BYTE);const k=t.getSymbolTotalCodewords(w),C=i.getTotalCodewordsCount(w,y),P=(k-C)*8;if(x===o.MIXED)return P;const A=P-f(x,w);switch(x){case o.NUMERIC:return Math.floor(A/10*3);case o.ALPHANUMERIC:return Math.floor(A/11*2);case o.KANJI:return Math.floor(A/13);case o.BYTE:default:return Math.floor(A/8)}},e.getBestVersionForData=function(w,y){let x;const k=s.from(y,s.M);if(Array.isArray(w)){if(w.length>1)return b(w,k);if(w.length===0)return 1;x=w[0]}else x=w;return p(x.mode,x.getLength(),k)},e.getEncodedBits=function(w){if(!a.isValid(w)||w<7)throw new Error("Invalid QR Code version");let y=w<<12;for(;t.getBCHDigit(y)-h>=0;)y^=u<<t.getBCHDigit(y)-h;return w<<12|y}})(Uu)),Uu}var Vu={},vv;function Lk(){if(vv)return Vu;vv=1;const e=jr(),t=1335,i=21522,s=e.getBCHDigit(t);return Vu.getEncodedBits=function(a,u){const h=a.bit<<3|u;let p=h<<10;for(;e.getBCHDigit(p)-s>=0;)p^=t<<e.getBCHDigit(p)-s;return(h<<10|p)^i},Vu}var Yu={},Xu,_v;function Mk(){if(_v)return Xu;_v=1;const e=Dr();function t(i){this.mode=e.NUMERIC,this.data=i.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,a,u;for(o=0;o+3<=this.data.length;o+=3)a=this.data.substr(o,3),u=parseInt(a,10),s.put(u,10);const h=this.data.length-o;h>0&&(a=this.data.substr(o),u=parseInt(a,10),s.put(u,h*3+1))},Xu=t,Xu}var Gu,yv;function Tk(){if(yv)return Gu;yv=1;const e=Dr(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(s){this.mode=e.ALPHANUMERIC,this.data=s}return i.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(o){let a;for(a=0;a+2<=this.data.length;a+=2){let u=t.indexOf(this.data[a])*45;u+=t.indexOf(this.data[a+1]),o.put(u,11)}this.data.length%2&&o.put(t.indexOf(this.data[a]),6)},Gu=i,Gu}var Qu,wv;function Ak(){if(wv)return Qu;wv=1;const e=Dr();function t(i){this.mode=e.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(i){for(let s=0,o=this.data.length;s<o;s++)i.put(this.data[s],8)},Qu=t,Qu}var Ju,Sv;function Ik(){if(Sv)return Ju;Sv=1;const e=Dr(),t=jr();function i(s){this.mode=e.KANJI,this.data=s}return i.getBitsLength=function(o){return o*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let a=t.toSJIS(this.data[o]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
|
|
83
|
+
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),s.put(a,13)}},Ju=i,Ju}var Zu={exports:{}},bv;function Bk(){return bv||(bv=1,(function(e){var t={single_source_shortest_paths:function(i,s,o){var a={},u={};u[s]=0;var h=t.PriorityQueue.make();h.push(s,0);for(var p,f,_,b,S,w,y,x,k;!h.empty();){p=h.pop(),f=p.value,b=p.cost,S=i[f]||{};for(_ in S)S.hasOwnProperty(_)&&(w=S[_],y=b+w,x=u[_],k=typeof u[_]>"u",(k||x>y)&&(u[_]=y,h.push(_,y),a[_]=f))}if(typeof o<"u"&&typeof u[o]>"u"){var C=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(C)}return a},extract_shortest_path_from_predecessor_list:function(i,s){for(var o=[],a=s;a;)o.push(a),i[a],a=i[a];return o.reverse(),o},find_path:function(i,s,o){var a=t.single_source_shortest_paths(i,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(i){var s=t.PriorityQueue,o={},a;i=i||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=i.sorter||s.default_sorter,o},default_sorter:function(i,s){return i.cost-s.cost},push:function(i,s){var o={value:i,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(Zu)),Zu.exports}var xv;function Ok(){return xv||(xv=1,(function(e){const t=Dr(),i=Mk(),s=Tk(),o=Ak(),a=Ik(),u=Ny(),h=jr(),p=Bk();function f(C){return unescape(encodeURIComponent(C)).length}function _(C,P,A){const M=[];let ee;for(;(ee=C.exec(A))!==null;)M.push({data:ee[0],index:ee.index,mode:P,length:ee[0].length});return M}function b(C){const P=_(u.NUMERIC,t.NUMERIC,C),A=_(u.ALPHANUMERIC,t.ALPHANUMERIC,C);let M,ee;return h.isKanjiModeEnabled()?(M=_(u.BYTE,t.BYTE,C),ee=_(u.KANJI,t.KANJI,C)):(M=_(u.BYTE_KANJI,t.BYTE,C),ee=[]),P.concat(A,M,ee).sort(function(B,Z){return B.index-Z.index}).map(function(B){return{data:B.data,mode:B.mode,length:B.length}})}function S(C,P){switch(P){case t.NUMERIC:return i.getBitsLength(C);case t.ALPHANUMERIC:return s.getBitsLength(C);case t.KANJI:return a.getBitsLength(C);case t.BYTE:return o.getBitsLength(C)}}function w(C){return C.reduce(function(P,A){const M=P.length-1>=0?P[P.length-1]:null;return M&&M.mode===A.mode?(P[P.length-1].data+=A.data,P):(P.push(A),P)},[])}function y(C){const P=[];for(let A=0;A<C.length;A++){const M=C[A];switch(M.mode){case t.NUMERIC:P.push([M,{data:M.data,mode:t.ALPHANUMERIC,length:M.length},{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.ALPHANUMERIC:P.push([M,{data:M.data,mode:t.BYTE,length:M.length}]);break;case t.KANJI:P.push([M,{data:M.data,mode:t.BYTE,length:f(M.data)}]);break;case t.BYTE:P.push([{data:M.data,mode:t.BYTE,length:f(M.data)}])}}return P}function x(C,P){const A={},M={start:{}};let ee=["start"];for(let q=0;q<C.length;q++){const B=C[q],Z=[];for(let H=0;H<B.length;H++){const te=B[H],K=""+q+H;Z.push(K),A[K]={node:te,lastCount:0},M[K]={};for(let T=0;T<ee.length;T++){const E=ee[T];A[E]&&A[E].node.mode===te.mode?(M[E][K]=S(A[E].lastCount+te.length,te.mode)-S(A[E].lastCount,te.mode),A[E].lastCount+=te.length):(A[E]&&(A[E].lastCount=te.length),M[E][K]=S(te.length,te.mode)+4+t.getCharCountIndicator(te.mode,P))}}ee=Z}for(let q=0;q<ee.length;q++)M[ee[q]].end=0;return{map:M,table:A}}function k(C,P){let A;const M=t.getBestModeForData(C);if(A=t.from(P,M),A!==t.BYTE&&A.bit<M.bit)throw new Error('"'+C+'" cannot be encoded with mode '+t.toString(A)+`.
|
|
84
|
+
Suggested mode is: `+t.toString(M));switch(A===t.KANJI&&!h.isKanjiModeEnabled()&&(A=t.BYTE),A){case t.NUMERIC:return new i(C);case t.ALPHANUMERIC:return new s(C);case t.KANJI:return new a(C);case t.BYTE:return new o(C)}}e.fromArray=function(P){return P.reduce(function(A,M){return typeof M=="string"?A.push(k(M,null)):M.data&&A.push(k(M.data,M.mode)),A},[])},e.fromString=function(P,A){const M=b(P,h.isKanjiModeEnabled()),ee=y(M),q=x(ee,A),B=p.find_path(q.map,"start","end"),Z=[];for(let H=1;H<B.length-1;H++)Z.push(q.table[B[H]].node);return e.fromArray(w(Z))},e.rawSplit=function(P){return e.fromArray(b(P,h.isKanjiModeEnabled()))}})(Yu)),Yu}var Cv;function zk(){if(Cv)return Au;Cv=1;const e=jr(),t=Lh(),i=xk(),s=Ck(),o=kk(),a=Ek(),u=Nk(),h=ky(),p=jk(),f=Dk(),_=Lk(),b=Dr(),S=Ok();function w(q,B){const Z=q.size,H=a.getPositions(B);for(let te=0;te<H.length;te++){const K=H[te][0],T=H[te][1];for(let E=-1;E<=7;E++)if(!(K+E<=-1||Z<=K+E))for(let j=-1;j<=7;j++)T+j<=-1||Z<=T+j||(E>=0&&E<=6&&(j===0||j===6)||j>=0&&j<=6&&(E===0||E===6)||E>=2&&E<=4&&j>=2&&j<=4?q.set(K+E,T+j,!0,!0):q.set(K+E,T+j,!1,!0))}}function y(q){const B=q.size;for(let Z=8;Z<B-8;Z++){const H=Z%2===0;q.set(Z,6,H,!0),q.set(6,Z,H,!0)}}function x(q,B){const Z=o.getPositions(B);for(let H=0;H<Z.length;H++){const te=Z[H][0],K=Z[H][1];for(let T=-2;T<=2;T++)for(let E=-2;E<=2;E++)T===-2||T===2||E===-2||E===2||T===0&&E===0?q.set(te+T,K+E,!0,!0):q.set(te+T,K+E,!1,!0)}}function k(q,B){const Z=q.size,H=f.getEncodedBits(B);let te,K,T;for(let E=0;E<18;E++)te=Math.floor(E/3),K=E%3+Z-8-3,T=(H>>E&1)===1,q.set(te,K,T,!0),q.set(K,te,T,!0)}function C(q,B,Z){const H=q.size,te=_.getEncodedBits(B,Z);let K,T;for(K=0;K<15;K++)T=(te>>K&1)===1,K<6?q.set(K,8,T,!0):K<8?q.set(K+1,8,T,!0):q.set(H-15+K,8,T,!0),K<8?q.set(8,H-K-1,T,!0):K<9?q.set(8,15-K-1+1,T,!0):q.set(8,15-K-1,T,!0);q.set(H-8,8,1,!0)}function P(q,B){const Z=q.size;let H=-1,te=Z-1,K=7,T=0;for(let E=Z-1;E>0;E-=2)for(E===6&&E--;;){for(let j=0;j<2;j++)if(!q.isReserved(te,E-j)){let D=!1;T<B.length&&(D=(B[T]>>>K&1)===1),q.set(te,E-j,D),K--,K===-1&&(T++,K=7)}if(te+=H,te<0||Z<=te){te-=H,H=-H;break}}}function A(q,B,Z){const H=new i;Z.forEach(function(j){H.put(j.mode.bit,4),H.put(j.getLength(),b.getCharCountIndicator(j.mode,q)),j.write(H)});const te=e.getSymbolTotalCodewords(q),K=h.getTotalCodewordsCount(q,B),T=(te-K)*8;for(H.getLengthInBits()+4<=T&&H.put(0,4);H.getLengthInBits()%8!==0;)H.putBit(0);const E=(T-H.getLengthInBits())/8;for(let j=0;j<E;j++)H.put(j%2?17:236,8);return M(H,q,B)}function M(q,B,Z){const H=e.getSymbolTotalCodewords(B),te=h.getTotalCodewordsCount(B,Z),K=H-te,T=h.getBlocksCount(B,Z),E=H%T,j=T-E,D=Math.floor(H/T),U=Math.floor(K/T),re=U+1,I=D-U,V=new p(I);let $=0;const L=new Array(T),z=new Array(T);let oe=0;const ce=new Uint8Array(q.buffer);for(let ge=0;ge<T;ge++){const Me=ge<j?U:re;L[ge]=ce.slice($,$+Me),z[ge]=V.encode(L[ge]),$+=Me,oe=Math.max(oe,Me)}const he=new Uint8Array(H);let me=0,G,J;for(G=0;G<oe;G++)for(J=0;J<T;J++)G<L[J].length&&(he[me++]=L[J][G]);for(G=0;G<I;G++)for(J=0;J<T;J++)he[me++]=z[J][G];return he}function ee(q,B,Z,H){let te;if(Array.isArray(q))te=S.fromArray(q);else if(typeof q=="string"){let D=B;if(!D){const U=S.rawSplit(q);D=f.getBestVersionForData(U,Z)}te=S.fromString(q,D||40)}else throw new Error("Invalid data");const K=f.getBestVersionForData(te,Z);if(!K)throw new Error("The amount of data is too big to be stored in a QR Code");if(!B)B=K;else if(B<K)throw new Error(`
|
|
85
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
+
Minimum version required to store current data is: `+K+`.
|
|
87
|
+
`);const T=A(B,Z,te),E=e.getSymbolSize(B),j=new s(E);return w(j,B),y(j),x(j,B),C(j,Z,0),B>=7&&k(j,B),P(j,T),isNaN(H)&&(H=u.getBestMask(j,C.bind(null,j,Z))),u.applyMask(H,j),C(j,Z,H),{modules:j,version:B,errorCorrectionLevel:Z,maskPattern:H,segments:te}}return Au.create=function(B,Z){if(typeof B>"u"||B==="")throw new Error("No input text");let H=t.M,te,K;return typeof Z<"u"&&(H=t.from(Z.errorCorrectionLevel,t.M),te=f.from(Z.version),K=u.from(Z.maskPattern),Z.toSJISFunc&&e.setToSJISFunction(Z.toSJISFunc)),ee(B,te,H,K)},Au}var ed={},td={},kv;function Ry(){return kv||(kv=1,(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let s=i.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+i);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(a){return[a,a]}))),s.length===6&&s.push("F","F");const o=parseInt(s.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+s.slice(0,6).join("")}}e.getOptions=function(s){s||(s={}),s.color||(s.color={});const o=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,u=s.scale||4;return{width:a,scale:a?4:u,margin:o,color:{dark:t(s.color.dark||"#000000ff"),light:t(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},e.getScale=function(s,o){return o.width&&o.width>=s+o.margin*2?o.width/(s+o.margin*2):o.scale},e.getImageWidth=function(s,o){const a=e.getScale(s,o);return Math.floor((s+o.margin*2)*a)},e.qrToImageData=function(s,o,a){const u=o.modules.size,h=o.modules.data,p=e.getScale(u,a),f=Math.floor((u+a.margin*2)*p),_=a.margin*p,b=[a.color.light,a.color.dark];for(let S=0;S<f;S++)for(let w=0;w<f;w++){let y=(S*f+w)*4,x=a.color.light;if(S>=_&&w>=_&&S<f-_&&w<f-_){const k=Math.floor((S-_)/p),C=Math.floor((w-_)/p);x=b[h[k*u+C]?1:0]}s[y++]=x.r,s[y++]=x.g,s[y++]=x.b,s[y]=x.a}}})(td)),td}var Ev;function Fk(){return Ev||(Ev=1,(function(e){const t=Ry();function i(o,a,u){o.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=u,a.width=u,a.style.height=u+"px",a.style.width=u+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(a,u,h){let p=h,f=u;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),u||(f=s()),p=t.getOptions(p);const _=t.getImageWidth(a.modules.size,p),b=f.getContext("2d"),S=b.createImageData(_,_);return t.qrToImageData(S.data,a,p),i(b,f,_),b.putImageData(S,0,0),f},e.renderToDataURL=function(a,u,h){let p=h;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),p||(p={});const f=e.render(a,u,p),_=p.type||"image/png",b=p.rendererOpts||{};return f.toDataURL(_,b.quality)}})(ed)),ed}var id={},Nv;function $k(){if(Nv)return id;Nv=1;const e=Ry();function t(o,a){const u=o.a/255,h=a+'="'+o.hex+'"';return u<1?h+" "+a+'-opacity="'+u.toFixed(2).slice(1)+'"':h}function i(o,a,u){let h=o+a;return typeof u<"u"&&(h+=" "+u),h}function s(o,a,u){let h="",p=0,f=!1,_=0;for(let b=0;b<o.length;b++){const S=Math.floor(b%a),w=Math.floor(b/a);!S&&!f&&(f=!0),o[b]?(_++,b>0&&S>0&&o[b-1]||(h+=f?i("M",S+u,.5+w+u):i("m",p,0),p=0,f=!1),S+1<a&&o[b+1]||(h+=i("h",_),_=0)):p++}return h}return id.render=function(a,u,h){const p=e.getOptions(u),f=a.modules.size,_=a.modules.data,b=f+p.margin*2,S=p.color.light.a?"<path "+t(p.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",w="<path "+t(p.color.dark,"stroke")+' d="'+s(_,f,p.margin)+'"/>',y='viewBox="0 0 '+b+" "+b+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+y+' shape-rendering="crispEdges">'+S+w+`</svg>
|
|
88
|
+
`;return typeof h=="function"&&h(null,k),k},id}var Rv;function Hk(){if(Rv)return rs;Rv=1;const e=bk(),t=zk(),i=Fk(),s=$k();function o(a,u,h,p,f){const _=[].slice.call(arguments,1),b=_.length,S=typeof _[b-1]=="function";if(!S&&!e())throw new Error("Callback required as last argument");if(S){if(b<2)throw new Error("Too few arguments provided");b===2?(f=h,h=u,u=p=void 0):b===3&&(u.getContext&&typeof f>"u"?(f=p,p=void 0):(f=p,p=h,h=u,u=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(h=u,u=p=void 0):b===2&&!u.getContext&&(p=h,h=u,u=void 0),new Promise(function(w,y){try{const x=t.create(h,p);w(a(x,u,p))}catch(x){y(x)}})}try{const w=t.create(h,p);f(null,a(w,u,p))}catch(w){f(w)}}return rs.create=t.create,rs.toCanvas=o.bind(null,i.render),rs.toDataURL=o.bind(null,i.renderToDataURL),rs.toString=o.bind(null,function(a,u,h){return s.render(a,h)}),rs}var Wk=Hk();const Uk=sh(Wk);function Pv(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function Kk(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const i=hb(t);if(!i||!i.ok)return{kind:"invalid"};const s=[];return i.ssh||s.push("ssh"),i.name||s.push("name"),s.length?{kind:"partial",decoded:i,missing:s}:{kind:"complete",decoded:i}}function qk(e,t,i=new Set,s=!1){if(!t||!t.ok)return e;const o=fb(e,t,i);return t.version===2&&t.name&&!i.has("name")&&!s&&(o.name=t.name),!i.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function jv(e,t,i=new Set,s=!1){const o=String(t||"").trim(),a=Kk(o);let u={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(u={...qk(u,a.decoded,i,s),pairingUrl:o}),{classification:a,form:u}}function rl(e,t){const i=String(t||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(i))return"";const s=String(e||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let o=Zn(s);(o==="localhost"||o==="node")&&(o="nexuscrew");const a=i.slice(0,4),u=Math.max(1,32-a.length-1);return`${o.slice(0,u).replace(/-+$/g,"")||"n"}-${a}`}function Vk(e,{deviceDefault:t="",localNodeId:i="",localNameDefault:s=""}={}){const o={name:e.name,ssh:e.ssh,pairingUrl:e.pairingUrl,...e.label?{label:e.label}:{},...e.sshPort?{sshPort:Number(e.sshPort)}:{}},a=e.localLabel||t;a&&(o.localLabel=a);const u=String(e.localName||rl(a,i)||s||"").trim();return u&&(o.localName=u),o}function Yk(){const e=new Set;let t=!1;return{canAuto(i){return!t&&!e.has(String(i||""))},start(i){return t?!1:(t=!0,e.add(String(i||"")),!0)},finish(){t=!1},reset(i){e.delete(String(i||""))},isBusy(){return t}}}const Xk=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function Gk(e){const t=e&&e.data||{},i=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:i,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",suggestedName:typeof t.suggestedName=="string"?t.suggestedName:"",retryable:typeof t.retryable=="boolean"?t.retryable:!i,message:s||String(e&&e.message||e)}}const Qk="modulepreload",Jk=function(e){return"/"+e},Dv={},Zk=function(t,i,s){let o=Promise.resolve();if(i&&i.length>0){let u=function(f){return Promise.all(f.map(_=>Promise.resolve(_).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));o=u(i.map(f=>{if(f=Jk(f),f in Dv)return;Dv[f]=!0;const _=f.endsWith(".css"),b=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${b}`))return;const S=document.createElement("link");if(S.rel=_?"stylesheet":Qk,_||(S.as="script"),S.crossOrigin="",S.href=f,p&&S.setAttribute("nonce",p),document.head.appendChild(S),_)return new Promise((w,y)=>{S.addEventListener("load",w),S.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${f}`)))})}))}function a(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return o.then(u=>{for(const h of u||[])h.status==="rejected"&&a(h.reason);return t().catch(a)})};class Ye{constructor(t,i,s,o,a){this._legacyCanvasSize=Ye.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=i:(console.warn(s||o||a?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=i),i=typeof s=="object"?s:{},this._onDecodeError=i.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=i.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=i.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=i.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),s=t.parentElement,i.highlightScanRegion||i.highlightCodeOutline){if(o=!!i.overlay,this.$overlay=i.overlay||document.createElement("div"),a=this.$overlay.style,a.position="absolute",a.display="none",a.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!o&&i.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}i.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let h=window.getComputedStyle(t);h.display==="none"&&(t.style.setProperty("display","block","important"),u=!0),h.visibility!=="visible"&&(t.style.setProperty("visibility","visible","important"),u=!0),u&&(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=Ye.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 Ye.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let i=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await i()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await i()).map((o,a)=>({id:o.deviceId,label:o.label||(a===0?"Default Camera":`Camera ${a+1}`)}))}finally{s&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),Ye._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"),Ye._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(),Ye._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:i}=await this._getCameraStream();!this._active||this._paused?Ye._stopVideoStream(t):(this._setVideoMirror(i),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let i=()=>{this.$video.srcObject instanceof MediaStream&&(Ye._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(i(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(i(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,i,s,o,a=!1,u=!1){let h,p=!1;i&&("scanRegion"in i||"qrEngine"in i||"canvas"in i||"disallowCanvasResizing"in i||"alsoTryWithoutScanRegion"in i||"returnDetailedScanResult"in i)?(h=i.scanRegion,s=i.qrEngine,o=i.canvas,a=i.disallowCanvasResizing||!1,u=i.alsoTryWithoutScanRegion||!1,p=!0):console.warn(i||s||o||a||u?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),i=!!s;try{let f,_;[s,f]=await Promise.all([s||Ye.createQrEngine(),Ye._loadImage(t)]),[o,_]=Ye._drawToCanvas(f,h,o,a);let b;if(s instanceof Worker){let S=s;i||Ye._postWorkerMessageSync(S,"inversionMode","both"),b=await new Promise((w,y)=>{let x,k,C,P=-1;k=M=>{M.data.id===P&&(S.removeEventListener("message",k),S.removeEventListener("error",C),clearTimeout(x),M.data.data!==null?w({data:M.data.data,cornerPoints:Ye._convertPoints(M.data.cornerPoints,h)}):y(Ye.NO_QR_CODE_FOUND))},C=M=>{S.removeEventListener("message",k),S.removeEventListener("error",C),clearTimeout(x),y("Scanner error: "+(M?M.message||M:"Unknown Error"))},S.addEventListener("message",k),S.addEventListener("error",C),x=setTimeout(()=>C("timeout"),1e4);let A=_.getImageData(0,0,o.width,o.height);P=Ye._postWorkerMessageSync(S,"decode",A,[A.data.buffer])})}else b=await Promise.race([new Promise((S,w)=>window.setTimeout(()=>w("Scanner error: timeout"),1e4)),(async()=>{try{var[S]=await s.detect(o);if(!S)throw Ye.NO_QR_CODE_FOUND;return{data:S.rawValue,cornerPoints:Ye._convertPoints(S.cornerPoints,h)}}catch(w){if(S=w.message||w,/not implemented|service unavailable/.test(S))return Ye._disableBarcodeDetector=!0,Ye.scanImage(t,{scanRegion:h,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:u});throw`Scanner error: ${S}`}})()]);return p?b:b.data}catch(f){if(!h||!u)throw f;let _=await Ye.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return p?_:_.data}finally{i||Ye._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,i,s,o=!0){Ye._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:i,blue:s,useIntegerApproximation:o})}setInversionMode(t){Ye._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=()=>Zk(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Ye._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let i=navigator.userAgentData;return i&&i.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(i.platform)&&await i.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let i=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-i)/2),y:Math.round((t.videoHeight-i)/2),width:i,height:i,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,i=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,u=t.offsetLeft,h=t.offsetTop,p=window.getComputedStyle(t),f=p.objectFit,_=i/s,b=o/a;switch(f){case"none":var S=i,w=s;break;case"fill":S=o,w=a;break;default:(f==="cover"?_>b:_<b)?(w=a,S=w*_):(S=o,w=S/_),f==="scale-down"&&(S=Math.min(S,i),w=Math.min(w,s))}var[y,x]=p.objectPosition.split(" ").map((C,P)=>{const A=parseFloat(C);return C.endsWith("%")?(P?a-w:o-S)*A/100:A});p=this._scanRegion.width||i,b=this._scanRegion.height||s,f=this._scanRegion.x||0;var k=this._scanRegion.y||0;_=this.$overlay.style,_.width=`${p/i*S}px`,_.height=`${b/s*w}px`,_.top=`${h+x+k/s*w}px`,s=/scaleX\(-1\)/.test(t.style.transform),_.left=`${u+(s?o-y-S:y)+(s?i-f-p:f)/i*S}px`,_.transform=t.style.transform}})}static _convertPoints(t,i){if(!i)return t;let s=i.x||0,o=i.y||0,a=i.width&&i.downScaledWidth?i.width/i.downScaledWidth:1;i=i.height&&i.downScaledHeight?i.height/i.downScaledHeight:1;for(let u of t)u.x=u.x*a+s,u.y=u.y*i+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,i=1e3/this._maxScansPerSecond;t<i&&await new Promise(o=>setTimeout(o,i-t)),this._lastScanTimestamp=Date.now();try{var s=await Ye.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!Ye._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Ye.createQrEngine()),s?(this._onDecode?this._onDecode(s):this._legacyOnDecode&&this._legacyOnDecode(s.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",s.cornerPoints.map(({x:o,y:a})=>`${o},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(t){t!==Ye.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",i=[{width:{min:1024}},{width:{min:768}},{}],s=i.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...i])try{let a=await navigator.mediaDevices.getUserMedia({video:o,audio:!1}),u=this._getFacingMode(a)||(o.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:u}}catch{}throw"Camera not found."}async _restartVideoStream(){let t=this._paused;await this.pause(!0)&&!t&&this._active&&await this.start()}static _stopVideoStream(t){for(let i of t.getTracks())i.stop(),t.removeTrack(i)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,i,s,o=!1){s=s||document.createElement("canvas");let a=i&&i.x?i.x:0,u=i&&i.y?i.y:0,h=i&&i.width?i.width:t.videoWidth||t.width,p=i&&i.height?i.height:t.videoHeight||t.height;return o||(o=i&&i.downScaledWidth?i.downScaledWidth:h,i=i&&i.downScaledHeight?i.downScaledHeight:p,s.width!==o&&(s.width=o),s.height!==i&&(s.height=i)),i=s.getContext("2d",{alpha:!1}),i.imageSmoothingEnabled=!1,i.drawImage(t,a,u,h,p,0,0,s.width,s.height),[s,i]}static async _loadImage(t){if(t instanceof Image)return await Ye._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let i=new Image;i.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await Ye._awaitImageLoad(i),i}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(i.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((i,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):i()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,i,s,o){return Ye._postWorkerMessageSync(await t,i,s,o)}static _postWorkerMessageSync(t,i,s,o){if(!(t instanceof Worker))return-1;let a=Ye._workerMessageId++;return t.postMessage({id:a,type:i,data:s},o),a}}Ye.DEFAULT_CANVAS_SIZE=400;Ye.NO_QR_CODE_FOUND="No QR code found";Ye._disableBarcodeDetector=!1;Ye._workerMessageId=0;function eE({onResult:e,onClose:t}){const i=R.useRef(null),s=R.useRef(null),o=R.useRef(!1),[a,u]=R.useState("");R.useEffect(()=>{let p=!1;const f=i.current,_=b=>{p||o.current||(o.current=!0,e(b))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(g("qr-unsupported"));return}let b=!1;try{b=await Ye.hasCamera()}catch{b=!1}if(!b){u(g("qr-no-camera"));return}if(p||!f)return;const S=new Ye(f,w=>{const y=Pv(w);y&&_(y)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:w=>{const y=w.videoWidth||640,x=w.videoHeight||480,k=Math.max(1,Math.round(Math.min(y,x)*.92));return{x:Math.round((y-k)/2),y:Math.round((x-k)/2),width:k,height:k,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=S;try{await S.start()}catch(w){if(p)return;const y=w&&w.name||"";u(g(y==="NotAllowedError"||y==="SecurityError"?"qr-permission":y==="NotFoundError"||y==="OverconstrainedError"||y==="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 S=f,w=S&&S.srcObject;if(w&&typeof w.getTracks=="function"){for(const y of w.getTracks())try{y.stop()}catch{}try{S.srcObject=null}catch{}}}},[]);const h=async p=>{const f=p.target.files&&p.target.files[0];if(p.target.value="",!!f)try{const _=await Ye.scanImage(f,{returnDetailedScanResult:!0}),b=Pv(_);if(!b)throw new Error("empty");o.current||(o.current=!0,e(b))}catch{u(g("pairing-qr-invalid"))}};return c.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:c.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:p=>p.stopPropagation(),children:[c.jsx("div",{className:"nc-sheet-head",children:c.jsx("b",{children:g("scan-qr")})}),c.jsx("video",{ref:i,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&c.jsx("div",{className:"nc-err",role:"alert",children:a}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[g("qr-upload"),c.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:h})]}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:g("cancel")})]})]})})}const Lv=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function Py({token:e,initial:t="",autoStart:i=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:u=!1,onSuccess:h,onBusyChange:p}){const[f,_]=R.useState(Lv),[b,S]=R.useState(!1),[w,y]=R.useState(!1),[x,k]=R.useState("idle"),[C,P]=R.useState(null),[A,M]=R.useState(""),[ee,q]=R.useState(!1),[B,Z]=R.useState(!1),H=R.useRef(Yk()),te=R.useRef(new Set),K=x==="busy",T=rl(f.localLabel||s,o)||a,E=B?f.localName:T;R.useEffect(()=>(p&&p(K),()=>{p&&p(!1)}),[K,p]);const j=async $=>{const L=String($.pairingUrl||"").trim();if(H.current.start(L)){k("busy"),P(null),M("");try{await u0(e,Vk({...$,localName:B?$.localName:rl($.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a})),k("ok"),S(!1),_(Lv()),te.current=new Set,q(!1),Z(!1),H.current.finish(),h&&await h()}catch(z){const oe=Gk(z);P(oe),k("idle"),H.current.finish(),oe.code==="peer-name-conflict"&&dd(oe.suggestedName)&&(Z(!0),te.current.add("localName"),_(ce=>({...ce,localName:oe.suggestedName}))),(oe.stage==="validation"||oe.stage==="conflict"||oe.stage==="ssh-start"||oe.stage==="ssh-ready"||String(oe.code||"").startsWith("ssh-"))&&S(!0)}}},D=($,L=!0)=>{const{classification:z,form:oe}=jv(f,$,te.current,ee),ce=oe.pairingUrl;if(P(null),M(""),x==="ok"&&k("idle"),_(oe),z.kind==="invalid"){P({stage:"validation",code:"bad-link",message:g("pair-invalid-link"),hint:g("pair-invalid-hint"),retryable:!0});return}if(z.kind==="partial"){S(!0),M(z.missing.includes("ssh")?g("pair-missing-ssh"):g("pair-missing-name"));return}z.kind==="complete"&&L&&!u&&H.current.canAuto(ce)&&j(oe)};R.useEffect(()=>{t&&D(t,i)},[]);const U=()=>{const $=String(f.pairingUrl||"").trim(),{classification:L,form:z}=jv(f,$,te.current,ee);if(_(z),M(""),P(null),L.kind==="empty"){P({stage:"validation",message:g("pairing-required"),retryable:!0});return}if(L.kind==="invalid"){P({stage:"validation",code:"bad-link",message:g("pair-invalid-link"),hint:g("pair-invalid-hint"),retryable:!0});return}if(!z.ssh||!z.name){S(!0),M(z.ssh?g("pair-missing-name"):g("pair-missing-ssh"));return}if(z.label&&!ds(z.label)){P({stage:"validation",message:g("err-label"),retryable:!0});return}if(z.localLabel&&!ds(z.localLabel)){P({stage:"validation",message:g("err-label"),retryable:!0});return}const oe=B?z.localName:rl(z.localLabel||s,o)||a;if(!dd(oe)||oe==="localhost"){S(!0),P({stage:"validation",code:"bad-local-name",message:g("err-local-name"),retryable:!0});return}H.current.reset($),j(z)},re=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const $=await navigator.clipboard.readText();$&&$.trim()?D($):M(g("pair-clipboard-empty"))}catch{M(g("pair-clipboard-denied"))}},I=($,L)=>{te.current.add($),_(z=>({...z,[$]:L}))},V=C&&C.stage&&(Xk.includes(C.stage)||C.stage==="internal")?g(`pair-stage-${C.stage}`):g("pair-stage-generic");return c.jsxs("div",{className:"nc-set-form nc-pair-card",children:[c.jsx("div",{className:"nc-sheet-label",children:g("pair-card-title")}),c.jsx("div",{className:"nc-set-info",children:g("pair-card-help")}),c.jsx("input",{className:"nc-pair-input",placeholder:g("pair-paste-ph"),value:f.pairingUrl,disabled:u||K,onChange:$=>{_({...f,pairingUrl:$.target.value}),P(null),M("")},onPaste:$=>{const L=$.clipboardData&&$.clipboardData.getData("text")||"";L.trim()&&($.preventDefault(),D(L))},onKeyDown:$=>{$.key==="Enter"&&($.preventDefault(),U())}}),c.jsxs("div",{className:"nc-pair-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||K,onClick:re,children:g("pair-paste-btn")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||K,onClick:()=>y(!0),children:g("scan-qr")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||K,title:u?g("settings-readonly"):"",onClick:U,children:g("test-and-connect")})]}),c.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[K&&c.jsx("div",{className:"nc-pair-progress",children:g("pair-progress")}),x==="ok"&&c.jsx("div",{className:"nc-set-test ok",children:g("node-connected")}),A&&c.jsx("div",{className:"nc-set-hint nc-pair-notice",children:A}),C&&c.jsxs("div",{className:"nc-err",role:"alert",children:[c.jsx("b",{children:V})," — ",C.message,C.hint&&c.jsx("div",{className:"nc-pair-hint",children:C.hint}),C.retryable&&c.jsx("div",{children:c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||K,onClick:U,children:g("pair-retry")})})]})]}),c.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:K,onClick:()=>S($=>!$),children:[b?"▾":"▸"," ",g("pair-advanced")]}),b&&c.jsxs("div",{className:"nc-pair-advanced",children:[c.jsxs("label",{className:"nc-field",children:[g("node-display-label"),c.jsx("input",{placeholder:"Home Relay",value:f.label,disabled:u||K,onChange:$=>{te.current.add("label"),_(L=>({...L,label:$.target.value,name:ee?L.name:Zn($.target.value)}))}})]}),c.jsxs("label",{className:"nc-field",children:[g("node-name-label"),c.jsx("input",{placeholder:g("node-name-ph"),value:f.name,disabled:u||K,onChange:$=>{q(!0),te.current.add("name"),_(L=>({...L,name:$.target.value?Zn($.target.value):""}))}})]}),c.jsx("small",{className:"nc-set-hint",children:g("node-slug-hint").replace("{slug}",f.name||"home-relay")}),c.jsxs("label",{className:"nc-field",children:[g("pair-ssh-local-label"),c.jsx("input",{placeholder:"my-relay",value:f.ssh,disabled:u||K,onChange:$=>{te.current.add("ssh"),I("ssh",$.target.value)}}),c.jsx("small",{className:"nc-set-hint",children:g("node-ssh-local-help")})]}),c.jsxs("label",{className:"nc-field",children:[g("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:g("node-ssh-port-help"),value:f.sshPort,disabled:u||K,onChange:$=>I("sshPort",$.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),c.jsxs("label",{className:"nc-field",children:[g("device-name-label"),c.jsx("input",{placeholder:s||"NexusCrew",value:f.localLabel,disabled:u||K,onChange:$=>I("localLabel",$.target.value)}),c.jsx("small",{className:"nc-set-hint",children:g("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[g("local-route-name-label"),c.jsx("input",{placeholder:T||"nexuscrew-5bd6",value:E,disabled:u||K,onChange:$=>{Z(!0),te.current.add("localName"),_(L=>({...L,localName:$.target.value?Zn($.target.value):""}))}}),c.jsx("small",{className:"nc-set-hint",children:g("local-route-name-hint")})]})]}),w&&c.jsx(eE,{onResult:$=>{y(!1),D($)},onClose:()=>y(!1)})]})}function Mh(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function tE(e){const t="=".repeat((4-e.length%4)%4),i=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(i),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function iE(){if(!Mh())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function nE(e){if(!Mh())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const i=await Vt("/api/push/vapid",e),{publicKey:s}=await i.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:tE(s)}),u=await Vt("/api/push/subscribe",e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!u.ok){try{await a.unsubscribe()}catch{}const h=await u.json().catch(()=>({}));throw new Error(h.error||`HTTP ${u.status}`)}return!0}async function rE(e){if(!Mh())return!1;const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!i)return!1;const s=i.endpoint;try{await i.unsubscribe()}catch{}try{await Vt("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const eh="nexuscrew.fleet",jy=3,sE="nexuscrew.cells",Dy=/^[A-Za-z0-9._-]{1,32}$/,jl=/^[a-z0-9._-]{1,32}$/,Ly=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,My=new Set(["standard","unsafe"]),oE=4096,aE=4096,wl=256,Ty=8192,lE=4096,cE=32,uE=24,dE=new Set(["format","version","exportedAt","cells","engines"]),hE=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt"]),fE=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function wr(e){if(typeof e!="string"||e.length>aE)return null;for(let i=0;i<e.length;i+=1){const s=e.charCodeAt(i);if(s<=31||s===127||s===92)return null}if(e==="")return"";if(e.charAt(0)==="/"||/^[A-Za-z]:/.test(e))return null;const t=[];for(const i of e.split("/"))if(!(i===""||i===".")){if(i==="..")return null;t.push(i)}return t.join("/")}const pE=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag"]),mE=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]);function Xn(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function Th(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 yo(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const i=Object.entries(e);if(i.length>128)return null;const s={};for(const[o,a]of i){if(!jl.test(o)||!t(a))return null;s[o]=a}return s}function Ay(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(h=>!hE.has(h))||!Dy.test(String(e.id||""))||typeof e.cwdRel!="string")return null;const t=wr(e.cwdRel);if(t===null||!jl.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>wl)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const i=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof i!="string"||i.length>Ty)return null;const s=yo(e.models,h=>typeof h=="string"&&!!h&&h.length<=wl),o=yo(e.permissionPolicies,h=>My.has(h)),a=yo(e.commands,h=>Xn(h,lE)&&!Th(h));if(s===null||o===null||a===null)return null;const u={id:e.id,cwdRel:t,engine:e.engine,boot:e.boot===!0,systemPrompt:i};return e.model&&(u.model=e.model),Object.keys(s).length&&(u.models=s),Object.keys(o).length&&(u.permissionPolicies=o),Object.keys(a).length&&(u.commands=a),u}function gE(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!fE.has(a))||!Dy.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>oE||!jl.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>wl)||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>Ty)return null;const i=yo(e.models,a=>typeof a=="string"&&!!a&&a.length<=wl),s=yo(e.permissionPolicies,a=>My.has(a));if(i===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(i).length&&(o.models=i),Object.keys(s).length&&(o.permissionPolicies=s),o}function vE(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(i=>!mE.has(i)))return null;const t={};for(const[i,s]of Object.entries(e)){if(typeof s!="string"||!Xn(s,i==="baseUrl"?512:128)||Th(s))return null;t[i]=s}return!t.client||!t.provider||t.envKey&&!Ly.test(t.envKey)?null:t}function Iy(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!pE.has(s))||!jl.test(String(e.id||""))||!Xn(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=vE(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!Xn(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!Xn(s,1024)||Th(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!Xn(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")||!Xn(e.model.flag,32)||/\s/.test(e.model.flag)||!Xn(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const i=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(i)||i.length>32||i.some(s=>!Ly.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(i)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function By(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.managed?{id:e.id,label:e.label,rc:e.rc,managed:e.managed}:{id:e.id,label:e.label,rc:e.rc,command:e.command,args:e.args,envKeys:e.envKeys,model:e.model,promptMode:e.promptMode,promptFlag:e.promptFlag},i=Iy(t);return i||null}function _E(e,t,i=[],s=[],o=new Date){i instanceof Date&&(o=i,i=[],s=[]);const a=t instanceof Set?t:new Set(t||[]),u=s instanceof Set?s:new Set(s||[]),h=[];for(const f of Array.isArray(e)?e:[]){if(!a.has(f.id))continue;const _=Ay({id:f.id,cwdRel:f.cwdRel,engine:f.engine,boot:f.boot===!0,...f.model?{model:f.model}:{},...f.models?{models:f.models}:{},...f.permissionPolicies?{permissionPolicies:f.permissionPolicies}:{},systemPrompt:f.prompt||"",...f.commands?{commands:f.commands}:{}});if(!_)return{ok:!1,error:"invalid-cell",invalidCellIds:[f.id]};h.push(_)}const p=[];for(const f of Array.isArray(i)?i:[]){if(!u.has(f.id))continue;const _=By(f);_&&p.push(_)}return{format:eh,version:jy,exportedAt:o.toISOString(),cells:h,engines:p}}function yE(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const i=(t==null?void 0:t.format)===sE&&(t==null?void 0:t.version)===1,s=(t==null?void 0:t.format)===eh&&(t==null?void 0:t.version)===2,o=(t==null?void 0:t.format)===eh&&(t==null?void 0:t.version)===jy,a=i||s,u=s||o;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(b=>!dE.has(b))||!i&&!s&&!o||!Array.isArray(t.cells)||t.cells.length>cE||u&&(!Array.isArray(t.engines)||t.engines.length>uE))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const h=[],p=new Set;for(const b of t.cells){const S=a?gE(b):Ay(b);if(!S)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(p.has(S.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};p.add(S.id),h.push(S)}const f=[],_=new Set;for(const b of u?t.engines:[]){const S=Iy(b);if(!S)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(_.has(S.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};_.add(S.id),f.push(S)}return{ok:!0,cells:h,engines:f,legacy:a,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function wE(e,t,i){const s=new Set(i||[]);if(!s.has(t))return null;const o=f=>Object.fromEntries(Object.entries(f||{}).filter(([_])=>s.has(_))),a={id:e.id,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};typeof e.cwdRel=="string"?a.cwdRel=e.cwdRel:typeof e.cwd=="string"&&e.cwd&&(a.cwd=e.cwd),t===e.engine&&e.model?a.model=e.model:e.models&&e.models[t]&&(a.model=e.models[t]);const u=o(e.models),h=o(e.permissionPolicies),p=o(e.commands);return Object.keys(u).length&&(a.models=u),Object.keys(h).length&&(a.permissionPolicies=h),Object.keys(p).length&&(a.commands=p),a}const SE=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",displayName:"",protocol:"anthropic_messages",baseUrl:"",envKey:"",providerId:"nexuscrew-custom",command:"",argsText:"",rc:!0,promptMode:"send-keys",promptFlag:"",modelFlag:"",modelValue:"",envRows:[],credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}),Mv=(e="")=>({id:"",cwd:"",engine:e,boot:!1,model:"",prompt:"",commands:{},command:""}),Oy=e=>e==="claude"?"unsafe":"standard",xo=(e,t)=>e.find(i=>i.client===t.client&&i.provider===t.provider&&(i.credentialProfile||"")===(t.credentialProfile||"")),bE=(e,t)=>{var i;return((i=xo(e,t))==null?void 0:i.label)||`${t.client} · ${t.provider}`};function xE(e){var t,i,s,o,a,u,h,p,f,_,b,S,w,y;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
|
|
89
|
+
`),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((i=e.managed)==null?void 0:i.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((a=e.managed)==null?void 0:a.permissionPolicy)||Oy((u=e.managed)==null?void 0:u.client),displayName:((h=e.managed)==null?void 0:h.displayName)||"",protocol:((p=e.managed)==null?void 0:p.protocol)||"",baseUrl:((f=e.managed)==null?void 0:f.baseUrl)||"",envKey:((_=e.managed)==null?void 0:_.envKey)||"",providerId:((b=e.managed)==null?void 0:b.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((S=e.managedInfo)==null?void 0:S.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((w=e.model)==null?void 0:w.flag)||"",modelValue:((y=e.model)==null?void 0:y.value)||"",envRows:(e.envKeys||[]).map(x=>({key:x,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1}}function CE(e,t,i=[]){if(e.kind==="managed"){const o={client:e.client,provider:e.provider,model:e.client==="shell"?"":e.managedModel||"",permissionPolicy:e.client==="shell"?"standard":e.permissionPolicy||Oy(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile);const a=xo(i,e);return(a==null?void 0:a.credentialEnv)===!0&&(o.envKey=e.envKey),e.provider==="custom"&&Object.assign(o,{displayName:e.displayName,protocol:e.protocol,baseUrl:e.baseUrl,envKey:e.envKey,providerId:e.providerId}),{...t?{id:e.id}:{},label:e.label||bE(i,e),rc:!!e.rc,managed:o}}const s={...t?{id:e.id}:{},label:e.label||e.id,rc:!!e.rc,command:e.command,args:e.argsText.split(`
|
|
90
|
+
`).filter(o=>o!==""),promptMode:e.promptMode};return e.modelFlag&&(s.model={flag:e.modelFlag,value:e.modelValue||""}),e.promptMode==="flag"&&(s.promptFlag=e.promptFlag),t&&(s.env=Object.fromEntries(e.envRows.filter(o=>!o.remove&&o.key).map(o=>[o.key,o.value]))),s}function gr({children:e,onClose:t,label:i,error:s=""}){const o=R.useRef(null),a=R.useRef(null),u=R.useRef(t);return u.current=t,R.useEffect(()=>{const h=document.activeElement,p=o.current,f=()=>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(S=>S.offsetParent!==null),_=requestAnimationFrame(()=>{var S;return(S=f()[0]||p)==null?void 0:S.focus({preventScroll:!0})}),b=S=>{var k;if(S.key==="Escape"){S.preventDefault(),(k=u.current)==null||k.call(u);return}if(S.key!=="Tab")return;const w=f();if(!w.length){S.preventDefault(),p==null||p.focus();return}const y=w[0],x=w[w.length-1];S.shiftKey&&document.activeElement===y?(S.preventDefault(),x.focus()):!S.shiftKey&&document.activeElement===x&&(S.preventDefault(),y.focus())};return document.addEventListener("keydown",b),()=>{cancelAnimationFrame(_),document.removeEventListener("keydown",b),h&&h.isConnected&&typeof h.focus=="function"&&h.focus({preventScroll:!0})}},[]),R.useEffect(()=>{s&&requestAnimationFrame(()=>{var h;return(h=a.current)==null?void 0:h.scrollIntoView({block:"nearest"})})},[s]),c.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:h=>{h.target===h.currentTarget&&t()},children:c.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":i||g("settings"),tabIndex:-1,children:[e,s&&c.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function nd({token:e,targets:t=[],readonly:i=!1,onPower:s,onImport:o}){const[a,u]=R.useState([]),[h,p]=R.useState(0);R.useEffect(()=>{let k=!0;async function C(){const A=[{route:[],label:g("local")}].concat((t||[]).map(ee=>({route:Array.isArray(ee.route)?ee.route:[],label:ee.label||(ee.route||[]).join(" › ")}))),M=await Promise.all(A.map(async ee=>{const q={...ee,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const B=await Rr(e,ee.route);q.available=!!B.available,q.capabilities=B.capabilities||[],q.provider=B.provider||null,q.cells=(B.cells||[]).map(Z=>({...Z,route:ee.route}));try{q.readonly=!!(await dh(e,ee.route)).readonlyDefault}catch{}try{const Z=await Xv(e,ee.route),H=new Set(q.cells.map(te=>te.tmuxSession).filter(Boolean));q.unmanaged=(Z.sessions||[]).filter(te=>te&&!H.has(te.name))}catch{}}catch(B){q.err=String(B&&B.message||B)}return q}));k&&u(M)}C();const P=setInterval(C,6e3);return()=>{k=!1,clearInterval(P)}},[e,t,h]);const f=(k,C)=>Array.isArray(k.capabilities)&&k.capabilities.includes(C)&&!i&&!k.readonly,_=()=>p(k=>k+1),b=(k,C)=>{s&&s({...k,route:C})},S=(k,C)=>{s&&s({...k,route:C})},w=async(k,C)=>{try{await ho(e,k.cell,C)}catch{}_()},y=async(k,C)=>{if(window.confirm(g("fleet-remove-cell").replace("{id}",k.cell))){try{await qv(e,k.cell,!0,C)}catch{}_()}},x=async(k,C)=>{if(window.confirm(g("terminate-confirm").replace("{name}",k.name))){try{await ch(e,k.name,C)}catch{}_()}};return c.jsxs("div",{className:"nc-fleet-inventory",children:[c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:g("fleet-inventory")}),c.jsx("small",{children:g("fleet-inventory-help")})]}),a.map(k=>{const C=k.route.length?k.route.join("/"):"local";return c.jsxs("div",{className:"nc-fleet-pos",children:[c.jsxs("div",{className:"nc-fleet-pos-title",children:[c.jsx("span",{className:`dot ${k.available?"on":"warn"}`}),c.jsx("b",{children:k.label}),c.jsx("small",{children:k.available?`${k.cells.length} ${g("fleet-cells")} · ${k.unmanaged.length} ${g("fleet-tmux")}`:k.err||g("fleet-not-available")})]}),k.cells.map(P=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[c.jsxs("span",{children:[c.jsx("b",{children:P.cell}),c.jsx("small",{children:`${P.engine||""}${P.key?`·${P.key}`:""}${P.active?"":` · ${g("cell-off")}`}`})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[P.active&&f(k,"down")&&c.jsx("button",{className:"nc-btn ghost",title:g("power-off"),onClick:()=>S(P,k.route),children:g("stop")}),!P.active&&f(k,"up")&&c.jsx("button",{className:"nc-btn ghost",title:g("power-on"),onClick:()=>b(P,k.route),children:g("start")}),f(k,"restart")&&P.active&&c.jsx("button",{className:"nc-btn ghost",title:g("restart"),onClick:()=>w(P,k.route),children:g("restart")}),f(k,"remove")&&c.jsx("button",{className:"nc-btn danger",title:g("delete"),onClick:()=>y(P,k.route),children:"×"})]})]},`${C}:${P.cell}`)),k.unmanaged.map(P=>c.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[c.jsxs("span",{children:[c.jsx("b",{children:P.name}),c.jsx("small",{children:g("fleet-tmux")})]}),c.jsxs("span",{className:"nc-fleet-cell-actions",children:[f(k,"import")&&o&&c.jsx("button",{className:"nc-btn ghost",title:g("import-as-cell"),onClick:()=>o(P,k.route),children:g("import-as-cell")}),c.jsx("button",{className:"nc-btn danger",title:g("terminate"),onClick:()=>x(P,k.route),children:"×"})]})]},`${C}:u:${P.name}`)),k.available&&k.cells.length===0&&k.unmanaged.length===0&&c.jsx("div",{className:"nc-empty",children:g("fleet-inventory-empty")})]},C)})]})}function kE({cells:e=[],engines:t=[],busy:i,canRestore:s=!1,onRestore:o,onClose:a}){const[u,h]=R.useState("export"),[p,f]=R.useState(()=>new Set(e.map(E=>E.id))),[_,b]=R.useState(()=>new Set(t.map(E=>E.id))),[S,w]=R.useState([]),[y,x]=R.useState([]),[k,C]=R.useState(""),P=new Set(t.map(E=>E.id)),A=new Set(e.map(E=>E.id)),M=(E,j)=>E(D=>{const U=new Set(D);return U.has(j)?U.delete(j):U.add(j),U}),ee=()=>{const E=_E(e,p,t,_);if(E.ok===!1){C(g(`fleet-backup-${E.error}`));return}const j=e.filter(V=>p.has(V.id)).length,D=t.filter(V=>_.has(V.id)).length;if(E.cells.length!==j){C(g("fleet-backup-invalid-cell"));return}if(E.engines.length!==D){C(g("fleet-backup-invalid-engine"));return}if(!E.cells.length&&!E.engines.length){C(g("fleet-backup-select-one"));return}const U=new Blob([`${JSON.stringify(E,null,2)}
|
|
91
|
+
`],{type:"application/json"}),re=URL.createObjectURL(U),I=document.createElement("a");I.href=re,I.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(I),I.click(),I.remove(),setTimeout(()=>URL.revokeObjectURL(re),0),C("")},q=async E=>{if(C(""),w([]),x([]),!!E){if(E.size>1024*1024){C(g("fleet-backup-too-large"));return}try{const j=yE(await E.text());if(!j.ok){C(g(`fleet-backup-${j.error}`));return}const D=new Set(j.engines.map(U=>U.id));x(j.engines.map(U=>({engine:U,exists:P.has(U.id),selected:!P.has(U.id)}))),w(j.cells.map(U=>{const re=P.has(U.engine)||D.has(U.engine),I=A.has(U.id);return{cell:U,engine:re?U.engine:"",selected:re&&!I,exists:I}}))}catch(j){C(String(j.message||j))}}},B=(E,j)=>w(D=>D.map((U,re)=>re===E?{...U,...j}:U)),Z=(E,j)=>x(D=>D.map((U,re)=>re===E?{...U,...j}:U)),H=new Set([...P,...y.filter(E=>E.selected).map(E=>E.engine.id)]),te=S.filter(E=>E.selected&&E.engine&&H.has(E.engine)),K=y.filter(E=>E.selected),T=[...new Map([...t.map(E=>[E.id,E.label||E.id]),...y.filter(E=>E.selected).map(E=>[E.engine.id,E.engine.label||E.engine.id])]).entries()];return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[c.jsx("b",{children:g("fleet-backup")}),c.jsx("small",{children:g("fleet-backup-help")}),c.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{h("export"),C("")},children:g("fleet-backup-export")}),c.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!s,title:s?"":g("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),C("")},children:g("fleet-backup-import")})]}),u==="export"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{f(new Set(e.map(E=>E.id))),b(new Set(t.map(E=>E.id)))},children:g("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{f(new Set),b(new Set)},children:g("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[c.jsx("b",{children:g("fleet-engines")}),t.map(E=>{var j;return c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:_.has(E.id),onChange:()=>M(b,E.id)}),c.jsxs("span",{children:[c.jsx("b",{children:E.label||E.id}),c.jsxs("small",{children:[E.id,(j=E.envKeys)!=null&&j.length?` · ${E.envKeys.length} ${g("fleet-backup-env-names")}`:""]})]})]},E.id)}),c.jsx("b",{children:g("fleet-cells")}),e.map(E=>c.jsxs("label",{className:"nc-check nc-backup-row",children:[c.jsx("input",{type:"checkbox",checked:p.has(E.id),onChange:()=>M(f,E.id)}),c.jsxs("span",{children:[c.jsx("b",{children:E.id}),c.jsxs("small",{children:[E.engine," · ",g("fleet-system-prompt")," ",(E.prompt||"").length," ",g("characters")]})]})]},E.id)),!e.length&&!t.length&&c.jsx("div",{className:"nc-empty",children:g("fleet-backup-empty")})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:g("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!p.size&&!_.size,onClick:ee,children:g("fleet-backup-download")})]})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"file",accept:"application/json,.json",disabled:i,onChange:E=>q(E.target.files&&E.target.files[0])}),c.jsx("small",{children:g("fleet-backup-import-help")}),!!(S.length||y.length)&&c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(E=>E.map(j=>({...j,selected:!0}))),w(E=>E.map(j=>({...j,selected:!!j.engine})))},children:g("select-all")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{x(E=>E.map(j=>({...j,selected:!1}))),w(E=>E.map(j=>({...j,selected:!1})))},children:g("select-none")})]}),c.jsxs("div",{className:"nc-backup-list",children:[!!y.length&&c.jsx("b",{children:g("fleet-engines")}),y.map((E,j)=>{var D;return c.jsx("div",{className:"nc-backup-import-row",children:c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:E.selected,onChange:U=>Z(j,{selected:U.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:E.engine.label||E.engine.id}),c.jsxs("small",{children:[E.engine.id," · ",E.exists?g("fleet-backup-overwrite"):g("fleet-backup-new"),(D=E.engine.envKeys)!=null&&D.length?` · ${g("fleet-backup-env-values-required")}`:""]})]})]})},E.engine.id)}),!!S.length&&c.jsx("b",{children:g("fleet-cells")}),S.map((E,j)=>c.jsxs("div",{className:"nc-backup-import-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:E.selected,disabled:!E.engine||!H.has(E.engine),onChange:D=>B(j,{selected:D.target.checked})}),c.jsxs("span",{children:[c.jsx("b",{children:E.cell.id}),c.jsxs("small",{children:[E.exists?g("fleet-backup-overwrite"):g("fleet-backup-new")," · ",g("fleet-system-prompt")," ",E.cell.systemPrompt.length," ",g("characters")]})]})]}),c.jsxs("select",{value:E.engine,onChange:D=>B(j,{engine:D.target.value,selected:!!D.target.value}),children:[c.jsx("option",{value:"",children:g("fleet-backup-engine-missing")}),T.map(([D,U])=>c.jsx("option",{value:D,children:U},D))]})]},E.cell.id))]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:a,children:g("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!te.length&&!K.length,onClick:()=>o({engineRows:y,cellRows:S}),children:g("fleet-backup-restore")})]})]}),k&&c.jsx("div",{className:"nc-err",children:k})]})}function EE({state:e,setState:t,busy:i,onSave:s,catalog:o}){var k;const a=e.form,u=C=>t({...e,form:{...a,...C}}),h=a.envRows||[],p=[...new Map(o.map(C=>[C.client,C.clientLabel||C.client])).entries()],f=o.filter(C=>C.client===a.client),_=xo(o,a),b=typeof(_==null?void 0:_.credentialEnv)=="string"?_.credentialEnv:"",S=Array.isArray(_==null?void 0:_.credentialUsedBy)?_.credentialUsedBy:[],w=(_==null?void 0:_.credentialSource)||"missing",y=!!b&&e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,x=C=>{C&&u({client:C.client,provider:C.provider,credentialProfile:C.credentialProfile||"",managedModel:C.model||"",protocol:C.protocol||"",permissionPolicy:C.permissionPolicyDefault||"standard",rc:!!C.rc,displayName:C.custom?g("fleet-custom-provider-default"):"",baseUrl:C.custom?"":C.endpoint||"",envKey:C.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:C.id,label:""}:{}})};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:e.mode==="new"?g("fleet-new-engine"):`${g("edit")} ${a.id}`}),c.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:C=>u({id:C.target.value})}),c.jsx("input",{value:a.label,placeholder:g("label"),onChange:C=>u({label:C.target.value})}),c.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:C=>u({kind:C.target.value}),children:[c.jsx("option",{value:"managed",children:g("fleet-managed")}),c.jsx("option",{value:"custom",children:g("fleet-custom")})]}),a.kind==="managed"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:C=>x(o.find(P=>P.client===C.target.value&&P.default)||o.find(P=>P.client===C.target.value)),children:p.map(([C,P])=>c.jsx("option",{value:C,children:P},C))}),c.jsx("select",{value:((k=xo(o,a))==null?void 0:k.id)||"",disabled:e.mode!=="new",onChange:C=>x(o.find(P=>P.id===C.target.value)),children:f.map(C=>c.jsx("option",{value:C.id,children:C.label},C.id))})]}),a.client!=="shell"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:g(_!=null&&_.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:C=>u({managedModel:C.target.value})}),c.jsx("datalist",{id:"nc-managed-models",children:[...(_==null?void 0:_.models)||[],...a.modelOptions||[]].filter((C,P,A)=>C&&A.indexOf(C)===P).map(C=>c.jsx("option",{value:C},C))})]}),_!=null&&_.supportsUnsafe?c.jsxs("select",{value:a.permissionPolicy,onChange:C=>u({permissionPolicy:C.target.value}),children:[c.jsx("option",{value:"standard",children:g("fleet-standard-permissions")}),c.jsx("option",{value:"unsafe",children:g("fleet-unsafe-permissions")})]}):c.jsx("small",{children:g("fleet-standard-permissions")}),(_==null?void 0:_.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&c.jsx("small",{className:"nc-err",children:g("fleet-unsafe-warning")}),(_==null?void 0:_.credentialEnv)===!0&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.envKey,placeholder:g("fleet-api-key-env"),onChange:C=>u({envKey:C.target.value})}),c.jsx("small",{children:g("fleet-custom-secret-help")})]}),b&&c.jsxs("section",{className:"nc-fleet-key","aria-label":g("fleet-key-section"),children:[c.jsxs("div",{className:"nc-fleet-key-head",children:[c.jsx("b",{children:g("fleet-key-section")}),c.jsx("span",{children:g(`fleet-credential-source-${w}`)})]}),c.jsxs("label",{className:"nc-field",children:[g("fleet-key-variable"),c.jsx("input",{value:b,readOnly:!0,"aria-label":g("fleet-key-variable")})]}),c.jsx("small",{children:S.length?g("fleet-key-used-by").replace("{engines}",S.join(", ")):g("fleet-key-used-by-none")}),S.length>0&&c.jsx("small",{children:g("fleet-key-shared-impact").replace("{key}",b).replace("{engines}",S.join(", "))}),c.jsxs("div",{className:"nc-fleet-key-input",children:[c.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":g("fleet-key-value").replace("{key}",b),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:_!=null&&_.authConfigured||e.mode==="edit"?g("fleet-key-blank-keeps"):g("fleet-key-enter"),onChange:C=>u({credentialValue:C.target.value,allowMissingCredential:C.target.value?!1:a.allowMissingCredential})}),c.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":g(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>u({credentialReveal:!a.credentialReveal}),children:g(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),c.jsx("small",{children:g("fleet-key-local-help")}),e.mode==="new"&&(_==null?void 0:_.authConfigured)!==!0&&!a.credentialValue&&c.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[c.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:C=>u({allowMissingCredential:C.target.checked})}),g("fleet-key-create-missing")]}),(_==null?void 0:_.notice)&&c.jsx("small",{className:"nc-fleet-provider-notice",children:g(`fleet-provider-notice-${_.notice}`)})]}),a.provider==="custom"&&c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.displayName,placeholder:g("fleet-provider-display"),onChange:C=>u({displayName:C.target.value})}),c.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:C=>u({baseUrl:C.target.value})}),((_==null?void 0:_.protocols)||[]).length>1&&c.jsx("select",{value:a.protocol,onChange:C=>u({protocol:C.target.value}),children:_.protocols.map(C=>c.jsx("option",{value:C,children:C},C))}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.envKey,placeholder:g("fleet-api-key-env"),onChange:C=>u({envKey:C.target.value})}),c.jsx("input",{value:a.providerId,placeholder:g("fleet-provider-id"),onChange:C=>u({providerId:C.target.value})})]}),c.jsxs("small",{children:[a.protocol," · ",g("fleet-custom-secret-help")]})]}),c.jsx("small",{children:g(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:a.command,placeholder:g("command-path"),onChange:C=>u({command:C.target.value})}),c.jsx("textarea",{value:a.argsText,placeholder:g("args-lines"),onChange:C=>u({argsText:C.target.value})}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:a.rc,onChange:C=>u({rc:C.target.checked})})," remote control"]}),c.jsxs("select",{value:a.promptMode,onChange:C=>u({promptMode:C.target.value}),children:[c.jsx("option",{value:"send-keys",children:"send-keys"}),c.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&c.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:C=>u({promptFlag:C.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:C=>u({modelFlag:C.target.value})}),c.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:C=>u({modelValue:C.target.value})})]}),c.jsx("small",{children:g("env-write-only")}),h.map((C,P)=>c.jsxs("div",{className:"nc-fleet-env",children:[c.jsx("input",{value:C.key,disabled:C.configured,placeholder:"ENV_KEY",onChange:A=>{const M=h.slice();M[P]={...C,key:A.target.value},u({envRows:M})}}),c.jsx("input",{type:"password",value:C.value,placeholder:C.configured?"•••••• (unchanged)":"value",onChange:A=>{const M=h.slice();M[P]={...C,value:A.target.value},u({envRows:M})}}),c.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:h.filter((A,M)=>M!==P)}),children:"×"})]},`${C.key}-${P}`)),c.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...h,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:g("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:i||!a.id||y||a.kind==="custom"&&!a.command||a.kind==="managed"&&(_==null?void 0:_.requiresModel)&&!a.managedModel||a.kind==="managed"&&(_==null?void 0:_.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:g("save")})]})]})}function NE({token:e,route:t,targets:i=[],location:s,setLocation:o,state:a,setState:u,engines:h,busy:p,onSave:f}){var q;const[_,b]=R.useState(null),[S,w]=R.useState(""),y=a.form,x=B=>u({...a,form:{...y,...B}}),k=h.find(B=>B.id===y.engine),C=((q=k==null?void 0:k.managed)==null?void 0:q.client)==="shell",P=B=>{var te,K,T,E;const Z=h.find(j=>j.id===B),H={...y.commands||{}};((te=k==null?void 0:k.managed)==null?void 0:te.client)==="shell"&&(y.command?H[y.engine]=y.command:delete H[y.engine]),x({engine:B,model:((K=y.models)==null?void 0:K[B])||((T=Z==null?void 0:Z.managed)==null?void 0:T.model)||((E=Z==null?void 0:Z.model)==null?void 0:E.value)||"",commands:H,command:H[B]||""})},A=B=>{const Z={...y.commands||{}};B?Z[y.engine]=B:delete Z[y.engine],x({command:B,commands:Z})},M=C&&/[|&;<>()`$*?{}\[\]~]/.test(y.command||""),ee=async B=>{try{const Z=await uh(e,B,t);b(Z),x({cwd:Z.path}),w("")}catch(Z){w(String(Z.message||Z))}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsx("b",{children:a.mode==="new"?g("fleet-new-cell"):`${g("edit")} ${y.id}`}),a.mode==="new"&&c.jsxs("label",{className:"nc-field",children:[g("location"),c.jsx("span",{className:"nc-req",children:" *"}),c.jsxs("select",{value:s,onChange:B=>{o(B.target.value),x({engine:""})},children:[c.jsx("option",{value:"",children:g("local")}),i.map(B=>c.jsxs("option",{value:B.route.join("/"),disabled:B.status&&B.status!=="up",children:[B.label,B.status&&B.status!=="up"?` · ${g("node-offline")}`:""]},B.route.join("/")))]})]}),c.jsx("input",{value:y.id,disabled:a.mode!=="new",placeholder:"id",onChange:B=>x({id:B.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:y.cwd,placeholder:g("cwd"),onChange:B=>x({cwd:B.target.value})}),c.jsx("button",{className:"nc-btn ghost",onClick:()=>_?b(null):ee(y.cwd),children:g("browse")})]}),_&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:_.path}),c.jsxs("div",{className:"nc-fs-list",children:[_.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>ee(_.parent),children:["↑ ",g("fs-parent")]}),(_.dirs||[]).map(B=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>ee(`${_.path.replace(/\/$/,"")}/${B}`),children:["📁 ",B]},B))]})]}),S&&c.jsx("div",{className:"nc-err",children:S}),c.jsx("select",{value:y.engine,onChange:B=>P(B.target.value),children:h.map(B=>c.jsx("option",{value:B.id,children:B.label},B.id))}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!y.boot,onChange:B=>x({boot:B.target.checked})})," boot"]}),C?c.jsxs(c.Fragment,{children:[c.jsx("input",{value:y.command||"",maxLength:4096,placeholder:g("fleet-shell-command-placeholder"),onChange:B=>A(B.target.value)}),c.jsx("small",{children:y.command?g("fleet-shell-command-help"):g("fleet-shell-interactive")}),M&&c.jsx("small",{className:"nc-note",children:g("fleet-shell-command-metachar")})]}):c.jsxs(c.Fragment,{children:[c.jsx("input",{value:y.model||"",list:"nc-cell-models",placeholder:g("fleet-model-override"),onChange:B=>x({model:B.target.value})}),c.jsx("datalist",{id:"nc-cell-models",children:((k==null?void 0:k.availableModels)||[]).map(B=>c.jsx("option",{value:B},B))}),c.jsx("textarea",{value:y.prompt||"",placeholder:"prompt",onChange:B=>x({prompt:B.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:g("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:p||!y.id||!y.cwd||!y.engine,onClick:f,children:g("save")})]})]})}function Tv({token:e,route:t=[],state:i,setState:s,busy:o,onSave:a}){const[u,h]=R.useState(null),[p,f]=R.useState([]),[_,b]=R.useState(""),S=Array.isArray(t)?t.join("/"):"";R.useEffect(()=>{let C=!0;return lh(e,S?S.split("/"):[]).then(P=>{C&&(f(P.engines||[]),b(""))}).catch(P=>{C&&(f([]),b(String(P.message||P)))}),()=>{C=!1}},[e,S]);const w=i.form,y=C=>s({...i,form:{...w,...C}}),x=async C=>{try{const P=await uh(e,C,t);h(P),y({cwd:P.path})}catch{}},k=!w.id&&w.tmuxSession?w.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):w.id;return c.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[c.jsxs("b",{children:[g("import-as-cell")," · ",w.tmuxSession]}),c.jsx("small",{children:g("import-help")}),c.jsx("input",{value:w.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),c.jsx("input",{value:w.id,placeholder:g("name"),onChange:C=>y({id:C.target.value})}),c.jsxs("div",{className:"nc-fleet-pair",children:[c.jsx("input",{value:w.cwd,placeholder:g("cwd"),onChange:C=>y({cwd:C.target.value})}),c.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?h(null):x(w.cwd),children:g("browse")})]}),u&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:u.path}),c.jsxs("div",{className:"nc-fs-list",children:[u.parent&&c.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>x(u.parent),children:["↑ ",g("fs-parent")]}),(u.dirs||[]).map(C=>c.jsxs("button",{className:"nc-fs-item",onClick:()=>x(`${u.path.replace(/\/$/,"")}/${C}`),children:["📁 ",C]},C))]})]}),c.jsxs("select",{value:w.engine,onChange:C=>y({engine:C.target.value}),children:[c.jsx("option",{value:"",children:g("import-engine-required")}),p.map(C=>c.jsx("option",{value:C.id,children:C.label},C.id))]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:!!w.boot,onChange:C=>y({boot:C.target.checked})})," boot"]}),(i.err||_)&&c.jsx("div",{className:"nc-err",children:i.err||_}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:g("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:o||!w.tmuxSession||!w.engine||!p.length,onClick:a,children:g(k?"import-as-cell":"save")})]})]})}function Ga(e){const t=wr(e);return t===null?`~/${e}`:t?`~/${t}`:"~"}function RE(e){if(!e||typeof e.path!="string"||typeof e.home!="string")return"";const{path:t,home:i}=e;return!i||t===i||!t.startsWith(i+"/")?"":t.slice(i.length+1).replace(/\/+$/,"")}function PE({token:e,route:t,cell:i,busy:s=!1,onSaved:o,onClose:a}){const[u,h]=R.useState(""),[p,f]=R.useState(null),[_,b]=R.useState(!1),[S,w]=R.useState(""),y=typeof(i==null?void 0:i.cwdSuggestion)=="string"&&wr(i.cwdSuggestion)!==null?wr(i.cwdSuggestion):null,[x,k]=R.useState(y),C=i==null?void 0:i.id,P=s||_,A=async H=>{const te=wr(H);if(te===null){f({rel:"",dirs:[],loading:!1,err:g("fleet-cwd-repair-invalid")});return}f({rel:te,dirs:[],loading:!0,err:""});try{const K=await uh(e,te,t),T=RE(K);f({rel:T,dirs:Array.isArray(K.dirs)?K.dirs:[],loading:!1,err:""})}catch(K){f({rel:te,dirs:[],loading:!1,err:String(K&&K.message||K)})}},M=H=>{if(!p)return;const te=p.rel?`${p.rel}/${H}`:H;A(te)},ee=()=>{p!=null&&p.rel&&A(p.rel.split("/").slice(0,-1).join("/"))},q=()=>{p&&(h(p.rel||""),f(null),w(""),k(null))},B=()=>{x!==null&&(h(x),k(null),w(""))},Z=async()=>{if(P)return;const H=wr(u);if(H===null){w(g("fleet-cwd-repair-invalid"));return}const te=Ga(H);let K=!0;try{K=window.confirm(g("fleet-cwd-repair-confirm").replace("{id}",String(C||"")).replace("{path}",te))}catch{K=!1}if(K){b(!0),w(""),k(null);try{const T=await Kv(e,C,{cwdRel:H},t);o==null||o(T)}catch(T){const E=T&&T.data||{};if(E.code==="unportable-cwd"){w(g("fleet-cwd-repair-unportable"));const j=Array.isArray(E.cells)?E.cells.find(U=>U&&U.id===C):null,D=j&&typeof j.suggestion=="string"?j.suggestion:null;D!==null&&wr(D)!==null&&k(D)}else w(String(T&&T.message||T))}finally{b(!1)}}};return c.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[c.jsx("b",{children:g("fleet-cwd-repair-title").replace("{id}",String(C||""))}),c.jsx("small",{className:"nc-set-info",children:g("fleet-cwd-repair-help")}),c.jsx("small",{className:"nc-cwd-no-source",children:g("fleet-cwd-repair-no-source-path")}),c.jsxs("label",{className:"nc-field",children:[g("cwd"),c.jsxs("div",{className:"nc-cwd-rel-row",children:[c.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),c.jsx("input",{value:u,placeholder:g("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:H=>h(H.target.value)}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:P,onClick:()=>p?f(null):A(""),children:g(p?"close":"fleet-cwd-repair-browse")})]})]}),c.jsx("div",{className:"nc-cwd-preview",children:g("fleet-cwd-repair-preview").replace("{path}",Ga(u))}),p&&c.jsxs("div",{className:"nc-fs",children:[c.jsx("div",{className:"nc-fs-path",children:Ga(p.rel)}),c.jsxs("div",{className:"nc-fs-list",children:[p.rel&&c.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:ee,children:["↑ ",g("fs-parent")]}),p.loading&&c.jsx("div",{className:"nc-fs-empty",children:"…"}),!p.loading&&p.dirs.length===0&&c.jsx("div",{className:"nc-fs-empty",children:g("fleet-cwd-repair-fs-empty")}),!p.loading&&p.dirs.map(H=>c.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>M(H),children:["📁 ",H]},H))]}),p.err&&c.jsx("div",{className:"nc-err",children:p.err}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{type:"button",className:"nc-btn primary",disabled:P||p.loading||!!p.err,onClick:q,children:g("fleet-cwd-repair-use-current")})})]}),S&&c.jsx("div",{className:"nc-err",role:"alert",children:S}),x!==null&&c.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[c.jsx("span",{children:g("fleet-cwd-repair-suggestion")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:B,children:g("fleet-cwd-repair-use-suggestion").replace("{path}",Ga(x))})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:a,children:g("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:P,onClick:Z,children:_?"…":g("save")})]})]})}function jE({token:e,readonly:t,targets:i=[],startNewCell:s=!1,initialLocation:o=""}){const[a,u]=R.useState({engines:[],cells:[],managedCatalog:[]}),[h,p]=R.useState({available:!1,capabilities:[]}),[f,_]=R.useState(!1),[b,S]=R.useState(null),[w,y]=R.useState(null),[x,k]=R.useState(!1),[C,P]=R.useState(""),[A,M]=R.useState(""),[ee,q]=R.useState(o),[B,Z]=R.useState(!1),[H,te]=R.useState(null),[K,T]=R.useState(null),[E,j]=R.useState(null),[D,U]=R.useState(!1),[re,I]=R.useState([]),[V,$]=R.useState(null),[L,z]=R.useState("manage"),oe=R.useRef(!1),ce=ee?ee.split("/"):[],he=R.useCallback(async()=>{try{const ae=await Rr(e,ce);p(ae);try{const xe=await dh(e,ce);Z(!!xe.readonlyDefault)}catch{Z(!1)}if(ae.provider==="builtin"&&(ae.capabilities||[]).includes("definitions")){const xe=await lh(e,ce),de=new Map((ae.engines||[]).map(Ne=>[Ne.id,Ne]));if(xe.engines=(xe.engines||[]).map(Ne=>{var Ee;return{...Ne,availableModels:((Ee=de.get(Ne.id))==null?void 0:Ee.models)||[]}}),u(xe),(ae.capabilities||[]).includes("credentials"))try{I((await QS(e,ce)).credentials||[])}catch{I([])}else I([])}P("")}catch(ae){P(String(ae.message||ae))}finally{_(!0)}},[e,ee]);R.useEffect(()=>{he();const ae=setInterval(he,5e3);return()=>clearInterval(ae)},[he]);const me=new Set((h.cells||[]).filter(ae=>ae.active).map(ae=>ae.cell)),G=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),J=(h.capabilities||[]).includes("restore");R.useEffect(()=>{!s||oe.current||!G||!a.engines.length||(oe.current=!0,y({mode:"new",form:Mv(a.engines[0].id)}))},[s,G,a.engines]);const ge=async ae=>{k(!0),P(""),M("");try{await ae(),await he()}catch(xe){P(String(xe.message||xe))}k(!1)},Me=()=>ge(async()=>{var Ce;const ae=b.mode==="new",xe=b.form,de=a.managedCatalog||[],Ne=xe.kind==="managed"?xo(de,xe):null,Ee=typeof(Ne==null?void 0:Ne.credentialEnv)=="string"?Ne.credentialEnv:"",X=Ee&&xe.credentialValue||"",ie=CE(xe,ae,de);!ae&&b.form.kind==="custom"&&!b.form.modelFlag&&(ie.model=null),!ae&&b.form.kind==="custom"&&b.form.promptMode!=="flag"&&(ie.promptFlag=null);let F;if(ae)F=await ZS(e,ie,ce);else{const _e=b.original,Re=new Set(b.form.envRows.filter(ze=>!ze.remove).map(ze=>ze.key)),Qe=(_e.envKeys||[]).filter(ze=>!Re.has(ze)),zt=Object.fromEntries(b.form.envRows.filter(ze=>!ze.remove&&ze.key&&(!ze.configured||ze.value!=="")).map(ze=>[ze.key,ze.value]));F=await e0(e,_e.id,ie,b.form.kind==="custom"?{set:zt,remove:Qe}:void 0,ce)}let W=null;if(Ee&&X)try{W=await xm(e,Ee,X,ce),I(W.credentials||[])}catch{throw await he(),ae&&S({mode:"edit",original:{...ie,id:xe.id},form:{...xe,credentialReveal:!1}}),new Error(g(ae?"fleet-key-partial-create":"fleet-key-partial-edit"))}await he(),S(null),M(g("fleet-saved"));const ue=((Ce=((W==null?void 0:W.credentials)||[]).find(_e=>_e.envKey===Ee))==null?void 0:Ce.activeCells)||[],ve=[...new Set([...(F==null?void 0:F.activeCells)||[],...ue])];if(ve.length&&window.confirm(g("fleet-restart-confirm").replace("{cells}",ve.join(", "))))for(const _e of ve)await ho(e,_e,ce)}),Ze=()=>ge(async()=>{var F,W,ue,ve,Ce,_e;const ae=w.mode==="new",xe=w.form,de={...ae?{id:xe.id}:{},cwd:xe.cwd,engine:xe.engine,boot:!!xe.boot},Ne={...xe.commands||{}},Ee=a.engines.find(Re=>Re.id===xe.engine);((F=Ee==null?void 0:Ee.managed)==null?void 0:F.client)==="shell"&&typeof xe.command=="string"&&xe.command.length?Ne[xe.engine]=xe.command:((W=Ee==null?void 0:Ee.managed)==null?void 0:W.client)==="shell"&&delete Ne[xe.engine],(Object.keys(Ne).length||!ae)&&(de.commands=Ne),ae?(((ue=Ee==null?void 0:Ee.managed)==null?void 0:ue.client)!=="shell"&&xe.model&&(de.model=xe.model),((ve=Ee==null?void 0:Ee.managed)==null?void 0:ve.client)!=="shell"&&xe.prompt&&(de.prompt=xe.prompt)):(de.model=((Ce=Ee==null?void 0:Ee.managed)==null?void 0:Ce.client)==="shell"?null:xe.model||null,((_e=Ee==null?void 0:Ee.managed)==null?void 0:_e.client)!=="shell"&&(de.prompt=xe.prompt||null));const X=ae?await i0(e,de,ce):await Kv(e,w.original.id,de,ce),ie=ae?xe.id:w.original.id;y(null),M(g("fleet-saved")),!ae&&(X!=null&&X.active)&&window.confirm(g("fleet-restart-confirm").replace("{cells}",ie))&&await ho(e,ie,ce)}),Be=t||B,Fe=ae=>re.find(xe=>{var de;return(de=xe.engines)==null?void 0:de.includes(ae.id)})||null,ct=()=>ge(async()=>{var de;const ae=await xm(e,V.envKey,V.value,ce);I(ae.credentials||[]),$(null),M(g("fleet-credential-saved"));const xe=((de=(ae.credentials||[]).find(Ne=>Ne.envKey===V.envKey))==null?void 0:de.activeCells)||[];if(xe.length&&window.confirm(g("fleet-restart-confirm").replace("{cells}",xe.join(", "))))for(const Ne of xe)await ho(e,Ne,ce)}),Ve=ae=>ge(async()=>{if(!window.confirm(g("fleet-credential-remove-confirm").replace("{key}",ae.envKey)))return;const xe=await JS(e,ae.envKey,ce);I(xe.credentials||[]),M(g("fleet-credential-removed"))}),gt=ae=>te({...ae,route:Array.isArray(ae==null?void 0:ae.route)?ae.route:ce}),ut=async ae=>{if(!H)return;const xe=H.cell||H.id,de=Array.isArray(H.route)?H.route:ce;ae.action==="up"?await ah(e,{cell:xe,boot:!!ae.boot,...ae.engine?{engine:ae.engine}:{},...ae.model!==void 0?{model:ae.model}:{},...ae.permissionPolicy?{permissionPolicy:ae.permissionPolicy}:{}},de):await sl(e,{cell:xe,boot:!!ae.boot},de)},lt=(ae,xe)=>{P(""),T({mode:"new",route:Array.isArray(xe)?xe:ce,form:{tmuxSession:ae.name,id:"",engine:"",cwd:"",boot:!1},err:""})},nt=()=>ge(async()=>{const ae=K.form;if(!ae.engine){T({...K,err:g("import-engine-required")});return}await n0(e,{tmuxSession:ae.tmuxSession,id:ae.id||void 0,engine:ae.engine,cwd:ae.cwd||void 0,boot:!!ae.boot},ae.route||ce),T(null),M(g("fleet-saved"))}),dt=({engineRows:ae=[],cellRows:xe=[]})=>ge(async()=>{const de=ae.filter(Ce=>Ce.selected),Ne=de.map(Ce=>By(Ce.engine));if(Ne.some(Ce=>!Ce))throw new Error(g("fleet-backup-invalid-engine"));const Ee=de.filter(Ce=>Ce.exists).map(Ce=>Ce.engine.id);if(Ee.length&&!window.confirm(g("fleet-backup-confirm-engine-overwrite").replace("{engines}",Ee.join(", "))))return;const X=[...new Set([...a.engines.map(Ce=>Ce.id),...Ne.map(Ce=>Ce.id)])],ie=[];for(const Ce of xe.filter(_e=>_e.selected)){const _e=wE(Ce.cell,Ce.engine,X);if(!_e)throw new Error(`${Ce.cell.id}: ${g("fleet-backup-engine-missing")}`);ie.push(_e)}const F=xe.filter(Ce=>Ce.selected&&Ce.exists).map(Ce=>Ce.cell.id);if(F.length&&!window.confirm(g("fleet-backup-confirm-overwrite").replace("{cells}",F.join(", "))))return;const W=Ne.length?await s0(e,Ne,Ee.length>0,ce):{needsRestart:[]},ue=ie.length?await r0(e,ie,ce):{needsRestart:[]},ve=[...new Set([...W.needsRestart||[],...ue.needsRestart||[]])];U(!1),M(`${g("fleet-backup-restored").replace("{n}",String(ie.length))}${Ne.length?` · ${Ne.length} ${g("fleet-engines").toLowerCase()}`:""}${ve.length?` · ${g("fleet-backup-needs-restart").replace("{cells}",ve.join(", "))}`:""}`)}),rt=c.jsxs("label",{className:"nc-field",children:[g("location"),c.jsxs("select",{value:ee,onChange:ae=>{q(ae.target.value),S(null),y(null),P(""),M(""),Z(!1),_(!1),p({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),I([]),$(null)},children:[c.jsx("option",{value:"",children:g("local")}),i.map(ae=>c.jsxs("option",{value:ae.route.join("/"),disabled:ae.status&&ae.status!=="up",children:[ae.label,ae.status&&ae.status!=="up"?` · ${g("node-offline")}`:""]},ae.route.join("/")))]})]}),ot=c.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":g("tab-fleet"),children:[c.jsx("button",{type:"button",role:"tab","aria-selected":L==="manage",className:`nc-set-tabbtn${L==="manage"?" on":""}`,onClick:()=>z("manage"),children:g("fleet-manage-location")}),c.jsx("button",{type:"button",role:"tab","aria-selected":L==="overview",className:`nc-set-tabbtn${L==="overview"?" on":""}`,onClick:()=>z("overview"),children:g("fleet-network-overview")})]});return f?G?c.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[ot,L==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:g("fleet-overview-help")}),c.jsx(nd,{token:e,targets:i,readonly:t,onPower:gt,onImport:lt})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:g("fleet-manage-help")}),rt,c.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:Be||x,onClick:()=>{P(""),U(!0)},children:g("fleet-backup")}),c.jsx("small",{children:g("fleet-backup-help")})]}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:g("fleet-cells")}),c.jsx("span",{className:"nc-fleet-head-actions",children:c.jsxs("button",{className:"nc-btn primary",disabled:Be||x||!a.engines.length,onClick:()=>{var ae;P(""),y({mode:"new",form:Mv((ae=a.engines[0])==null?void 0:ae.id)})},children:["+ ",g("add")]})})]}),a.cells.map(ae=>{const xe=me.has(ae.id),de=h.capabilities||[],Ne=ae.needsRepair===!0;return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:ae.id}),c.jsxs("small",{children:[ae.engine," · ",Ne?c.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:g("fleet-cwd-needs-repair")}):ae.cwd,xe?` · ${g("service-active")}`:` · ${g("cell-off")}`]})]}),c.jsxs("span",{children:[xe&&de.includes("down")&&c.jsx("button",{className:"nc-btn ghost",disabled:Be||x,onClick:()=>ge(()=>sl(e,{cell:ae.id},ce)),children:g("stop")}),!xe&&de.includes("up")&&c.jsx("button",{className:"nc-btn primary",disabled:Be||x,onClick:()=>gt({cell:ae.id,id:ae.id,engine:ae.engine,model:ae.model,models:ae.models,permissionPolicies:ae.permissionPolicies,active:!1,boot:ae.boot}),children:g("start")}),xe&&de.includes("restart")&&c.jsx("button",{className:"nc-btn ghost",disabled:Be||x,onClick:()=>ge(()=>ho(e,ae.id,ce)),children:g("restart")}),Ne?c.jsx("button",{className:"nc-btn ghost",disabled:Be||x,onClick:()=>{P(""),j(ae)},children:g("fleet-cwd-repair")}):c.jsx("button",{className:"nc-btn ghost",disabled:Be||x,onClick:()=>{var Ee;P(""),y({mode:"edit",original:ae,form:{...ae,commands:{...ae.commands||{}},command:((Ee=ae.commands)==null?void 0:Ee[ae.engine])||""}})},children:g("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:Be||x,onClick:()=>ge(async()=>{window.confirm(g("fleet-remove-cell").replace("{id}",ae.id))&&await qv(e,ae.id,!0,ce)}),children:"×"})]})]},ae.id)}),c.jsxs("div",{className:"nc-fleet-section-head",children:[c.jsx("b",{children:g("fleet-engines")}),c.jsxs("button",{className:"nc-btn primary",disabled:Be||x,onClick:()=>{P(""),S({mode:"new",form:SE()})},children:["+ ",g("add")]})]}),a.engines.map(ae=>{var de,Ne;const xe=Fe(ae);return c.jsxs("div",{className:"nc-fleet-item",children:[c.jsxs("span",{children:[c.jsx("b",{children:ae.label}),c.jsx("small",{children:ae.managed?`${ae.id} · ${ae.managed.client} / ${ae.managed.provider} · ${(de=ae.managedInfo)!=null&&de.configured?g("fleet-ready"):((Ne=ae.managedInfo)==null?void 0:Ne.reason)||g("fleet-not-ready")}`:`${ae.id} · ${ae.command}`}),xe&&c.jsxs("small",{children:[xe.envKey," · ",g(`fleet-credential-source-${xe.source||"missing"}`)]})]}),c.jsxs("span",{children:[xe&&c.jsx("button",{className:"nc-btn ghost",disabled:Be||x,onClick:()=>{P(""),$({envKey:xe.envKey,value:""})},children:xe.configured?g("fleet-credential-change"):g("fleet-credential-set")}),(xe==null?void 0:xe.source)==="local"&&c.jsx("button",{className:"nc-btn danger",disabled:Be||x,onClick:()=>Ve(xe),children:g("fleet-credential-forget")}),c.jsx("button",{className:"nc-btn ghost",disabled:Be||x,onClick:()=>{P(""),S({mode:"edit",original:ae,form:xE(ae)})},children:g("edit")}),c.jsx("button",{className:"nc-btn danger",disabled:Be||x,onClick:()=>ge(async()=>{window.confirm(g("fleet-remove-engine").replace("{id}",ae.id))&&await t0(e,ae.id,ce)}),children:"×"})]})]},ae.id)})]}),b&&c.jsx(gr,{onClose:()=>S(null),label:g("fleet-new-engine"),error:C,children:c.jsx(EE,{state:b,setState:S,busy:x,onSave:Me,catalog:a.managedCatalog||[]})}),w&&c.jsx(gr,{onClose:()=>y(null),label:g("fleet-new-cell"),error:C,children:c.jsx(NE,{token:e,route:ce,targets:i,location:ee,setLocation:q,state:w,setState:y,engines:a.engines,busy:x,onSave:Ze})}),E&&c.jsx(gr,{onClose:()=>j(null),label:g("fleet-cwd-repair-title").replace("{id}",E.id),error:"",children:c.jsx(PE,{token:e,route:ce,cell:E,busy:x,onSaved:async()=>{j(null),M(g("fleet-cwd-repaired")),await he()},onClose:()=>j(null)})}),A&&c.jsx("div",{className:"nc-set-note",children:A}),C&&c.jsx("div",{className:"nc-err",children:C}),D&&c.jsx(gr,{onClose:()=>U(!1),label:g("fleet-backup"),error:C,children:c.jsx(kE,{cells:a.cells,engines:a.engines,busy:x,canRestore:J,onRestore:dt,onClose:()=>U(!1)})}),V&&c.jsx(gr,{onClose:()=>$(null),label:g("fleet-credential-title"),error:C,children:c.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[c.jsx("b",{children:g("fleet-credential-title")}),c.jsx("small",{children:g("fleet-credential-help")}),c.jsxs("label",{className:"nc-field",children:[V.envKey,c.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:V.value,onChange:ae=>$({...V,value:ae.target.value})})]}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",onClick:()=>$(null),children:g("cancel")}),c.jsx("button",{className:"nc-btn primary",disabled:x||!V.value,onClick:ct,children:g("save")})]})]})}),K&&c.jsx(gr,{onClose:()=>T(null),label:g("import-as-cell"),error:C,children:c.jsx(Tv,{token:e,route:K.route||ce,state:K,setState:T,busy:x,onSave:nt})}),H&&c.jsx(ol,{cell:H,token:e,route:Array.isArray(H.route)?H.route:ce,onConfirm:async ae=>{try{await ut(ae)}finally{await he()}},onClose:()=>te(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[ot,L==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:g("fleet-overview-help")}),c.jsx(nd,{token:e,targets:i,readonly:t,onPower:gt,onImport:lt})]}):c.jsxs(c.Fragment,{children:[rt,c.jsxs("div",{className:"nc-set-info",children:[g(C?"fleet-editor-load-error":"fleet-editor-unavailable"),!C&&h.reason?` ${h.reason}`:""]})]}),C&&c.jsx("div",{className:"nc-err",children:C}),K&&c.jsx(gr,{onClose:()=>T(null),label:g("import-as-cell"),error:C,children:c.jsx(Tv,{token:e,route:K.route||ce,state:K,setState:T,busy:x,onSave:nt})}),H&&c.jsx(ol,{cell:H,token:e,route:Array.isArray(H.route)?H.route:ce,onConfirm:async ae=>{try{await ut(ae)}finally{await he()}},onClose:()=>te(null)})]}):c.jsxs("div",{className:"nc-set-tab",children:[ot,L==="overview"?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"nc-set-info",children:g("fleet-overview-help")}),c.jsx(nd,{token:e,targets:i,readonly:t,onPower:gt,onImport:lt})]}):c.jsxs(c.Fragment,{children:[rt,c.jsx("div",{className:"nc-set-info",children:g("fleet-editor-loading")})]})]})}function DE({text:e}){const[t,i]=R.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch{}};return c.jsxs("div",{className:"nc-set-copyline",children:[c.jsx("code",{children:e}),c.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[c.jsx(et,{name:"copy",size:14})," ",g(t?"copied":"copy")]})]})}function LE({value:e}){const[t,i]=R.useState("");return R.useEffect(()=>{let s=!0;return Uk.toDataURL(e,{margin:1,width:220}).then(o=>{s&&i(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?c.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function ME({token:e,nodes:t,roster:i,settings:s,readonly:o,refresh:a,refreshAliases:u}){const[h,p]=R.useState(null),[f,_]=R.useState(null),[b,S]=R.useState({}),[w,y]=R.useState(null),[x,k]=R.useState({ssh:"",sshPort:"",name:""}),[C,P]=R.useState(""),[A,M]=R.useState(""),[ee,q]=R.useState(""),[B,Z]=R.useState(!1),[H,te]=R.useState(null),[K,T]=R.useState(null),E=Date.now(),j=s&&s.deviceName||"",D=(t||[]).filter(G=>G&&G.direction==="outbound"&&G.name&&G.ssh),U=D.find(G=>G.name===C)||D[0]||null,re=D.find(G=>G.name===A)||D[0]||null,I=re?Hm(re.tunnel,E):null,V=re!=null&&re.shared?I!=null&&I.up?"share-local-active":"share-local-pending":I!=null&&I.up?"share-local-private":"share-local-private-down",$=[{key:"peer-group-hubs",rows:(t||[]).filter(G=>G.kind!=="transitive"&&G.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(G=>G.kind!=="transitive"&&G.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(G=>G.kind==="transitive")}],L=async(G,J)=>{p(null),_(`${G}:${J}`);try{const ge=await hh(e,G,J);J==="test"&&S(Me=>({...Me,[G]:ge})),await a()}catch(ge){p(`${G}: ${String(ge.message||ge)}`)}_(null)},z=async G=>{p(null),_(`${G}:remove`);try{await p0(e,G),T(null),await a()}catch(J){p(`${G}: ${String(J.message||J)}`)}_(null)},oe=G=>te({name:G.name,direction:G.direction,label:G.label||G.name,ssh:G.ssh||"",sshPort:G.sshPort?String(G.sshPort):"",autostart:G.autostart===!0,visibility:G.visibility||"network",selected:[...G.selected||[]]}),ce=async()=>{if(!H||!ds(H.label)){p(g("err-label"));return}const G=H.direction==="inbound"?{label:H.label,visibility:H.visibility,selected:H.visibility==="selected"?H.selected:[]}:{label:H.label,ssh:H.ssh,autostart:H.autostart,...H.sshPort?{sshPort:Number(H.sshPort)}:{}};p(null),_(`${H.name}:edit`);try{await f0(e,H.name,G),te(null),await a()}catch(J){p(`${H.name}: ${String(J.message||J)}`)}_(null)},he=async G=>{if(re){p(null),_(`${re.name}:share`);try{await m0(e,re.name,G),await a()}catch(J){const ge=J!=null&&J.data&&typeof J.data.hint=="string"?J.data.hint:"";p(`${re.name}: ${String(J.message||J)}${ge?` — ${ge}`:""}`)}_(null)}},me=async()=>{if(p(null),U){const ge=$m({name:U.name,ssh:U.ssh,sshPort:U.sshPort||""});if(!ge.ok){p(g(ge.error));return}_("invite");try{y(await km(e,{ssh:ge.value.ssh,...ge.value.sshPort?{sshPort:ge.value.sshPort}:{}},[U.name]))}catch(Me){p(String(Me.message||Me))}_(null);return}const G=Zn(x.name||ee||j||"NexusCrew"),J=$m({name:G,ssh:x.ssh,sshPort:x.sshPort});if(!J.ok){p(g(J.error));return}_("invite");try{y(await km(e,{...ee||j?{label:ee||j}:{},name:G,ssh:J.value.ssh,...J.value.sshPort?{sshPort:J.value.sshPort}:{}}))}catch(ge){p(String(ge.message||ge))}_(null)};return c.jsxs("div",{className:"nc-set-tab",children:[c.jsx("div",{className:"nc-sheet-label",children:g("peer-inventory-title")}),(t||[]).length===0&&c.jsx("div",{className:"nc-empty",children:g("no-nodes")}),$.map(G=>G.rows.length>0&&c.jsxs("div",{className:"nc-peer-group",children:[c.jsxs("div",{className:"nc-peer-group-title",children:[g(G.key)," ",c.jsx("span",{children:G.rows.length})]}),G.rows.map(J=>{var Fe,ct;const ge=J.kind==="transitive",Me=ge?{up:J.stale!==!0,label:J.stale===!0?"peer-routed-stale":"peer-routed"}:Hm(J.tunnel,E),Ze=b[J.name],Be=J.actions||{};return c.jsxs("div",{className:`nc-set-node${ge?" routed":""}`,children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${Me.up?"on":""}`}),c.jsx("b",{children:J.label||J.name}),c.jsxs("small",{children:[J.name,ge?` · ${J.route.join(" → ")}`:J.direction==="outbound"?` · SSH ${J.ssh||""}`:` · ${g("node-connected-client")}`,(Fe=J.tunnel)!=null&&Fe.transport?` · ${J.tunnel.transport} ${g("transport-used")}`:""]}),c.jsxs("span",{className:`nc-set-tunnel${Me.up?" up":""}`,children:[g(Me.label),Me.since?` · ${Me.since}`:""]})]}),!ge&&J.direction==="inbound"&&c.jsx("div",{className:"nc-set-info",children:g(J.shared?"peer-shared":"peer-private")}),Be.visibility&&J.shared&&c.jsxs(c.Fragment,{children:[c.jsxs("select",{value:J.visibility||"network",disabled:o||!!f,onChange:async Ve=>{_(`${J.name}:visibility`);try{await Nm(e,J.name,Ve.target.value),await a()}catch(gt){p(String(gt.message||gt))}_(null)},children:[c.jsx("option",{value:"network",children:g("visibility-network")}),c.jsx("option",{value:"relay-only",children:g("visibility-relay")}),c.jsx("option",{value:"selected",children:g("visibility-selected")})]}),J.visibility==="selected"&&c.jsx("div",{className:"nc-set-row",children:(t||[]).filter(Ve=>Ve.name!==J.name&&Ve.nodeId).map(Ve=>{const gt=(J.selected||[]).includes(Ve.nodeId);return c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:gt,disabled:o||!!f,onChange:async ut=>{const lt=ut.target.checked?[...J.selected||[],Ve.nodeId]:(J.selected||[]).filter(nt=>nt!==Ve.nodeId);_(`${J.name}:visibility`);try{await Nm(e,J.name,"selected",lt),await a()}catch(nt){p(String(nt.message||nt))}_(null)}})," ",Ve.label||Ve.name]},Ve.nodeId)})})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[Be.edit&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>oe(J),children:g("edit")}),Be.test&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>L(J.name,"test"),children:g("node-test")}),Be.disconnect&&Me.up&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>L(J.name,"down"),children:g("tunnel-stop")}),Be.connect&&!Me.up&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>L(J.name,"up"),children:g("tunnel-start")}),Be.restart&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>L(J.name,"restart"),children:g("tunnel-restart")}),Be.remove&&c.jsxs("button",{type:"button",className:"nc-btn danger",disabled:o||!!f,title:g(o?"settings-readonly":"delete"),onClick:()=>T(J.name),children:[c.jsx(et,{name:"trash",size:14})," ",g("delete")]})]}),(H==null?void 0:H.name)===J.name&&c.jsxs("div",{className:"nc-set-form nc-node-editor",children:[c.jsxs("label",{className:"nc-field",children:[g("node-display-label"),c.jsx("input",{value:H.label,disabled:!!f,onChange:Ve=>te({...H,label:Ve.target.value})})]}),H.direction==="outbound"?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"nc-field",children:[g("node-ssh-label"),c.jsx("input",{value:H.ssh,disabled:!!f,onChange:Ve=>te({...H,ssh:Ve.target.value})})]}),c.jsxs("label",{className:"nc-field",children:[g("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",value:H.sshPort,disabled:!!f,onChange:Ve=>te({...H,sshPort:Ve.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:H.autostart,disabled:!!f,onChange:Ve=>te({...H,autostart:Ve.target.checked})})," ",g("boot-persist")]})]}):c.jsxs("label",{className:"nc-field",children:[g("peer-visibility"),c.jsxs("select",{value:H.visibility,disabled:!!f,onChange:Ve=>te({...H,visibility:Ve.target.value}),children:[c.jsx("option",{value:"network",children:g("visibility-network")}),c.jsx("option",{value:"relay-only",children:g("visibility-relay")}),c.jsx("option",{value:"selected",children:g("visibility-selected")})]})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!f,onClick:ce,children:g("save")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>te(null),children:g("cancel")})]})]}),K===J.name&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("b",{children:g("node-remove-confirm").replace("{name}",J.label||J.name)}),c.jsx("small",{children:g("node-remove-warning")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!f,onClick:()=>z(J.name),children:g("delete")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>T(null),children:g("cancel")})]})]}),((ct=J.health)==null?void 0:ct.detail)&&c.jsx("div",{className:`nc-set-test${J.health.status==="healthy"?" ok":J.health.status==="passive"?"":" ko"}`,children:J.health.detail}),Ze&&c.jsxs("div",{className:`nc-set-test${Ze.ok?" ok":" ko"}`,children:[Ze.result,Ze.detail?` — ${Ze.detail}`:""]})]},`${J.kind||"direct"}:${J.nodeId||J.name}`)})]},G.key)),(i||[]).some(G=>!G.direct&&G.instanceId)&&c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:g("routed-node-aliases")}),c.jsx("small",{className:"nc-set-hint",children:g("routed-node-aliases-help")}),(i||[]).filter(G=>!G.direct&&G.instanceId).map(G=>c.jsxs("div",{className:"nc-set-node",children:[c.jsxs("div",{className:"nc-set-node-head",children:[c.jsx("span",{className:`nc-dot ${G.status==="up"?"on":""}`}),c.jsx("b",{children:G.label||G.name}),c.jsx("small",{children:(G.route||[]).join(" › ")})]}),c.jsxs("div",{className:"nc-set-node-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:async()=>{const J=window.prompt(g("node-local-alias"),G.alias||"");if(J!=null){if(J.trim()&&!ds(J.normalize("NFC"))){p(g("err-label"));return}_(`${G.instanceId}:alias`),p(null);try{J.trim()?await h0(e,G.instanceId,J):await Em(e,G.instanceId),u()}catch(ge){p(String(ge.message||ge))}_(null)}},children:g("alias-on-device")}),G.alias&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:async()=>{_(`${G.instanceId}:alias-reset`),p(null);try{await Em(e,G.instanceId),u()}catch(J){p(String(J.message||J))}_(null)},children:g("reset-alias")})]})]},G.instanceId))]}),re&&c.jsxs("div",{className:"nc-set-form nc-local-share",children:[c.jsx("div",{className:"nc-sheet-label",children:g("share-local-heading")}),D.length>1&&c.jsxs("label",{className:"nc-field",children:[g("share-local-hub"),c.jsx("select",{value:re.name,disabled:o||!!f,onChange:G=>M(G.target.value),children:D.map(G=>c.jsx("option",{value:G.name,children:G.label||G.name},G.name))})]}),c.jsxs("label",{className:"nc-check nc-node-share",children:[c.jsx("input",{type:"checkbox",checked:re.shared===!0,disabled:o||!!f,onChange:G=>he(G.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:g("share-local-through").replace("{device}",j||g("local")).replace("{hub}",re.label||re.name)}),c.jsx("small",{children:g(re.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),c.jsx("div",{className:`nc-set-test${re.shared&&(I!=null&&I.up)?" ok":I!=null&&I.up?"":" ko"}`,children:g(V)}),!(I!=null&&I.up)&&c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!f,onClick:()=>he(re.shared===!0),children:g("share-local-reconnect")})]}),c.jsx(Py,{token:e,deviceDefault:j,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:o,onSuccess:a}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:g("invite-node")}),c.jsx("small",{className:"nc-set-hint",children:g(U?"invite-network-hint":"invite-v2-hint")}),U?c.jsxs(c.Fragment,{children:[D.length>1&&c.jsxs("label",{className:"nc-field",children:[g("invite-network-label"),c.jsx("select",{value:U.name,disabled:o||!!f,onChange:G=>{P(G.target.value),y(null)},children:D.map(G=>c.jsx("option",{value:G.name,children:G.label||G.name},G.name))})]}),c.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[g("invite-network-via"),": ",c.jsx("b",{children:U.label||U.name})," · ",U.ssh,U.sshPort?`:${U.sshPort}`:""]}),c.jsx("small",{className:"nc-set-hint",children:g("invite-network-route")})]}):c.jsxs("label",{className:"nc-field",children:[g("invite-endpoint-label"),c.jsx("input",{placeholder:"user@host",value:x.ssh,disabled:o,onChange:G=>k({...x,ssh:G.target.value})}),c.jsx("small",{className:"nc-set-hint",children:g("invite-endpoint-needed")})]}),!U&&B&&c.jsxs("div",{className:"nc-invite-advanced",children:[c.jsxs("label",{className:"nc-field",children:[g("node-ssh-port-label"),c.jsx("input",{inputMode:"numeric",placeholder:"22",value:x.sshPort,disabled:o,onChange:G=>k({...x,sshPort:G.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),c.jsxs("label",{className:"nc-field",children:[g("device-name-label"),c.jsx("input",{placeholder:j||"NexusCrew",value:ee,disabled:o,onChange:G=>q(G.target.value)}),c.jsx("small",{className:"nc-set-hint",children:g("device-name-hint")})]}),c.jsxs("label",{className:"nc-field",children:[g("node-name-label"),c.jsx("input",{placeholder:Zn(ee||j||g("node-name-ph")),value:x.name,disabled:o,onChange:G=>k({...x,name:G.target.value?Zn(G.target.value):""})})]})]}),c.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[c.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||!!f||!U&&!x.ssh.trim(),onClick:me,children:g("create-pairing-link")}),!U&&c.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!f,onClick:()=>Z(G=>!G),children:[B?"▾":"▸"," ",g("pair-advanced")]})]}),w&&c.jsxs(c.Fragment,{children:[c.jsx(LE,{value:w.pairingUrl}),c.jsx(DE,{text:w.pairingUrl}),c.jsx("div",{className:"nc-set-info",children:g("invite-next-steps")})]})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function TE({token:e,readonly:t}){const[i,s]=R.useState("idle"),[o,a]=R.useState(!1),[u,h]=R.useState(null);R.useEffect(()=>{let f=!1;return iE().then(_=>{f||s(_)}),()=>{f=!0}},[]);const p=async()=>{h(null),a(!0);try{i==="subscribed"?(await rE(e),s("idle")):(await nE(e),s("subscribed"))}catch(f){const _=String(f.message||f);_==="push-denied"?(s("denied"),h(g("push-denied"))):_==="push-unsupported"?(s("unsupported"),h(g("push-unsupported"))):h(_)}a(!1)};return i==="unsupported"?c.jsx("div",{className:"nc-set-info",children:g("push-unsupported")}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||i==="denied",title:t?g("settings-readonly"):"",onClick:p,children:g(i==="subscribed"?"push-disable":"push-enable")}),c.jsx("span",{className:"nc-set-info",children:g(i==="subscribed"?"push-on":i==="denied"?"push-denied":"push-off")})]}),u&&c.jsx("div",{className:"nc-err",children:u})]})}function AE({token:e,roster:t=[],readonly:i}){const s=[{key:"local",route:[],label:g("diagnostics-local"),status:"up"},...t.filter(D=>Array.isArray(D.route)&&D.route.length).map(D=>({key:D.route.join("/"),route:D.route,label:D.label||D.name,status:D.status}))],[o,a]=R.useState("local"),u=s.find(D=>D.key===o)||s[0],[h,p]=R.useState(null),[f,_]=R.useState([]),[b,S]=R.useState(""),[w,y]=R.useState(!1),[x,k]=R.useState(!0),[C,P]=R.useState(900),[A,M]=R.useState("all"),[ee,q]=R.useState(""),B=R.useRef(0),Z=R.useRef(null),H=R.useCallback(async()=>{try{const D=await y0(e,u.route);if(p(D),S(""),!w){const U=await w0(e,{after:B.current,limit:200},u.route);Array.isArray(U.records)&&U.records.length&&(B.current=U.cursor,_(re=>[...re,...U.records].slice(-500)))}}catch(D){S(D&&D.status===404?g("diagnostics-unsupported"):String(D.message||D))}},[e,u.key,w]);R.useEffect(()=>{B.current=0,_([]),p(null),S("")},[u.key]),R.useEffect(()=>{let D=null,U=!0;const re=()=>{!U||document.visibilityState==="hidden"||H()},I=()=>{D&&clearInterval(D),D=document.visibilityState==="hidden"?null:setInterval(re,2e3),document.visibilityState!=="hidden"&&re()};return document.addEventListener("visibilitychange",I),I(),()=>{U=!1,D&&clearInterval(D),document.removeEventListener("visibilitychange",I)}},[H]),R.useEffect(()=>{x&&Z.current&&(Z.current.scrollTop=Z.current.scrollHeight)},[f,x]);const te=f.filter(D=>(A==="all"||D.level===A)&&(!ee||String(D.component||"").toLowerCase().includes(ee.toLowerCase()))),K=te.map(D=>`${D.ts} ${D.level.toUpperCase()} ${D.component} ${D.code} ${D.message}${Object.keys(D.meta||{}).length?` ${JSON.stringify(D.meta)}`:""}`).join(`
|
|
92
|
+
`),T=async D=>{S("");try{const U=await D();p(U),await H()}catch(U){S(String(U.message||U))}},E=async()=>{try{await navigator.clipboard.writeText(K)}catch{S(g("copy-manual"))}},j=()=>{try{const D=new Blob([`${JSON.stringify(te,null,2)}
|
|
93
|
+
`],{type:"application/json"}),U=URL.createObjectURL(D),re=document.createElement("a");re.href=U,re.download="nexuscrew-diagnostics.json",re.click(),URL.revokeObjectURL(U)}catch{S(g("diagnostics-export-failed"))}};return c.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[c.jsxs("label",{className:"nc-field",children:[g("diagnostics-target"),c.jsx("select",{value:u.key,onChange:D=>a(D.target.value),children:s.map(D=>c.jsxs("option",{value:D.key,children:[D.label,D.status!=="up"?` · ${D.status}`:""]},D.key))})]}),c.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[c.jsx("div",{className:"nc-sheet-label",children:g("diagnostics-verbose")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("select",{"aria-label":g("diagnostics-duration"),value:C,onChange:D=>P(Number(D.target.value)),disabled:i,children:[300,900,1800,3600].map(D=>c.jsxs("option",{value:D,children:[D/60," min"]},D))}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||(h==null?void 0:h.verbose)===!0,onClick:()=>T(()=>Rm(e,!0,C,u.route)),children:g("enable")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||(h==null?void 0:h.verbose)!==!0,onClick:()=>T(()=>Rm(e,!1,C,u.route)),children:g("stop")})]}),c.jsx("small",{className:"nc-set-hint",children:h!=null&&h.verbose?g("diagnostics-expires").replace("{time}",new Date(h.expiresAt).toLocaleTimeString()):g("diagnostics-off")})]}),c.jsxs("div",{className:"nc-diag-filters",children:[c.jsxs("select",{"aria-label":g("diagnostics-level"),value:A,onChange:D=>M(D.target.value),children:[c.jsx("option",{value:"all",children:g("diagnostics-all-levels")}),["debug","info","warn","error"].map(D=>c.jsx("option",{value:D,children:D},D))]}),c.jsx("input",{"aria-label":g("diagnostics-component"),placeholder:g("diagnostics-component"),value:ee,onChange:D=>q(D.target.value)})]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:w,onChange:D=>y(D.target.checked)})," ",g("diagnostics-pause")]}),c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:x,onChange:D=>k(D.target.checked)})," ",g("diagnostics-autoscroll")]})]}),c.jsx("pre",{ref:Z,className:"nc-diag-log","aria-label":g("diagnostics-log"),children:K||g("diagnostics-empty")}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:E,children:g("copy")}),c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:j,children:g("diagnostics-export")}),c.jsx("button",{type:"button",className:"nc-btn danger",disabled:i,onClick:()=>{window.confirm(g("diagnostics-clear-confirm"))&&T(async()=>{const D=await S0(e,u.route);return B.current=0,_([]),D})},children:g("diagnostics-clear")})]}),b&&c.jsx("div",{className:"nc-err",children:b})]})}function IE({token:e,settings:t,readonly:i,refresh:s}){const[o,a]=R.useState(null),[u,h]=R.useState(null),[p,f]=R.useState(!1),[_,b]=R.useState(!1),[S,w]=R.useState(null),[y,x]=R.useState(!0);R.useEffect(()=>{w(t&&t.update||null),x(!t||t.autoUpdate!==!1)},[t]);const k=async()=>{a(null),h(null),b(!0);try{const B=await c0(e);h(B.note||"ok"),f(!1)}catch(B){a(String(B.message||B))}b(!1)},C=async()=>{a(null),h(null),b(!0);try{const B=await g0(e);h(`${B.note||"ok"}${B.target?` (${B.target})`:""}`)}catch(B){a(String(B.message||B))}b(!1)},P=async B=>{a(null),h(null),b(!0);try{await Gv(e,{autoUpdate:B}),x(B),s&&await s()}catch(Z){a(String(Z.message||Z))}b(!1)},A=async()=>{a(null),h(null),b(!0);try{w(await v0(e))}catch(B){a(String(B.message||B))}b(!1)},M=async()=>{a(null),h(null),b(!0);try{const B=await _0(e);w(B),h(g("npm-update-restarting"))}catch(B){a(String(B.message||B))}b(!1)},ee=()=>{window.confirm(g("composer-clear-confirm"))&&(a(null),GC()?(window.dispatchEvent(new Event(Xd)),h(g("composer-clear-done"))):a(g("composer-clear-failed")))},q=t&&t.service;return c.jsxs("div",{className:"nc-set-tab",children:[t&&c.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,c.jsx("br",{}),q&&q.installed?g("service-installed"):g("service-missing"),q&&q.installed?` · ${q.active?g("service-active"):g("service-inactive")}`:"",q?` · boot ${q.boot?"on":"off"}`:""]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_,title:i?g("settings-readonly"):"",onClick:()=>{a(null),h(null),f(!0)},children:g("token-rotate")}),c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_,title:i?g("settings-readonly"):"",onClick:C,children:g("service-regenerate")})]}),c.jsxs("div",{className:"nc-set-form nc-update-settings",children:[c.jsxs("label",{className:"nc-check",children:[c.jsx("input",{type:"checkbox",checked:y,disabled:i||_||S&&!S.supported,onChange:B=>P(B.target.checked)}),c.jsxs("span",{children:[c.jsx("b",{children:g("npm-auto-update")}),c.jsx("small",{children:g("npm-auto-update-help")})]})]}),S&&c.jsxs("div",{className:"nc-set-info",children:[g("npm-update-current")," v",S.current,S.latest?` · ${g("npm-update-latest")} v${S.latest}`:""," · ",g(`npm-update-${S.supported?S.phase:"unsupported"}`)]}),c.jsxs("div",{className:"nc-set-row",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||_||!S||!S.supported,onClick:A,children:g("npm-update-check")}),S&&S.available&&c.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||_||S.phase==="installing",onClick:M,children:g("npm-update-install")})]}),S&&S.lastError&&c.jsx("div",{className:"nc-err",children:S.lastError})]}),c.jsx(TE,{token:e,readonly:i}),c.jsxs("div",{className:"nc-set-form",children:[c.jsx("div",{className:"nc-sheet-label",children:g("composer-clear-data")}),c.jsx("small",{className:"nc-set-hint",children:g("composer-clear-data-help")}),c.jsx("div",{className:"nc-set-row",children:c.jsx("button",{type:"button",className:"nc-btn ghost",onClick:ee,children:g("composer-clear-data")})})]}),p&&c.jsxs("div",{className:"nc-set-confirm",children:[c.jsx("div",{children:g("token-rotate-explain")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>f(!1),children:g("cancel")}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:_,onClick:k,children:g("confirm")})]})]}),u&&c.jsx("div",{className:"nc-set-note",children:u}),o&&c.jsx("div",{className:"nc-err",children:o})]})}function BE({token:e,onClose:t,initialTab:i="nodes",initialLocation:s="",startNewCell:o=!1}){ji();const[a,u]=R.useState(i),[h,p]=R.useState(null),[f,_]=R.useState([]),[b,S]=R.useState(!1),[w,y]=R.useState(null),[x,k]=R.useState(0),C=ph(e,!0,x),P=R.useCallback(async()=>{try{const A=await Yv(e);p(A),y(null)}catch(A){y(String(A.message||A))}try{const A=await a0(e);_(A.peers||[])}catch(A){y(String(A.message||A))}},[e]);return R.useEffect(()=>{P();const A=setInterval(P,5e3);return()=>clearInterval(A)},[P]),R.useEffect(()=>{let A=!1;return Vt("/api/config",e).then(M=>M.json()).then(M=>{A||S(!!M.readonlyDefault)}).catch(()=>{}),()=>{A=!0}},[e]),c.jsx("div",{className:"nc-set-overlay",onClick:t,children:c.jsxs("div",{className:"nc-set-panel",onClick:A=>A.stopPropagation(),children:[c.jsxs("div",{className:"nc-set-head",children:[c.jsx(et,{name:"gear",size:18}),c.jsx("b",{children:g("settings")}),c.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:g("close"),children:c.jsx(et,{name:"x",size:18})})]}),b&&c.jsx("div",{className:"nc-set-readonly",children:g("settings-readonly")}),w&&c.jsx("div",{className:"nc-err",children:w}),c.jsx("div",{className:"nc-set-tabs",children:["nodes","fleet","diagnostics","system"].map(A=>c.jsx("button",{type:"button",className:`nc-set-tabbtn${a===A?" on":""}`,onClick:()=>u(A),children:g(`tab-${A}`)},A))}),c.jsxs("div",{className:"nc-set-body",children:[a==="nodes"&&c.jsx(ME,{token:e,nodes:f,roster:C,settings:h,readonly:b,refresh:P,refreshAliases:()=>k(A=>A+1)}),a==="fleet"&&c.jsx(jE,{token:e,readonly:b,startNewCell:o,initialLocation:s,targets:C.map(A=>({route:A.route,label:A.label||A.name,status:A.status}))}),a==="diagnostics"&&c.jsx(AE,{token:e,roster:C,readonly:b}),a==="system"&&c.jsx(IE,{token:e,settings:h,readonly:b,refresh:P})]})]})})}function OE({token:e,initialPair:t,deviceDefault:i="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:u}){ji();const[h,p]=R.useState(t?"pair":"welcome"),[f,_]=R.useState(!1),[b,S]=R.useState(null),w=async()=>{_(!0),S(null);try{await Gv(e,{wizardDone:!0}),a&&a(),u()}catch(y){S(String(y.message||y)),_(!1)}};return c.jsx("div",{className:"nc-wiz-overlay",children:c.jsxs("div",{className:"nc-wiz",children:[c.jsxs("div",{className:"nc-wiz-head",children:[c.jsx("b",{children:g("wizard-title")}),c.jsx("small",{children:g("hydra-simple")})]}),h==="welcome"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:g("local-ready")}),c.jsxs("div",{className:"nc-sheet-actions",children:[c.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:w,children:g("local-only")}),c.jsx("button",{className:"nc-btn primary",disabled:f,onClick:()=>p("pair"),children:g("add-node")})]})]}),h==="pair"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx(Py,{token:e,initial:t||"",autoStart:!!t,deviceDefault:i,localNodeId:s,localNameDefault:o,onBusyChange:_,onSuccess:async()=>{a&&a(),p("done")}}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn ghost",disabled:f,onClick:()=>{a&&a(),p("welcome")},children:g("back")})})]}),h==="done"&&c.jsxs("div",{className:"nc-wiz-body",children:[c.jsx("div",{className:"nc-wiz-done",children:g("node-connected")}),c.jsx("div",{className:"nc-sheet-actions",children:c.jsx("button",{className:"nc-btn primary",disabled:f,onClick:w,children:g("finish")})})]}),b&&c.jsx("div",{className:"nc-err",children:b})]})})}function zE(e,t){if(typeof EventSource>"u"||!e)return()=>{};const i=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return i.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{i.close()}catch{}}}const FE=6e3,$E=12e3;function HE({n:e,onClose:t}){return c.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[c.jsxs("div",{className:"nc-ntf-toast-txt",children:[c.jsx("b",{children:e.title}),e.body&&c.jsx("small",{children:e.body}),e.session&&c.jsx("span",{className:"nc-ntf-from",children:e.session})]}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:g("close"),children:c.jsx(et,{name:"x",size:14})})]})}function WE({ask:e,token:t,onAnswered:i}){const[s,o]=R.useState(""),[a,u]=R.useState(!1),[h,p]=R.useState(null),f=async _=>{const b=String(_||"").trim();if(!(!b||a)){p(null),u(!0);try{await x0(t,e.id,b),i(e.id)}catch(S){p(String(S.message||S))}u(!1)}};return c.jsxs("div",{className:"nc-ask-card",children:[c.jsxs("div",{className:"nc-ask-head",children:[c.jsx("span",{className:"nc-ntf-from",children:e.session}),c.jsxs("code",{className:"nc-ask-id",children:["#",e.id]})]}),c.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&c.jsx("div",{className:"nc-ask-opts",children:e.options.map(_=>c.jsx("button",{type:"button",className:"nc-btn ghost",disabled:a,onClick:()=>f(_),children:_},_))}),c.jsxs("div",{className:"nc-ask-reply",children:[c.jsx("textarea",{rows:2,placeholder:g("ask-reply-ph"),value:s,disabled:a,onChange:_=>o(_.target.value)}),c.jsx("button",{type:"button",className:"nc-btn primary",disabled:a||!s.trim(),onClick:()=>f(s),children:g("send")})]}),h&&c.jsx("div",{className:"nc-err",children:h})]})}function UE({token:e}){ji();const[t,i]=R.useState([]),[s,o]=R.useState([]),[a,u]=R.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),h=R.useRef(0),p=R.useCallback(b=>{i(S=>S.filter(w=>w.key!==b))},[]),f=R.useCallback(b=>{const S=`t${h.current+=1}`;i(w=>[...w.slice(-3),{...b,key:S}]),setTimeout(()=>p(S),b.urgency==="high"?$E:FE)},[p]);R.useEffect(()=>{if(!e)return;let b=!1;b0(e).then(w=>{b||o(w.asks||[])}).catch(()=>{});const S=zE(e,w=>{w.type==="notify"?f(w):w.type==="ask"&&w.ask&&w.ask.id?o(y=>y.some(x=>x.id===w.ask.id)?y:[...y,w.ask]):w.type==="ask-answered"&&w.id&&o(y=>y.filter(x=>x.id!==w.id))});return()=>{b=!0,S()}},[e,f]);const _=b=>o(S=>S.filter(w=>w.id!==b));return c.jsxs(c.Fragment,{children:[t.length>0&&c.jsx("div",{className:"nc-ntf-toasts",children:t.map(b=>c.jsx(HE,{n:b,onClose:()=>p(b.key)},b.key))}),s.length>0&&!a&&c.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>u(!0),title:g("asks-title"),children:["? ",c.jsx("span",{className:"nc-ask-count",children:s.length})]}),s.length>0&&a&&c.jsxs("div",{className:"nc-ask-panel",children:[c.jsxs("div",{className:"nc-ask-panel-head",children:[c.jsx("b",{children:g("asks-title")}),c.jsx("span",{className:"nc-ask-count",children:s.length}),c.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>u(!1),title:g("close"),children:c.jsx(et,{name:"x",size:16})})]}),c.jsx("div",{className:"nc-ask-panel-body",children:s.map(b=>c.jsx(WE,{ask:b,token:e,onAnswered:_},b.id))})]})]})}const rd=e=>ln(Cr(e)).length===0,sd=e=>Array.isArray(e)?e.join("/"):"";function KE(e){const t=new Set,i=[];for(const s of Array.isArray(e)?e:[])!s||!Hi.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),i.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return i.sort((s,o)=>s.label.localeCompare(o.label))}function uo(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function vr(e,t,i,s=!1,o=!0){const a=t.instanceId;return{...e,id:ls(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(i)?i:[],layout:Qd(e.layout,a,i)}}function qE(e,t,i,s,o=[]){const[a,u]=R.useState([]),[h,p]=R.useState(!1),[f,_]=R.useState("idle"),[b,S]=R.useState(""),[w,y]=R.useState(""),x=R.useRef([]),k=R.useRef([]),C=R.useRef(""),P=R.useRef(t),A=R.useRef(i),M=R.useRef(!1),ee=R.useRef(!0),q=R.useRef(""),B=R.useMemo(()=>KE(o),[o]),Z=B.map($=>`${$.instanceId}:${sd($.route)}:${$.status}:${$.label}`).join("|");k.current=B,A.current=i,P.current=t,x.current=a;const H=R.useCallback($=>Jd($.layout,C.current,k.current),[]),te=R.useCallback(($,L=!0,z=P.current)=>{const oe=Jg($,Ya()),ce=x.current.some(me=>me.id===z);x.current=oe,u(oe);const he=oe.find(me=>me.id===z);if(L&&he){ee.current=!0;const me=H(he);s(me),he.local&&yk(he.name,me)}else ce&&!he&&(ee.current=!0,s(as()),S("deck non più condiviso dal nodo owner"));mk(oe.filter(me=>me.local).map(me=>me.name))},[s,H]),K=R.useCallback(async $=>{let L=await za(e);const z=L.decks.find(oe=>oe.name==="main");if(L.decks.length===1&&z&&z.revision===0&&rd(z.layout)){const oe=pk(),ce=Cr(Zd("main")||as());if(!rd(ce)){const he=Qd(ce,$,[]);L.decks[0]=await Fa(e,"main",he,0,[])}for(const he of oe.filter(me=>me!=="main"))try{let me=await Pm(e,he,[]);const G=Cr(Zd(he)||as());rd(G)||(me=await Fa(e,he,Qd(G,$,[]),me.revision,[]))}catch{}L=await za(e)}return L},[e]),T=R.useCallback(async({migrate:$=!1}={})=>{const L=await dh(e,[]),z=Hi.test(String(L.instanceId||""))?L.instanceId:"";if(!z)throw new Error("instanceId locale non disponibile");C.current=z,y(z);const[oe,ce]=await Promise.all([$?K(z):za(e),Cm(e,[]).catch(()=>({nodes:[]}))]),he={instanceId:z,route:[],label:"Local"},me=oe.decks.map(J=>vr(J,he,ce.nodes,!0,!0)),G=x.current;return await Promise.all(k.current.map(async J=>{if(J.status!=="up"){me.push(...G.filter(ge=>!ge.local&&ge.ownerId===J.instanceId).map(ge=>({...ge,ownerRoute:[...J.route],ownerLabel:J.label,available:!1})));return}try{const[ge,Me]=await Promise.all([za(e,J.route),Cm(e,J.route).catch(()=>({nodes:[]}))]);me.push(...ge.decks.map(Ze=>vr(Ze,J,Me.nodes,!1,!0)))}catch{me.push(...G.filter(Me=>!Me.local&&Me.ownerId===J.instanceId).map(Me=>({...Me,ownerRoute:[...J.route],ownerLabel:J.label,available:!1})))}})),me.sort((J,ge)=>J.local===ge.local?J.ownerLabel.localeCompare(ge.ownerLabel)||(J.name==="main"?-1:ge.name==="main"?1:J.name.localeCompare(ge.name)):J.local?-1:1),me},[e,K,Z]);R.useEffect(()=>{if(!e)return;let $=!1;const L=q.current!==e;return q.current=e,T({migrate:L}).then(z=>{if($)return;const oe=x.current.find(me=>me.id===P.current),ce=z.find(me=>me.id===P.current),he=ce&&(!oe||ce.revision>oe.revision||oe.available!==ce.available||sd(oe.ownerRoute)!==sd(ce.ownerRoute));te(z,L||!!he&&!M.current),p(!0),ce&&S("")}).catch(z=>{$||(p(!0),S(String(z.message||z)))}),()=>{$=!0}},[te,T,Z,e]);const E=R.useCallback(async($=P.current)=>{if(!h||!M.current)return!0;const L=x.current.find(z=>z.id===$);if(!L)return S(`deck inesistente: ${$}`),!1;if(L.available===!1)return S(`nodo owner offline: ${L.ownerLabel}`),!1;_("saving");try{const z=Gg(Cr(A.current),L.ownerId,L.ownerTopology),oe=await Fa(e,L.name,z,L.revision,L.ownerRoute),ce=vr(oe,uo(L),L.ownerTopology,L.local,!0);return te(x.current.map(he=>he.id===$?ce:he),!1),M.current=!1,_("saved"),S(""),setTimeout(()=>_("idle"),1500),!0}catch(z){if(_("error"),S(String(z.message||z)),z.status===409&&z.data&&z.data.current){const oe=x.current.find(he=>he.id===$),ce=vr(z.data.current,uo(oe),oe.ownerTopology,oe.local,!0);te(x.current.map(he=>he.id===$?ce:he),!1)}return!1}},[h,e,te]);return R.useEffect(()=>{if(!h)return;if(ee.current){ee.current=!1;return}M.current=!0,_("saving");const $=setTimeout(E,650);return()=>clearTimeout($)},[i,h,E]),R.useEffect(()=>{if(!h)return;const $=setInterval(async()=>{try{const L=await T(),z=x.current.find(he=>he.id===P.current),oe=L.find(he=>he.id===P.current),ce=oe&&(!z||oe.revision>z.revision||z.available!==oe.available);te(L,ce&&!M.current)}catch{}},5e3);return()=>clearInterval($)},[h,T,te]),{decks:a,records:a,localNodeId:w,ready:h,saveState:f,error:b,setError:S,saveNow:E,select:async $=>{if(M.current&&!await E(P.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const L=x.current.find(z=>z.id===$);if(!L)throw new Error(`deck inesistente: ${$}`);return M.current=!1,ee.current=!0,H(L)},add:async($,L=null)=>{const z=L===Sn?x.current.find(he=>he.local):L?x.current.find(he=>he.ownerId===L):null;if(!z||z.available===!1)throw new Error("nodo owner non disponibile");const oe=await Pm(e,$,z.ownerRoute),ce=vr(oe,uo(z),z.ownerTopology,z.local,!0);return te([...x.current,ce],!1),ce},rename:async($,L)=>{const z=x.current.find(G=>G.id===$);if(!z)throw new Error("deck inesistente");if($===P.current&&M.current&&!await E($))throw new Error(`salvataggio di "${z.name}" fallito: rinomina annullata`);const oe=x.current.find(G=>G.id===$);if(!oe)throw new Error("deck inesistente");const ce=await C0(e,oe.name,L,oe.revision,oe.ownerRoute),he=vr(ce,uo(oe),oe.ownerTopology,oe.local,!0),me=oe.local?Sn:oe.ownerId;return Mu(vk(Ya(),me,$,he.id)),te(x.current.map(G=>G.id===$?he:G),!1),he},remove:async $=>{const L=x.current.find(oe=>oe.id===$);if(!L)throw new Error("deck inesistente");$===P.current&&(M.current=!1),await k0(e,L.name,L.revision,L.ownerRoute);const z=L.local?Sn:L.ownerId;Mu(_k(Ya(),z,$)),te(x.current.filter(oe=>oe.id!==$),!1)},reorder:($,L)=>{const z=x.current.find(J=>J.id===$),oe=x.current.find(J=>J.id===L);if(!z||!oe)return!1;const ce=z.local?Sn:z.ownerId,he=oe.local?Sn:oe.ownerId;if(ce!==he)return!1;const me=x.current.filter(J=>(J.local?Sn:J.ownerId)===ce).map(J=>J.id),G=Mu(gk(Ya(),ce,$,L,me));return te(Jg(x.current,G),!1),!0},addTileTo:async($,L)=>{const z=x.current.find(J=>J.id===$);if(!z)throw new Error("deck inesistente");if(z.available===!1)throw new Error(`nodo owner offline: ${z.ownerLabel}`);const oe=yy(L,C.current,k.current);if(!oe)throw new Error("riferimento sessione non valido");const ce=H(z),he=Gg(f_(ce,oe),z.ownerId,z.ownerTopology),me=await Fa(e,z.name,he,z.revision,z.ownerRoute),G=vr(me,uo(z),z.ownerTopology,z.local,!0);return te(x.current.map(J=>J.id===$?G:J),!1),G},localMainId:ls(null,"main"),parseDeckId:jh}}const VE="/sw.js",th="nc-sw-update";let ih=null,nh=!1,rh=null,zy=Object.freeze({needed:!1,kind:null,version:""}),Fy=!1;function $y(){typeof window<"u"&&window.dispatchEvent(new Event(th))}function Hy(){const e=rh||(nh?{kind:"reload",version:""}:null);zy=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function Av(){return zy}function YE(e){return typeof window>"u"?()=>{}:(window.addEventListener(th,e),()=>window.removeEventListener(th,e))}function Ah(e){nh!==e&&(nh=e,Hy(),$y())}function XE(e,t,i){let s=null;e&&t&&e!==t?s={kind:"install",version:e}:t&&i&&t!==i&&(s={kind:"reload",version:t});const o=JSON.stringify(s)===JSON.stringify(rh);rh=s,Hy(),o||$y()}function GE(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&Ah(!0)})}function QE(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{Fy&&location.reload()}),navigator.serviceWorker.register(VE).then(e=>{ih=e,e.waiting&&Ah(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&GE(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function JE(){Fy=!0,Ah(!1);const e=ih&&ih.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function ZE({hash:e="",origin:t="",pathname:i="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${i||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const u=new URLSearchParams(o),h=u.get("token")||"",p=u.get("pair")||"",f=p?`${t||""}${i||""}#pair=${p}`:"";return{token:h,pair:f,nextUrl:a}}const Wy=9,Uy=24,Ky="nc_side_w",Iv="nc_side_min",e2=240,Bv="(min-width:1024px) and (pointer:fine)";function t2(){const e=Number(localStorage.getItem(Ky));return e>=180&&e<=480?e:e2}function i2(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=Wy&&e<=Uy?e:13}function n2(){const e={token:"",pair:""};try{const{token:t,pair:i,nextUrl:s}=ZE({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(i){e.pair=i;try{sessionStorage.setItem("nc_pair",i)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function r2(e){try{return Cr(Zd(e))}catch{return as()}}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 s2(){const[e,t]=R.useState(()=>window.matchMedia(Bv).matches);return R.useEffect(()=>{const i=window.matchMedia(Bv),s=o=>t(o.matches);return i.addEventListener("change",s),()=>i.removeEventListener("change",s)},[]),e}function zv({session:e,node:t,ownerId:i,cellName:s,token:o,readonly:a=!1,onBack:u}){ji();const[h,p]=R.useState(!1),[f,_]=R.useState(()=>window.matchMedia("(pointer: coarse)").matches),[b,S]=R.useState(null),[w,y]=R.useState(i2),[x,k]=R.useState(s||e),[C,P]=R.useState(""),A=E=>y(j=>{const D=Math.max(Wy,Math.min(Uy,j+E));return localStorage.setItem("nc_fontsize",String(D)),D}),M=R.useRef(()=>{}),ee=R.useRef(()=>!1),q=R.useRef(()=>{}),B=R.useRef(!1),[Z,H]=R.useState(!1),[te,K]=R.useState(!1),T=()=>{B.current=!B.current,H(B.current)};return R.useEffect(()=>{k(s||e)},[s,e]),R.useEffect(()=>{let E=!0;const j=t?t.split("/"):[],D=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function U(){let I=null,V=null;try{const z=await(await Vt(`${D}/sessions`,o)).json();Array.isArray(z.sessions)&&(I=z.sessions.find(oe=>oe.name===e))}catch{}try{const L=await Rr(o,j);L.available&&Array.isArray(L.cells)&&(V=L.cells.find(z=>z.tmuxSession===e))}catch{}if(!E)return;k(Ph({session:e,cell:V||(s?{cell:s}:null)}));let $="";V?$=`${V.engine}${V.key?`·${V.key}`:""}`:I&&($=I.attached?`attached · ${Ov(I.activity)}`:I.activity?Ov(I.activity):""),P($)}U();const re=setInterval(U,4e3);return()=>{E=!1,clearInterval(re)}},[e,t,o]),c.jsxs("div",{className:"nc-app",children:[c.jsxs("header",{className:"nc-bar nc-bar-single",children:[c.jsxs("button",{onClick:u,title:g("sessions"),children:[c.jsx(et,{name:"chevronLeft",size:18}),c.jsx("span",{className:"nc-bar-label",children:g("sessions")})]}),c.jsxs("span",{className:"nc-bar-center",children:[c.jsx("b",{title:t?`${x} · ${t}`:x,children:x}),C&&c.jsx("small",{className:"nc-bar-sub",children:C})]}),c.jsxs("span",{className:"nc-bar-right",children:[c.jsx("button",{onClick:()=>A(-1),title:g("zoom-out"),children:c.jsx(et,{name:"zoomOut",size:18})}),c.jsx("button",{onClick:()=>A(1),title:g("zoom-in"),children:c.jsx(et,{name:"zoomIn",size:18})}),c.jsx("button",{onClick:()=>_(E=>!E),title:g("composer"),children:c.jsx(et,{name:"keyboard",size:20})}),c.jsx("button",{onClick:()=>p(E=>!E),title:g("files"),children:c.jsx(et,{name:"folder",size:20})})]})]}),c.jsx("div",{className:"nc-termwrap",children:c.jsx(ay,{session:e,node:t,token:o,readonly:a,takeSize:!0,sendRef:M,composerRef:ee,actionRef:q,ctrlRef:B,setCtrlArmed:H,onFiles:S,fontSize:w,selectionMode:te,onSelectionModeChange:K})}),c.jsx(zC,{onKeyboard:()=>_(E=>!E),send:E=>M.current(E),action:E=>q.current(E),ctrlArmed:Z,onCtrl:T,selectionMode:te,onSelectionMode:K}),f&&c.jsx(vy,{submitText:E=>ee.current(E),token:o,session:e,node:t,ownerId:i}),h&&c.jsx(ly,{session:e,node:t,token:o,filesEvent:b,onClose:()=>p(!1)})]})}function o2(){ji();const[e]=R.useState(n2),[t,i]=R.useState(e.token),[s,o]=R.useState(e.pair||""),a=R.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,h]=R.useState(!1),p=s2(),[f]=R.useState(()=>fk(typeof location<"u"?location.pathname:"/")),[_,b]=R.useState(f.id),S=_===ls(null,Pi),[w,y]=R.useState(null),x=fe=>{const Pe=tr(fe);y(Pe?{...Pe,...typeof(fe==null?void 0:fe.cellName)=="string"&&fe.cellName?{cellName:fe.cellName}:{}}:null)},[k,C]=R.useState([]),[P,A]=R.useState([]),[M,ee]=R.useState([]),[q,B]=R.useState(()=>f.ownerId?as():r2(f.name)),[Z,H]=R.useState(null),[te,K]=R.useState(null),T=fe=>K(tr(fe)),E=ph(t,p),j=R.useMemo(()=>(E||[]).filter(fe=>fe.instanceId).map(fe=>({instanceId:fe.instanceId,route:fe.route,label:fe.label,status:fe.status})),[E]),D=qE(t,_,q,B,j),U=D.decks;R.useEffect(()=>{const fe=new Map;for(const Pe of E||[]){const qe=(Pe.route||[Pe.name]).join("/"),xt=new Set((Pe.sessions||[]).map(oi=>oi.name));for(const oi of Pe.cells||[])!oi.cell||!oi.tmuxSession||oi.cell===oi.tmuxSession||xt.has(oi.cell)||fe.set(`${qe}:${oi.cell}`,`${qe}:${oi.tmuxSession}`)}B(Pe=>Z0(Pe,fe))},[E]),R.useEffect(()=>{D.localNodeId&&B(fe=>{const Pe=Jd(fe,D.localNodeId,j);return JSON.stringify(Pe)===JSON.stringify(fe)?fe:Pe})},[j,D.localNodeId]);const[re,I]=R.useState(null),[V,$]=R.useState(null),L=R.useRef(0),[z,oe]=R.useState(!1),[ce,he]=R.useState(t2),[me,G]=R.useState(!S),[J,ge]=R.useState(()=>S?localStorage.getItem(Iv)==="1":!0),[Me,Ze]=R.useState(!1),[Be,Fe]=R.useState("nodes"),[ct,Ve]=R.useState(!1),[gt,ut]=R.useState(""),lt=(fe="nodes",Pe=!1,qe="")=>{Fe(fe),Ve(Pe),ut(qe),Ze(!0)},[nt,dt]=R.useState(!1),[rt,ot]=R.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[ae,xe]=R.useState(!1);R.useEffect(()=>{try{localStorage.setItem(Ky,String(ce))}catch{}},[ce]),R.useEffect(()=>{try{localStorage.setItem(Iv,J?"1":"")}catch{}},[J]),R.useEffect(()=>{if(!t)return;let fe=!1;return Promise.all([Yv(t),Vt("/api/config",t).then(Pe=>Pe.json())]).then(([Pe,qe])=>{fe||(ot({deviceDefault:Pe.deviceName||"",localNodeId:Pe.nodeId||"",localNameDefault:Pe.localName||""}),xe(!!qe.readonlyDefault),(Pe.firstRun===!0&&!qe.readonlyDefault||s)&&dt(!0))}).catch(()=>{}),()=>{fe=!0}},[t,s]);const de=R.useCallback(async()=>{try{const Pe=await(await Vt("/api/sessions",t)).json();Pe.error||C(Pe.sessions||[])}catch{}try{const fe=await Rr(t);A(fe.available?fe.cells||[]:[]),ee(fe.available?fe.capabilities||[]:[])}catch{A([]),ee([])}},[t]);R.useEffect(()=>{if(!p)return;de();const fe=setInterval(de,4e3);return()=>clearInterval(fe)},[p,de]),R.useEffect(()=>{let fe=!1;return Vt("/api/config",t).then(Pe=>Pe.json()).then(Pe=>{fe||XE(Pe.version,Pe.uiVersion,"0.8.28")}).catch(()=>{}),()=>{fe=!0}},[t]);const Ne=new Set([...k.map(fe=>fe.name),...E.flatMap(fe=>fe.sessions.map(Pe=>Pe.key))]),Ee=ln(q),X=fe=>B(Pe=>{const qe=yy(fe,D.localNodeId,j)||fe,xt=f_(Pe,qe);return xt===Pe&&ln(Pe).length>=9&&D.setError(g("grid-full")),xt}),ie=async(fe,Pe=[])=>{try{await ch(t,fe,Pe)}catch{return}const qe=Pe.length?`${Pe.join("/")}:${fe}`:fe;B(xt=>dl(xt,qe)),de()},F=async(fe,Pe,qe=[])=>{try{await Vv(t,fe,Pe,qe)}catch{return}de()},W=async(fe,Pe,qe=[])=>{await Uv(t,{cell:fe,enabled:!!Pe},qe),de()},ue=async fe=>{if(!re)return;const{cell:Pe}=re,qe=Array.isArray(re.route)?re.route:[];fe.action==="up"?await ah(t,{cell:Pe,boot:!!fe.boot,...fe.engine?{engine:fe.engine}:{},...fe.model!==void 0?{model:fe.model}:{},...fe.permissionPolicy?{permissionPolicy:fe.permissionPolicy}:{}},qe):await sl(t,{cell:Pe,boot:!!fe.boot},qe);const xt=fe.action==="up"?!!fe.boot:fe.boot?!1:!!re.boot;$({id:++L.current,cell:Pe,route:qe,enabled:xt}),de()},ve=R.useCallback(fe=>{$(Pe=>(Pe==null?void 0:Pe.id)===fe?null:Pe)},[]),Ce=async fe=>{if(!(!(fe!=null&&fe.direct)||z)){oe(!0);try{await hh(t,fe.name,fe.tunnelStatus==="up"?"down":"up")}finally{oe(!1)}}},_e=async(fe,Pe)=>{const qe=String(Pe||"").trim();return!(fe!=null&&fe.direct)||!ds(qe)?!1:(await Qv(t,fe.name,qe),!0)},Re=fe=>{const Pe=U.find(qe=>qe.id===fe);if(!Pe)return!1;try{const qe=window.open(Lu(Pe,t),"_blank");return qe&&(qe.opener=null),!!qe}catch{return!1}},Qe=async fe=>{if(!fe||fe===_)return;const Pe=await D.select(fe),qe=D.records.find(xt=>xt.id===fe);b(fe),B(Pe),H(null),K(null);try{history.replaceState(null,"",Lu(qe||fe,null))}catch{}},zt=async(fe,Pe)=>{const qe=await D.add(fe,Pe);await Qe(qe.id)},ze=async(fe,Pe)=>{const qe=await D.rename(fe,Pe);if(fe===_){b(qe.id),B(Jd(qe.layout,D.localNodeId,j)),H(null),K(null);try{history.replaceState(null,"",Lu(qe,null))}catch{}}},Di=async fe=>{await D.remove(fe),fe===_&&await Qe(D.localMainId)},Nt=async(fe,Pe)=>{!Pe||Pe===_||(await D.addTileTo(Pe,fe),B(qe=>dl(qe,fe)))};if(!t)return c.jsxs("div",{className:"nc-auth",children:[c.jsx("p",{children:g("auth-prompt")}),c.jsx("input",{onChange:fe=>i(fe.target.value.trim()),placeholder:"token"}),c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:u,onChange:fe=>h(fe.target.checked)})," ",g("remember-device")]}),c.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const Ke=c.jsxs(c.Fragment,{children:[Me&&c.jsx(BE,{token:t,initialTab:Be,initialLocation:gt,startNewCell:ct,onClose:()=>{Ze(!1),Ve(!1),ut("")}}),nt&&c.jsx(OE,{token:t,initialPair:s,...rt,onPairDone:a,onDone:()=>dt(!1)}),c.jsx(UE,{token:t})]});if(!p)return w?c.jsxs(c.Fragment,{children:[c.jsx(zv,{session:w.session,node:w.node,ownerId:w.ownerId,cellName:w.cellName,token:t,readonly:ae,onBack:()=>y(null)}),Ke]}):c.jsxs(c.Fragment,{children:[c.jsx(pb,{onPick:x,token:t,onSettings:lt}),Ke]});const ei=S||!me;return c.jsxs("div",{className:"nc-workspace",children:[ei&&c.jsx(ik,{sessions:k,cells:P,activeSessions:Ee,nodeGroups:E,fleetCapabilities:M,bootSettlement:V,onBootSettlementApplied:ve,localNodeId:D.localNodeId,onPick:T,onAddTile:X,onPower:I,onBoot:W,onBootError:fe=>D.setError(String((fe==null?void 0:fe.message)||fe)),onNodePower:Ce,onNodeRename:_e,onKill:ie,onVisibility:F,onNew:()=>lt("fleet",!0),onSettings:lt,width:ce,collapsed:J,onResize:he,onToggleCollapse:()=>ge(fe=>!fe)}),c.jsxs("div",{className:"nc-workspace-main",children:[c.jsx(Sk,{decks:U,currentDeck:_,onCreate:zt,onRename:ze,onDelete:Di,onReorder:D.reorder,onOpenWindow:Re,onNavigate:Qe,saveState:D.saveState,error:D.error,sidebarVisible:ei,onToggleSidebar:S?null:()=>G(fe=>!fe)}),c.jsx(lk,{layout:q,onLayoutChange:B,token:t,readonly:ae,sessionsAlive:Ne,focusSession:Z,onFocus:H,onOpenSingle:T,decks:U,currentDeck:_,onSendToDeck:Nt,cells:P,nodeGroups:E})]}),te&&c.jsx("div",{className:"nc-single-overlay",children:c.jsx(zv,{session:te.session,node:te.node,ownerId:te.ownerId,cellName:Ph({session:te.session,node:te.node,ownerId:te.ownerId,cells:P,nodeGroups:E}),token:t,readonly:ae,onBack:()=>K(null)})}),re&&c.jsx(ol,{cell:re,token:t,route:Array.isArray(re.route)?re.route:[],onConfirm:ue,onClose:()=>I(null)}),Ke]})}function a2(){ji();const e=R.useSyncExternalStore(YE,Av,Av);if(!e.needed)return null;const t=e.kind==="install"?g("install-version-mismatch").replace("{v}",e.version):g("update-available").replace("{v}",e.version).replace(" "," ").trim();return c.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&c.jsx("button",{className:"nc-update-btn",onClick:JE,children:g("reload")})]})}QE();GS.createRoot(document.getElementById("root")).render(c.jsxs(WS.StrictMode,{children:[c.jsx(o2,{}),c.jsx(a2,{})]}));
|