@mmmbuto/nexuscrew 0.9.4 → 0.9.5
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 +83 -0
- package/frontend/dist/assets/index-BUbgwJsU.js +93 -0
- package/frontend/dist/assets/index-BzmGsXBy.css +32 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/cli/pidfile.js +389 -16
- package/lib/cli/runtime-lifecycle.js +11 -0
- package/lib/nodes/commands.js +8 -2
- package/lib/nodes/health.js +1 -0
- package/lib/nodes/peer-transitions.js +10 -4
- package/lib/nodes/tunnel-supervisor.js +274 -30
- package/lib/nodes/tunnel.js +112 -0
- package/lib/proxy/panel-auth.js +45 -5
- package/lib/settings/pairing-coordinator.js +28 -1
- package/lib/update/runner.js +10 -3
- package/package.json +1 -1
- package/frontend/dist/assets/index-CbMytNmg.css +0 -32
- package/frontend/dist/assets/index-DFI1J-u5.js +0 -93
|
@@ -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 n(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=n(o);fetch(o.href,a)}})();function nf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vu={exports:{}},Ao={},Yu={exports:{}},mt={};/**
|
|
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 kg;function N0(){if(kg)return mt;kg=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),w=Symbol.iterator;function y(M){return M===null||typeof M!="object"?null:(M=w&&M[w]||M["@@iterator"],typeof M=="function"?M:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,E={};function b(M,O,H){this.props=M,this.context=O,this.refs=E,this.updater=H||S}b.prototype.isReactComponent={},b.prototype.setState=function(M,O){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,O,"setState")},b.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function j(){}j.prototype=b.prototype;function N(M,O,H){this.props=M,this.context=O,this.refs=E,this.updater=H||S}var z=N.prototype=new j;z.constructor=N,k(z,b.prototype),z.isPureReactComponent=!0;var D=Array.isArray,U=Object.prototype.hasOwnProperty,W={current:null},K={key:!0,ref:!0,__self:!0,__source:!0};function te(M,O,H){var se,ee={},le=null,ve=null;if(O!=null)for(se in O.ref!==void 0&&(ve=O.ref),O.key!==void 0&&(le=""+O.key),O)U.call(O,se)&&!K.hasOwnProperty(se)&&(ee[se]=O[se]);var de=arguments.length-2;if(de===1)ee.children=H;else if(1<de){for(var fe=Array(de),He=0;He<de;He++)fe[He]=arguments[He+2];ee.children=fe}if(M&&M.defaultProps)for(se in de=M.defaultProps,de)ee[se]===void 0&&(ee[se]=de[se]);return{$$typeof:e,type:M,key:le,ref:ve,props:ee,_owner:W.current}}function G(M,O){return{$$typeof:e,type:M.type,key:O,ref:M.ref,props:M.props,_owner:M._owner}}function Q(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function q(M){var O={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(H){return O[H]})}var F=/\/+/g;function R(M,O){return typeof M=="object"&&M!==null&&M.key!=null?q(""+M.key):O.toString(36)}function B(M,O,H,se,ee){var le=typeof M;(le==="undefined"||le==="boolean")&&(M=null);var ve=!1;if(M===null)ve=!0;else switch(le){case"string":case"number":ve=!0;break;case"object":switch(M.$$typeof){case e:case t:ve=!0}}if(ve)return ve=M,ee=ee(ve),M=se===""?"."+R(ve,0):se,D(ee)?(H="",M!=null&&(H=M.replace(F,"$&/")+"/"),B(ee,O,H,"",function(He){return He})):ee!=null&&(Q(ee)&&(ee=G(ee,H+(!ee.key||ve&&ve.key===ee.key?"":(""+ee.key).replace(F,"$&/")+"/")+M)),O.push(ee)),1;if(ve=0,se=se===""?".":se+":",D(M))for(var de=0;de<M.length;de++){le=M[de];var fe=se+R(le,de);ve+=B(le,O,H,fe,ee)}else if(fe=y(M),typeof fe=="function")for(M=fe.call(M),de=0;!(le=M.next()).done;)le=le.value,fe=se+R(le,de++),ve+=B(le,O,H,fe,ee);else if(le==="object")throw O=String(M),Error("Objects are not valid as a React child (found: "+(O==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":O)+"). If you meant to render a collection of children, use an array instead.");return ve}function $(M,O,H){if(M==null)return M;var se=[],ee=0;return B(M,se,"","",function(le){return O.call(H,le,ee++)}),se}function L(M){if(M._status===-1){var O=M._result;O=O(),O.then(function(H){(M._status===0||M._status===-1)&&(M._status=1,M._result=H)},function(H){(M._status===0||M._status===-1)&&(M._status=2,M._result=H)}),M._status===-1&&(M._status=0,M._result=O)}if(M._status===1)return M._result.default;throw M._result}var A={current:null},x={transition:null},I={ReactCurrentDispatcher:A,ReactCurrentBatchConfig:x,ReactCurrentOwner:W};function T(){throw Error("act(...) is not supported in production builds of React.")}return mt.Children={map:$,forEach:function(M,O,H){$(M,function(){O.apply(this,arguments)},H)},count:function(M){var O=0;return $(M,function(){O++}),O},toArray:function(M){return $(M,function(O){return O})||[]},only:function(M){if(!Q(M))throw Error("React.Children.only expected to receive a single React element child.");return M}},mt.Component=b,mt.Fragment=n,mt.Profiler=o,mt.PureComponent=N,mt.StrictMode=s,mt.Suspense=p,mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=I,mt.act=T,mt.cloneElement=function(M,O,H){if(M==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+M+".");var se=k({},M.props),ee=M.key,le=M.ref,ve=M._owner;if(O!=null){if(O.ref!==void 0&&(le=O.ref,ve=W.current),O.key!==void 0&&(ee=""+O.key),M.type&&M.type.defaultProps)var de=M.type.defaultProps;for(fe in O)U.call(O,fe)&&!K.hasOwnProperty(fe)&&(se[fe]=O[fe]===void 0&&de!==void 0?de[fe]:O[fe])}var fe=arguments.length-2;if(fe===1)se.children=H;else if(1<fe){de=Array(fe);for(var He=0;He<fe;He++)de[He]=arguments[He+2];se.children=de}return{$$typeof:e,type:M.type,key:ee,ref:le,props:se,_owner:ve}},mt.createContext=function(M){return M={$$typeof:u,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},M.Provider={$$typeof:a,_context:M},M.Consumer=M},mt.createElement=te,mt.createFactory=function(M){var O=te.bind(null,M);return O.type=M,O},mt.createRef=function(){return{current:null}},mt.forwardRef=function(M){return{$$typeof:h,render:M}},mt.isValidElement=Q,mt.lazy=function(M){return{$$typeof:v,_payload:{_status:-1,_result:M},_init:L}},mt.memo=function(M,O){return{$$typeof:m,type:M,compare:O===void 0?null:O}},mt.startTransition=function(M){var O=x.transition;x.transition={};try{M()}finally{x.transition=O}},mt.unstable_act=T,mt.useCallback=function(M,O){return A.current.useCallback(M,O)},mt.useContext=function(M){return A.current.useContext(M)},mt.useDebugValue=function(){},mt.useDeferredValue=function(M){return A.current.useDeferredValue(M)},mt.useEffect=function(M,O){return A.current.useEffect(M,O)},mt.useId=function(){return A.current.useId()},mt.useImperativeHandle=function(M,O,H){return A.current.useImperativeHandle(M,O,H)},mt.useInsertionEffect=function(M,O){return A.current.useInsertionEffect(M,O)},mt.useLayoutEffect=function(M,O){return A.current.useLayoutEffect(M,O)},mt.useMemo=function(M,O){return A.current.useMemo(M,O)},mt.useReducer=function(M,O,H){return A.current.useReducer(M,O,H)},mt.useRef=function(M){return A.current.useRef(M)},mt.useState=function(M){return A.current.useState(M)},mt.useSyncExternalStore=function(M,O,H){return A.current.useSyncExternalStore(M,O,H)},mt.useTransition=function(){return A.current.useTransition()},mt.version="18.3.1",mt}var Cg;function sf(){return Cg||(Cg=1,Yu.exports=N0()),Yu.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 Eg;function j0(){if(Eg)return Ao;Eg=1;var e=sf(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function u(h,p,m){var v,w={},y=null,S=null;m!==void 0&&(y=""+m),p.key!==void 0&&(y=""+p.key),p.ref!==void 0&&(S=p.ref);for(v in p)s.call(p,v)&&!a.hasOwnProperty(v)&&(w[v]=p[v]);if(h&&h.defaultProps)for(v in p=h.defaultProps,p)w[v]===void 0&&(w[v]=p[v]);return{$$typeof:t,type:h,key:y,ref:S,props:w,_owner:o.current}}return Ao.Fragment=n,Ao.jsx=u,Ao.jsxs=u,Ao}var Ng;function R0(){return Ng||(Ng=1,Vu.exports=j0()),Vu.exports}var l=R0(),C=sf();const P0=nf(C);var pl={},Gu={exports:{}},Gn={},Xu={exports:{}},Qu={};/**
|
|
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 jg;function A0(){return jg||(jg=1,(function(e){function t(x,I){var T=x.length;x.push(I);e:for(;0<T;){var M=T-1>>>1,O=x[M];if(0<o(O,I))x[M]=I,x[T]=O,T=M;else break e}}function n(x){return x.length===0?null:x[0]}function s(x){if(x.length===0)return null;var I=x[0],T=x.pop();if(T!==I){x[0]=T;e:for(var M=0,O=x.length,H=O>>>1;M<H;){var se=2*(M+1)-1,ee=x[se],le=se+1,ve=x[le];if(0>o(ee,T))le<O&&0>o(ve,ee)?(x[M]=ve,x[le]=T,M=le):(x[M]=ee,x[se]=T,M=se);else if(le<O&&0>o(ve,T))x[M]=ve,x[le]=T,M=le;else break e}}return I}function o(x,I){var T=x.sortIndex-I.sortIndex;return T!==0?T:x.id-I.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=[],m=[],v=1,w=null,y=3,S=!1,k=!1,E=!1,b=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function z(x){for(var I=n(m);I!==null;){if(I.callback===null)s(m);else if(I.startTime<=x)s(m),I.sortIndex=I.expirationTime,t(p,I);else break;I=n(m)}}function D(x){if(E=!1,z(x),!k)if(n(p)!==null)k=!0,L(U);else{var I=n(m);I!==null&&A(D,I.startTime-x)}}function U(x,I){k=!1,E&&(E=!1,j(te),te=-1),S=!0;var T=y;try{for(z(I),w=n(p);w!==null&&(!(w.expirationTime>I)||x&&!q());){var M=w.callback;if(typeof M=="function"){w.callback=null,y=w.priorityLevel;var O=M(w.expirationTime<=I);I=e.unstable_now(),typeof O=="function"?w.callback=O:w===n(p)&&s(p),z(I)}else s(p);w=n(p)}if(w!==null)var H=!0;else{var se=n(m);se!==null&&A(D,se.startTime-I),H=!1}return H}finally{w=null,y=T,S=!1}}var W=!1,K=null,te=-1,G=5,Q=-1;function q(){return!(e.unstable_now()-Q<G)}function F(){if(K!==null){var x=e.unstable_now();Q=x;var I=!0;try{I=K(!0,x)}finally{I?R():(W=!1,K=null)}}else W=!1}var R;if(typeof N=="function")R=function(){N(F)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,$=B.port2;B.port1.onmessage=F,R=function(){$.postMessage(null)}}else R=function(){b(F,0)};function L(x){K=x,W||(W=!0,R())}function A(x,I){te=b(function(){x(e.unstable_now())},I)}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(x){x.callback=null},e.unstable_continueExecution=function(){k||S||(k=!0,L(U))},e.unstable_forceFrameRate=function(x){0>x||125<x?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<x?Math.floor(1e3/x):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(p)},e.unstable_next=function(x){switch(y){case 1:case 2:case 3:var I=3;break;default:I=y}var T=y;y=I;try{return x()}finally{y=T}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(x,I){switch(x){case 1:case 2:case 3:case 4:case 5:break;default:x=3}var T=y;y=x;try{return I()}finally{y=T}},e.unstable_scheduleCallback=function(x,I,T){var M=e.unstable_now();switch(typeof T=="object"&&T!==null?(T=T.delay,T=typeof T=="number"&&0<T?M+T:M):T=M,x){case 1:var O=-1;break;case 2:O=250;break;case 5:O=1073741823;break;case 4:O=1e4;break;default:O=5e3}return O=T+O,x={id:v++,callback:I,priorityLevel:x,startTime:T,expirationTime:O,sortIndex:-1},T>M?(x.sortIndex=T,t(m,x),n(p)===null&&x===n(m)&&(E?(j(te),te=-1):E=!0,A(D,T-M))):(x.sortIndex=O,t(p,x),k||S||(k=!0,L(U))),x},e.unstable_shouldYield=q,e.unstable_wrapCallback=function(x){var I=y;return function(){var T=y;y=I;try{return x.apply(this,arguments)}finally{y=T}}}})(Qu)),Qu}var Rg;function L0(){return Rg||(Rg=1,Xu.exports=A0()),Xu.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 Pg;function T0(){if(Pg)return Gn;Pg=1;var e=sf(),t=L0();function n(i){for(var r="https://reactjs.org/docs/error-decoder.html?invariant="+i,c=1;c<arguments.length;c++)r+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+i+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,o={};function a(i,r){u(i,r),u(i+"Capture",r)}function u(i,r){for(o[i]=r,i=0;i<r.length;i++)s.add(r[i])}var h=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,m=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},w={};function y(i){return p.call(w,i)?!0:p.call(v,i)?!1:m.test(i)?w[i]=!0:(v[i]=!0,!1)}function S(i,r,c,d){if(c!==null&&c.type===0)return!1;switch(typeof r){case"function":case"symbol":return!0;case"boolean":return d?!1:c!==null?!c.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function k(i,r,c,d){if(r===null||typeof r>"u"||S(i,r,c,d))return!0;if(d)return!1;if(c!==null)switch(c.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 E(i,r,c,d,g,_,P){this.acceptsBooleans=r===2||r===3||r===4,this.attributeName=d,this.attributeNamespace=g,this.mustUseProperty=c,this.propertyName=i,this.type=r,this.sanitizeURL=_,this.removeEmptyString=P}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){b[i]=new E(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var r=i[0];b[r]=new E(r,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){b[i]=new E(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){b[i]=new E(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){b[i]=new E(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){b[i]=new E(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){b[i]=new E(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){b[i]=new E(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){b[i]=new E(i,5,!1,i.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function N(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var r=i.replace(j,N);b[r]=new E(r,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var r=i.replace(j,N);b[r]=new E(r,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var r=i.replace(j,N);b[r]=new E(r,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){b[i]=new E(i,1,!1,i.toLowerCase(),null,!1,!1)}),b.xlinkHref=new E("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){b[i]=new E(i,1,!1,i.toLowerCase(),null,!0,!0)});function z(i,r,c,d){var g=b.hasOwnProperty(r)?b[r]:null;(g!==null?g.type!==0:d||!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(k(r,c,g,d)&&(c=null),d||g===null?y(r)&&(c===null?i.removeAttribute(r):i.setAttribute(r,""+c)):g.mustUseProperty?i[g.propertyName]=c===null?g.type===3?!1:"":c:(r=g.attributeName,d=g.attributeNamespace,c===null?i.removeAttribute(r):(g=g.type,c=g===3||g===4&&c===!0?"":""+c,d?i.setAttributeNS(d,r,c):i.setAttribute(r,c))))}var D=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,U=Symbol.for("react.element"),W=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),te=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),Q=Symbol.for("react.provider"),q=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),A=Symbol.for("react.offscreen"),x=Symbol.iterator;function I(i){return i===null||typeof i!="object"?null:(i=x&&i[x]||i["@@iterator"],typeof i=="function"?i:null)}var T=Object.assign,M;function O(i){if(M===void 0)try{throw Error()}catch(c){var r=c.stack.trim().match(/\n( *(at )?)/);M=r&&r[1]||""}return`
|
|
34
|
+
`+M+i}var H=!1;function se(i,r){if(!i||H)return"";H=!0;var c=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(ue){var d=ue}Reflect.construct(i,[],r)}else{try{r.call()}catch(ue){d=ue}i.call(r.prototype)}else{try{throw Error()}catch(ue){d=ue}i()}}catch(ue){if(ue&&d&&typeof ue.stack=="string"){for(var g=ue.stack.split(`
|
|
35
|
+
`),_=d.stack.split(`
|
|
36
|
+
`),P=g.length-1,V=_.length-1;1<=P&&0<=V&&g[P]!==_[V];)V--;for(;1<=P&&0<=V;P--,V--)if(g[P]!==_[V]){if(P!==1||V!==1)do if(P--,V--,0>V||g[P]!==_[V]){var X=`
|
|
37
|
+
`+g[P].replace(" at new "," at ");return i.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",i.displayName)),X}while(1<=P&&0<=V);break}}}finally{H=!1,Error.prepareStackTrace=c}return(i=i?i.displayName||i.name:"")?O(i):""}function ee(i){switch(i.tag){case 5:return O(i.type);case 16:return O("Lazy");case 13:return O("Suspense");case 19:return O("SuspenseList");case 0:case 2:case 15:return i=se(i.type,!1),i;case 11:return i=se(i.type.render,!1),i;case 1:return i=se(i.type,!0),i;default:return""}}function le(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case K:return"Fragment";case W:return"Portal";case G:return"Profiler";case te:return"StrictMode";case R:return"Suspense";case B:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case q:return(i.displayName||"Context")+".Consumer";case Q:return(i._context.displayName||"Context")+".Provider";case F:var r=i.render;return i=i.displayName,i||(i=r.displayName||r.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case $:return r=i.displayName||null,r!==null?r:le(i.type)||"Memo";case L:r=i._payload,i=i._init;try{return le(i(r))}catch{}}return null}function ve(i){var r=i.type;switch(i.tag){case 24:return"Cache";case 9:return(r.displayName||"Context")+".Consumer";case 10:return(r._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=r.render,i=i.displayName||i.name||"",r.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return r;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return le(r);case 8:return r===te?"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 de(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function fe(i){var r=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function He(i){var r=fe(i)?"checked":"value",c=Object.getOwnPropertyDescriptor(i.constructor.prototype,r),d=""+i[r];if(!i.hasOwnProperty(r)&&typeof c<"u"&&typeof c.get=="function"&&typeof c.set=="function"){var g=c.get,_=c.set;return Object.defineProperty(i,r,{configurable:!0,get:function(){return g.call(this)},set:function(P){d=""+P,_.call(this,P)}}),Object.defineProperty(i,r,{enumerable:c.enumerable}),{getValue:function(){return d},setValue:function(P){d=""+P},stopTracking:function(){i._valueTracker=null,delete i[r]}}}}function st(i){i._valueTracker||(i._valueTracker=He(i))}function lt(i){if(!i)return!1;var r=i._valueTracker;if(!r)return!0;var c=r.getValue(),d="";return i&&(d=fe(i)?i.checked?"true":"false":i.value),i=d,i!==c?(r.setValue(i),!0):!1}function Ee(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function xt(i,r){var c=r.checked;return T({},r,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:c??i._wrapperState.initialChecked})}function qt(i,r){var c=r.defaultValue==null?"":r.defaultValue,d=r.checked!=null?r.checked:r.defaultChecked;c=de(r.value!=null?r.value:c),i._wrapperState={initialChecked:d,initialValue:c,controlled:r.type==="checkbox"||r.type==="radio"?r.checked!=null:r.value!=null}}function ze(i,r){r=r.checked,r!=null&&z(i,"checked",r,!1)}function Rt(i,r){ze(i,r);var c=de(r.value),d=r.type;if(c!=null)d==="number"?(c===0&&i.value===""||i.value!=c)&&(i.value=""+c):i.value!==""+c&&(i.value=""+c);else if(d==="submit"||d==="reset"){i.removeAttribute("value");return}r.hasOwnProperty("value")?Mt(i,r.type,c):r.hasOwnProperty("defaultValue")&&Mt(i,r.type,de(r.defaultValue)),r.checked==null&&r.defaultChecked!=null&&(i.defaultChecked=!!r.defaultChecked)}function gt(i,r,c){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=""+i._wrapperState.initialValue,c||r===i.value||(i.value=r),i.defaultValue=r}c=i.name,c!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,c!==""&&(i.name=c)}function Mt(i,r,c){(r!=="number"||Ee(i.ownerDocument)!==i)&&(c==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+c&&(i.defaultValue=""+c))}var ht=Array.isArray;function bt(i,r,c,d){if(i=i.options,r){r={};for(var g=0;g<c.length;g++)r["$"+c[g]]=!0;for(c=0;c<i.length;c++)g=r.hasOwnProperty("$"+i[c].value),i[c].selected!==g&&(i[c].selected=g),g&&d&&(i[c].defaultSelected=!0)}else{for(c=""+de(c),r=null,g=0;g<i.length;g++){if(i[g].value===c){i[g].selected=!0,d&&(i[g].defaultSelected=!0);return}r!==null||i[g].disabled||(r=i[g])}r!==null&&(r.selected=!0)}}function Bt(i,r){if(r.dangerouslySetInnerHTML!=null)throw Error(n(91));return T({},r,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function kt(i,r){var c=r.value;if(c==null){if(c=r.children,r=r.defaultValue,c!=null){if(r!=null)throw Error(n(92));if(ht(c)){if(1<c.length)throw Error(n(93));c=c[0]}r=c}r==null&&(r=""),c=r}i._wrapperState={initialValue:de(c)}}function Dt(i,r){var c=de(r.value),d=de(r.defaultValue);c!=null&&(c=""+c,c!==i.value&&(i.value=c),r.defaultValue==null&&i.defaultValue!==c&&(i.defaultValue=c)),d!=null&&(i.defaultValue=""+d)}function Lt(i){var r=i.textContent;r===i._wrapperState.initialValue&&r!==""&&r!==null&&(i.value=r)}function Ct(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ye(i,r){return i==null||i==="http://www.w3.org/1999/xhtml"?Ct(r):i==="http://www.w3.org/2000/svg"&&r==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var ce,Le=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(r,c,d,g){MSApp.execUnsafeLocalFunction(function(){return i(r,c,d,g)})}:i})(function(i,r){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=r;else{for(ce=ce||document.createElement("div"),ce.innerHTML="<svg>"+r.valueOf().toString()+"</svg>",r=ce.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;r.firstChild;)i.appendChild(r.firstChild)}});function qe(i,r){if(r){var c=i.firstChild;if(c&&c===i.lastChild&&c.nodeType===3){c.nodeValue=r;return}}i.textContent=r}var ie={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},_e=["Webkit","ms","Moz","O"];Object.keys(ie).forEach(function(i){_e.forEach(function(r){r=r+i.charAt(0).toUpperCase()+i.substring(1),ie[r]=ie[i]})});function Ce(i,r,c){return r==null||typeof r=="boolean"||r===""?"":c||typeof r!="number"||r===0||ie.hasOwnProperty(i)&&ie[i]?(""+r).trim():r+"px"}function Ue(i,r){i=i.style;for(var c in r)if(r.hasOwnProperty(c)){var d=c.indexOf("--")===0,g=Ce(c,r[c],d);c==="float"&&(c="cssFloat"),d?i.setProperty(c,g):i[c]=g}}var Ve=T({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 ft(i,r){if(r){if(Ve[i]&&(r.children!=null||r.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(r.dangerouslySetInnerHTML!=null){if(r.children!=null)throw Error(n(60));if(typeof r.dangerouslySetInnerHTML!="object"||!("__html"in r.dangerouslySetInnerHTML))throw Error(n(61))}if(r.style!=null&&typeof r.style!="object")throw Error(n(62))}}function Et(i,r){if(i.indexOf("-")===-1)return typeof r.is=="string";switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var St=null;function Nt(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Z=null,we=null,Oe=null;function je(i){if(i=go(i)){if(typeof Z!="function")throw Error(n(280));var r=i.stateNode;r&&(r=Ra(r),Z(i.stateNode,i.type,r))}}function tt(i){we?Oe?Oe.push(i):Oe=[i]:we=i}function Ye(){if(we){var i=we,r=Oe;if(Oe=we=null,je(i),r)for(i=0;i<r.length;i++)je(r[i])}}function pt(i,r){return i(r)}function yt(){}var gn=!1;function Y(i,r,c){if(gn)return i(r,c);gn=!0;try{return pt(i,r,c)}finally{gn=!1,(we!==null||Oe!==null)&&(yt(),Ye())}}function re(i,r){var c=i.stateNode;if(c===null)return null;var d=Ra(c);if(d===null)return null;c=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)||(i=i.type,d=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!d;break e;default:i=!1}if(i)return null;if(c&&typeof c!="function")throw Error(n(231,r,typeof c));return c}var xe=!1;if(h)try{var ge={};Object.defineProperty(ge,"passive",{get:function(){xe=!0}}),window.addEventListener("test",ge,ge),window.removeEventListener("test",ge,ge)}catch{xe=!1}function Ae(i,r,c,d,g,_,P,V,X){var ue=Array.prototype.slice.call(arguments,3);try{r.apply(c,ue)}catch(Se){this.onError(Se)}}var Ge=!1,rt=null,Pe=!1,J=null,pe={onError:function(i){Ge=!0,rt=i}};function Me(i,r,c,d,g,_,P,V,X){Ge=!1,rt=null,Ae.apply(pe,arguments)}function ot(i,r,c,d,g,_,P,V,X){if(Me.apply(this,arguments),Ge){if(Ge){var ue=rt;Ge=!1,rt=null}else throw Error(n(198));Pe||(Pe=!0,J=ue)}}function Xe(i){var r=i,c=i;if(i.alternate)for(;r.return;)r=r.return;else{i=r;do r=i,(r.flags&4098)!==0&&(c=r.return),i=r.return;while(i)}return r.tag===3?c:null}function vt(i){if(i.tag===13){var r=i.memoizedState;if(r===null&&(i=i.alternate,i!==null&&(r=i.memoizedState)),r!==null)return r.dehydrated}return null}function Pt(i){if(Xe(i)!==i)throw Error(n(188))}function nn(i){var r=i.alternate;if(!r){if(r=Xe(i),r===null)throw Error(n(188));return r!==i?null:i}for(var c=i,d=r;;){var g=c.return;if(g===null)break;var _=g.alternate;if(_===null){if(d=g.return,d!==null){c=d;continue}break}if(g.child===_.child){for(_=g.child;_;){if(_===c)return Pt(g),i;if(_===d)return Pt(g),r;_=_.sibling}throw Error(n(188))}if(c.return!==d.return)c=g,d=_;else{for(var P=!1,V=g.child;V;){if(V===c){P=!0,c=g,d=_;break}if(V===d){P=!0,d=g,c=_;break}V=V.sibling}if(!P){for(V=_.child;V;){if(V===c){P=!0,c=_,d=g;break}if(V===d){P=!0,d=_,c=g;break}V=V.sibling}if(!P)throw Error(n(189))}}if(c.alternate!==d)throw Error(n(190))}if(c.tag!==3)throw Error(n(188));return c.stateNode.current===c?i:r}function Dn(i){return i=nn(i),i!==null?In(i):null}function In(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var r=In(i);if(r!==null)return r;i=i.sibling}return null}var zi=t.unstable_scheduleCallback,Gr=t.unstable_cancelCallback,rr=t.unstable_shouldYield,ua=t.unstable_requestPaint,Ut=t.unstable_now,he=t.unstable_getCurrentPriorityLevel,Ke=t.unstable_ImmediatePriority,et=t.unstable_UserBlockingPriority,Ze=t.unstable_NormalPriority,Tt=t.unstable_LowPriority,zt=t.unstable_IdlePriority,an=null,vn=null;function fc(i){if(vn&&typeof vn.onCommitFiberRoot=="function")try{vn.onCommitFiberRoot(an,i,void 0,(i.current.flags&128)===128)}catch{}}var Un=Math.clz32?Math.clz32:Kb,Xr=Math.log,Wb=Math.LN2;function Kb(i){return i>>>=0,i===0?32:31-(Xr(i)/Wb|0)|0}var da=64,ha=4194304;function Qr(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function fa(i,r){var c=i.pendingLanes;if(c===0)return 0;var d=0,g=i.suspendedLanes,_=i.pingedLanes,P=c&268435455;if(P!==0){var V=P&~g;V!==0?d=Qr(V):(_&=P,_!==0&&(d=Qr(_)))}else P=c&~g,P!==0?d=Qr(P):_!==0&&(d=Qr(_));if(d===0)return 0;if(r!==0&&r!==d&&(r&g)===0&&(g=d&-d,_=r&-r,g>=_||g===16&&(_&4194240)!==0))return r;if((d&4)!==0&&(d|=c&16),r=i.entangledLanes,r!==0)for(i=i.entanglements,r&=d;0<r;)c=31-Un(r),g=1<<c,d|=i[c],r&=~g;return d}function qb(i,r){switch(i){case 1:case 2:case 4:return r+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Vb(i,r){for(var c=i.suspendedLanes,d=i.pingedLanes,g=i.expirationTimes,_=i.pendingLanes;0<_;){var P=31-Un(_),V=1<<P,X=g[P];X===-1?((V&c)===0||(V&d)!==0)&&(g[P]=qb(V,r)):X<=r&&(i.expiredLanes|=V),_&=~V}}function pc(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function tp(){var i=da;return da<<=1,(da&4194240)===0&&(da=64),i}function mc(i){for(var r=[],c=0;31>c;c++)r.push(i);return r}function Jr(i,r,c){i.pendingLanes|=r,r!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,r=31-Un(r),i[r]=c}function Yb(i,r){var c=i.pendingLanes&~r;i.pendingLanes=r,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=r,i.mutableReadLanes&=r,i.entangledLanes&=r,r=i.entanglements;var d=i.eventTimes;for(i=i.expirationTimes;0<c;){var g=31-Un(c),_=1<<g;r[g]=0,d[g]=-1,i[g]=-1,c&=~_}}function gc(i,r){var c=i.entangledLanes|=r;for(i=i.entanglements;c;){var d=31-Un(c),g=1<<d;g&r|i[d]&r&&(i[d]|=r),c&=~g}}var jt=0;function np(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var ip,vc,sp,rp,op,_c=!1,pa=[],ts=null,ns=null,is=null,Zr=new Map,eo=new Map,ss=[],Gb="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 ap(i,r){switch(i){case"focusin":case"focusout":ts=null;break;case"dragenter":case"dragleave":ns=null;break;case"mouseover":case"mouseout":is=null;break;case"pointerover":case"pointerout":Zr.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":eo.delete(r.pointerId)}}function to(i,r,c,d,g,_){return i===null||i.nativeEvent!==_?(i={blockedOn:r,domEventName:c,eventSystemFlags:d,nativeEvent:_,targetContainers:[g]},r!==null&&(r=go(r),r!==null&&vc(r)),i):(i.eventSystemFlags|=d,r=i.targetContainers,g!==null&&r.indexOf(g)===-1&&r.push(g),i)}function Xb(i,r,c,d,g){switch(r){case"focusin":return ts=to(ts,i,r,c,d,g),!0;case"dragenter":return ns=to(ns,i,r,c,d,g),!0;case"mouseover":return is=to(is,i,r,c,d,g),!0;case"pointerover":var _=g.pointerId;return Zr.set(_,to(Zr.get(_)||null,i,r,c,d,g)),!0;case"gotpointercapture":return _=g.pointerId,eo.set(_,to(eo.get(_)||null,i,r,c,d,g)),!0}return!1}function lp(i){var r=Ts(i.target);if(r!==null){var c=Xe(r);if(c!==null){if(r=c.tag,r===13){if(r=vt(c),r!==null){i.blockedOn=r,op(i.priority,function(){sp(c)});return}}else if(r===3&&c.stateNode.current.memoizedState.isDehydrated){i.blockedOn=c.tag===3?c.stateNode.containerInfo:null;return}}}i.blockedOn=null}function ma(i){if(i.blockedOn!==null)return!1;for(var r=i.targetContainers;0<r.length;){var c=wc(i.domEventName,i.eventSystemFlags,r[0],i.nativeEvent);if(c===null){c=i.nativeEvent;var d=new c.constructor(c.type,c);St=d,c.target.dispatchEvent(d),St=null}else return r=go(c),r!==null&&vc(r),i.blockedOn=c,!1;r.shift()}return!0}function cp(i,r,c){ma(i)&&c.delete(r)}function Qb(){_c=!1,ts!==null&&ma(ts)&&(ts=null),ns!==null&&ma(ns)&&(ns=null),is!==null&&ma(is)&&(is=null),Zr.forEach(cp),eo.forEach(cp)}function no(i,r){i.blockedOn===r&&(i.blockedOn=null,_c||(_c=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Qb)))}function io(i){function r(g){return no(g,i)}if(0<pa.length){no(pa[0],i);for(var c=1;c<pa.length;c++){var d=pa[c];d.blockedOn===i&&(d.blockedOn=null)}}for(ts!==null&&no(ts,i),ns!==null&&no(ns,i),is!==null&&no(is,i),Zr.forEach(r),eo.forEach(r),c=0;c<ss.length;c++)d=ss[c],d.blockedOn===i&&(d.blockedOn=null);for(;0<ss.length&&(c=ss[0],c.blockedOn===null);)lp(c),c.blockedOn===null&&ss.shift()}var or=D.ReactCurrentBatchConfig,ga=!0;function Jb(i,r,c,d){var g=jt,_=or.transition;or.transition=null;try{jt=1,yc(i,r,c,d)}finally{jt=g,or.transition=_}}function Zb(i,r,c,d){var g=jt,_=or.transition;or.transition=null;try{jt=4,yc(i,r,c,d)}finally{jt=g,or.transition=_}}function yc(i,r,c,d){if(ga){var g=wc(i,r,c,d);if(g===null)Oc(i,r,d,va,c),ap(i,d);else if(Xb(g,i,r,c,d))d.stopPropagation();else if(ap(i,d),r&4&&-1<Gb.indexOf(i)){for(;g!==null;){var _=go(g);if(_!==null&&ip(_),_=wc(i,r,c,d),_===null&&Oc(i,r,d,va,c),_===g)break;g=_}g!==null&&d.stopPropagation()}else Oc(i,r,d,null,c)}}var va=null;function wc(i,r,c,d){if(va=null,i=Nt(d),i=Ts(i),i!==null)if(r=Xe(i),r===null)i=null;else if(c=r.tag,c===13){if(i=vt(r),i!==null)return i;i=null}else if(c===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;i=null}else r!==i&&(i=null);return va=i,null}function up(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(he()){case Ke:return 1;case et:return 4;case Ze:case Tt:return 16;case zt:return 536870912;default:return 16}default:return 16}}var rs=null,bc=null,_a=null;function dp(){if(_a)return _a;var i,r=bc,c=r.length,d,g="value"in rs?rs.value:rs.textContent,_=g.length;for(i=0;i<c&&r[i]===g[i];i++);var P=c-i;for(d=1;d<=P&&r[c-d]===g[_-d];d++);return _a=g.slice(i,1<d?1-d:void 0)}function ya(i){var r=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&r===13&&(i=13)):i=r,i===10&&(i=13),32<=i||i===13?i:0}function wa(){return!0}function hp(){return!1}function Qn(i){function r(c,d,g,_,P){this._reactName=c,this._targetInst=g,this.type=d,this.nativeEvent=_,this.target=P,this.currentTarget=null;for(var V in i)i.hasOwnProperty(V)&&(c=i[V],this[V]=c?c(_):_[V]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?wa:hp,this.isPropagationStopped=hp,this}return T(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var c=this.nativeEvent;c&&(c.preventDefault?c.preventDefault():typeof c.returnValue!="unknown"&&(c.returnValue=!1),this.isDefaultPrevented=wa)},stopPropagation:function(){var c=this.nativeEvent;c&&(c.stopPropagation?c.stopPropagation():typeof c.cancelBubble!="unknown"&&(c.cancelBubble=!0),this.isPropagationStopped=wa)},persist:function(){},isPersistent:wa}),r}var ar={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Sc=Qn(ar),so=T({},ar,{view:0,detail:0}),eS=Qn(so),xc,kc,ro,ba=T({},so,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ec,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ro&&(ro&&i.type==="mousemove"?(xc=i.screenX-ro.screenX,kc=i.screenY-ro.screenY):kc=xc=0,ro=i),xc)},movementY:function(i){return"movementY"in i?i.movementY:kc}}),fp=Qn(ba),tS=T({},ba,{dataTransfer:0}),nS=Qn(tS),iS=T({},so,{relatedTarget:0}),Cc=Qn(iS),sS=T({},ar,{animationName:0,elapsedTime:0,pseudoElement:0}),rS=Qn(sS),oS=T({},ar,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),aS=Qn(oS),lS=T({},ar,{data:0}),pp=Qn(lS),cS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uS={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"},dS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hS(i){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(i):(i=dS[i])?!!r[i]:!1}function Ec(){return hS}var fS=T({},so,{key:function(i){if(i.key){var r=cS[i.key]||i.key;if(r!=="Unidentified")return r}return i.type==="keypress"?(i=ya(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?uS[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ec,charCode:function(i){return i.type==="keypress"?ya(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ya(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),pS=Qn(fS),mS=T({},ba,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),mp=Qn(mS),gS=T({},so,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ec}),vS=Qn(gS),_S=T({},ar,{propertyName:0,elapsedTime:0,pseudoElement:0}),yS=Qn(_S),wS=T({},ba,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),bS=Qn(wS),SS=[9,13,27,32],Nc=h&&"CompositionEvent"in window,oo=null;h&&"documentMode"in document&&(oo=document.documentMode);var xS=h&&"TextEvent"in window&&!oo,gp=h&&(!Nc||oo&&8<oo&&11>=oo),vp=" ",_p=!1;function yp(i,r){switch(i){case"keyup":return SS.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wp(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var lr=!1;function kS(i,r){switch(i){case"compositionend":return wp(r);case"keypress":return r.which!==32?null:(_p=!0,vp);case"textInput":return i=r.data,i===vp&&_p?null:i;default:return null}}function CS(i,r){if(lr)return i==="compositionend"||!Nc&&yp(i,r)?(i=dp(),_a=bc=rs=null,lr=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return gp&&r.locale!=="ko"?null:r.data;default:return null}}var ES={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 bp(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r==="input"?!!ES[i.type]:r==="textarea"}function Sp(i,r,c,d){tt(d),r=Ea(r,"onChange"),0<r.length&&(c=new Sc("onChange","change",null,c,d),i.push({event:c,listeners:r}))}var ao=null,lo=null;function NS(i){$p(i,0)}function Sa(i){var r=fr(i);if(lt(r))return i}function jS(i,r){if(i==="change")return r}var xp=!1;if(h){var jc;if(h){var Rc="oninput"in document;if(!Rc){var kp=document.createElement("div");kp.setAttribute("oninput","return;"),Rc=typeof kp.oninput=="function"}jc=Rc}else jc=!1;xp=jc&&(!document.documentMode||9<document.documentMode)}function Cp(){ao&&(ao.detachEvent("onpropertychange",Ep),lo=ao=null)}function Ep(i){if(i.propertyName==="value"&&Sa(lo)){var r=[];Sp(r,lo,i,Nt(i)),Y(NS,r)}}function RS(i,r,c){i==="focusin"?(Cp(),ao=r,lo=c,ao.attachEvent("onpropertychange",Ep)):i==="focusout"&&Cp()}function PS(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Sa(lo)}function AS(i,r){if(i==="click")return Sa(r)}function LS(i,r){if(i==="input"||i==="change")return Sa(r)}function TS(i,r){return i===r&&(i!==0||1/i===1/r)||i!==i&&r!==r}var gi=typeof Object.is=="function"?Object.is:TS;function co(i,r){if(gi(i,r))return!0;if(typeof i!="object"||i===null||typeof r!="object"||r===null)return!1;var c=Object.keys(i),d=Object.keys(r);if(c.length!==d.length)return!1;for(d=0;d<c.length;d++){var g=c[d];if(!p.call(r,g)||!gi(i[g],r[g]))return!1}return!0}function Np(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function jp(i,r){var c=Np(i);i=0;for(var d;c;){if(c.nodeType===3){if(d=i+c.textContent.length,i<=r&&d>=r)return{node:c,offset:r-i};i=d}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Np(c)}}function Rp(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Rp(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Pp(){for(var i=window,r=Ee();r instanceof i.HTMLIFrameElement;){try{var c=typeof r.contentWindow.location.href=="string"}catch{c=!1}if(c)i=r.contentWindow;else break;r=Ee(i.document)}return r}function Pc(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}function MS(i){var r=Pp(),c=i.focusedElem,d=i.selectionRange;if(r!==c&&c&&c.ownerDocument&&Rp(c.ownerDocument.documentElement,c)){if(d!==null&&Pc(c)){if(r=d.start,i=d.end,i===void 0&&(i=r),"selectionStart"in c)c.selectionStart=r,c.selectionEnd=Math.min(i,c.value.length);else if(i=(r=c.ownerDocument||document)&&r.defaultView||window,i.getSelection){i=i.getSelection();var g=c.textContent.length,_=Math.min(d.start,g);d=d.end===void 0?_:Math.min(d.end,g),!i.extend&&_>d&&(g=d,d=_,_=g),g=jp(c,_);var P=jp(c,d);g&&P&&(i.rangeCount!==1||i.anchorNode!==g.node||i.anchorOffset!==g.offset||i.focusNode!==P.node||i.focusOffset!==P.offset)&&(r=r.createRange(),r.setStart(g.node,g.offset),i.removeAllRanges(),_>d?(i.addRange(r),i.extend(P.node,P.offset)):(r.setEnd(P.node,P.offset),i.addRange(r)))}}for(r=[],i=c;i=i.parentNode;)i.nodeType===1&&r.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof c.focus=="function"&&c.focus(),c=0;c<r.length;c++)i=r[c],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var DS=h&&"documentMode"in document&&11>=document.documentMode,cr=null,Ac=null,uo=null,Lc=!1;function Ap(i,r,c){var d=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Lc||cr==null||cr!==Ee(d)||(d=cr,"selectionStart"in d&&Pc(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}),uo&&co(uo,d)||(uo=d,d=Ea(Ac,"onSelect"),0<d.length&&(r=new Sc("onSelect","select",null,r,c),i.push({event:r,listeners:d}),r.target=cr)))}function xa(i,r){var c={};return c[i.toLowerCase()]=r.toLowerCase(),c["Webkit"+i]="webkit"+r,c["Moz"+i]="moz"+r,c}var ur={animationend:xa("Animation","AnimationEnd"),animationiteration:xa("Animation","AnimationIteration"),animationstart:xa("Animation","AnimationStart"),transitionend:xa("Transition","TransitionEnd")},Tc={},Lp={};h&&(Lp=document.createElement("div").style,"AnimationEvent"in window||(delete ur.animationend.animation,delete ur.animationiteration.animation,delete ur.animationstart.animation),"TransitionEvent"in window||delete ur.transitionend.transition);function ka(i){if(Tc[i])return Tc[i];if(!ur[i])return i;var r=ur[i],c;for(c in r)if(r.hasOwnProperty(c)&&c in Lp)return Tc[i]=r[c];return i}var Tp=ka("animationend"),Mp=ka("animationiteration"),Dp=ka("animationstart"),Ip=ka("transitionend"),Op=new Map,Bp="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 os(i,r){Op.set(i,r),a(r,[i])}for(var Mc=0;Mc<Bp.length;Mc++){var Dc=Bp[Mc],IS=Dc.toLowerCase(),OS=Dc[0].toUpperCase()+Dc.slice(1);os(IS,"on"+OS)}os(Tp,"onAnimationEnd"),os(Mp,"onAnimationIteration"),os(Dp,"onAnimationStart"),os("dblclick","onDoubleClick"),os("focusin","onFocus"),os("focusout","onBlur"),os(Ip,"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 ho="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(" "),BS=new Set("cancel close invalid load scroll toggle".split(" ").concat(ho));function zp(i,r,c){var d=i.type||"unknown-event";i.currentTarget=c,ot(d,r,void 0,i),i.currentTarget=null}function $p(i,r){r=(r&4)!==0;for(var c=0;c<i.length;c++){var d=i[c],g=d.event;d=d.listeners;e:{var _=void 0;if(r)for(var P=d.length-1;0<=P;P--){var V=d[P],X=V.instance,ue=V.currentTarget;if(V=V.listener,X!==_&&g.isPropagationStopped())break e;zp(g,V,ue),_=X}else for(P=0;P<d.length;P++){if(V=d[P],X=V.instance,ue=V.currentTarget,V=V.listener,X!==_&&g.isPropagationStopped())break e;zp(g,V,ue),_=X}}}if(Pe)throw i=J,Pe=!1,J=null,i}function $t(i,r){var c=r[Uc];c===void 0&&(c=r[Uc]=new Set);var d=i+"__bubble";c.has(d)||(Fp(r,i,2,!1),c.add(d))}function Ic(i,r,c){var d=0;r&&(d|=4),Fp(c,i,d,r)}var Ca="_reactListening"+Math.random().toString(36).slice(2);function fo(i){if(!i[Ca]){i[Ca]=!0,s.forEach(function(c){c!=="selectionchange"&&(BS.has(c)||Ic(c,!1,i),Ic(c,!0,i))});var r=i.nodeType===9?i:i.ownerDocument;r===null||r[Ca]||(r[Ca]=!0,Ic("selectionchange",!1,r))}}function Fp(i,r,c,d){switch(up(r)){case 1:var g=Jb;break;case 4:g=Zb;break;default:g=yc}c=g.bind(null,r,c,i),g=void 0,!xe||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(g=!0),d?g!==void 0?i.addEventListener(r,c,{capture:!0,passive:g}):i.addEventListener(r,c,!0):g!==void 0?i.addEventListener(r,c,{passive:g}):i.addEventListener(r,c,!1)}function Oc(i,r,c,d,g){var _=d;if((r&1)===0&&(r&2)===0&&d!==null)e:for(;;){if(d===null)return;var P=d.tag;if(P===3||P===4){var V=d.stateNode.containerInfo;if(V===g||V.nodeType===8&&V.parentNode===g)break;if(P===4)for(P=d.return;P!==null;){var X=P.tag;if((X===3||X===4)&&(X=P.stateNode.containerInfo,X===g||X.nodeType===8&&X.parentNode===g))return;P=P.return}for(;V!==null;){if(P=Ts(V),P===null)return;if(X=P.tag,X===5||X===6){d=_=P;continue e}V=V.parentNode}}d=d.return}Y(function(){var ue=_,Se=Nt(c),ke=[];e:{var be=Op.get(i);if(be!==void 0){var Ie=Sc,$e=i;switch(i){case"keypress":if(ya(c)===0)break e;case"keydown":case"keyup":Ie=pS;break;case"focusin":$e="focus",Ie=Cc;break;case"focusout":$e="blur",Ie=Cc;break;case"beforeblur":case"afterblur":Ie=Cc;break;case"click":if(c.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ie=fp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ie=nS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ie=vS;break;case Tp:case Mp:case Dp:Ie=rS;break;case Ip:Ie=yS;break;case"scroll":Ie=eS;break;case"wheel":Ie=bS;break;case"copy":case"cut":case"paste":Ie=aS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ie=mp}var Fe=(r&4)!==0,sn=!Fe&&i==="scroll",oe=Fe?be!==null?be+"Capture":null:be;Fe=[];for(var ne=ue,ae;ne!==null;){ae=ne;var Ne=ae.stateNode;if(ae.tag===5&&Ne!==null&&(ae=Ne,oe!==null&&(Ne=re(ne,oe),Ne!=null&&Fe.push(po(ne,Ne,ae)))),sn)break;ne=ne.return}0<Fe.length&&(be=new Ie(be,$e,null,c,Se),ke.push({event:be,listeners:Fe}))}}if((r&7)===0){e:{if(be=i==="mouseover"||i==="pointerover",Ie=i==="mouseout"||i==="pointerout",be&&c!==St&&($e=c.relatedTarget||c.fromElement)&&(Ts($e)||$e[$i]))break e;if((Ie||be)&&(be=Se.window===Se?Se:(be=Se.ownerDocument)?be.defaultView||be.parentWindow:window,Ie?($e=c.relatedTarget||c.toElement,Ie=ue,$e=$e?Ts($e):null,$e!==null&&(sn=Xe($e),$e!==sn||$e.tag!==5&&$e.tag!==6)&&($e=null)):(Ie=null,$e=ue),Ie!==$e)){if(Fe=fp,Ne="onMouseLeave",oe="onMouseEnter",ne="mouse",(i==="pointerout"||i==="pointerover")&&(Fe=mp,Ne="onPointerLeave",oe="onPointerEnter",ne="pointer"),sn=Ie==null?be:fr(Ie),ae=$e==null?be:fr($e),be=new Fe(Ne,ne+"leave",Ie,c,Se),be.target=sn,be.relatedTarget=ae,Ne=null,Ts(Se)===ue&&(Fe=new Fe(oe,ne+"enter",$e,c,Se),Fe.target=ae,Fe.relatedTarget=sn,Ne=Fe),sn=Ne,Ie&&$e)t:{for(Fe=Ie,oe=$e,ne=0,ae=Fe;ae;ae=dr(ae))ne++;for(ae=0,Ne=oe;Ne;Ne=dr(Ne))ae++;for(;0<ne-ae;)Fe=dr(Fe),ne--;for(;0<ae-ne;)oe=dr(oe),ae--;for(;ne--;){if(Fe===oe||oe!==null&&Fe===oe.alternate)break t;Fe=dr(Fe),oe=dr(oe)}Fe=null}else Fe=null;Ie!==null&&Hp(ke,be,Ie,Fe,!1),$e!==null&&sn!==null&&Hp(ke,sn,$e,Fe,!0)}}e:{if(be=ue?fr(ue):window,Ie=be.nodeName&&be.nodeName.toLowerCase(),Ie==="select"||Ie==="input"&&be.type==="file")var We=jS;else if(bp(be))if(xp)We=LS;else{We=PS;var Qe=RS}else(Ie=be.nodeName)&&Ie.toLowerCase()==="input"&&(be.type==="checkbox"||be.type==="radio")&&(We=AS);if(We&&(We=We(i,ue))){Sp(ke,We,c,Se);break e}Qe&&Qe(i,be,ue),i==="focusout"&&(Qe=be._wrapperState)&&Qe.controlled&&be.type==="number"&&Mt(be,"number",be.value)}switch(Qe=ue?fr(ue):window,i){case"focusin":(bp(Qe)||Qe.contentEditable==="true")&&(cr=Qe,Ac=ue,uo=null);break;case"focusout":uo=Ac=cr=null;break;case"mousedown":Lc=!0;break;case"contextmenu":case"mouseup":case"dragend":Lc=!1,Ap(ke,c,Se);break;case"selectionchange":if(DS)break;case"keydown":case"keyup":Ap(ke,c,Se)}var Je;if(Nc)e:{switch(i){case"compositionstart":var nt="onCompositionStart";break e;case"compositionend":nt="onCompositionEnd";break e;case"compositionupdate":nt="onCompositionUpdate";break e}nt=void 0}else lr?yp(i,c)&&(nt="onCompositionEnd"):i==="keydown"&&c.keyCode===229&&(nt="onCompositionStart");nt&&(gp&&c.locale!=="ko"&&(lr||nt!=="onCompositionStart"?nt==="onCompositionEnd"&&lr&&(Je=dp()):(rs=Se,bc="value"in rs?rs.value:rs.textContent,lr=!0)),Qe=Ea(ue,nt),0<Qe.length&&(nt=new pp(nt,i,null,c,Se),ke.push({event:nt,listeners:Qe}),Je?nt.data=Je:(Je=wp(c),Je!==null&&(nt.data=Je)))),(Je=xS?kS(i,c):CS(i,c))&&(ue=Ea(ue,"onBeforeInput"),0<ue.length&&(Se=new pp("onBeforeInput","beforeinput",null,c,Se),ke.push({event:Se,listeners:ue}),Se.data=Je))}$p(ke,r)})}function po(i,r,c){return{instance:i,listener:r,currentTarget:c}}function Ea(i,r){for(var c=r+"Capture",d=[];i!==null;){var g=i,_=g.stateNode;g.tag===5&&_!==null&&(g=_,_=re(i,c),_!=null&&d.unshift(po(i,_,g)),_=re(i,r),_!=null&&d.push(po(i,_,g))),i=i.return}return d}function dr(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Hp(i,r,c,d,g){for(var _=r._reactName,P=[];c!==null&&c!==d;){var V=c,X=V.alternate,ue=V.stateNode;if(X!==null&&X===d)break;V.tag===5&&ue!==null&&(V=ue,g?(X=re(c,_),X!=null&&P.unshift(po(c,X,V))):g||(X=re(c,_),X!=null&&P.push(po(c,X,V)))),c=c.return}P.length!==0&&i.push({event:r,listeners:P})}var zS=/\r\n?/g,$S=/\u0000|\uFFFD/g;function Up(i){return(typeof i=="string"?i:""+i).replace(zS,`
|
|
38
|
+
`).replace($S,"")}function Na(i,r,c){if(r=Up(r),Up(i)!==r&&c)throw Error(n(425))}function ja(){}var Bc=null,zc=null;function $c(i,r){return i==="textarea"||i==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Fc=typeof setTimeout=="function"?setTimeout:void 0,FS=typeof clearTimeout=="function"?clearTimeout:void 0,Wp=typeof Promise=="function"?Promise:void 0,HS=typeof queueMicrotask=="function"?queueMicrotask:typeof Wp<"u"?function(i){return Wp.resolve(null).then(i).catch(US)}:Fc;function US(i){setTimeout(function(){throw i})}function Hc(i,r){var c=r,d=0;do{var g=c.nextSibling;if(i.removeChild(c),g&&g.nodeType===8)if(c=g.data,c==="/$"){if(d===0){i.removeChild(g),io(r);return}d--}else c!=="$"&&c!=="$?"&&c!=="$!"||d++;c=g}while(c);io(r)}function as(i){for(;i!=null;i=i.nextSibling){var r=i.nodeType;if(r===1||r===3)break;if(r===8){if(r=i.data,r==="$"||r==="$!"||r==="$?")break;if(r==="/$")return null}}return i}function Kp(i){i=i.previousSibling;for(var r=0;i;){if(i.nodeType===8){var c=i.data;if(c==="$"||c==="$!"||c==="$?"){if(r===0)return i;r--}else c==="/$"&&r++}i=i.previousSibling}return null}var hr=Math.random().toString(36).slice(2),xi="__reactFiber$"+hr,mo="__reactProps$"+hr,$i="__reactContainer$"+hr,Uc="__reactEvents$"+hr,WS="__reactListeners$"+hr,KS="__reactHandles$"+hr;function Ts(i){var r=i[xi];if(r)return r;for(var c=i.parentNode;c;){if(r=c[$i]||c[xi]){if(c=r.alternate,r.child!==null||c!==null&&c.child!==null)for(i=Kp(i);i!==null;){if(c=i[xi])return c;i=Kp(i)}return r}i=c,c=i.parentNode}return null}function go(i){return i=i[xi]||i[$i],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function fr(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Ra(i){return i[mo]||null}var Wc=[],pr=-1;function ls(i){return{current:i}}function Ft(i){0>pr||(i.current=Wc[pr],Wc[pr]=null,pr--)}function It(i,r){pr++,Wc[pr]=i.current,i.current=r}var cs={},Pn=ls(cs),Wn=ls(!1),Ms=cs;function mr(i,r){var c=i.type.contextTypes;if(!c)return cs;var d=i.stateNode;if(d&&d.__reactInternalMemoizedUnmaskedChildContext===r)return d.__reactInternalMemoizedMaskedChildContext;var g={},_;for(_ in c)g[_]=r[_];return d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=r,i.__reactInternalMemoizedMaskedChildContext=g),g}function Kn(i){return i=i.childContextTypes,i!=null}function Pa(){Ft(Wn),Ft(Pn)}function qp(i,r,c){if(Pn.current!==cs)throw Error(n(168));It(Pn,r),It(Wn,c)}function Vp(i,r,c){var d=i.stateNode;if(r=r.childContextTypes,typeof d.getChildContext!="function")return c;d=d.getChildContext();for(var g in d)if(!(g in r))throw Error(n(108,ve(i)||"Unknown",g));return T({},c,d)}function Aa(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||cs,Ms=Pn.current,It(Pn,i),It(Wn,Wn.current),!0}function Yp(i,r,c){var d=i.stateNode;if(!d)throw Error(n(169));c?(i=Vp(i,r,Ms),d.__reactInternalMemoizedMergedChildContext=i,Ft(Wn),Ft(Pn),It(Pn,i)):Ft(Wn),It(Wn,c)}var Fi=null,La=!1,Kc=!1;function Gp(i){Fi===null?Fi=[i]:Fi.push(i)}function qS(i){La=!0,Gp(i)}function us(){if(!Kc&&Fi!==null){Kc=!0;var i=0,r=jt;try{var c=Fi;for(jt=1;i<c.length;i++){var d=c[i];do d=d(!0);while(d!==null)}Fi=null,La=!1}catch(g){throw Fi!==null&&(Fi=Fi.slice(i+1)),zi(Ke,us),g}finally{jt=r,Kc=!1}}return null}var gr=[],vr=0,Ta=null,Ma=0,oi=[],ai=0,Ds=null,Hi=1,Ui="";function Is(i,r){gr[vr++]=Ma,gr[vr++]=Ta,Ta=i,Ma=r}function Xp(i,r,c){oi[ai++]=Hi,oi[ai++]=Ui,oi[ai++]=Ds,Ds=i;var d=Hi;i=Ui;var g=32-Un(d)-1;d&=~(1<<g),c+=1;var _=32-Un(r)+g;if(30<_){var P=g-g%5;_=(d&(1<<P)-1).toString(32),d>>=P,g-=P,Hi=1<<32-Un(r)+g|c<<g|d,Ui=_+i}else Hi=1<<_|c<<g|d,Ui=i}function qc(i){i.return!==null&&(Is(i,1),Xp(i,1,0))}function Vc(i){for(;i===Ta;)Ta=gr[--vr],gr[vr]=null,Ma=gr[--vr],gr[vr]=null;for(;i===Ds;)Ds=oi[--ai],oi[ai]=null,Ui=oi[--ai],oi[ai]=null,Hi=oi[--ai],oi[ai]=null}var Jn=null,Zn=null,Wt=!1,vi=null;function Qp(i,r){var c=di(5,null,null,0);c.elementType="DELETED",c.stateNode=r,c.return=i,r=i.deletions,r===null?(i.deletions=[c],i.flags|=16):r.push(c)}function Jp(i,r){switch(i.tag){case 5:var c=i.type;return r=r.nodeType!==1||c.toLowerCase()!==r.nodeName.toLowerCase()?null:r,r!==null?(i.stateNode=r,Jn=i,Zn=as(r.firstChild),!0):!1;case 6:return r=i.pendingProps===""||r.nodeType!==3?null:r,r!==null?(i.stateNode=r,Jn=i,Zn=null,!0):!1;case 13:return r=r.nodeType!==8?null:r,r!==null?(c=Ds!==null?{id:Hi,overflow:Ui}:null,i.memoizedState={dehydrated:r,treeContext:c,retryLane:1073741824},c=di(18,null,null,0),c.stateNode=r,c.return=i,i.child=c,Jn=i,Zn=null,!0):!1;default:return!1}}function Yc(i){return(i.mode&1)!==0&&(i.flags&128)===0}function Gc(i){if(Wt){var r=Zn;if(r){var c=r;if(!Jp(i,r)){if(Yc(i))throw Error(n(418));r=as(c.nextSibling);var d=Jn;r&&Jp(i,r)?Qp(d,c):(i.flags=i.flags&-4097|2,Wt=!1,Jn=i)}}else{if(Yc(i))throw Error(n(418));i.flags=i.flags&-4097|2,Wt=!1,Jn=i}}}function Zp(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;Jn=i}function Da(i){if(i!==Jn)return!1;if(!Wt)return Zp(i),Wt=!0,!1;var r;if((r=i.tag!==3)&&!(r=i.tag!==5)&&(r=i.type,r=r!=="head"&&r!=="body"&&!$c(i.type,i.memoizedProps)),r&&(r=Zn)){if(Yc(i))throw em(),Error(n(418));for(;r;)Qp(i,r),r=as(r.nextSibling)}if(Zp(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,r=0;i;){if(i.nodeType===8){var c=i.data;if(c==="/$"){if(r===0){Zn=as(i.nextSibling);break e}r--}else c!=="$"&&c!=="$!"&&c!=="$?"||r++}i=i.nextSibling}Zn=null}}else Zn=Jn?as(i.stateNode.nextSibling):null;return!0}function em(){for(var i=Zn;i;)i=as(i.nextSibling)}function _r(){Zn=Jn=null,Wt=!1}function Xc(i){vi===null?vi=[i]:vi.push(i)}var VS=D.ReactCurrentBatchConfig;function vo(i,r,c){if(i=c.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(c._owner){if(c=c._owner,c){if(c.tag!==1)throw Error(n(309));var d=c.stateNode}if(!d)throw Error(n(147,i));var g=d,_=""+i;return r!==null&&r.ref!==null&&typeof r.ref=="function"&&r.ref._stringRef===_?r.ref:(r=function(P){var V=g.refs;P===null?delete V[_]:V[_]=P},r._stringRef=_,r)}if(typeof i!="string")throw Error(n(284));if(!c._owner)throw Error(n(290,i))}return i}function Ia(i,r){throw i=Object.prototype.toString.call(r),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":i))}function tm(i){var r=i._init;return r(i._payload)}function nm(i){function r(oe,ne){if(i){var ae=oe.deletions;ae===null?(oe.deletions=[ne],oe.flags|=16):ae.push(ne)}}function c(oe,ne){if(!i)return null;for(;ne!==null;)r(oe,ne),ne=ne.sibling;return null}function d(oe,ne){for(oe=new Map;ne!==null;)ne.key!==null?oe.set(ne.key,ne):oe.set(ne.index,ne),ne=ne.sibling;return oe}function g(oe,ne){return oe=_s(oe,ne),oe.index=0,oe.sibling=null,oe}function _(oe,ne,ae){return oe.index=ae,i?(ae=oe.alternate,ae!==null?(ae=ae.index,ae<ne?(oe.flags|=2,ne):ae):(oe.flags|=2,ne)):(oe.flags|=1048576,ne)}function P(oe){return i&&oe.alternate===null&&(oe.flags|=2),oe}function V(oe,ne,ae,Ne){return ne===null||ne.tag!==6?(ne=Fu(ae,oe.mode,Ne),ne.return=oe,ne):(ne=g(ne,ae),ne.return=oe,ne)}function X(oe,ne,ae,Ne){var We=ae.type;return We===K?Se(oe,ne,ae.props.children,Ne,ae.key):ne!==null&&(ne.elementType===We||typeof We=="object"&&We!==null&&We.$$typeof===L&&tm(We)===ne.type)?(Ne=g(ne,ae.props),Ne.ref=vo(oe,ne,ae),Ne.return=oe,Ne):(Ne=ol(ae.type,ae.key,ae.props,null,oe.mode,Ne),Ne.ref=vo(oe,ne,ae),Ne.return=oe,Ne)}function ue(oe,ne,ae,Ne){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==ae.containerInfo||ne.stateNode.implementation!==ae.implementation?(ne=Hu(ae,oe.mode,Ne),ne.return=oe,ne):(ne=g(ne,ae.children||[]),ne.return=oe,ne)}function Se(oe,ne,ae,Ne,We){return ne===null||ne.tag!==7?(ne=Ws(ae,oe.mode,Ne,We),ne.return=oe,ne):(ne=g(ne,ae),ne.return=oe,ne)}function ke(oe,ne,ae){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=Fu(""+ne,oe.mode,ae),ne.return=oe,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case U:return ae=ol(ne.type,ne.key,ne.props,null,oe.mode,ae),ae.ref=vo(oe,null,ne),ae.return=oe,ae;case W:return ne=Hu(ne,oe.mode,ae),ne.return=oe,ne;case L:var Ne=ne._init;return ke(oe,Ne(ne._payload),ae)}if(ht(ne)||I(ne))return ne=Ws(ne,oe.mode,ae,null),ne.return=oe,ne;Ia(oe,ne)}return null}function be(oe,ne,ae,Ne){var We=ne!==null?ne.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number")return We!==null?null:V(oe,ne,""+ae,Ne);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case U:return ae.key===We?X(oe,ne,ae,Ne):null;case W:return ae.key===We?ue(oe,ne,ae,Ne):null;case L:return We=ae._init,be(oe,ne,We(ae._payload),Ne)}if(ht(ae)||I(ae))return We!==null?null:Se(oe,ne,ae,Ne,null);Ia(oe,ae)}return null}function Ie(oe,ne,ae,Ne,We){if(typeof Ne=="string"&&Ne!==""||typeof Ne=="number")return oe=oe.get(ae)||null,V(ne,oe,""+Ne,We);if(typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case U:return oe=oe.get(Ne.key===null?ae:Ne.key)||null,X(ne,oe,Ne,We);case W:return oe=oe.get(Ne.key===null?ae:Ne.key)||null,ue(ne,oe,Ne,We);case L:var Qe=Ne._init;return Ie(oe,ne,ae,Qe(Ne._payload),We)}if(ht(Ne)||I(Ne))return oe=oe.get(ae)||null,Se(ne,oe,Ne,We,null);Ia(ne,Ne)}return null}function $e(oe,ne,ae,Ne){for(var We=null,Qe=null,Je=ne,nt=ne=0,wn=null;Je!==null&&nt<ae.length;nt++){Je.index>nt?(wn=Je,Je=null):wn=Je.sibling;var wt=be(oe,Je,ae[nt],Ne);if(wt===null){Je===null&&(Je=wn);break}i&&Je&&wt.alternate===null&&r(oe,Je),ne=_(wt,ne,nt),Qe===null?We=wt:Qe.sibling=wt,Qe=wt,Je=wn}if(nt===ae.length)return c(oe,Je),Wt&&Is(oe,nt),We;if(Je===null){for(;nt<ae.length;nt++)Je=ke(oe,ae[nt],Ne),Je!==null&&(ne=_(Je,ne,nt),Qe===null?We=Je:Qe.sibling=Je,Qe=Je);return Wt&&Is(oe,nt),We}for(Je=d(oe,Je);nt<ae.length;nt++)wn=Ie(Je,oe,nt,ae[nt],Ne),wn!==null&&(i&&wn.alternate!==null&&Je.delete(wn.key===null?nt:wn.key),ne=_(wn,ne,nt),Qe===null?We=wn:Qe.sibling=wn,Qe=wn);return i&&Je.forEach(function(ys){return r(oe,ys)}),Wt&&Is(oe,nt),We}function Fe(oe,ne,ae,Ne){var We=I(ae);if(typeof We!="function")throw Error(n(150));if(ae=We.call(ae),ae==null)throw Error(n(151));for(var Qe=We=null,Je=ne,nt=ne=0,wn=null,wt=ae.next();Je!==null&&!wt.done;nt++,wt=ae.next()){Je.index>nt?(wn=Je,Je=null):wn=Je.sibling;var ys=be(oe,Je,wt.value,Ne);if(ys===null){Je===null&&(Je=wn);break}i&&Je&&ys.alternate===null&&r(oe,Je),ne=_(ys,ne,nt),Qe===null?We=ys:Qe.sibling=ys,Qe=ys,Je=wn}if(wt.done)return c(oe,Je),Wt&&Is(oe,nt),We;if(Je===null){for(;!wt.done;nt++,wt=ae.next())wt=ke(oe,wt.value,Ne),wt!==null&&(ne=_(wt,ne,nt),Qe===null?We=wt:Qe.sibling=wt,Qe=wt);return Wt&&Is(oe,nt),We}for(Je=d(oe,Je);!wt.done;nt++,wt=ae.next())wt=Ie(Je,oe,nt,wt.value,Ne),wt!==null&&(i&&wt.alternate!==null&&Je.delete(wt.key===null?nt:wt.key),ne=_(wt,ne,nt),Qe===null?We=wt:Qe.sibling=wt,Qe=wt);return i&&Je.forEach(function(E0){return r(oe,E0)}),Wt&&Is(oe,nt),We}function sn(oe,ne,ae,Ne){if(typeof ae=="object"&&ae!==null&&ae.type===K&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case U:e:{for(var We=ae.key,Qe=ne;Qe!==null;){if(Qe.key===We){if(We=ae.type,We===K){if(Qe.tag===7){c(oe,Qe.sibling),ne=g(Qe,ae.props.children),ne.return=oe,oe=ne;break e}}else if(Qe.elementType===We||typeof We=="object"&&We!==null&&We.$$typeof===L&&tm(We)===Qe.type){c(oe,Qe.sibling),ne=g(Qe,ae.props),ne.ref=vo(oe,Qe,ae),ne.return=oe,oe=ne;break e}c(oe,Qe);break}else r(oe,Qe);Qe=Qe.sibling}ae.type===K?(ne=Ws(ae.props.children,oe.mode,Ne,ae.key),ne.return=oe,oe=ne):(Ne=ol(ae.type,ae.key,ae.props,null,oe.mode,Ne),Ne.ref=vo(oe,ne,ae),Ne.return=oe,oe=Ne)}return P(oe);case W:e:{for(Qe=ae.key;ne!==null;){if(ne.key===Qe)if(ne.tag===4&&ne.stateNode.containerInfo===ae.containerInfo&&ne.stateNode.implementation===ae.implementation){c(oe,ne.sibling),ne=g(ne,ae.children||[]),ne.return=oe,oe=ne;break e}else{c(oe,ne);break}else r(oe,ne);ne=ne.sibling}ne=Hu(ae,oe.mode,Ne),ne.return=oe,oe=ne}return P(oe);case L:return Qe=ae._init,sn(oe,ne,Qe(ae._payload),Ne)}if(ht(ae))return $e(oe,ne,ae,Ne);if(I(ae))return Fe(oe,ne,ae,Ne);Ia(oe,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"?(ae=""+ae,ne!==null&&ne.tag===6?(c(oe,ne.sibling),ne=g(ne,ae),ne.return=oe,oe=ne):(c(oe,ne),ne=Fu(ae,oe.mode,Ne),ne.return=oe,oe=ne),P(oe)):c(oe,ne)}return sn}var yr=nm(!0),im=nm(!1),Oa=ls(null),Ba=null,wr=null,Qc=null;function Jc(){Qc=wr=Ba=null}function Zc(i){var r=Oa.current;Ft(Oa),i._currentValue=r}function eu(i,r,c){for(;i!==null;){var d=i.alternate;if((i.childLanes&r)!==r?(i.childLanes|=r,d!==null&&(d.childLanes|=r)):d!==null&&(d.childLanes&r)!==r&&(d.childLanes|=r),i===c)break;i=i.return}}function br(i,r){Ba=i,Qc=wr=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&r)!==0&&(qn=!0),i.firstContext=null)}function li(i){var r=i._currentValue;if(Qc!==i)if(i={context:i,memoizedValue:r,next:null},wr===null){if(Ba===null)throw Error(n(308));wr=i,Ba.dependencies={lanes:0,firstContext:i}}else wr=wr.next=i;return r}var Os=null;function tu(i){Os===null?Os=[i]:Os.push(i)}function sm(i,r,c,d){var g=r.interleaved;return g===null?(c.next=c,tu(r)):(c.next=g.next,g.next=c),r.interleaved=c,Wi(i,d)}function Wi(i,r){i.lanes|=r;var c=i.alternate;for(c!==null&&(c.lanes|=r),c=i,i=i.return;i!==null;)i.childLanes|=r,c=i.alternate,c!==null&&(c.childLanes|=r),c=i,i=i.return;return c.tag===3?c.stateNode:null}var ds=!1;function nu(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function rm(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function Ki(i,r){return{eventTime:i,lane:r,tag:0,payload:null,callback:null,next:null}}function hs(i,r,c){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(_t&2)!==0){var g=d.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),d.pending=r,Wi(i,c)}return g=d.interleaved,g===null?(r.next=r,tu(d)):(r.next=g.next,g.next=r),d.interleaved=r,Wi(i,c)}function za(i,r,c){if(r=r.updateQueue,r!==null&&(r=r.shared,(c&4194240)!==0)){var d=r.lanes;d&=i.pendingLanes,c|=d,r.lanes=c,gc(i,c)}}function om(i,r){var c=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,c===d)){var g=null,_=null;if(c=c.firstBaseUpdate,c!==null){do{var P={eventTime:c.eventTime,lane:c.lane,tag:c.tag,payload:c.payload,callback:c.callback,next:null};_===null?g=_=P:_=_.next=P,c=c.next}while(c!==null);_===null?g=_=r:_=_.next=r}else g=_=r;c={baseState:d.baseState,firstBaseUpdate:g,lastBaseUpdate:_,shared:d.shared,effects:d.effects},i.updateQueue=c;return}i=c.lastBaseUpdate,i===null?c.firstBaseUpdate=r:i.next=r,c.lastBaseUpdate=r}function $a(i,r,c,d){var g=i.updateQueue;ds=!1;var _=g.firstBaseUpdate,P=g.lastBaseUpdate,V=g.shared.pending;if(V!==null){g.shared.pending=null;var X=V,ue=X.next;X.next=null,P===null?_=ue:P.next=ue,P=X;var Se=i.alternate;Se!==null&&(Se=Se.updateQueue,V=Se.lastBaseUpdate,V!==P&&(V===null?Se.firstBaseUpdate=ue:V.next=ue,Se.lastBaseUpdate=X))}if(_!==null){var ke=g.baseState;P=0,Se=ue=X=null,V=_;do{var be=V.lane,Ie=V.eventTime;if((d&be)===be){Se!==null&&(Se=Se.next={eventTime:Ie,lane:0,tag:V.tag,payload:V.payload,callback:V.callback,next:null});e:{var $e=i,Fe=V;switch(be=r,Ie=c,Fe.tag){case 1:if($e=Fe.payload,typeof $e=="function"){ke=$e.call(Ie,ke,be);break e}ke=$e;break e;case 3:$e.flags=$e.flags&-65537|128;case 0:if($e=Fe.payload,be=typeof $e=="function"?$e.call(Ie,ke,be):$e,be==null)break e;ke=T({},ke,be);break e;case 2:ds=!0}}V.callback!==null&&V.lane!==0&&(i.flags|=64,be=g.effects,be===null?g.effects=[V]:be.push(V))}else Ie={eventTime:Ie,lane:be,tag:V.tag,payload:V.payload,callback:V.callback,next:null},Se===null?(ue=Se=Ie,X=ke):Se=Se.next=Ie,P|=be;if(V=V.next,V===null){if(V=g.shared.pending,V===null)break;be=V,V=be.next,be.next=null,g.lastBaseUpdate=be,g.shared.pending=null}}while(!0);if(Se===null&&(X=ke),g.baseState=X,g.firstBaseUpdate=ue,g.lastBaseUpdate=Se,r=g.shared.interleaved,r!==null){g=r;do P|=g.lane,g=g.next;while(g!==r)}else _===null&&(g.shared.lanes=0);$s|=P,i.lanes=P,i.memoizedState=ke}}function am(i,r,c){if(i=r.effects,r.effects=null,i!==null)for(r=0;r<i.length;r++){var d=i[r],g=d.callback;if(g!==null){if(d.callback=null,d=c,typeof g!="function")throw Error(n(191,g));g.call(d)}}}var _o={},ki=ls(_o),yo=ls(_o),wo=ls(_o);function Bs(i){if(i===_o)throw Error(n(174));return i}function iu(i,r){switch(It(wo,r),It(yo,i),It(ki,_o),i=r.nodeType,i){case 9:case 11:r=(r=r.documentElement)?r.namespaceURI:ye(null,"");break;default:i=i===8?r.parentNode:r,r=i.namespaceURI||null,i=i.tagName,r=ye(r,i)}Ft(ki),It(ki,r)}function Sr(){Ft(ki),Ft(yo),Ft(wo)}function lm(i){Bs(wo.current);var r=Bs(ki.current),c=ye(r,i.type);r!==c&&(It(yo,i),It(ki,c))}function su(i){yo.current===i&&(Ft(ki),Ft(yo))}var Vt=ls(0);function Fa(i){for(var r=i;r!==null;){if(r.tag===13){var c=r.memoizedState;if(c!==null&&(c=c.dehydrated,c===null||c.data==="$?"||c.data==="$!"))return r}else if(r.tag===19&&r.memoizedProps.revealOrder!==void 0){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var ru=[];function ou(){for(var i=0;i<ru.length;i++)ru[i]._workInProgressVersionPrimary=null;ru.length=0}var Ha=D.ReactCurrentDispatcher,au=D.ReactCurrentBatchConfig,zs=0,Yt=null,dn=null,_n=null,Ua=!1,bo=!1,So=0,YS=0;function An(){throw Error(n(321))}function lu(i,r){if(r===null)return!1;for(var c=0;c<r.length&&c<i.length;c++)if(!gi(i[c],r[c]))return!1;return!0}function cu(i,r,c,d,g,_){if(zs=_,Yt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,Ha.current=i===null||i.memoizedState===null?JS:ZS,i=c(d,g),bo){_=0;do{if(bo=!1,So=0,25<=_)throw Error(n(301));_+=1,_n=dn=null,r.updateQueue=null,Ha.current=e0,i=c(d,g)}while(bo)}if(Ha.current=qa,r=dn!==null&&dn.next!==null,zs=0,_n=dn=Yt=null,Ua=!1,r)throw Error(n(300));return i}function uu(){var i=So!==0;return So=0,i}function Ci(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return _n===null?Yt.memoizedState=_n=i:_n=_n.next=i,_n}function ci(){if(dn===null){var i=Yt.alternate;i=i!==null?i.memoizedState:null}else i=dn.next;var r=_n===null?Yt.memoizedState:_n.next;if(r!==null)_n=r,dn=i;else{if(i===null)throw Error(n(310));dn=i,i={memoizedState:dn.memoizedState,baseState:dn.baseState,baseQueue:dn.baseQueue,queue:dn.queue,next:null},_n===null?Yt.memoizedState=_n=i:_n=_n.next=i}return _n}function xo(i,r){return typeof r=="function"?r(i):r}function du(i){var r=ci(),c=r.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=i;var d=dn,g=d.baseQueue,_=c.pending;if(_!==null){if(g!==null){var P=g.next;g.next=_.next,_.next=P}d.baseQueue=g=_,c.pending=null}if(g!==null){_=g.next,d=d.baseState;var V=P=null,X=null,ue=_;do{var Se=ue.lane;if((zs&Se)===Se)X!==null&&(X=X.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),d=ue.hasEagerState?ue.eagerState:i(d,ue.action);else{var ke={lane:Se,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};X===null?(V=X=ke,P=d):X=X.next=ke,Yt.lanes|=Se,$s|=Se}ue=ue.next}while(ue!==null&&ue!==_);X===null?P=d:X.next=V,gi(d,r.memoizedState)||(qn=!0),r.memoizedState=d,r.baseState=P,r.baseQueue=X,c.lastRenderedState=d}if(i=c.interleaved,i!==null){g=i;do _=g.lane,Yt.lanes|=_,$s|=_,g=g.next;while(g!==i)}else g===null&&(c.lanes=0);return[r.memoizedState,c.dispatch]}function hu(i){var r=ci(),c=r.queue;if(c===null)throw Error(n(311));c.lastRenderedReducer=i;var d=c.dispatch,g=c.pending,_=r.memoizedState;if(g!==null){c.pending=null;var P=g=g.next;do _=i(_,P.action),P=P.next;while(P!==g);gi(_,r.memoizedState)||(qn=!0),r.memoizedState=_,r.baseQueue===null&&(r.baseState=_),c.lastRenderedState=_}return[_,d]}function cm(){}function um(i,r){var c=Yt,d=ci(),g=r(),_=!gi(d.memoizedState,g);if(_&&(d.memoizedState=g,qn=!0),d=d.queue,fu(fm.bind(null,c,d,i),[i]),d.getSnapshot!==r||_||_n!==null&&_n.memoizedState.tag&1){if(c.flags|=2048,ko(9,hm.bind(null,c,d,g,r),void 0,null),yn===null)throw Error(n(349));(zs&30)!==0||dm(c,r,g)}return g}function dm(i,r,c){i.flags|=16384,i={getSnapshot:r,value:c},r=Yt.updateQueue,r===null?(r={lastEffect:null,stores:null},Yt.updateQueue=r,r.stores=[i]):(c=r.stores,c===null?r.stores=[i]:c.push(i))}function hm(i,r,c,d){r.value=c,r.getSnapshot=d,pm(r)&&mm(i)}function fm(i,r,c){return c(function(){pm(r)&&mm(i)})}function pm(i){var r=i.getSnapshot;i=i.value;try{var c=r();return!gi(i,c)}catch{return!0}}function mm(i){var r=Wi(i,1);r!==null&&bi(r,i,1,-1)}function gm(i){var r=Ci();return typeof i=="function"&&(i=i()),r.memoizedState=r.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:xo,lastRenderedState:i},r.queue=i,i=i.dispatch=QS.bind(null,Yt,i),[r.memoizedState,i]}function ko(i,r,c,d){return i={tag:i,create:r,destroy:c,deps:d,next:null},r=Yt.updateQueue,r===null?(r={lastEffect:null,stores:null},Yt.updateQueue=r,r.lastEffect=i.next=i):(c=r.lastEffect,c===null?r.lastEffect=i.next=i:(d=c.next,c.next=i,i.next=d,r.lastEffect=i)),i}function vm(){return ci().memoizedState}function Wa(i,r,c,d){var g=Ci();Yt.flags|=i,g.memoizedState=ko(1|r,c,void 0,d===void 0?null:d)}function Ka(i,r,c,d){var g=ci();d=d===void 0?null:d;var _=void 0;if(dn!==null){var P=dn.memoizedState;if(_=P.destroy,d!==null&&lu(d,P.deps)){g.memoizedState=ko(r,c,_,d);return}}Yt.flags|=i,g.memoizedState=ko(1|r,c,_,d)}function _m(i,r){return Wa(8390656,8,i,r)}function fu(i,r){return Ka(2048,8,i,r)}function ym(i,r){return Ka(4,2,i,r)}function wm(i,r){return Ka(4,4,i,r)}function bm(i,r){if(typeof r=="function")return i=i(),r(i),function(){r(null)};if(r!=null)return i=i(),r.current=i,function(){r.current=null}}function Sm(i,r,c){return c=c!=null?c.concat([i]):null,Ka(4,4,bm.bind(null,r,i),c)}function pu(){}function xm(i,r){var c=ci();r=r===void 0?null:r;var d=c.memoizedState;return d!==null&&r!==null&&lu(r,d[1])?d[0]:(c.memoizedState=[i,r],i)}function km(i,r){var c=ci();r=r===void 0?null:r;var d=c.memoizedState;return d!==null&&r!==null&&lu(r,d[1])?d[0]:(i=i(),c.memoizedState=[i,r],i)}function Cm(i,r,c){return(zs&21)===0?(i.baseState&&(i.baseState=!1,qn=!0),i.memoizedState=c):(gi(c,r)||(c=tp(),Yt.lanes|=c,$s|=c,i.baseState=!0),r)}function GS(i,r){var c=jt;jt=c!==0&&4>c?c:4,i(!0);var d=au.transition;au.transition={};try{i(!1),r()}finally{jt=c,au.transition=d}}function Em(){return ci().memoizedState}function XS(i,r,c){var d=gs(i);if(c={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null},Nm(i))jm(r,c);else if(c=sm(i,r,c,d),c!==null){var g=Bn();bi(c,i,d,g),Rm(c,r,d)}}function QS(i,r,c){var d=gs(i),g={lane:d,action:c,hasEagerState:!1,eagerState:null,next:null};if(Nm(i))jm(r,g);else{var _=i.alternate;if(i.lanes===0&&(_===null||_.lanes===0)&&(_=r.lastRenderedReducer,_!==null))try{var P=r.lastRenderedState,V=_(P,c);if(g.hasEagerState=!0,g.eagerState=V,gi(V,P)){var X=r.interleaved;X===null?(g.next=g,tu(r)):(g.next=X.next,X.next=g),r.interleaved=g;return}}catch{}finally{}c=sm(i,r,g,d),c!==null&&(g=Bn(),bi(c,i,d,g),Rm(c,r,d))}}function Nm(i){var r=i.alternate;return i===Yt||r!==null&&r===Yt}function jm(i,r){bo=Ua=!0;var c=i.pending;c===null?r.next=r:(r.next=c.next,c.next=r),i.pending=r}function Rm(i,r,c){if((c&4194240)!==0){var d=r.lanes;d&=i.pendingLanes,c|=d,r.lanes=c,gc(i,c)}}var qa={readContext:li,useCallback:An,useContext:An,useEffect:An,useImperativeHandle:An,useInsertionEffect:An,useLayoutEffect:An,useMemo:An,useReducer:An,useRef:An,useState:An,useDebugValue:An,useDeferredValue:An,useTransition:An,useMutableSource:An,useSyncExternalStore:An,useId:An,unstable_isNewReconciler:!1},JS={readContext:li,useCallback:function(i,r){return Ci().memoizedState=[i,r===void 0?null:r],i},useContext:li,useEffect:_m,useImperativeHandle:function(i,r,c){return c=c!=null?c.concat([i]):null,Wa(4194308,4,bm.bind(null,r,i),c)},useLayoutEffect:function(i,r){return Wa(4194308,4,i,r)},useInsertionEffect:function(i,r){return Wa(4,2,i,r)},useMemo:function(i,r){var c=Ci();return r=r===void 0?null:r,i=i(),c.memoizedState=[i,r],i},useReducer:function(i,r,c){var d=Ci();return r=c!==void 0?c(r):r,d.memoizedState=d.baseState=r,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:r},d.queue=i,i=i.dispatch=XS.bind(null,Yt,i),[d.memoizedState,i]},useRef:function(i){var r=Ci();return i={current:i},r.memoizedState=i},useState:gm,useDebugValue:pu,useDeferredValue:function(i){return Ci().memoizedState=i},useTransition:function(){var i=gm(!1),r=i[0];return i=GS.bind(null,i[1]),Ci().memoizedState=i,[r,i]},useMutableSource:function(){},useSyncExternalStore:function(i,r,c){var d=Yt,g=Ci();if(Wt){if(c===void 0)throw Error(n(407));c=c()}else{if(c=r(),yn===null)throw Error(n(349));(zs&30)!==0||dm(d,r,c)}g.memoizedState=c;var _={value:c,getSnapshot:r};return g.queue=_,_m(fm.bind(null,d,_,i),[i]),d.flags|=2048,ko(9,hm.bind(null,d,_,c,r),void 0,null),c},useId:function(){var i=Ci(),r=yn.identifierPrefix;if(Wt){var c=Ui,d=Hi;c=(d&~(1<<32-Un(d)-1)).toString(32)+c,r=":"+r+"R"+c,c=So++,0<c&&(r+="H"+c.toString(32)),r+=":"}else c=YS++,r=":"+r+"r"+c.toString(32)+":";return i.memoizedState=r},unstable_isNewReconciler:!1},ZS={readContext:li,useCallback:xm,useContext:li,useEffect:fu,useImperativeHandle:Sm,useInsertionEffect:ym,useLayoutEffect:wm,useMemo:km,useReducer:du,useRef:vm,useState:function(){return du(xo)},useDebugValue:pu,useDeferredValue:function(i){var r=ci();return Cm(r,dn.memoizedState,i)},useTransition:function(){var i=du(xo)[0],r=ci().memoizedState;return[i,r]},useMutableSource:cm,useSyncExternalStore:um,useId:Em,unstable_isNewReconciler:!1},e0={readContext:li,useCallback:xm,useContext:li,useEffect:fu,useImperativeHandle:Sm,useInsertionEffect:ym,useLayoutEffect:wm,useMemo:km,useReducer:hu,useRef:vm,useState:function(){return hu(xo)},useDebugValue:pu,useDeferredValue:function(i){var r=ci();return dn===null?r.memoizedState=i:Cm(r,dn.memoizedState,i)},useTransition:function(){var i=hu(xo)[0],r=ci().memoizedState;return[i,r]},useMutableSource:cm,useSyncExternalStore:um,useId:Em,unstable_isNewReconciler:!1};function _i(i,r){if(i&&i.defaultProps){r=T({},r),i=i.defaultProps;for(var c in i)r[c]===void 0&&(r[c]=i[c]);return r}return r}function mu(i,r,c,d){r=i.memoizedState,c=c(d,r),c=c==null?r:T({},r,c),i.memoizedState=c,i.lanes===0&&(i.updateQueue.baseState=c)}var Va={isMounted:function(i){return(i=i._reactInternals)?Xe(i)===i:!1},enqueueSetState:function(i,r,c){i=i._reactInternals;var d=Bn(),g=gs(i),_=Ki(d,g);_.payload=r,c!=null&&(_.callback=c),r=hs(i,_,g),r!==null&&(bi(r,i,g,d),za(r,i,g))},enqueueReplaceState:function(i,r,c){i=i._reactInternals;var d=Bn(),g=gs(i),_=Ki(d,g);_.tag=1,_.payload=r,c!=null&&(_.callback=c),r=hs(i,_,g),r!==null&&(bi(r,i,g,d),za(r,i,g))},enqueueForceUpdate:function(i,r){i=i._reactInternals;var c=Bn(),d=gs(i),g=Ki(c,d);g.tag=2,r!=null&&(g.callback=r),r=hs(i,g,d),r!==null&&(bi(r,i,d,c),za(r,i,d))}};function Pm(i,r,c,d,g,_,P){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(d,_,P):r.prototype&&r.prototype.isPureReactComponent?!co(c,d)||!co(g,_):!0}function Am(i,r,c){var d=!1,g=cs,_=r.contextType;return typeof _=="object"&&_!==null?_=li(_):(g=Kn(r)?Ms:Pn.current,d=r.contextTypes,_=(d=d!=null)?mr(i,g):cs),r=new r(c,_),i.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,r.updater=Va,i.stateNode=r,r._reactInternals=i,d&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=g,i.__reactInternalMemoizedMaskedChildContext=_),r}function Lm(i,r,c,d){i=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(c,d),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(c,d),r.state!==i&&Va.enqueueReplaceState(r,r.state,null)}function gu(i,r,c,d){var g=i.stateNode;g.props=c,g.state=i.memoizedState,g.refs={},nu(i);var _=r.contextType;typeof _=="object"&&_!==null?g.context=li(_):(_=Kn(r)?Ms:Pn.current,g.context=mr(i,_)),g.state=i.memoizedState,_=r.getDerivedStateFromProps,typeof _=="function"&&(mu(i,r,_,c),g.state=i.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(r=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),r!==g.state&&Va.enqueueReplaceState(g,g.state,null),$a(i,c,g,d),g.state=i.memoizedState),typeof g.componentDidMount=="function"&&(i.flags|=4194308)}function xr(i,r){try{var c="",d=r;do c+=ee(d),d=d.return;while(d);var g=c}catch(_){g=`
|
|
39
|
+
Error generating stack: `+_.message+`
|
|
40
|
+
`+_.stack}return{value:i,source:r,stack:g,digest:null}}function vu(i,r,c){return{value:i,source:null,stack:c??null,digest:r??null}}function _u(i,r){try{console.error(r.value)}catch(c){setTimeout(function(){throw c})}}var t0=typeof WeakMap=="function"?WeakMap:Map;function Tm(i,r,c){c=Ki(-1,c),c.tag=3,c.payload={element:null};var d=r.value;return c.callback=function(){el||(el=!0,Tu=d),_u(i,r)},c}function Mm(i,r,c){c=Ki(-1,c),c.tag=3;var d=i.type.getDerivedStateFromError;if(typeof d=="function"){var g=r.value;c.payload=function(){return d(g)},c.callback=function(){_u(i,r)}}var _=i.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(c.callback=function(){_u(i,r),typeof d!="function"&&(ps===null?ps=new Set([this]):ps.add(this));var P=r.stack;this.componentDidCatch(r.value,{componentStack:P!==null?P:""})}),c}function Dm(i,r,c){var d=i.pingCache;if(d===null){d=i.pingCache=new t0;var g=new Set;d.set(r,g)}else g=d.get(r),g===void 0&&(g=new Set,d.set(r,g));g.has(c)||(g.add(c),i=m0.bind(null,i,r,c),r.then(i,i))}function Im(i){do{var r;if((r=i.tag===13)&&(r=i.memoizedState,r=r!==null?r.dehydrated!==null:!0),r)return i;i=i.return}while(i!==null);return null}function Om(i,r,c,d,g){return(i.mode&1)===0?(i===r?i.flags|=65536:(i.flags|=128,c.flags|=131072,c.flags&=-52805,c.tag===1&&(c.alternate===null?c.tag=17:(r=Ki(-1,1),r.tag=2,hs(c,r,1))),c.lanes|=1),i):(i.flags|=65536,i.lanes=g,i)}var n0=D.ReactCurrentOwner,qn=!1;function On(i,r,c,d){r.child=i===null?im(r,null,c,d):yr(r,i.child,c,d)}function Bm(i,r,c,d,g){c=c.render;var _=r.ref;return br(r,g),d=cu(i,r,c,d,_,g),c=uu(),i!==null&&!qn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,qi(i,r,g)):(Wt&&c&&qc(r),r.flags|=1,On(i,r,d,g),r.child)}function zm(i,r,c,d,g){if(i===null){var _=c.type;return typeof _=="function"&&!$u(_)&&_.defaultProps===void 0&&c.compare===null&&c.defaultProps===void 0?(r.tag=15,r.type=_,$m(i,r,_,d,g)):(i=ol(c.type,null,d,r,r.mode,g),i.ref=r.ref,i.return=r,r.child=i)}if(_=i.child,(i.lanes&g)===0){var P=_.memoizedProps;if(c=c.compare,c=c!==null?c:co,c(P,d)&&i.ref===r.ref)return qi(i,r,g)}return r.flags|=1,i=_s(_,d),i.ref=r.ref,i.return=r,r.child=i}function $m(i,r,c,d,g){if(i!==null){var _=i.memoizedProps;if(co(_,d)&&i.ref===r.ref)if(qn=!1,r.pendingProps=d=_,(i.lanes&g)!==0)(i.flags&131072)!==0&&(qn=!0);else return r.lanes=i.lanes,qi(i,r,g)}return yu(i,r,c,d,g)}function Fm(i,r,c){var d=r.pendingProps,g=d.children,_=i!==null?i.memoizedState:null;if(d.mode==="hidden")if((r.mode&1)===0)r.memoizedState={baseLanes:0,cachePool:null,transitions:null},It(Cr,ei),ei|=c;else{if((c&1073741824)===0)return i=_!==null?_.baseLanes|c:c,r.lanes=r.childLanes=1073741824,r.memoizedState={baseLanes:i,cachePool:null,transitions:null},r.updateQueue=null,It(Cr,ei),ei|=i,null;r.memoizedState={baseLanes:0,cachePool:null,transitions:null},d=_!==null?_.baseLanes:c,It(Cr,ei),ei|=d}else _!==null?(d=_.baseLanes|c,r.memoizedState=null):d=c,It(Cr,ei),ei|=d;return On(i,r,g,c),r.child}function Hm(i,r){var c=r.ref;(i===null&&c!==null||i!==null&&i.ref!==c)&&(r.flags|=512,r.flags|=2097152)}function yu(i,r,c,d,g){var _=Kn(c)?Ms:Pn.current;return _=mr(r,_),br(r,g),c=cu(i,r,c,d,_,g),d=uu(),i!==null&&!qn?(r.updateQueue=i.updateQueue,r.flags&=-2053,i.lanes&=~g,qi(i,r,g)):(Wt&&d&&qc(r),r.flags|=1,On(i,r,c,g),r.child)}function Um(i,r,c,d,g){if(Kn(c)){var _=!0;Aa(r)}else _=!1;if(br(r,g),r.stateNode===null)Ga(i,r),Am(r,c,d),gu(r,c,d,g),d=!0;else if(i===null){var P=r.stateNode,V=r.memoizedProps;P.props=V;var X=P.context,ue=c.contextType;typeof ue=="object"&&ue!==null?ue=li(ue):(ue=Kn(c)?Ms:Pn.current,ue=mr(r,ue));var Se=c.getDerivedStateFromProps,ke=typeof Se=="function"||typeof P.getSnapshotBeforeUpdate=="function";ke||typeof P.UNSAFE_componentWillReceiveProps!="function"&&typeof P.componentWillReceiveProps!="function"||(V!==d||X!==ue)&&Lm(r,P,d,ue),ds=!1;var be=r.memoizedState;P.state=be,$a(r,d,P,g),X=r.memoizedState,V!==d||be!==X||Wn.current||ds?(typeof Se=="function"&&(mu(r,c,Se,d),X=r.memoizedState),(V=ds||Pm(r,c,V,d,be,X,ue))?(ke||typeof P.UNSAFE_componentWillMount!="function"&&typeof P.componentWillMount!="function"||(typeof P.componentWillMount=="function"&&P.componentWillMount(),typeof P.UNSAFE_componentWillMount=="function"&&P.UNSAFE_componentWillMount()),typeof P.componentDidMount=="function"&&(r.flags|=4194308)):(typeof P.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=d,r.memoizedState=X),P.props=d,P.state=X,P.context=ue,d=V):(typeof P.componentDidMount=="function"&&(r.flags|=4194308),d=!1)}else{P=r.stateNode,rm(i,r),V=r.memoizedProps,ue=r.type===r.elementType?V:_i(r.type,V),P.props=ue,ke=r.pendingProps,be=P.context,X=c.contextType,typeof X=="object"&&X!==null?X=li(X):(X=Kn(c)?Ms:Pn.current,X=mr(r,X));var Ie=c.getDerivedStateFromProps;(Se=typeof Ie=="function"||typeof P.getSnapshotBeforeUpdate=="function")||typeof P.UNSAFE_componentWillReceiveProps!="function"&&typeof P.componentWillReceiveProps!="function"||(V!==ke||be!==X)&&Lm(r,P,d,X),ds=!1,be=r.memoizedState,P.state=be,$a(r,d,P,g);var $e=r.memoizedState;V!==ke||be!==$e||Wn.current||ds?(typeof Ie=="function"&&(mu(r,c,Ie,d),$e=r.memoizedState),(ue=ds||Pm(r,c,ue,d,be,$e,X)||!1)?(Se||typeof P.UNSAFE_componentWillUpdate!="function"&&typeof P.componentWillUpdate!="function"||(typeof P.componentWillUpdate=="function"&&P.componentWillUpdate(d,$e,X),typeof P.UNSAFE_componentWillUpdate=="function"&&P.UNSAFE_componentWillUpdate(d,$e,X)),typeof P.componentDidUpdate=="function"&&(r.flags|=4),typeof P.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof P.componentDidUpdate!="function"||V===i.memoizedProps&&be===i.memoizedState||(r.flags|=4),typeof P.getSnapshotBeforeUpdate!="function"||V===i.memoizedProps&&be===i.memoizedState||(r.flags|=1024),r.memoizedProps=d,r.memoizedState=$e),P.props=d,P.state=$e,P.context=X,d=ue):(typeof P.componentDidUpdate!="function"||V===i.memoizedProps&&be===i.memoizedState||(r.flags|=4),typeof P.getSnapshotBeforeUpdate!="function"||V===i.memoizedProps&&be===i.memoizedState||(r.flags|=1024),d=!1)}return wu(i,r,c,d,_,g)}function wu(i,r,c,d,g,_){Hm(i,r);var P=(r.flags&128)!==0;if(!d&&!P)return g&&Yp(r,c,!1),qi(i,r,_);d=r.stateNode,n0.current=r;var V=P&&typeof c.getDerivedStateFromError!="function"?null:d.render();return r.flags|=1,i!==null&&P?(r.child=yr(r,i.child,null,_),r.child=yr(r,null,V,_)):On(i,r,V,_),r.memoizedState=d.state,g&&Yp(r,c,!0),r.child}function Wm(i){var r=i.stateNode;r.pendingContext?qp(i,r.pendingContext,r.pendingContext!==r.context):r.context&&qp(i,r.context,!1),iu(i,r.containerInfo)}function Km(i,r,c,d,g){return _r(),Xc(g),r.flags|=256,On(i,r,c,d),r.child}var bu={dehydrated:null,treeContext:null,retryLane:0};function Su(i){return{baseLanes:i,cachePool:null,transitions:null}}function qm(i,r,c){var d=r.pendingProps,g=Vt.current,_=!1,P=(r.flags&128)!==0,V;if((V=P)||(V=i!==null&&i.memoizedState===null?!1:(g&2)!==0),V?(_=!0,r.flags&=-129):(i===null||i.memoizedState!==null)&&(g|=1),It(Vt,g&1),i===null)return Gc(r),i=r.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((r.mode&1)===0?r.lanes=1:i.data==="$!"?r.lanes=8:r.lanes=1073741824,null):(P=d.children,i=d.fallback,_?(d=r.mode,_=r.child,P={mode:"hidden",children:P},(d&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=P):_=al(P,d,0,null),i=Ws(i,d,c,null),_.return=r,i.return=r,_.sibling=i,r.child=_,r.child.memoizedState=Su(c),r.memoizedState=bu,i):xu(r,P));if(g=i.memoizedState,g!==null&&(V=g.dehydrated,V!==null))return i0(i,r,P,d,V,g,c);if(_){_=d.fallback,P=r.mode,g=i.child,V=g.sibling;var X={mode:"hidden",children:d.children};return(P&1)===0&&r.child!==g?(d=r.child,d.childLanes=0,d.pendingProps=X,r.deletions=null):(d=_s(g,X),d.subtreeFlags=g.subtreeFlags&14680064),V!==null?_=_s(V,_):(_=Ws(_,P,c,null),_.flags|=2),_.return=r,d.return=r,d.sibling=_,r.child=d,d=_,_=r.child,P=i.child.memoizedState,P=P===null?Su(c):{baseLanes:P.baseLanes|c,cachePool:null,transitions:P.transitions},_.memoizedState=P,_.childLanes=i.childLanes&~c,r.memoizedState=bu,d}return _=i.child,i=_.sibling,d=_s(_,{mode:"visible",children:d.children}),(r.mode&1)===0&&(d.lanes=c),d.return=r,d.sibling=null,i!==null&&(c=r.deletions,c===null?(r.deletions=[i],r.flags|=16):c.push(i)),r.child=d,r.memoizedState=null,d}function xu(i,r){return r=al({mode:"visible",children:r},i.mode,0,null),r.return=i,i.child=r}function Ya(i,r,c,d){return d!==null&&Xc(d),yr(r,i.child,null,c),i=xu(r,r.pendingProps.children),i.flags|=2,r.memoizedState=null,i}function i0(i,r,c,d,g,_,P){if(c)return r.flags&256?(r.flags&=-257,d=vu(Error(n(422))),Ya(i,r,P,d)):r.memoizedState!==null?(r.child=i.child,r.flags|=128,null):(_=d.fallback,g=r.mode,d=al({mode:"visible",children:d.children},g,0,null),_=Ws(_,g,P,null),_.flags|=2,d.return=r,_.return=r,d.sibling=_,r.child=d,(r.mode&1)!==0&&yr(r,i.child,null,P),r.child.memoizedState=Su(P),r.memoizedState=bu,_);if((r.mode&1)===0)return Ya(i,r,P,null);if(g.data==="$!"){if(d=g.nextSibling&&g.nextSibling.dataset,d)var V=d.dgst;return d=V,_=Error(n(419)),d=vu(_,d,void 0),Ya(i,r,P,d)}if(V=(P&i.childLanes)!==0,qn||V){if(d=yn,d!==null){switch(P&-P){case 4:g=2;break;case 16:g=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:g=32;break;case 536870912:g=268435456;break;default:g=0}g=(g&(d.suspendedLanes|P))!==0?0:g,g!==0&&g!==_.retryLane&&(_.retryLane=g,Wi(i,g),bi(d,i,g,-1))}return zu(),d=vu(Error(n(421))),Ya(i,r,P,d)}return g.data==="$?"?(r.flags|=128,r.child=i.child,r=g0.bind(null,i),g._reactRetry=r,null):(i=_.treeContext,Zn=as(g.nextSibling),Jn=r,Wt=!0,vi=null,i!==null&&(oi[ai++]=Hi,oi[ai++]=Ui,oi[ai++]=Ds,Hi=i.id,Ui=i.overflow,Ds=r),r=xu(r,d.children),r.flags|=4096,r)}function Vm(i,r,c){i.lanes|=r;var d=i.alternate;d!==null&&(d.lanes|=r),eu(i.return,r,c)}function ku(i,r,c,d,g){var _=i.memoizedState;_===null?i.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:d,tail:c,tailMode:g}:(_.isBackwards=r,_.rendering=null,_.renderingStartTime=0,_.last=d,_.tail=c,_.tailMode=g)}function Ym(i,r,c){var d=r.pendingProps,g=d.revealOrder,_=d.tail;if(On(i,r,d.children,c),d=Vt.current,(d&2)!==0)d=d&1|2,r.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=r.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Vm(i,c,r);else if(i.tag===19)Vm(i,c,r);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===r)break e;for(;i.sibling===null;){if(i.return===null||i.return===r)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}d&=1}if(It(Vt,d),(r.mode&1)===0)r.memoizedState=null;else switch(g){case"forwards":for(c=r.child,g=null;c!==null;)i=c.alternate,i!==null&&Fa(i)===null&&(g=c),c=c.sibling;c=g,c===null?(g=r.child,r.child=null):(g=c.sibling,c.sibling=null),ku(r,!1,g,c,_);break;case"backwards":for(c=null,g=r.child,r.child=null;g!==null;){if(i=g.alternate,i!==null&&Fa(i)===null){r.child=g;break}i=g.sibling,g.sibling=c,c=g,g=i}ku(r,!0,c,null,_);break;case"together":ku(r,!1,null,null,void 0);break;default:r.memoizedState=null}return r.child}function Ga(i,r){(r.mode&1)===0&&i!==null&&(i.alternate=null,r.alternate=null,r.flags|=2)}function qi(i,r,c){if(i!==null&&(r.dependencies=i.dependencies),$s|=r.lanes,(c&r.childLanes)===0)return null;if(i!==null&&r.child!==i.child)throw Error(n(153));if(r.child!==null){for(i=r.child,c=_s(i,i.pendingProps),r.child=c,c.return=r;i.sibling!==null;)i=i.sibling,c=c.sibling=_s(i,i.pendingProps),c.return=r;c.sibling=null}return r.child}function s0(i,r,c){switch(r.tag){case 3:Wm(r),_r();break;case 5:lm(r);break;case 1:Kn(r.type)&&Aa(r);break;case 4:iu(r,r.stateNode.containerInfo);break;case 10:var d=r.type._context,g=r.memoizedProps.value;It(Oa,d._currentValue),d._currentValue=g;break;case 13:if(d=r.memoizedState,d!==null)return d.dehydrated!==null?(It(Vt,Vt.current&1),r.flags|=128,null):(c&r.child.childLanes)!==0?qm(i,r,c):(It(Vt,Vt.current&1),i=qi(i,r,c),i!==null?i.sibling:null);It(Vt,Vt.current&1);break;case 19:if(d=(c&r.childLanes)!==0,(i.flags&128)!==0){if(d)return Ym(i,r,c);r.flags|=128}if(g=r.memoizedState,g!==null&&(g.rendering=null,g.tail=null,g.lastEffect=null),It(Vt,Vt.current),d)break;return null;case 22:case 23:return r.lanes=0,Fm(i,r,c)}return qi(i,r,c)}var Gm,Cu,Xm,Qm;Gm=function(i,r){for(var c=r.child;c!==null;){if(c.tag===5||c.tag===6)i.appendChild(c.stateNode);else if(c.tag!==4&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===r)break;for(;c.sibling===null;){if(c.return===null||c.return===r)return;c=c.return}c.sibling.return=c.return,c=c.sibling}},Cu=function(){},Xm=function(i,r,c,d){var g=i.memoizedProps;if(g!==d){i=r.stateNode,Bs(ki.current);var _=null;switch(c){case"input":g=xt(i,g),d=xt(i,d),_=[];break;case"select":g=T({},g,{value:void 0}),d=T({},d,{value:void 0}),_=[];break;case"textarea":g=Bt(i,g),d=Bt(i,d),_=[];break;default:typeof g.onClick!="function"&&typeof d.onClick=="function"&&(i.onclick=ja)}ft(c,d);var P;c=null;for(ue in g)if(!d.hasOwnProperty(ue)&&g.hasOwnProperty(ue)&&g[ue]!=null)if(ue==="style"){var V=g[ue];for(P in V)V.hasOwnProperty(P)&&(c||(c={}),c[P]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(o.hasOwnProperty(ue)?_||(_=[]):(_=_||[]).push(ue,null));for(ue in d){var X=d[ue];if(V=g!=null?g[ue]:void 0,d.hasOwnProperty(ue)&&X!==V&&(X!=null||V!=null))if(ue==="style")if(V){for(P in V)!V.hasOwnProperty(P)||X&&X.hasOwnProperty(P)||(c||(c={}),c[P]="");for(P in X)X.hasOwnProperty(P)&&V[P]!==X[P]&&(c||(c={}),c[P]=X[P])}else c||(_||(_=[]),_.push(ue,c)),c=X;else ue==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,V=V?V.__html:void 0,X!=null&&V!==X&&(_=_||[]).push(ue,X)):ue==="children"?typeof X!="string"&&typeof X!="number"||(_=_||[]).push(ue,""+X):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(o.hasOwnProperty(ue)?(X!=null&&ue==="onScroll"&&$t("scroll",i),_||V===X||(_=[])):(_=_||[]).push(ue,X))}c&&(_=_||[]).push("style",c);var ue=_;(r.updateQueue=ue)&&(r.flags|=4)}},Qm=function(i,r,c,d){c!==d&&(r.flags|=4)};function Co(i,r){if(!Wt)switch(i.tailMode){case"hidden":r=i.tail;for(var c=null;r!==null;)r.alternate!==null&&(c=r),r=r.sibling;c===null?i.tail=null:c.sibling=null;break;case"collapsed":c=i.tail;for(var d=null;c!==null;)c.alternate!==null&&(d=c),c=c.sibling;d===null?r||i.tail===null?i.tail=null:i.tail.sibling=null:d.sibling=null}}function Ln(i){var r=i.alternate!==null&&i.alternate.child===i.child,c=0,d=0;if(r)for(var g=i.child;g!==null;)c|=g.lanes|g.childLanes,d|=g.subtreeFlags&14680064,d|=g.flags&14680064,g.return=i,g=g.sibling;else for(g=i.child;g!==null;)c|=g.lanes|g.childLanes,d|=g.subtreeFlags,d|=g.flags,g.return=i,g=g.sibling;return i.subtreeFlags|=d,i.childLanes=c,r}function r0(i,r,c){var d=r.pendingProps;switch(Vc(r),r.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ln(r),null;case 1:return Kn(r.type)&&Pa(),Ln(r),null;case 3:return d=r.stateNode,Sr(),Ft(Wn),Ft(Pn),ou(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(i===null||i.child===null)&&(Da(r)?r.flags|=4:i===null||i.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,vi!==null&&(Iu(vi),vi=null))),Cu(i,r),Ln(r),null;case 5:su(r);var g=Bs(wo.current);if(c=r.type,i!==null&&r.stateNode!=null)Xm(i,r,c,d,g),i.ref!==r.ref&&(r.flags|=512,r.flags|=2097152);else{if(!d){if(r.stateNode===null)throw Error(n(166));return Ln(r),null}if(i=Bs(ki.current),Da(r)){d=r.stateNode,c=r.type;var _=r.memoizedProps;switch(d[xi]=r,d[mo]=_,i=(r.mode&1)!==0,c){case"dialog":$t("cancel",d),$t("close",d);break;case"iframe":case"object":case"embed":$t("load",d);break;case"video":case"audio":for(g=0;g<ho.length;g++)$t(ho[g],d);break;case"source":$t("error",d);break;case"img":case"image":case"link":$t("error",d),$t("load",d);break;case"details":$t("toggle",d);break;case"input":qt(d,_),$t("invalid",d);break;case"select":d._wrapperState={wasMultiple:!!_.multiple},$t("invalid",d);break;case"textarea":kt(d,_),$t("invalid",d)}ft(c,_),g=null;for(var P in _)if(_.hasOwnProperty(P)){var V=_[P];P==="children"?typeof V=="string"?d.textContent!==V&&(_.suppressHydrationWarning!==!0&&Na(d.textContent,V,i),g=["children",V]):typeof V=="number"&&d.textContent!==""+V&&(_.suppressHydrationWarning!==!0&&Na(d.textContent,V,i),g=["children",""+V]):o.hasOwnProperty(P)&&V!=null&&P==="onScroll"&&$t("scroll",d)}switch(c){case"input":st(d),gt(d,_,!0);break;case"textarea":st(d),Lt(d);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(d.onclick=ja)}d=g,r.updateQueue=d,d!==null&&(r.flags|=4)}else{P=g.nodeType===9?g:g.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Ct(c)),i==="http://www.w3.org/1999/xhtml"?c==="script"?(i=P.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof d.is=="string"?i=P.createElement(c,{is:d.is}):(i=P.createElement(c),c==="select"&&(P=i,d.multiple?P.multiple=!0:d.size&&(P.size=d.size))):i=P.createElementNS(i,c),i[xi]=r,i[mo]=d,Gm(i,r,!1,!1),r.stateNode=i;e:{switch(P=Et(c,d),c){case"dialog":$t("cancel",i),$t("close",i),g=d;break;case"iframe":case"object":case"embed":$t("load",i),g=d;break;case"video":case"audio":for(g=0;g<ho.length;g++)$t(ho[g],i);g=d;break;case"source":$t("error",i),g=d;break;case"img":case"image":case"link":$t("error",i),$t("load",i),g=d;break;case"details":$t("toggle",i),g=d;break;case"input":qt(i,d),g=xt(i,d),$t("invalid",i);break;case"option":g=d;break;case"select":i._wrapperState={wasMultiple:!!d.multiple},g=T({},d,{value:void 0}),$t("invalid",i);break;case"textarea":kt(i,d),g=Bt(i,d),$t("invalid",i);break;default:g=d}ft(c,g),V=g;for(_ in V)if(V.hasOwnProperty(_)){var X=V[_];_==="style"?Ue(i,X):_==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&Le(i,X)):_==="children"?typeof X=="string"?(c!=="textarea"||X!=="")&&qe(i,X):typeof X=="number"&&qe(i,""+X):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(o.hasOwnProperty(_)?X!=null&&_==="onScroll"&&$t("scroll",i):X!=null&&z(i,_,X,P))}switch(c){case"input":st(i),gt(i,d,!1);break;case"textarea":st(i),Lt(i);break;case"option":d.value!=null&&i.setAttribute("value",""+de(d.value));break;case"select":i.multiple=!!d.multiple,_=d.value,_!=null?bt(i,!!d.multiple,_,!1):d.defaultValue!=null&&bt(i,!!d.multiple,d.defaultValue,!0);break;default:typeof g.onClick=="function"&&(i.onclick=ja)}switch(c){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 Ln(r),null;case 6:if(i&&r.stateNode!=null)Qm(i,r,i.memoizedProps,d);else{if(typeof d!="string"&&r.stateNode===null)throw Error(n(166));if(c=Bs(wo.current),Bs(ki.current),Da(r)){if(d=r.stateNode,c=r.memoizedProps,d[xi]=r,(_=d.nodeValue!==c)&&(i=Jn,i!==null))switch(i.tag){case 3:Na(d.nodeValue,c,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Na(d.nodeValue,c,(i.mode&1)!==0)}_&&(r.flags|=4)}else d=(c.nodeType===9?c:c.ownerDocument).createTextNode(d),d[xi]=r,r.stateNode=d}return Ln(r),null;case 13:if(Ft(Vt),d=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(Wt&&Zn!==null&&(r.mode&1)!==0&&(r.flags&128)===0)em(),_r(),r.flags|=98560,_=!1;else if(_=Da(r),d!==null&&d.dehydrated!==null){if(i===null){if(!_)throw Error(n(318));if(_=r.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(n(317));_[xi]=r}else _r(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Ln(r),_=!1}else vi!==null&&(Iu(vi),vi=null),_=!0;if(!_)return r.flags&65536?r:null}return(r.flags&128)!==0?(r.lanes=c,r):(d=d!==null,d!==(i!==null&&i.memoizedState!==null)&&d&&(r.child.flags|=8192,(r.mode&1)!==0&&(i===null||(Vt.current&1)!==0?hn===0&&(hn=3):zu())),r.updateQueue!==null&&(r.flags|=4),Ln(r),null);case 4:return Sr(),Cu(i,r),i===null&&fo(r.stateNode.containerInfo),Ln(r),null;case 10:return Zc(r.type._context),Ln(r),null;case 17:return Kn(r.type)&&Pa(),Ln(r),null;case 19:if(Ft(Vt),_=r.memoizedState,_===null)return Ln(r),null;if(d=(r.flags&128)!==0,P=_.rendering,P===null)if(d)Co(_,!1);else{if(hn!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(P=Fa(i),P!==null){for(r.flags|=128,Co(_,!1),d=P.updateQueue,d!==null&&(r.updateQueue=d,r.flags|=4),r.subtreeFlags=0,d=c,c=r.child;c!==null;)_=c,i=d,_.flags&=14680066,P=_.alternate,P===null?(_.childLanes=0,_.lanes=i,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=P.childLanes,_.lanes=P.lanes,_.child=P.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=P.memoizedProps,_.memoizedState=P.memoizedState,_.updateQueue=P.updateQueue,_.type=P.type,i=P.dependencies,_.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),c=c.sibling;return It(Vt,Vt.current&1|2),r.child}i=i.sibling}_.tail!==null&&Ut()>Er&&(r.flags|=128,d=!0,Co(_,!1),r.lanes=4194304)}else{if(!d)if(i=Fa(P),i!==null){if(r.flags|=128,d=!0,c=i.updateQueue,c!==null&&(r.updateQueue=c,r.flags|=4),Co(_,!0),_.tail===null&&_.tailMode==="hidden"&&!P.alternate&&!Wt)return Ln(r),null}else 2*Ut()-_.renderingStartTime>Er&&c!==1073741824&&(r.flags|=128,d=!0,Co(_,!1),r.lanes=4194304);_.isBackwards?(P.sibling=r.child,r.child=P):(c=_.last,c!==null?c.sibling=P:r.child=P,_.last=P)}return _.tail!==null?(r=_.tail,_.rendering=r,_.tail=r.sibling,_.renderingStartTime=Ut(),r.sibling=null,c=Vt.current,It(Vt,d?c&1|2:c&1),r):(Ln(r),null);case 22:case 23:return Bu(),d=r.memoizedState!==null,i!==null&&i.memoizedState!==null!==d&&(r.flags|=8192),d&&(r.mode&1)!==0?(ei&1073741824)!==0&&(Ln(r),r.subtreeFlags&6&&(r.flags|=8192)):Ln(r),null;case 24:return null;case 25:return null}throw Error(n(156,r.tag))}function o0(i,r){switch(Vc(r),r.tag){case 1:return Kn(r.type)&&Pa(),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return Sr(),Ft(Wn),Ft(Pn),ou(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 5:return su(r),null;case 13:if(Ft(Vt),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(n(340));_r()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return Ft(Vt),null;case 4:return Sr(),null;case 10:return Zc(r.type._context),null;case 22:case 23:return Bu(),null;case 24:return null;default:return null}}var Xa=!1,Tn=!1,a0=typeof WeakSet=="function"?WeakSet:Set,Be=null;function kr(i,r){var c=i.ref;if(c!==null)if(typeof c=="function")try{c(null)}catch(d){Jt(i,r,d)}else c.current=null}function Eu(i,r,c){try{c()}catch(d){Jt(i,r,d)}}var Jm=!1;function l0(i,r){if(Bc=ga,i=Pp(),Pc(i)){if("selectionStart"in i)var c={start:i.selectionStart,end:i.selectionEnd};else e:{c=(c=i.ownerDocument)&&c.defaultView||window;var d=c.getSelection&&c.getSelection();if(d&&d.rangeCount!==0){c=d.anchorNode;var g=d.anchorOffset,_=d.focusNode;d=d.focusOffset;try{c.nodeType,_.nodeType}catch{c=null;break e}var P=0,V=-1,X=-1,ue=0,Se=0,ke=i,be=null;t:for(;;){for(var Ie;ke!==c||g!==0&&ke.nodeType!==3||(V=P+g),ke!==_||d!==0&&ke.nodeType!==3||(X=P+d),ke.nodeType===3&&(P+=ke.nodeValue.length),(Ie=ke.firstChild)!==null;)be=ke,ke=Ie;for(;;){if(ke===i)break t;if(be===c&&++ue===g&&(V=P),be===_&&++Se===d&&(X=P),(Ie=ke.nextSibling)!==null)break;ke=be,be=ke.parentNode}ke=Ie}c=V===-1||X===-1?null:{start:V,end:X}}else c=null}c=c||{start:0,end:0}}else c=null;for(zc={focusedElem:i,selectionRange:c},ga=!1,Be=r;Be!==null;)if(r=Be,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,Be=i;else for(;Be!==null;){r=Be;try{var $e=r.alternate;if((r.flags&1024)!==0)switch(r.tag){case 0:case 11:case 15:break;case 1:if($e!==null){var Fe=$e.memoizedProps,sn=$e.memoizedState,oe=r.stateNode,ne=oe.getSnapshotBeforeUpdate(r.elementType===r.type?Fe:_i(r.type,Fe),sn);oe.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var ae=r.stateNode.containerInfo;ae.nodeType===1?ae.textContent="":ae.nodeType===9&&ae.documentElement&&ae.removeChild(ae.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ne){Jt(r,r.return,Ne)}if(i=r.sibling,i!==null){i.return=r.return,Be=i;break}Be=r.return}return $e=Jm,Jm=!1,$e}function Eo(i,r,c){var d=r.updateQueue;if(d=d!==null?d.lastEffect:null,d!==null){var g=d=d.next;do{if((g.tag&i)===i){var _=g.destroy;g.destroy=void 0,_!==void 0&&Eu(r,c,_)}g=g.next}while(g!==d)}}function Qa(i,r){if(r=r.updateQueue,r=r!==null?r.lastEffect:null,r!==null){var c=r=r.next;do{if((c.tag&i)===i){var d=c.create;c.destroy=d()}c=c.next}while(c!==r)}}function Nu(i){var r=i.ref;if(r!==null){var c=i.stateNode;switch(i.tag){case 5:i=c;break;default:i=c}typeof r=="function"?r(i):r.current=i}}function Zm(i){var r=i.alternate;r!==null&&(i.alternate=null,Zm(r)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(r=i.stateNode,r!==null&&(delete r[xi],delete r[mo],delete r[Uc],delete r[WS],delete r[KS])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function eg(i){return i.tag===5||i.tag===3||i.tag===4}function tg(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||eg(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function ju(i,r,c){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?c.nodeType===8?c.parentNode.insertBefore(i,r):c.insertBefore(i,r):(c.nodeType===8?(r=c.parentNode,r.insertBefore(i,c)):(r=c,r.appendChild(i)),c=c._reactRootContainer,c!=null||r.onclick!==null||(r.onclick=ja));else if(d!==4&&(i=i.child,i!==null))for(ju(i,r,c),i=i.sibling;i!==null;)ju(i,r,c),i=i.sibling}function Ru(i,r,c){var d=i.tag;if(d===5||d===6)i=i.stateNode,r?c.insertBefore(i,r):c.appendChild(i);else if(d!==4&&(i=i.child,i!==null))for(Ru(i,r,c),i=i.sibling;i!==null;)Ru(i,r,c),i=i.sibling}var En=null,yi=!1;function fs(i,r,c){for(c=c.child;c!==null;)ng(i,r,c),c=c.sibling}function ng(i,r,c){if(vn&&typeof vn.onCommitFiberUnmount=="function")try{vn.onCommitFiberUnmount(an,c)}catch{}switch(c.tag){case 5:Tn||kr(c,r);case 6:var d=En,g=yi;En=null,fs(i,r,c),En=d,yi=g,En!==null&&(yi?(i=En,c=c.stateNode,i.nodeType===8?i.parentNode.removeChild(c):i.removeChild(c)):En.removeChild(c.stateNode));break;case 18:En!==null&&(yi?(i=En,c=c.stateNode,i.nodeType===8?Hc(i.parentNode,c):i.nodeType===1&&Hc(i,c),io(i)):Hc(En,c.stateNode));break;case 4:d=En,g=yi,En=c.stateNode.containerInfo,yi=!0,fs(i,r,c),En=d,yi=g;break;case 0:case 11:case 14:case 15:if(!Tn&&(d=c.updateQueue,d!==null&&(d=d.lastEffect,d!==null))){g=d=d.next;do{var _=g,P=_.destroy;_=_.tag,P!==void 0&&((_&2)!==0||(_&4)!==0)&&Eu(c,r,P),g=g.next}while(g!==d)}fs(i,r,c);break;case 1:if(!Tn&&(kr(c,r),d=c.stateNode,typeof d.componentWillUnmount=="function"))try{d.props=c.memoizedProps,d.state=c.memoizedState,d.componentWillUnmount()}catch(V){Jt(c,r,V)}fs(i,r,c);break;case 21:fs(i,r,c);break;case 22:c.mode&1?(Tn=(d=Tn)||c.memoizedState!==null,fs(i,r,c),Tn=d):fs(i,r,c);break;default:fs(i,r,c)}}function ig(i){var r=i.updateQueue;if(r!==null){i.updateQueue=null;var c=i.stateNode;c===null&&(c=i.stateNode=new a0),r.forEach(function(d){var g=v0.bind(null,i,d);c.has(d)||(c.add(d),d.then(g,g))})}}function wi(i,r){var c=r.deletions;if(c!==null)for(var d=0;d<c.length;d++){var g=c[d];try{var _=i,P=r,V=P;e:for(;V!==null;){switch(V.tag){case 5:En=V.stateNode,yi=!1;break e;case 3:En=V.stateNode.containerInfo,yi=!0;break e;case 4:En=V.stateNode.containerInfo,yi=!0;break e}V=V.return}if(En===null)throw Error(n(160));ng(_,P,g),En=null,yi=!1;var X=g.alternate;X!==null&&(X.return=null),g.return=null}catch(ue){Jt(g,r,ue)}}if(r.subtreeFlags&12854)for(r=r.child;r!==null;)sg(r,i),r=r.sibling}function sg(i,r){var c=i.alternate,d=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(wi(r,i),Ei(i),d&4){try{Eo(3,i,i.return),Qa(3,i)}catch(Fe){Jt(i,i.return,Fe)}try{Eo(5,i,i.return)}catch(Fe){Jt(i,i.return,Fe)}}break;case 1:wi(r,i),Ei(i),d&512&&c!==null&&kr(c,c.return);break;case 5:if(wi(r,i),Ei(i),d&512&&c!==null&&kr(c,c.return),i.flags&32){var g=i.stateNode;try{qe(g,"")}catch(Fe){Jt(i,i.return,Fe)}}if(d&4&&(g=i.stateNode,g!=null)){var _=i.memoizedProps,P=c!==null?c.memoizedProps:_,V=i.type,X=i.updateQueue;if(i.updateQueue=null,X!==null)try{V==="input"&&_.type==="radio"&&_.name!=null&&ze(g,_),Et(V,P);var ue=Et(V,_);for(P=0;P<X.length;P+=2){var Se=X[P],ke=X[P+1];Se==="style"?Ue(g,ke):Se==="dangerouslySetInnerHTML"?Le(g,ke):Se==="children"?qe(g,ke):z(g,Se,ke,ue)}switch(V){case"input":Rt(g,_);break;case"textarea":Dt(g,_);break;case"select":var be=g._wrapperState.wasMultiple;g._wrapperState.wasMultiple=!!_.multiple;var Ie=_.value;Ie!=null?bt(g,!!_.multiple,Ie,!1):be!==!!_.multiple&&(_.defaultValue!=null?bt(g,!!_.multiple,_.defaultValue,!0):bt(g,!!_.multiple,_.multiple?[]:"",!1))}g[mo]=_}catch(Fe){Jt(i,i.return,Fe)}}break;case 6:if(wi(r,i),Ei(i),d&4){if(i.stateNode===null)throw Error(n(162));g=i.stateNode,_=i.memoizedProps;try{g.nodeValue=_}catch(Fe){Jt(i,i.return,Fe)}}break;case 3:if(wi(r,i),Ei(i),d&4&&c!==null&&c.memoizedState.isDehydrated)try{io(r.containerInfo)}catch(Fe){Jt(i,i.return,Fe)}break;case 4:wi(r,i),Ei(i);break;case 13:wi(r,i),Ei(i),g=i.child,g.flags&8192&&(_=g.memoizedState!==null,g.stateNode.isHidden=_,!_||g.alternate!==null&&g.alternate.memoizedState!==null||(Lu=Ut())),d&4&&ig(i);break;case 22:if(Se=c!==null&&c.memoizedState!==null,i.mode&1?(Tn=(ue=Tn)||Se,wi(r,i),Tn=ue):wi(r,i),Ei(i),d&8192){if(ue=i.memoizedState!==null,(i.stateNode.isHidden=ue)&&!Se&&(i.mode&1)!==0)for(Be=i,Se=i.child;Se!==null;){for(ke=Be=Se;Be!==null;){switch(be=Be,Ie=be.child,be.tag){case 0:case 11:case 14:case 15:Eo(4,be,be.return);break;case 1:kr(be,be.return);var $e=be.stateNode;if(typeof $e.componentWillUnmount=="function"){d=be,c=be.return;try{r=d,$e.props=r.memoizedProps,$e.state=r.memoizedState,$e.componentWillUnmount()}catch(Fe){Jt(d,c,Fe)}}break;case 5:kr(be,be.return);break;case 22:if(be.memoizedState!==null){ag(ke);continue}}Ie!==null?(Ie.return=be,Be=Ie):ag(ke)}Se=Se.sibling}e:for(Se=null,ke=i;;){if(ke.tag===5){if(Se===null){Se=ke;try{g=ke.stateNode,ue?(_=g.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(V=ke.stateNode,X=ke.memoizedProps.style,P=X!=null&&X.hasOwnProperty("display")?X.display:null,V.style.display=Ce("display",P))}catch(Fe){Jt(i,i.return,Fe)}}}else if(ke.tag===6){if(Se===null)try{ke.stateNode.nodeValue=ue?"":ke.memoizedProps}catch(Fe){Jt(i,i.return,Fe)}}else if((ke.tag!==22&&ke.tag!==23||ke.memoizedState===null||ke===i)&&ke.child!==null){ke.child.return=ke,ke=ke.child;continue}if(ke===i)break e;for(;ke.sibling===null;){if(ke.return===null||ke.return===i)break e;Se===ke&&(Se=null),ke=ke.return}Se===ke&&(Se=null),ke.sibling.return=ke.return,ke=ke.sibling}}break;case 19:wi(r,i),Ei(i),d&4&&ig(i);break;case 21:break;default:wi(r,i),Ei(i)}}function Ei(i){var r=i.flags;if(r&2){try{e:{for(var c=i.return;c!==null;){if(eg(c)){var d=c;break e}c=c.return}throw Error(n(160))}switch(d.tag){case 5:var g=d.stateNode;d.flags&32&&(qe(g,""),d.flags&=-33);var _=tg(i);Ru(i,_,g);break;case 3:case 4:var P=d.stateNode.containerInfo,V=tg(i);ju(i,V,P);break;default:throw Error(n(161))}}catch(X){Jt(i,i.return,X)}i.flags&=-3}r&4096&&(i.flags&=-4097)}function c0(i,r,c){Be=i,rg(i)}function rg(i,r,c){for(var d=(i.mode&1)!==0;Be!==null;){var g=Be,_=g.child;if(g.tag===22&&d){var P=g.memoizedState!==null||Xa;if(!P){var V=g.alternate,X=V!==null&&V.memoizedState!==null||Tn;V=Xa;var ue=Tn;if(Xa=P,(Tn=X)&&!ue)for(Be=g;Be!==null;)P=Be,X=P.child,P.tag===22&&P.memoizedState!==null?lg(g):X!==null?(X.return=P,Be=X):lg(g);for(;_!==null;)Be=_,rg(_),_=_.sibling;Be=g,Xa=V,Tn=ue}og(i)}else(g.subtreeFlags&8772)!==0&&_!==null?(_.return=g,Be=_):og(i)}}function og(i){for(;Be!==null;){var r=Be;if((r.flags&8772)!==0){var c=r.alternate;try{if((r.flags&8772)!==0)switch(r.tag){case 0:case 11:case 15:Tn||Qa(5,r);break;case 1:var d=r.stateNode;if(r.flags&4&&!Tn)if(c===null)d.componentDidMount();else{var g=r.elementType===r.type?c.memoizedProps:_i(r.type,c.memoizedProps);d.componentDidUpdate(g,c.memoizedState,d.__reactInternalSnapshotBeforeUpdate)}var _=r.updateQueue;_!==null&&am(r,_,d);break;case 3:var P=r.updateQueue;if(P!==null){if(c=null,r.child!==null)switch(r.child.tag){case 5:c=r.child.stateNode;break;case 1:c=r.child.stateNode}am(r,P,c)}break;case 5:var V=r.stateNode;if(c===null&&r.flags&4){c=V;var X=r.memoizedProps;switch(r.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&c.focus();break;case"img":X.src&&(c.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(r.memoizedState===null){var ue=r.alternate;if(ue!==null){var Se=ue.memoizedState;if(Se!==null){var ke=Se.dehydrated;ke!==null&&io(ke)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Tn||r.flags&512&&Nu(r)}catch(be){Jt(r,r.return,be)}}if(r===i){Be=null;break}if(c=r.sibling,c!==null){c.return=r.return,Be=c;break}Be=r.return}}function ag(i){for(;Be!==null;){var r=Be;if(r===i){Be=null;break}var c=r.sibling;if(c!==null){c.return=r.return,Be=c;break}Be=r.return}}function lg(i){for(;Be!==null;){var r=Be;try{switch(r.tag){case 0:case 11:case 15:var c=r.return;try{Qa(4,r)}catch(X){Jt(r,c,X)}break;case 1:var d=r.stateNode;if(typeof d.componentDidMount=="function"){var g=r.return;try{d.componentDidMount()}catch(X){Jt(r,g,X)}}var _=r.return;try{Nu(r)}catch(X){Jt(r,_,X)}break;case 5:var P=r.return;try{Nu(r)}catch(X){Jt(r,P,X)}}}catch(X){Jt(r,r.return,X)}if(r===i){Be=null;break}var V=r.sibling;if(V!==null){V.return=r.return,Be=V;break}Be=r.return}}var u0=Math.ceil,Ja=D.ReactCurrentDispatcher,Pu=D.ReactCurrentOwner,ui=D.ReactCurrentBatchConfig,_t=0,yn=null,ln=null,Nn=0,ei=0,Cr=ls(0),hn=0,No=null,$s=0,Za=0,Au=0,jo=null,Vn=null,Lu=0,Er=1/0,Vi=null,el=!1,Tu=null,ps=null,tl=!1,ms=null,nl=0,Ro=0,Mu=null,il=-1,sl=0;function Bn(){return(_t&6)!==0?Ut():il!==-1?il:il=Ut()}function gs(i){return(i.mode&1)===0?1:(_t&2)!==0&&Nn!==0?Nn&-Nn:VS.transition!==null?(sl===0&&(sl=tp()),sl):(i=jt,i!==0||(i=window.event,i=i===void 0?16:up(i.type)),i)}function bi(i,r,c,d){if(50<Ro)throw Ro=0,Mu=null,Error(n(185));Jr(i,c,d),((_t&2)===0||i!==yn)&&(i===yn&&((_t&2)===0&&(Za|=c),hn===4&&vs(i,Nn)),Yn(i,d),c===1&&_t===0&&(r.mode&1)===0&&(Er=Ut()+500,La&&us()))}function Yn(i,r){var c=i.callbackNode;Vb(i,r);var d=fa(i,i===yn?Nn:0);if(d===0)c!==null&&Gr(c),i.callbackNode=null,i.callbackPriority=0;else if(r=d&-d,i.callbackPriority!==r){if(c!=null&&Gr(c),r===1)i.tag===0?qS(ug.bind(null,i)):Gp(ug.bind(null,i)),HS(function(){(_t&6)===0&&us()}),c=null;else{switch(np(d)){case 1:c=Ke;break;case 4:c=et;break;case 16:c=Ze;break;case 536870912:c=zt;break;default:c=Ze}c=_g(c,cg.bind(null,i))}i.callbackPriority=r,i.callbackNode=c}}function cg(i,r){if(il=-1,sl=0,(_t&6)!==0)throw Error(n(327));var c=i.callbackNode;if(Nr()&&i.callbackNode!==c)return null;var d=fa(i,i===yn?Nn:0);if(d===0)return null;if((d&30)!==0||(d&i.expiredLanes)!==0||r)r=rl(i,d);else{r=d;var g=_t;_t|=2;var _=hg();(yn!==i||Nn!==r)&&(Vi=null,Er=Ut()+500,Hs(i,r));do try{f0();break}catch(V){dg(i,V)}while(!0);Jc(),Ja.current=_,_t=g,ln!==null?r=0:(yn=null,Nn=0,r=hn)}if(r!==0){if(r===2&&(g=pc(i),g!==0&&(d=g,r=Du(i,g))),r===1)throw c=No,Hs(i,0),vs(i,d),Yn(i,Ut()),c;if(r===6)vs(i,d);else{if(g=i.current.alternate,(d&30)===0&&!d0(g)&&(r=rl(i,d),r===2&&(_=pc(i),_!==0&&(d=_,r=Du(i,_))),r===1))throw c=No,Hs(i,0),vs(i,d),Yn(i,Ut()),c;switch(i.finishedWork=g,i.finishedLanes=d,r){case 0:case 1:throw Error(n(345));case 2:Us(i,Vn,Vi);break;case 3:if(vs(i,d),(d&130023424)===d&&(r=Lu+500-Ut(),10<r)){if(fa(i,0)!==0)break;if(g=i.suspendedLanes,(g&d)!==d){Bn(),i.pingedLanes|=i.suspendedLanes&g;break}i.timeoutHandle=Fc(Us.bind(null,i,Vn,Vi),r);break}Us(i,Vn,Vi);break;case 4:if(vs(i,d),(d&4194240)===d)break;for(r=i.eventTimes,g=-1;0<d;){var P=31-Un(d);_=1<<P,P=r[P],P>g&&(g=P),d&=~_}if(d=g,d=Ut()-d,d=(120>d?120:480>d?480:1080>d?1080:1920>d?1920:3e3>d?3e3:4320>d?4320:1960*u0(d/1960))-d,10<d){i.timeoutHandle=Fc(Us.bind(null,i,Vn,Vi),d);break}Us(i,Vn,Vi);break;case 5:Us(i,Vn,Vi);break;default:throw Error(n(329))}}}return Yn(i,Ut()),i.callbackNode===c?cg.bind(null,i):null}function Du(i,r){var c=jo;return i.current.memoizedState.isDehydrated&&(Hs(i,r).flags|=256),i=rl(i,r),i!==2&&(r=Vn,Vn=c,r!==null&&Iu(r)),i}function Iu(i){Vn===null?Vn=i:Vn.push.apply(Vn,i)}function d0(i){for(var r=i;;){if(r.flags&16384){var c=r.updateQueue;if(c!==null&&(c=c.stores,c!==null))for(var d=0;d<c.length;d++){var g=c[d],_=g.getSnapshot;g=g.value;try{if(!gi(_(),g))return!1}catch{return!1}}}if(c=r.child,r.subtreeFlags&16384&&c!==null)c.return=r,r=c;else{if(r===i)break;for(;r.sibling===null;){if(r.return===null||r.return===i)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function vs(i,r){for(r&=~Au,r&=~Za,i.suspendedLanes|=r,i.pingedLanes&=~r,i=i.expirationTimes;0<r;){var c=31-Un(r),d=1<<c;i[c]=-1,r&=~d}}function ug(i){if((_t&6)!==0)throw Error(n(327));Nr();var r=fa(i,0);if((r&1)===0)return Yn(i,Ut()),null;var c=rl(i,r);if(i.tag!==0&&c===2){var d=pc(i);d!==0&&(r=d,c=Du(i,d))}if(c===1)throw c=No,Hs(i,0),vs(i,r),Yn(i,Ut()),c;if(c===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=r,Us(i,Vn,Vi),Yn(i,Ut()),null}function Ou(i,r){var c=_t;_t|=1;try{return i(r)}finally{_t=c,_t===0&&(Er=Ut()+500,La&&us())}}function Fs(i){ms!==null&&ms.tag===0&&(_t&6)===0&&Nr();var r=_t;_t|=1;var c=ui.transition,d=jt;try{if(ui.transition=null,jt=1,i)return i()}finally{jt=d,ui.transition=c,_t=r,(_t&6)===0&&us()}}function Bu(){ei=Cr.current,Ft(Cr)}function Hs(i,r){i.finishedWork=null,i.finishedLanes=0;var c=i.timeoutHandle;if(c!==-1&&(i.timeoutHandle=-1,FS(c)),ln!==null)for(c=ln.return;c!==null;){var d=c;switch(Vc(d),d.tag){case 1:d=d.type.childContextTypes,d!=null&&Pa();break;case 3:Sr(),Ft(Wn),Ft(Pn),ou();break;case 5:su(d);break;case 4:Sr();break;case 13:Ft(Vt);break;case 19:Ft(Vt);break;case 10:Zc(d.type._context);break;case 22:case 23:Bu()}c=c.return}if(yn=i,ln=i=_s(i.current,null),Nn=ei=r,hn=0,No=null,Au=Za=$s=0,Vn=jo=null,Os!==null){for(r=0;r<Os.length;r++)if(c=Os[r],d=c.interleaved,d!==null){c.interleaved=null;var g=d.next,_=c.pending;if(_!==null){var P=_.next;_.next=g,d.next=P}c.pending=d}Os=null}return i}function dg(i,r){do{var c=ln;try{if(Jc(),Ha.current=qa,Ua){for(var d=Yt.memoizedState;d!==null;){var g=d.queue;g!==null&&(g.pending=null),d=d.next}Ua=!1}if(zs=0,_n=dn=Yt=null,bo=!1,So=0,Pu.current=null,c===null||c.return===null){hn=1,No=r,ln=null;break}e:{var _=i,P=c.return,V=c,X=r;if(r=Nn,V.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var ue=X,Se=V,ke=Se.tag;if((Se.mode&1)===0&&(ke===0||ke===11||ke===15)){var be=Se.alternate;be?(Se.updateQueue=be.updateQueue,Se.memoizedState=be.memoizedState,Se.lanes=be.lanes):(Se.updateQueue=null,Se.memoizedState=null)}var Ie=Im(P);if(Ie!==null){Ie.flags&=-257,Om(Ie,P,V,_,r),Ie.mode&1&&Dm(_,ue,r),r=Ie,X=ue;var $e=r.updateQueue;if($e===null){var Fe=new Set;Fe.add(X),r.updateQueue=Fe}else $e.add(X);break e}else{if((r&1)===0){Dm(_,ue,r),zu();break e}X=Error(n(426))}}else if(Wt&&V.mode&1){var sn=Im(P);if(sn!==null){(sn.flags&65536)===0&&(sn.flags|=256),Om(sn,P,V,_,r),Xc(xr(X,V));break e}}_=X=xr(X,V),hn!==4&&(hn=2),jo===null?jo=[_]:jo.push(_),_=P;do{switch(_.tag){case 3:_.flags|=65536,r&=-r,_.lanes|=r;var oe=Tm(_,X,r);om(_,oe);break e;case 1:V=X;var ne=_.type,ae=_.stateNode;if((_.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||ae!==null&&typeof ae.componentDidCatch=="function"&&(ps===null||!ps.has(ae)))){_.flags|=65536,r&=-r,_.lanes|=r;var Ne=Mm(_,V,r);om(_,Ne);break e}}_=_.return}while(_!==null)}pg(c)}catch(We){r=We,ln===c&&c!==null&&(ln=c=c.return);continue}break}while(!0)}function hg(){var i=Ja.current;return Ja.current=qa,i===null?qa:i}function zu(){(hn===0||hn===3||hn===2)&&(hn=4),yn===null||($s&268435455)===0&&(Za&268435455)===0||vs(yn,Nn)}function rl(i,r){var c=_t;_t|=2;var d=hg();(yn!==i||Nn!==r)&&(Vi=null,Hs(i,r));do try{h0();break}catch(g){dg(i,g)}while(!0);if(Jc(),_t=c,Ja.current=d,ln!==null)throw Error(n(261));return yn=null,Nn=0,hn}function h0(){for(;ln!==null;)fg(ln)}function f0(){for(;ln!==null&&!rr();)fg(ln)}function fg(i){var r=vg(i.alternate,i,ei);i.memoizedProps=i.pendingProps,r===null?pg(i):ln=r,Pu.current=null}function pg(i){var r=i;do{var c=r.alternate;if(i=r.return,(r.flags&32768)===0){if(c=r0(c,r,ei),c!==null){ln=c;return}}else{if(c=o0(c,r),c!==null){c.flags&=32767,ln=c;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{hn=6,ln=null;return}}if(r=r.sibling,r!==null){ln=r;return}ln=r=i}while(r!==null);hn===0&&(hn=5)}function Us(i,r,c){var d=jt,g=ui.transition;try{ui.transition=null,jt=1,p0(i,r,c,d)}finally{ui.transition=g,jt=d}return null}function p0(i,r,c,d){do Nr();while(ms!==null);if((_t&6)!==0)throw Error(n(327));c=i.finishedWork;var g=i.finishedLanes;if(c===null)return null;if(i.finishedWork=null,i.finishedLanes=0,c===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var _=c.lanes|c.childLanes;if(Yb(i,_),i===yn&&(ln=yn=null,Nn=0),(c.subtreeFlags&2064)===0&&(c.flags&2064)===0||tl||(tl=!0,_g(Ze,function(){return Nr(),null})),_=(c.flags&15990)!==0,(c.subtreeFlags&15990)!==0||_){_=ui.transition,ui.transition=null;var P=jt;jt=1;var V=_t;_t|=4,Pu.current=null,l0(i,c),sg(c,i),MS(zc),ga=!!Bc,zc=Bc=null,i.current=c,c0(c),ua(),_t=V,jt=P,ui.transition=_}else i.current=c;if(tl&&(tl=!1,ms=i,nl=g),_=i.pendingLanes,_===0&&(ps=null),fc(c.stateNode),Yn(i,Ut()),r!==null)for(d=i.onRecoverableError,c=0;c<r.length;c++)g=r[c],d(g.value,{componentStack:g.stack,digest:g.digest});if(el)throw el=!1,i=Tu,Tu=null,i;return(nl&1)!==0&&i.tag!==0&&Nr(),_=i.pendingLanes,(_&1)!==0?i===Mu?Ro++:(Ro=0,Mu=i):Ro=0,us(),null}function Nr(){if(ms!==null){var i=np(nl),r=ui.transition,c=jt;try{if(ui.transition=null,jt=16>i?16:i,ms===null)var d=!1;else{if(i=ms,ms=null,nl=0,(_t&6)!==0)throw Error(n(331));var g=_t;for(_t|=4,Be=i.current;Be!==null;){var _=Be,P=_.child;if((Be.flags&16)!==0){var V=_.deletions;if(V!==null){for(var X=0;X<V.length;X++){var ue=V[X];for(Be=ue;Be!==null;){var Se=Be;switch(Se.tag){case 0:case 11:case 15:Eo(8,Se,_)}var ke=Se.child;if(ke!==null)ke.return=Se,Be=ke;else for(;Be!==null;){Se=Be;var be=Se.sibling,Ie=Se.return;if(Zm(Se),Se===ue){Be=null;break}if(be!==null){be.return=Ie,Be=be;break}Be=Ie}}}var $e=_.alternate;if($e!==null){var Fe=$e.child;if(Fe!==null){$e.child=null;do{var sn=Fe.sibling;Fe.sibling=null,Fe=sn}while(Fe!==null)}}Be=_}}if((_.subtreeFlags&2064)!==0&&P!==null)P.return=_,Be=P;else e:for(;Be!==null;){if(_=Be,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:Eo(9,_,_.return)}var oe=_.sibling;if(oe!==null){oe.return=_.return,Be=oe;break e}Be=_.return}}var ne=i.current;for(Be=ne;Be!==null;){P=Be;var ae=P.child;if((P.subtreeFlags&2064)!==0&&ae!==null)ae.return=P,Be=ae;else e:for(P=ne;Be!==null;){if(V=Be,(V.flags&2048)!==0)try{switch(V.tag){case 0:case 11:case 15:Qa(9,V)}}catch(We){Jt(V,V.return,We)}if(V===P){Be=null;break e}var Ne=V.sibling;if(Ne!==null){Ne.return=V.return,Be=Ne;break e}Be=V.return}}if(_t=g,us(),vn&&typeof vn.onPostCommitFiberRoot=="function")try{vn.onPostCommitFiberRoot(an,i)}catch{}d=!0}return d}finally{jt=c,ui.transition=r}}return!1}function mg(i,r,c){r=xr(c,r),r=Tm(i,r,1),i=hs(i,r,1),r=Bn(),i!==null&&(Jr(i,1,r),Yn(i,r))}function Jt(i,r,c){if(i.tag===3)mg(i,i,c);else for(;r!==null;){if(r.tag===3){mg(r,i,c);break}else if(r.tag===1){var d=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(ps===null||!ps.has(d))){i=xr(c,i),i=Mm(r,i,1),r=hs(r,i,1),i=Bn(),r!==null&&(Jr(r,1,i),Yn(r,i));break}}r=r.return}}function m0(i,r,c){var d=i.pingCache;d!==null&&d.delete(r),r=Bn(),i.pingedLanes|=i.suspendedLanes&c,yn===i&&(Nn&c)===c&&(hn===4||hn===3&&(Nn&130023424)===Nn&&500>Ut()-Lu?Hs(i,0):Au|=c),Yn(i,r)}function gg(i,r){r===0&&((i.mode&1)===0?r=1:(r=ha,ha<<=1,(ha&130023424)===0&&(ha=4194304)));var c=Bn();i=Wi(i,r),i!==null&&(Jr(i,r,c),Yn(i,c))}function g0(i){var r=i.memoizedState,c=0;r!==null&&(c=r.retryLane),gg(i,c)}function v0(i,r){var c=0;switch(i.tag){case 13:var d=i.stateNode,g=i.memoizedState;g!==null&&(c=g.retryLane);break;case 19:d=i.stateNode;break;default:throw Error(n(314))}d!==null&&d.delete(r),gg(i,c)}var vg;vg=function(i,r,c){if(i!==null)if(i.memoizedProps!==r.pendingProps||Wn.current)qn=!0;else{if((i.lanes&c)===0&&(r.flags&128)===0)return qn=!1,s0(i,r,c);qn=(i.flags&131072)!==0}else qn=!1,Wt&&(r.flags&1048576)!==0&&Xp(r,Ma,r.index);switch(r.lanes=0,r.tag){case 2:var d=r.type;Ga(i,r),i=r.pendingProps;var g=mr(r,Pn.current);br(r,c),g=cu(null,r,d,i,g,c);var _=uu();return r.flags|=1,typeof g=="object"&&g!==null&&typeof g.render=="function"&&g.$$typeof===void 0?(r.tag=1,r.memoizedState=null,r.updateQueue=null,Kn(d)?(_=!0,Aa(r)):_=!1,r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,nu(r),g.updater=Va,r.stateNode=g,g._reactInternals=r,gu(r,d,i,c),r=wu(null,r,d,!0,_,c)):(r.tag=0,Wt&&_&&qc(r),On(null,r,g,c),r=r.child),r;case 16:d=r.elementType;e:{switch(Ga(i,r),i=r.pendingProps,g=d._init,d=g(d._payload),r.type=d,g=r.tag=y0(d),i=_i(d,i),g){case 0:r=yu(null,r,d,i,c);break e;case 1:r=Um(null,r,d,i,c);break e;case 11:r=Bm(null,r,d,i,c);break e;case 14:r=zm(null,r,d,_i(d.type,i),c);break e}throw Error(n(306,d,""))}return r;case 0:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:_i(d,g),yu(i,r,d,g,c);case 1:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:_i(d,g),Um(i,r,d,g,c);case 3:e:{if(Wm(r),i===null)throw Error(n(387));d=r.pendingProps,_=r.memoizedState,g=_.element,rm(i,r),$a(r,d,null,c);var P=r.memoizedState;if(d=P.element,_.isDehydrated)if(_={element:d,isDehydrated:!1,cache:P.cache,pendingSuspenseBoundaries:P.pendingSuspenseBoundaries,transitions:P.transitions},r.updateQueue.baseState=_,r.memoizedState=_,r.flags&256){g=xr(Error(n(423)),r),r=Km(i,r,d,c,g);break e}else if(d!==g){g=xr(Error(n(424)),r),r=Km(i,r,d,c,g);break e}else for(Zn=as(r.stateNode.containerInfo.firstChild),Jn=r,Wt=!0,vi=null,c=im(r,null,d,c),r.child=c;c;)c.flags=c.flags&-3|4096,c=c.sibling;else{if(_r(),d===g){r=qi(i,r,c);break e}On(i,r,d,c)}r=r.child}return r;case 5:return lm(r),i===null&&Gc(r),d=r.type,g=r.pendingProps,_=i!==null?i.memoizedProps:null,P=g.children,$c(d,g)?P=null:_!==null&&$c(d,_)&&(r.flags|=32),Hm(i,r),On(i,r,P,c),r.child;case 6:return i===null&&Gc(r),null;case 13:return qm(i,r,c);case 4:return iu(r,r.stateNode.containerInfo),d=r.pendingProps,i===null?r.child=yr(r,null,d,c):On(i,r,d,c),r.child;case 11:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:_i(d,g),Bm(i,r,d,g,c);case 7:return On(i,r,r.pendingProps,c),r.child;case 8:return On(i,r,r.pendingProps.children,c),r.child;case 12:return On(i,r,r.pendingProps.children,c),r.child;case 10:e:{if(d=r.type._context,g=r.pendingProps,_=r.memoizedProps,P=g.value,It(Oa,d._currentValue),d._currentValue=P,_!==null)if(gi(_.value,P)){if(_.children===g.children&&!Wn.current){r=qi(i,r,c);break e}}else for(_=r.child,_!==null&&(_.return=r);_!==null;){var V=_.dependencies;if(V!==null){P=_.child;for(var X=V.firstContext;X!==null;){if(X.context===d){if(_.tag===1){X=Ki(-1,c&-c),X.tag=2;var ue=_.updateQueue;if(ue!==null){ue=ue.shared;var Se=ue.pending;Se===null?X.next=X:(X.next=Se.next,Se.next=X),ue.pending=X}}_.lanes|=c,X=_.alternate,X!==null&&(X.lanes|=c),eu(_.return,c,r),V.lanes|=c;break}X=X.next}}else if(_.tag===10)P=_.type===r.type?null:_.child;else if(_.tag===18){if(P=_.return,P===null)throw Error(n(341));P.lanes|=c,V=P.alternate,V!==null&&(V.lanes|=c),eu(P,c,r),P=_.sibling}else P=_.child;if(P!==null)P.return=_;else for(P=_;P!==null;){if(P===r){P=null;break}if(_=P.sibling,_!==null){_.return=P.return,P=_;break}P=P.return}_=P}On(i,r,g.children,c),r=r.child}return r;case 9:return g=r.type,d=r.pendingProps.children,br(r,c),g=li(g),d=d(g),r.flags|=1,On(i,r,d,c),r.child;case 14:return d=r.type,g=_i(d,r.pendingProps),g=_i(d.type,g),zm(i,r,d,g,c);case 15:return $m(i,r,r.type,r.pendingProps,c);case 17:return d=r.type,g=r.pendingProps,g=r.elementType===d?g:_i(d,g),Ga(i,r),r.tag=1,Kn(d)?(i=!0,Aa(r)):i=!1,br(r,c),Am(r,d,g),gu(r,d,g,c),wu(null,r,d,!0,i,c);case 19:return Ym(i,r,c);case 22:return Fm(i,r,c)}throw Error(n(156,r.tag))};function _g(i,r){return zi(i,r)}function _0(i,r,c,d){this.tag=i,this.key=c,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 di(i,r,c,d){return new _0(i,r,c,d)}function $u(i){return i=i.prototype,!(!i||!i.isReactComponent)}function y0(i){if(typeof i=="function")return $u(i)?1:0;if(i!=null){if(i=i.$$typeof,i===F)return 11;if(i===$)return 14}return 2}function _s(i,r){var c=i.alternate;return c===null?(c=di(i.tag,r,i.key,i.mode),c.elementType=i.elementType,c.type=i.type,c.stateNode=i.stateNode,c.alternate=i,i.alternate=c):(c.pendingProps=r,c.type=i.type,c.flags=0,c.subtreeFlags=0,c.deletions=null),c.flags=i.flags&14680064,c.childLanes=i.childLanes,c.lanes=i.lanes,c.child=i.child,c.memoizedProps=i.memoizedProps,c.memoizedState=i.memoizedState,c.updateQueue=i.updateQueue,r=i.dependencies,c.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},c.sibling=i.sibling,c.index=i.index,c.ref=i.ref,c}function ol(i,r,c,d,g,_){var P=2;if(d=i,typeof i=="function")$u(i)&&(P=1);else if(typeof i=="string")P=5;else e:switch(i){case K:return Ws(c.children,g,_,r);case te:P=8,g|=8;break;case G:return i=di(12,c,r,g|2),i.elementType=G,i.lanes=_,i;case R:return i=di(13,c,r,g),i.elementType=R,i.lanes=_,i;case B:return i=di(19,c,r,g),i.elementType=B,i.lanes=_,i;case A:return al(c,g,_,r);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case Q:P=10;break e;case q:P=9;break e;case F:P=11;break e;case $:P=14;break e;case L:P=16,d=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return r=di(P,c,r,g),r.elementType=i,r.type=d,r.lanes=_,r}function Ws(i,r,c,d){return i=di(7,i,d,r),i.lanes=c,i}function al(i,r,c,d){return i=di(22,i,d,r),i.elementType=A,i.lanes=c,i.stateNode={isHidden:!1},i}function Fu(i,r,c){return i=di(6,i,null,r),i.lanes=c,i}function Hu(i,r,c){return r=di(4,i.children!==null?i.children:[],i.key,r),r.lanes=c,r.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},r}function w0(i,r,c,d,g){this.tag=r,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=mc(0),this.expirationTimes=mc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mc(0),this.identifierPrefix=d,this.onRecoverableError=g,this.mutableSourceEagerHydrationData=null}function Uu(i,r,c,d,g,_,P,V,X){return i=new w0(i,r,c,V,X),r===1?(r=1,_===!0&&(r|=8)):r=0,_=di(3,null,null,r),i.current=_,_.stateNode=i,_.memoizedState={element:d,isDehydrated:c,cache:null,transitions:null,pendingSuspenseBoundaries:null},nu(_),i}function b0(i,r,c){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:W,key:d==null?null:""+d,children:i,containerInfo:r,implementation:c}}function yg(i){if(!i)return cs;i=i._reactInternals;e:{if(Xe(i)!==i||i.tag!==1)throw Error(n(170));var r=i;do{switch(r.tag){case 3:r=r.stateNode.context;break e;case 1:if(Kn(r.type)){r=r.stateNode.__reactInternalMemoizedMergedChildContext;break e}}r=r.return}while(r!==null);throw Error(n(171))}if(i.tag===1){var c=i.type;if(Kn(c))return Vp(i,c,r)}return r}function wg(i,r,c,d,g,_,P,V,X){return i=Uu(c,d,!0,i,g,_,P,V,X),i.context=yg(null),c=i.current,d=Bn(),g=gs(c),_=Ki(d,g),_.callback=r??null,hs(c,_,g),i.current.lanes=g,Jr(i,g,d),Yn(i,d),i}function ll(i,r,c,d){var g=r.current,_=Bn(),P=gs(g);return c=yg(c),r.context===null?r.context=c:r.pendingContext=c,r=Ki(_,P),r.payload={element:i},d=d===void 0?null:d,d!==null&&(r.callback=d),i=hs(g,r,P),i!==null&&(bi(i,g,P,_),za(i,g,P)),P}function cl(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function bg(i,r){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var c=i.retryLane;i.retryLane=c!==0&&c<r?c:r}}function Wu(i,r){bg(i,r),(i=i.alternate)&&bg(i,r)}function S0(){return null}var Sg=typeof reportError=="function"?reportError:function(i){console.error(i)};function Ku(i){this._internalRoot=i}ul.prototype.render=Ku.prototype.render=function(i){var r=this._internalRoot;if(r===null)throw Error(n(409));ll(i,r,null,null)},ul.prototype.unmount=Ku.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var r=i.containerInfo;Fs(function(){ll(null,i,null,null)}),r[$i]=null}};function ul(i){this._internalRoot=i}ul.prototype.unstable_scheduleHydration=function(i){if(i){var r=rp();i={blockedOn:null,target:i,priority:r};for(var c=0;c<ss.length&&r!==0&&r<ss[c].priority;c++);ss.splice(c,0,i),c===0&&lp(i)}};function qu(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function dl(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function xg(){}function x0(i,r,c,d,g){if(g){if(typeof d=="function"){var _=d;d=function(){var ue=cl(P);_.call(ue)}}var P=wg(r,d,i,0,null,!1,!1,"",xg);return i._reactRootContainer=P,i[$i]=P.current,fo(i.nodeType===8?i.parentNode:i),Fs(),P}for(;g=i.lastChild;)i.removeChild(g);if(typeof d=="function"){var V=d;d=function(){var ue=cl(X);V.call(ue)}}var X=Uu(i,0,!1,null,null,!1,!1,"",xg);return i._reactRootContainer=X,i[$i]=X.current,fo(i.nodeType===8?i.parentNode:i),Fs(function(){ll(r,X,c,d)}),X}function hl(i,r,c,d,g){var _=c._reactRootContainer;if(_){var P=_;if(typeof g=="function"){var V=g;g=function(){var X=cl(P);V.call(X)}}ll(r,P,i,g)}else P=x0(c,r,i,g,d);return cl(P)}ip=function(i){switch(i.tag){case 3:var r=i.stateNode;if(r.current.memoizedState.isDehydrated){var c=Qr(r.pendingLanes);c!==0&&(gc(r,c|1),Yn(r,Ut()),(_t&6)===0&&(Er=Ut()+500,us()))}break;case 13:Fs(function(){var d=Wi(i,1);if(d!==null){var g=Bn();bi(d,i,1,g)}}),Wu(i,1)}},vc=function(i){if(i.tag===13){var r=Wi(i,134217728);if(r!==null){var c=Bn();bi(r,i,134217728,c)}Wu(i,134217728)}},sp=function(i){if(i.tag===13){var r=gs(i),c=Wi(i,r);if(c!==null){var d=Bn();bi(c,i,r,d)}Wu(i,r)}},rp=function(){return jt},op=function(i,r){var c=jt;try{return jt=i,r()}finally{jt=c}},Z=function(i,r,c){switch(r){case"input":if(Rt(i,c),r=c.name,c.type==="radio"&&r!=null){for(c=i;c.parentNode;)c=c.parentNode;for(c=c.querySelectorAll("input[name="+JSON.stringify(""+r)+'][type="radio"]'),r=0;r<c.length;r++){var d=c[r];if(d!==i&&d.form===i.form){var g=Ra(d);if(!g)throw Error(n(90));lt(d),Rt(d,g)}}}break;case"textarea":Dt(i,c);break;case"select":r=c.value,r!=null&&bt(i,!!c.multiple,r,!1)}},pt=Ou,yt=Fs;var k0={usingClientEntryPoint:!1,Events:[go,fr,Ra,tt,Ye,Ou]},Po={findFiberByHostInstance:Ts,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},C0={bundleType:Po.bundleType,version:Po.version,rendererPackageName:Po.rendererPackageName,rendererConfig:Po.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:D.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=Dn(i),i===null?null:i.stateNode},findFiberByHostInstance:Po.findFiberByHostInstance||S0,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 fl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!fl.isDisabled&&fl.supportsFiber)try{an=fl.inject(C0),vn=fl}catch{}}return Gn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=k0,Gn.createPortal=function(i,r){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!qu(r))throw Error(n(200));return b0(i,r,null,c)},Gn.createRoot=function(i,r){if(!qu(i))throw Error(n(299));var c=!1,d="",g=Sg;return r!=null&&(r.unstable_strictMode===!0&&(c=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onRecoverableError!==void 0&&(g=r.onRecoverableError)),r=Uu(i,1,!1,null,null,c,!1,d,g),i[$i]=r.current,fo(i.nodeType===8?i.parentNode:i),new Ku(r)},Gn.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var r=i._reactInternals;if(r===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=Dn(r),i=i===null?null:i.stateNode,i},Gn.flushSync=function(i){return Fs(i)},Gn.hydrate=function(i,r,c){if(!dl(r))throw Error(n(200));return hl(null,i,r,!0,c)},Gn.hydrateRoot=function(i,r,c){if(!qu(i))throw Error(n(405));var d=c!=null&&c.hydratedSources||null,g=!1,_="",P=Sg;if(c!=null&&(c.unstable_strictMode===!0&&(g=!0),c.identifierPrefix!==void 0&&(_=c.identifierPrefix),c.onRecoverableError!==void 0&&(P=c.onRecoverableError)),r=wg(r,null,i,1,c??null,g,!1,_,P),i[$i]=r.current,fo(i),d)for(i=0;i<d.length;i++)c=d[i],g=c._getVersion,g=g(c._source),r.mutableSourceEagerHydrationData==null?r.mutableSourceEagerHydrationData=[c,g]:r.mutableSourceEagerHydrationData.push(c,g);return new ul(r)},Gn.render=function(i,r,c){if(!dl(r))throw Error(n(200));return hl(null,i,r,!1,c)},Gn.unmountComponentAtNode=function(i){if(!dl(i))throw Error(n(40));return i._reactRootContainer?(Fs(function(){hl(null,null,i,!1,function(){i._reactRootContainer=null,i[$i]=null})}),!0):!1},Gn.unstable_batchedUpdates=Ou,Gn.unstable_renderSubtreeIntoContainer=function(i,r,c,d){if(!dl(c))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return hl(i,r,c,!1,d)},Gn.version="18.3.1-next-f1338f8080-20240426",Gn}var Ag;function M0(){if(Ag)return Gu.exports;Ag=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(),Gu.exports=T0(),Gu.exports}var Lg;function D0(){if(Lg)return pl;Lg=1;var e=M0();return pl.createRoot=e.createRoot,pl.hydrateRoot=e.hydrateRoot,pl}var I0=D0();const O0=nf(I0);function en(e,t,n={}){return fetch(e,{...n,headers:{...n.headers||{},Authorization:`Bearer ${t}`}})}const hy=e=>`nc_seen_${e}`;async function Te(e,t,n={}){const s=await en(e,t,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0}),o=await s.json().catch(()=>({}));if(!s.ok){const a=new Error(o.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=o,a}return o}const Qt=e=>Array.isArray(e)&&e.length?`/api/route/${e.map(encodeURIComponent).join("/")}/_`:"/api",on=(e,t)=>`${Qt(e)}/fleet/${t}`;async function B0(e,t,n,{signal:s}={}){const o=await en(`${Qt(t)}/panel/${encodeURIComponent(n)}/ticket`,e,{method:"POST",signal:s}),a=await o.json().catch(()=>({}));return o.status===200&&a&&typeof a.ticket=="string"?{ok:!0,ticket:a.ticket}:o.status===403&&a&&a.reason==="panel-not-granted"?{ok:!1,cause:"not-granted"}:o.status===403?{ok:!1,cause:"node-refused"}:o.status===404?{ok:!1,cause:"no-panel"}:o.status===401?{ok:!1,cause:"unauthorized"}:{ok:!1,cause:"denied"}}const Ls=(e,t)=>Te(on(t,"status"),e),rf=(e,t,n)=>Te(on(n,"up"),e,{method:"POST",body:t}),Ol=(e,t,n)=>Te(on(n,"down"),e,{method:"POST",body:t}),fy=(e,t,n)=>Te(on(n,"boot"),e,{method:"POST",body:t}),Fo=(e,t,n)=>Te(on(n,"restart"),e,{method:"POST",body:{cell:t}}),ec=(e,t)=>Te(on(t,"definitions"),e),z0=(e,t)=>Te(on(t,"credentials/status"),e),Tg=(e,t,n,s)=>Te(on(s,"credentials/set"),e,{method:"POST",body:{envKey:t,value:n}}),$0=(e,t,n)=>Te(on(n,"credentials/remove"),e,{method:"POST",body:{envKey:t}}),F0=(e,t,n)=>Te(on(n,"define-engine"),e,{method:"POST",body:{def:t}}),H0=(e,t,n,s,o)=>Te(on(o,"edit-engine"),e,{method:"POST",body:{id:t,patch:n,envChanges:s}}),U0=(e,t,n)=>Te(on(n,"remove-engine"),e,{method:"POST",body:{id:t}}),W0=(e,t,n)=>Te(on(n,"define-model"),e,{method:"POST",body:{def:t}}),K0=(e,t,n,s)=>Te(on(s,"remove-model"),e,{method:"POST",body:{id:t,engine:n}}),q0=(e,t,n,s)=>Te(on(s,"model-test"),e,{method:"POST",body:{engine:t,model:n}}),V0=(e,t,n)=>Te(on(n,"define-cell"),e,{method:"POST",body:{def:t}}),py=(e,t,n,s)=>Te(on(s,"edit-cell"),e,{method:"POST",body:{id:t,patch:n}}),my=(e,t,n=!1,s)=>Te(on(s,"remove-cell"),e,{method:"POST",body:{id:t,stop:n}}),Y0=(e,t,n)=>Te(on(n,"import-cell"),e,{method:"POST",body:t}),G0=(e,t,n)=>Te(on(n,"restore-cells"),e,{method:"POST",body:{cells:t}}),X0=(e,t,n,s,o)=>Te(on(s,"restore-engines"),e,{method:"POST",body:{engines:t,overwrite:!!n,...Array.isArray(o)&&o.length?{models:o}:{}}}),of=(e,t,n)=>Te(`${Qt(n)}/sessions/${encodeURIComponent(t)}`,e,{method:"DELETE"}),gy=(e,t,n,s)=>Te(`${Qt(s)}/sessions/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{technical:!!n}}),af=(e,t,n)=>Te(`${Qt(n)}/fs/dirs${t?`?path=${encodeURIComponent(t)}`:""}`,e),vy=e=>Te("/api/settings",e),Q0=e=>Te("/api/nodes",e),J0=e=>Te("/api/peers",e),_y=(e,t=[])=>Te(`${Qt(t)}/vl-nodes`,e),Mg=(e,t,n,s={},o=[])=>Te(`${Qt(o)}/vl-nodes/${encodeURIComponent(t)}/commands`,e,{method:"POST",body:{kind:n,args:s}}),Z0=(e,t,n=0,s=[])=>Te(`${Qt(s)}/vl-nodes/${encodeURIComponent(t)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,e),yy=e=>Te("/api/topology",e),lf=(e,t)=>Te(`${Qt(t)}/sessions`,e),cf=(e,t)=>Te(`${Qt(t)}/config`,e),Dg=(e,t)=>Te(`${Qt(t)}/topology`,e),Yd=(e,t)=>Te("/api/settings/config",e,{method:"POST",body:t}),ex=e=>Te("/api/settings/token/rotate",e,{method:"POST"}),tx=(e,t)=>Te("/api/settings/nodes/pair",e,{method:"POST",body:t}),nx=(e,t,n=[])=>Te(`${Qt(n)}/settings/peering/invite`,e,{method:"POST",body:t||{}}),wy=(e,t,n)=>Te(`/api/settings/nodes/${encodeURIComponent(t)}/label`,e,{method:"PATCH",body:{label:n}}),ix=e=>Te("/api/settings/node-aliases",e),sx=(e,t,n)=>Te(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{alias:n}}),Ig=(e,t)=>Te(`/api/settings/node-aliases/${encodeURIComponent(t)}`,e,{method:"DELETE"}),Og=(e,t,n)=>Te(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"PATCH",body:n}),rx=(e,t)=>Te(`/api/settings/nodes/${encodeURIComponent(t)}`,e,{method:"DELETE"}),uf=(e,t,n)=>Te(`/api/settings/nodes/${encodeURIComponent(t)}/${n}`,e,{method:"POST"}),ox=(e,t,n)=>Te(`/api/settings/nodes/${encodeURIComponent(t)}/share`,e,{method:"PATCH",body:{shared:n}}),ax=(e,t,n,s=[])=>Te(`/api/settings/nodes/${encodeURIComponent(t)}/visibility`,e,{method:"PATCH",body:{visibility:n,selected:s}}),lx=e=>Te("/api/settings/audio",e),cx=(e,t)=>Te("/api/settings/audio/consent",e,{method:"PATCH",body:{consent:t}}),ux=e=>Te("/api/settings/audio/test",e,{method:"POST",body:{}}),dx=e=>Te("/api/settings/audio/stop",e,{method:"POST",body:{}}),hx=e=>Te("/api/settings/audio/groups",e),fx=(e,t,n)=>Te(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"PUT",body:n}),px=(e,t)=>Te(`/api/settings/audio/groups/${encodeURIComponent(t)}`,e,{method:"DELETE"}),mx=e=>Te("/api/settings/service/regenerate",e,{method:"POST"}),gx=e=>Te("/api/settings/update/check",e,{method:"POST"}),vx=e=>Te("/api/settings/update/apply",e,{method:"POST"}),tc=(e,t)=>`${Qt(e)}/diagnostics/${t}`,_x=(e,t=[])=>Te(tc(t,"status"),e),yx=(e,{after:t=0,limit:n=200}={},s=[])=>Te(`${tc(s,"logs")}?after=${encodeURIComponent(t)}&limit=${encodeURIComponent(n)}`,e),Bg=(e,t,n,s=[])=>Te(tc(s,"verbose"),e,{method:"PATCH",body:{enabled:t,durationSeconds:n}}),wx=(e,t=[])=>Te(tc(t,"logs"),e,{method:"DELETE"}),bx=(e,t=!0)=>Te(`/api/asks${t?"?open=1":""}`,e),Sx=(e,t,n)=>Te(`/api/asks/${encodeURIComponent(t)}/answer`,e,{method:"POST",body:{text:n}}),xx=(e,t)=>Te(`/api/asks/${encodeURIComponent(t)}`,e,{method:"DELETE"}),ml=(e,t=[])=>Te(`${Qt(t)}/decks`,e),zg=(e,t,n=[])=>Te(`${Qt(n)}/decks`,e,{method:"POST",body:{name:t}}),gl=(e,t,n,s,o=[])=>Te(`${Qt(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PUT",body:{layout:n,expectedRevision:s}}),kx=(e,t,n,s,o=[])=>Te(`${Qt(o)}/decks/${encodeURIComponent(t)}`,e,{method:"PATCH",body:{name:n,expectedRevision:s}}),Cx=(e,t,n,s=[])=>Te(`${Qt(s)}/decks/${encodeURIComponent(t)}`,e,{method:"DELETE",body:{expectedRevision:n}}),Ex=(e,t=[])=>Te(`${Qt(t)}/live-host`,e),Nx=(e,t,n,s=[])=>Te(`${Qt(s)}/live-host/designate`,e,{method:"POST",body:{cellId:t,expectedRevision:n}}),jx=(e,t,n=[])=>Te(`${Qt(n)}/live-host/clear`,e,{method:"POST",body:{expectedRevision:t}}),Rx={power:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M12 3v8"}),l.jsx("path",{d:"M6.6 6.6a8 8 0 1 0 10.8 0"})]}),folder:l.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:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"6",width:"18",height:"12",rx:"2"}),l.jsx("path",{d:"M7 10h.01M11 10h.01M15 10h.01M17 14h.01M7 14h7"})]}),mic:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),l.jsx("path",{d:"M5 11a7 7 0 0 0 14 0"}),l.jsx("path",{d:"M12 18v3"})]}),enter:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M20 5v6a2 2 0 0 1-2 2H5"}),l.jsx("polyline",{points:"9 9 5 13 9 17"})]}),send:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M22 2 15 22 11 13 2 9Z"}),l.jsx("path",{d:"M22 2 11 13"})]}),trash:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M4 7h16"}),l.jsx("path",{d:"M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"}),l.jsx("path",{d:"M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"}),l.jsx("path",{d:"M10 11v6M14 11v6"})]}),x:l.jsx("path",{d:"M6 6l12 12M18 6 6 18"}),monitor:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2"}),l.jsx("path",{d:"M8 20h8M12 16v4"})]}),refresh:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M21 12a9 9 0 1 1-2.64-6.36L21 8"}),l.jsx("polyline",{points:"21 3 21 8 16 8"})]}),boot:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),l.jsx("path",{d:"M8 21h8M12 17v4M12 12V7"}),l.jsx("polyline",{points:"9 10 12 7 15 10"})]}),upload:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M12 16V5"}),l.jsx("polyline",{points:"8 9 12 5 16 9"}),l.jsx("path",{d:"M5 20h14"})]}),chevronLeft:l.jsx("polyline",{points:"14 6 8 12 14 18"}),chevronUp:l.jsx("polyline",{points:"6 14 12 8 18 14"}),chevronDown:l.jsx("polyline",{points:"6 10 12 16 18 10"}),history:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),l.jsx("polyline",{points:"3 3 3 8 8 8"}),l.jsx("path",{d:"M12 7v5l3 2"})]}),attach:l.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:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),l.jsx("polyline",{points:"14 2 14 8 20 8"})]}),camera:l.jsxs(l.Fragment,{children:[l.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"}),l.jsx("circle",{cx:"12",cy:"13",r:"3.5"})]}),image:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),l.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),l.jsx("path",{d:"M21 15l-5-5L5 21"})]}),zoomIn:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"11",cy:"11",r:"7"}),l.jsx("path",{d:"M21 21l-4.35-4.35"}),l.jsx("path",{d:"M8 11h6M11 8v6"})]}),zoomOut:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"11",cy:"11",r:"7"}),l.jsx("path",{d:"M21 21l-4.35-4.35"}),l.jsx("path",{d:"M8 11h6"})]}),gear:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"12",cy:"12",r:"3"}),l.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:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})};function at({name:e,size:t=20}){return l.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:Rx[e]||null})}const Px=["all","pinned","active","off","technical"],by="nc_sidebar_views_v1",Sy="nc_sidebar_order_v1";function xy(e){return Px.includes(e)?e:"all"}function Ax(e,t=[],n="all"){const s=xy(n);return s==="technical"?e.technical===!0:e.technical===!0?!1:s==="pinned"?t.includes(e.key):s==="active"?!!e.live:s==="off"?!e.live:!0}function Lx(e,t,n=[],s=[]){const o=n.indexOf(e.key),a=n.indexOf(t.key),u=o===-1?Number.MAX_SAFE_INTEGER:o,h=a===-1?Number.MAX_SAFE_INTEGER:a,p=s.indexOf(e.key),m=s.indexOf(t.key),v=p===-1?Number.MAX_SAFE_INTEGER:p,w=m===-1?Number.MAX_SAFE_INTEGER:m;return u-h||v-w||+!!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 Tx(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Sy));if(!t||typeof t!="object"||Array.isArray(t))return{};const n={};for(const[s,o]of Object.entries(t).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(o))continue;const a=[...new Set(o.filter(u=>typeof u=="string"&&u&&u.length<=256))].slice(0,128);a.length&&(n[s]=a)}return n}catch{return{}}}function Ji(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function Mx(e,t=globalThis.localStorage){try{t.setItem(Sy,JSON.stringify(e))}catch{}return e}function Dx(e,t,n,s,o=[]){if(typeof t!="string"||!t||n===s)return e;const a=[...new Set(o.filter(y=>typeof y=="string"&&y))];if(!a.includes(n)||!a.includes(s))return e;const u=Ji(e,t).filter(y=>a.includes(y)),h=[...u,...a.filter(y=>!u.includes(y))],p=h.indexOf(n),m=h.indexOf(s);h.splice(p,1);const v=h.indexOf(s),w=p<m?v+1:v;return h.splice(w,0,n),{...e,[t]:h}}function Ix(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(by));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function $g(e,t){var n,s;return{open:((n=e==null?void 0:e[t])==null?void 0:n.open)!==!1,filter:xy((s=e==null?void 0:e[t])==null?void 0:s.filter)}}function Ox(e,t=globalThis.localStorage){try{t.setItem(by,JSON.stringify(e))}catch{}return e}function Fg(e,t=""){const n=String(t||"").trim().toLocaleLowerCase();return n?[e.label,e.key,e.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function js(e=[],t=[],n="all",s=[]){return[...e].filter(o=>Ax(o,t,n)).sort((o,a)=>Lx(o,a,t,s))}const df=["it","en","es"];function Bx(){try{const e=typeof navigator<"u"&&navigator.language||"",t=String(e).slice(0,2).toLowerCase();return df.includes(t)?t:"en"}catch{return"en"}}const Rl=Bx(),ky="nc_lang",Gd="nc-lang";function Cy(){return typeof localStorage<"u"?localStorage:null}const vl={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","host-lease-live":"host live: supervisione attiva","host-lease-grace":"host live: supervisione in recupero (grace)","host-lease-expired":"host live: supervisione scaduta","host-lease-none":"host live: mai supervisionata","host-lease-unavailable":"host live: garanzia di supervisione non disponibile su questo nodo","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",panel:"pannello","panel-none":"Nessun pannello configurato per questa cella.","panel-checking":"Apertura del pannello…","panel-not-granted":"Questo nodo non concede il pannello a chi lo chiede: l'accesso va concesso sul nodo che possiede la cella, non riprovando qui.","panel-denied":"Ingresso al pannello rifiutato: il biglietto non è più valido. Riprova: verrà chiesto un biglietto nuovo.","cell-peek":"Sbircia senza cambiare cella","cell-tele-ctx":"contesto","cell-tele-free":"libero","cell-tele-5h":"5h usati","cell-tele-7d":"7g usati","cell-activity":"attività","cell-activity-now":"adesso","cell-peek-preview":"Anteprima","cell-peek-stream":"Flusso","cell-peek-panel":"Pannello","cell-peek-vuoto":"Nessuna anteprima disponibile per questa cella.","panel-node-refused":"Il nodo che possiede la cella rifiuta la richiesta: è in sola lettura, o la sua policy blocca questa operazione. Riprovare qui non cambia l'esito.","panel-unauthorized":"Credenziale non valida per questo nodo: va corretta dove è configurata, non riprovando da qui.","panel-unreachable":"Il pannello non è raggiungibile attraverso questo nodo: riprova tra poco.","panel-timeout":"Il pannello non ha risposto in tempo: servizio lento a partire o sovraccarico. Riprova tra poco.","panel-retry":"Riprova","live-host-not-granted":"Questo nodo non concede la designazione della cella ospite Live a chi la chiede: va concessa sul nodo che possiede la cella (nodes live-host <nodo> on), non riprovando qui.","live-host-error":"La designazione della cella ospite Live non è riuscita: riprova tra poco.",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","expand-owner":"espandi i deck di {owner}","collapse-owner":"comprimi i deck di {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} deck","dot-working":"in uso (finestra attiva)","dot-on":"aperta in background","dot-neutral":"non aperta","dot-warn":"nodo offline","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.","pair-authkeys-title":"Riga da sostituire in ~/.ssh/authorized_keys sul peer","pair-authkeys-hint":"Senza questa riga il forward del pannello resta rifiutato: il tunnel sembra attivo e il pannello non risponde.","pair-authkeys-copy":"Copia la riga","pair-authkeys-copied":"Riga copiata","tab-system":"sistema","tab-fleet":"flotta","tab-audio":"audio","system-general":"generale","system-diagnostics":"diagnostica","system-this-node":"questo nodo","system-updates":"aggiornamenti","system-security":"sicurezza","system-local-data":"dati locali del browser","system-terminal":"terminale","alternate-screen":"schermo alternato","alternate-screen-help":"Mantiene il comportamento tmux standard per le nuove sessioni NexusCrew. Un’applicazione che segue il mouse scorre da sé; le altre fanno scorrere la storia di tmux. Non modifica le celle già attive.","tab-input":"input","tab-diagnostics":"diagnostica","input-settings-local":"Preferenze locali di questo browser. Si applicano subito a vista singola e deck, senza modificare il nodo remoto.","terminal-keyboard-gesture":"Apertura tastiera virtuale dal terminale","terminal-keyboard-double-tap":"Doppio tap (predefinito)","terminal-keyboard-single-tap":"Tap singolo","terminal-keyboard-never":"Mai dal terminale","terminal-keyboard-gesture-help":"Il tastierino e STT seguono i controlli separati sotto. Mouse e tastiera fisica restano utilizzabili.","keybar-ime-lock":"Tastierino: mantieni chiusa la tastiera virtuale","keybar-ime-lock-help":"ESC, frecce, PgUp/PgDn, Enter e menu inviano direttamente al PTY senza dare focus a un campo di testo.","voice-ime-lock":"Microfono STT: mantieni chiusa la tastiera virtuale","voice-ime-lock-help":"Il tap sul microfono avvia o ferma la voce senza focalizzare il composer.","keybar-enter-show":"Mostra Enter verticale nel tastierino","keybar-enter-show-help":"Enter resta a destra di PgUp/PgDn ed è alto quanto entrambe le righe.","keybar-layout":"Layout tastierino","keybar-layout-full":"Esteso (predefinito)","keybar-layout-compact":"Compatto","keybar-layout-help":"Compatto: una riga con expand ⊞ per accedere al set completo senza cambiare la preferenza.","input-settings-reset":"ripristina predefiniti input","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 tramite shell login interattiva (-lic), con PATH e alias utente. La cella si ferma quando il comando termina; gli errori immediati vengono segnalati.","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 e non viene mai mostrata né esportata. Se il nodo è remoto, il valore viaggia fino a lui sul canale accoppiato.","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-credential-source-nexuscrew-store":"store NexusCrew","fleet-credential-source-unreadable":"non verificabile","fleet-credential-source-login":"login del client","fleet-credential-source-none":"nessuna","fleet-credential-source-policy":"origine credenziale","fleet-credential-source-policy-auto":"auto (precedenza legacy)","fleet-credential-source-policy-nexuscrew-store":"solo store NexusCrew","fleet-credential-source-policy-environment":"solo ambiente","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: non viene mai riletto dalla rete e non entra in engine o backup. Se il nodo selezionato è remoto, il valore lo raggiunge attraverso il canale accoppiato.","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, ma i suoi strumenti MCP vengono ereditati.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY dal credential layer locale; qwen3.8-max è il modello predefinito e non viene usato alcun fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa il login del CLI (device-code) e la propria configurazione: NexusCrew non legge né copia credenziali. Distinto dal provider "Kimi Code" di Claude Code, che resta il percorso K3 gestito.',"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.","cell-prompt":"Prompt di avvio della cella","cell-prompt-help":"Inviato alla cella quando parte: e’ il suo incarico permanente. Vuoto = nessun prompt, la cella parte e basta.","fleet-boot":"avvio automatico","fleet-remote-control":"controllo remoto","cell-mcp":"Strumenti MCP","cell-mcp-all":"tutti","cell-mcp-none":"nessuno","cell-mcp-some":"scelti","cell-mcp-inert":"Per questo client gli strumenti MCP li registra il client nel proprio config, non NexusCrew: la selezione qui non ha effetto.","cell-mcp-help":"«Tutti» è il comportamento di sempre. «Nessuno» è l’unica esclusione CERTA: toglie ogni strumento e non dipende da dove i server sono definiti — è ciò che serve per una cella di cui non ci si fida. Con «scelti» si concede per nome, ma l’elenco copre solo i server che questo nodo sa enumerare: plugin e connettori non compaiono e resterebbero disponibili.","fleet-model-override":"modello alternativo","fleet-ready":"pronto","fleet-not-ready":"non configurato","fleet-engines":"Engine","fleet-cells":"Celle / sessioni cloud","fleet-models":"Modelli dichiarati","fleet-no-models":"Nessun modello dichiarato: si usano quelli del catalogo.","model-editor-engine":"Profilo","model-editor-id":"Id del modello","model-editor-id-help":"L’id esatto che il fornitore si aspetta. Profilo e id non si cambiano dopo: si ritira e si ridichiara.","model-editor-context":"Finestra di contesto (token)","model-editor-max-tokens":"Massimo di token in uscita","model-editor-reasoning":"Supporta il ragionamento esteso","model-test":"Prova sull’API","model-test-running":"Provo…","model-test-ok":"risponde","model-test-unknown-model":"il fornitore non conosce questo id","model-test-auth":"credenziale mancante o rifiutata","model-test-unreachable":"endpoint non raggiungibile","model-test-unverified":"non verificato","model-test-unverified-help":"Non significa che non funzioni: questo fornitore non espone l’elenco dei modelli, quindi la prova non ha potuto dire né sì né no.","model-remove":"Ritira","model-in-use":"in uso","fleet-backup":"backup / ripristino","fleet-backup-help":"Esporta o ripristina selettivamente engine, celle, modelli dichiarati 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-invalid-model":"il backup contiene un modello non valido","fleet-backup-duplicate-model":"il backup contiene modelli 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.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: conferma la custom API key (Yes) nel terminale della cella, poi riavvia la cella.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: nel terminale della cella apri /config e abilita "Use custom API key", poi riavvia la cella. Se la chiave è cambiata, aggiorna la credenziale e riprova.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: nel terminale della cella esegui /login (device-code Kimi) oppure /provider, poi riavvia la cella.","fleet-recovery-client-terminal-dialog":"Completa il dialogo mostrato nel terminale della cella, poi riavvia la cella.","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-group-vl":"Nodi VL","vl-owners-unavailable":"Owner VL non raggiunti","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-off-hub-reconcile-pending":"Stato privato salvato; la revoca sull’hub è ancora in attesa.","fleet-cell-label":"nome leggibile (facoltativo)","fleet-panel-url":"URL pannello (opzionale)","fleet-panel-url-help":"Endpoint del pannello grafico della cella (es. il noVNC di un container): solo http/https verso un host loopback — il proxy risolve la destinazione sulla macchina che ospita la cella.","fleet-panel-url-invalid":"Il pannello non è un port-forward: chi lo apre sceglie quale cella, mai dove connettersi. L’indirizzo viene risolto sulla macchina che ospita la cella, quindi deve essere raggiungibile lì in loopback — 127.0.0.1, localhost o [::1]. L’indirizzo di un container (es. 172.17.0.2) non lo è.","share-off-local-reconcile-pending":"Revoca confermata dall’hub; il tunnel locale deve ancora riconciliarsi.","share-reverse-pool-pending":"Il canale reverse non risulta spento in modo dimostrabile: resta in quarantena, non chiuso.","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","peer-vl-federated":"Nodo VL: federato","row-vl-federated":"federato","node-connected-client":"client collegato","transport-used":"in uso","tunnel-up":"tunnel su","tunnel-down":"tunnel giù","vl-poll-online":"online (poll)","vl-poll-offline":"non risponde","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-dismiss":"Scarta la domanda","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","notification-speech-enable":"leggi le notifiche ad alta voce","notification-speech-help":"Usa la voce del browser solo per nuove notifiche mentre questa PWA è visibile e in primo piano. Con l’app chiusa resta la notifica di sistema.","notification-speech-test":"prova voce","notification-speech-testing":"prova in corso…","notification-speech-preview":"NexusCrew. Notifiche vocali attive.","notification-speech-preview-ok":"Prova vocale completata.","notification-speech-preview-failed":"Il browser non ha avviato la prova vocale. Interagisci con la pagina e riprova.","notification-speech-needs-test":"Per questa sessione dell’app, premi “prova voce” prima di ricevere annunci vocali.","notification-speech-unsupported":"Sintesi vocale non supportata in questo browser.","audio-title":"Audio nativo del nodo","audio-help":"Consenso e controlli valgono solo per questo dispositivo. Share e visibilità non autorizzano suoni.","audio-consent":"consenti TTS su questo nodo","audio-consent-help":"Permette a celle autorizzate, locali o remote, di consegnare un comando vocale. Puoi revocarlo in ogni momento.","audio-capability":"Capability locale","audio-loading":"leggo lo stato audio locale…","audio-adapter":"adapter","audio-adapter-none":"nessuno","audio-installed":"installato","audio-installed-yes":"sì","audio-installed-no":"no","audio-liveness":"disponibilità","audio-liveness-ready":"pronto ad accettare","audio-liveness-unavailable":"non disponibile","audio-languages":"lingue dichiarate","audio-limits":"limiti","audio-test":"prova audio locale","audio-testing":"prova in corso…","audio-stop":"ferma audio locale","audio-stopping":"stop in corso…","audio-test-needs-consent":"Attiva il consenso locale prima di provare la voce.","audio-unavailable":"Nessun adapter TTS nativo disponibile su questo nodo.","audio-test-accepted":"Il nodo ha accettato la prova. Non dimostra che qualcuno l’abbia udita.","audio-test-refused":"Il nodo ha rifiutato la prova.","audio-test-unknown":"Esito della prova sconosciuto: il nodo non può confermare l’avvio.","audio-stop-stopped":"Audio locale fermato.","audio-stop-idle":"Nessun enunciato locale da fermare.","audio-groups-title":"Gruppi audio condivisi","audio-groups-help":"Decide su quali dispositivi si sente la voce quando una cella parla. Il gruppo è una preferenza locale di consegna, non un consenso. Ogni nodo conserva consenso, ACL, disponibilità e Stop locale.","audio-groups-empty":"Nessun gruppo: la voce esce solo su questo nodo.","audio-group-name":"nome gruppo","audio-group-mode":"modalità consegna","audio-group-primary":"primo disponibile (in ordine)","audio-group-fanout":"tutti i nodi elencati","audio-group-targets":"nodi target esatti","audio-group-local":"questo nodo","audio-group-unavailable-target":"non rilevato ora","audio-group-no-targets":"Nessun nodo con instanceId disponibile. Il gruppo non può usare nomi, wildcard o “tutti”.","audio-group-new":"nuovo gruppo","audio-group-edit":"modifica","audio-group-delete":"elimina","audio-group-save":"salva gruppo","audio-group-cancel":"annulla","audio-group-invalid":"Il gruppo richiede un nome valido e almeno un nodeId esatto.","audio-group-save-failed":"Salvataggio gruppo audio non riuscito.","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","cell-switcher-refreshing":"aggiorno le celle…","cell-switcher-empty-active":"nessuna cella attiva verificata","cell-switcher-not-confirmed":"stato non confermato","cell-switcher-not-active":"questa cella non è più attiva","cell-switcher-select":"seleziona una cella","cell-switcher-open":"apri cella","cell-switcher-show-all":"tutte","cell-switcher-show-active":"attive","cell-switcher-close":"chiudi selettore celle","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","selection-held":"evidenziazione persa, testo ancora in mano","invite-hub-only":"Un invito si conia sull’hub. Ammettere un nodo nuovo è la sola cosa che un nodo collegato non può chiedere per conto di un altro: apri NexusCrew sull’hub e crea l’invito da lì.","row-private":"privato","node-detail-open":"apri il dettaglio","node-detail-reach":"Raggiungibilità","node-detail-route":"percorso","node-detail-ssh":"SSH","node-detail-transport":"trasporto","node-detail-owner":"owner","node-detail-authority":"Cosa può fare questo nodo","authority-owner-equivalent":"Autorità pari alla tua: un nodo accoppiato può fare su questa macchina tutto quello che puoi fare tu.","authority-routed":"Non è accoppiato con questa macchina: la sua autorità vive presso l’hub che lo instrada.","authority-no-grants":"L’unico potere per-nodo che esiste è la scelta delle celle, qui sotto. Dentro quelle celle l’autorità resta piena.","authority-no-grants-elsewhere":"L’unico potere per-nodo che esiste è la scelta delle celle, e si imposta sull’installazione che le possiede — non da qui.","node-detail-network-view":"Cosa vede di questa rete","node-detail-command":"Comando","vl-no-commands":"Il device non dichiara comandi disponibili.","vl-events-title":"Sessione","vl-events-empty":"Nessun evento in memoria: la sessione non ha ancora parlato, oppure quello che ha detto è uscito dal buffer. La storia resta sul device.","vl-events-gap":"eventi non ricevuti:","vl-events-truncated":"contenuto troncato dal device","vl-events-turn-end":"— fine turno —","vl-events-done":"— fine risposta —","vl-events-writer-epoch":"— cambio scrittore —","vl-events-tool":"strumento","vl-events-tool-ok":"concluso","vl-events-tool-failed":"fallito","vl-events-usage":"consumo aggiornato","vl-events-stale":"Aggiornamento non riuscito: quello che vedi potrebbe non essere l’ultimo.","vl-cmd-phase-submitted":"inviato, in attesa di conferma","vl-cmd-phase-inflight":"in corso","vl-cmd-phase-done-ok":"completato","vl-cmd-phase-done-error":"fallito","vl-cmd-status":"stato","vl-cmd-health":"salute","vl-cmd-start":"avvia","vl-cmd-stop":"ferma","vl-cmd-restart":"riavvia","vl-cmd-version":"versione","vl-cmd-capabilities":"capacità","vl-cmd-logs":"log","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"scrivi il prompt per la sessione del device…","vl-prompt-send":"invia prompt","vl-cmd-unpair":"disaccoppia","node-grant-none":"Nessun nodo scelto: condiviso, ma verso nessuno.","node-grant-unknown":"non più in inventario","node-grant-remove":"togli","node-grant-add":"Aggiungi un nodo","node-grant-search":"Cerca fra i nodi","node-grant-no-candidates":"Nessun nodo corrisponde.","cell-scope":"Celle visibili a questo nodo","cell-scope-help":"Vale su cio’ che questo nodo elenca e su cio’ che può toccare, terminale compreso. Dentro le celle concesse resta un nodo accoppiato a pieno titolo: non è una sandbox.","cell-scope-all":"tutte le celle","cell-scope-none":"nessuna cella","cell-scope-selected":"celle selezionate","cell-scope-none-granted":"Nessuna cella scelta: questo nodo non ne vede nessuna.","cell-scope-unknown":"cella non più esistente","cell-scope-add":"Aggiungi una cella","cell-scope-search":"Cerca fra le celle","cell-scope-no-candidates":"Nessuna cella corrisponde.","cell-scope-reset-warning":"Cambiando modo l’elenco viene azzerato: tornando a «celle selezionate» andrà rifatto.","cell-scope-list-unavailable":"Elenco delle celle non disponibile ora: le concessioni qui sotto restano valide, ma non si può dire se esistono ancora.","single-view":"vista singola",retract:"riduci","keybar-expand":"espandi la barra tasti","keybar-retract":"riduci la barra tasti","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. Serve l’indirizzo SSH di questo dispositivo, raggiungibile da chi lo userà.","invite-target-local":"Il nuovo dispositivo entrerà in","invite-target-this":"questo dispositivo","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","host-lease-live":"live host: supervision active","host-lease-grace":"live host: supervision recovering (grace)","host-lease-expired":"live host: supervision expired","host-lease-none":"live host: never supervised","host-lease-unavailable":"live host: supervision guarantee not available on this node","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",panel:"panel","panel-none":"No panel configured for this cell.","panel-checking":"Opening panel…","panel-not-granted":"This node does not grant the panel to the requester: access must be granted on the node that owns the cell, not by retrying here.","panel-denied":"Panel entry refused: the ticket is no longer valid. Retry: a new ticket will be requested.","cell-peek":"Peek without switching cell","cell-tele-ctx":"context","cell-tele-free":"free","cell-tele-5h":"5h used","cell-tele-7d":"7d used","cell-activity":"activity","cell-activity-now":"now","cell-peek-preview":"Preview","cell-peek-stream":"Stream","cell-peek-panel":"Panel","cell-peek-vuoto":"No preview available for this cell.","panel-node-refused":"The node that owns the cell refuses the request: it is read-only, or its policy blocks this operation. Retrying here does not change the outcome.","panel-unauthorized":"Invalid credential for this node: fix it where it is configured, not by retrying from here.","panel-unreachable":"The panel is not reachable through this node: retry in a little while.","panel-timeout":"The panel did not answer in time: service slow to start or overloaded. Retry in a little while.","panel-retry":"Retry","live-host-not-granted":"This node does not grant the live host cell designation to the requester: it must be granted on the node that owns the cell (nodes live-host <node> on), not by retrying here.","live-host-error":"The live host cell designation failed: retry in a little while.",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","expand-owner":"expand {owner} decks","collapse-owner":"collapse {owner} decks","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"in use (active window)","dot-on":"open in background","dot-neutral":"not open","dot-warn":"owner offline","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.","pair-authkeys-title":"Line to replace in ~/.ssh/authorized_keys on the peer","pair-authkeys-hint":"Without this line the panel forward stays refused: the tunnel looks up while the panel does not answer.","pair-authkeys-copy":"Copy the line","pair-authkeys-copied":"Line copied","tab-system":"system","tab-fleet":"fleet","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnostics","system-this-node":"this node","system-updates":"updates","system-security":"security","system-local-data":"local browser data","system-terminal":"terminal","alternate-screen":"alternate screen","alternate-screen-help":"Keeps standard tmux behaviour for new NexusCrew sessions. An application that tracks the mouse scrolls on its own; the others browse the tmux scrollback. It does not change cells already running.","tab-input":"input","tab-diagnostics":"diagnostics","input-settings-local":"Local preferences for this browser. They apply immediately to single view and decks without changing the remote node.","terminal-keyboard-gesture":"Open the virtual keyboard from the terminal","terminal-keyboard-double-tap":"Double tap (default)","terminal-keyboard-single-tap":"Single tap","terminal-keyboard-never":"Never from terminal","terminal-keyboard-gesture-help":"The keypad and STT use the separate controls below. Mouse and physical keyboard remain available.","keybar-ime-lock":"Keypad: keep the virtual keyboard closed","keybar-ime-lock-help":"ESC, arrows, PgUp/PgDn, Enter and menu send directly to the PTY without focusing a text field.","voice-ime-lock":"STT microphone: keep the virtual keyboard closed","voice-ime-lock-help":"Tapping the microphone starts or stops voice without focusing the composer.","keybar-enter-show":"Show the tall Enter keypad key","keybar-enter-show-help":"Enter stays to the right of PgUp/PgDn and spans both rows.","keybar-layout":"Keypad layout","keybar-layout-full":"Full (default)","keybar-layout-compact":"Compact","keybar-layout-help":"Compact: one row with an expand toggle that reaches the full key set without changing the preference.","input-settings-reset":"restore input defaults","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":"Runs through an interactive login shell (-lic), with the user PATH and aliases. The cell stops when the command finishes; immediate failures are reported.","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 or exported. If the node is remote, the value travels to it over the paired channel.","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-credential-source-nexuscrew-store":"NexusCrew store","fleet-credential-source-unreadable":"unreadable","fleet-credential-source-login":"client login","fleet-credential-source-none":"none","fleet-credential-source-policy":"credential source","fleet-credential-source-policy-auto":"auto (legacy precedence)","fleet-credential-source-policy-nexuscrew-store":"NexusCrew store only","fleet-credential-source-policy-environment":"environment only","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: it is never read back over the network and never enters engines or backups. If the selected node is remote, the value reaches it over the paired channel.","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, but its MCP tools are inherited.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal uses only ALIBABA_CODE_API_KEY from the local credential layer; qwen3.8-max is the default and no OpenAI/PAYG fallback is used.","fleet-provider-notice-kimi-native":'Native Kimi Code CLI uses the CLI login (device code) and its own configuration: NexusCrew never reads or copies credentials. Distinct from the Claude Code "Kimi Code" provider, which remains the managed K3 path.',"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.","cell-prompt":"Cell start-up prompt","cell-prompt-help":"Sent to the cell when it starts: this is its standing brief. Empty means no prompt — the cell just starts.","fleet-boot":"start at boot","fleet-remote-control":"remote control","cell-mcp":"MCP tools","cell-mcp-all":"all","cell-mcp-none":"none","cell-mcp-some":"chosen","cell-mcp-inert":"For this client, MCP tools are registered by the client in its own config, not NexusCrew: the selection here has no effect.","cell-mcp-help":"“All” is the long-standing behaviour. “None” is the only CERTAIN exclusion: it removes every tool and does not depend on where the servers are defined — that is what you want for a cell you do not trust. “Chosen” grants by name, but the list only covers servers this node can enumerate: plugins and connectors do not appear and would stay available.","fleet-model-override":"model override","fleet-ready":"ready","fleet-not-ready":"not configured","fleet-engines":"Engines","fleet-cells":"Cells / cloud sessions","fleet-models":"Declared models","fleet-no-models":"No declared model: the built-in catalog is used.","model-editor-engine":"Profile","model-editor-id":"Model id","model-editor-id-help":"The exact id the provider expects. Profile and id cannot be changed later: withdraw and declare again.","model-editor-context":"Context window (tokens)","model-editor-max-tokens":"Max output tokens","model-editor-reasoning":"Supports extended reasoning","model-test":"Test against the API","model-test-running":"Testing…","model-test-ok":"responds","model-test-unknown-model":"the provider does not know this id","model-test-auth":"credential missing or refused","model-test-unreachable":"endpoint unreachable","model-test-unverified":"not verified","model-test-unverified-help":"This does not mean it fails: this provider does not expose a model list, so the test could say neither yes nor no.","model-remove":"Withdraw","model-in-use":"in use","fleet-backup":"backup / restore","fleet-backup-help":"Selectively export or restore engines, cells, declared models, 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-invalid-model":"the backup contains an invalid model","fleet-backup-duplicate-model":"the backup contains duplicate models","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.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirm the custom API key (Yes) in the cell terminal, then restart the cell.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: in the cell terminal open /config and enable "Use custom API key", then restart the cell. If the key changed, update the credential and retry.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: in the cell terminal run /login (Kimi device code) or /provider, then restart the cell.","fleet-recovery-client-terminal-dialog":"Complete the dialog shown in the cell terminal, then restart the cell.","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-group-vl":"VL nodes","vl-owners-unavailable":"VL owners unreachable","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-off-hub-reconcile-pending":"Private state saved; hub revocation is still pending.","fleet-cell-label":"readable name (optional)","fleet-panel-url":"Panel URL (optional)","fleet-panel-url-help":"Graphical panel endpoint for the cell (e.g. a container's noVNC): http/https only, toward a loopback host — the proxy resolves the destination on the machine that hosts the cell.","fleet-panel-url-invalid":"The panel is not a port-forward: whoever opens it picks which cell, never where to connect. The address is resolved on the machine that hosts the cell, so it must be reachable there on loopback — 127.0.0.1, localhost, or [::1]. A container's address (e.g. 172.17.0.2) is not.","share-off-local-reconcile-pending":"Hub revocation confirmed; the local tunnel still needs reconciliation.","share-reverse-pool-pending":"The reverse channel was not demonstrably shut down: it is quarantined, not closed.","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","peer-vl-federated":"VL node: federated","row-vl-federated":"federated","node-connected-client":"connected client","transport-used":"in use","tunnel-up":"tunnel up","tunnel-down":"tunnel down","vl-poll-online":"online (poll)","vl-poll-offline":"not responding","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-dismiss":"Dismiss question","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","notification-speech-enable":"read notifications aloud","notification-speech-help":"Uses the browser voice only for new notifications while this PWA is visible and in the foreground. When the app is closed, the system notification remains available.","notification-speech-test":"test voice","notification-speech-testing":"testing voice…","notification-speech-preview":"NexusCrew. Spoken notifications are active.","notification-speech-preview-ok":"Voice test completed.","notification-speech-preview-failed":"The browser did not start the voice test. Interact with the page and try again.","notification-speech-needs-test":"For this app session, select “test voice” before spoken alerts can play.","notification-speech-unsupported":"Speech synthesis is not supported in this browser.","audio-title":"Native node audio","audio-help":"Consent and controls apply only to this device. Share and visibility do not authorize sounds.","audio-consent":"allow TTS on this node","audio-consent-help":"Allows authorized local or remote cells to deliver a voice command. You can revoke it at any time.","audio-capability":"Local capability","audio-loading":"reading local audio state…","audio-adapter":"adapter","audio-adapter-none":"none","audio-installed":"installed","audio-installed-yes":"yes","audio-installed-no":"no","audio-liveness":"availability","audio-liveness-ready":"ready to accept","audio-liveness-unavailable":"unavailable","audio-languages":"declared languages","audio-limits":"limits","audio-test":"test local audio","audio-testing":"testing audio…","audio-stop":"stop local audio","audio-stopping":"stopping audio…","audio-test-needs-consent":"Enable local consent before testing the voice.","audio-unavailable":"No native TTS adapter is available on this node.","audio-test-accepted":"The node accepted the test. It does not prove that anyone heard it.","audio-test-refused":"The node refused the test.","audio-test-unknown":"Test outcome unknown: the node could not confirm startup.","audio-stop-stopped":"Local audio stopped.","audio-stop-idle":"No local utterance to stop.","audio-groups-title":"Shared audio groups","audio-groups-help":"Chooses which devices play the voice when a cell speaks. A group is a local delivery preference, not consent. Each node keeps its own consent, ACL, availability and local Stop.","audio-groups-empty":"No group: voice plays only on this node.","audio-group-name":"group name","audio-group-mode":"delivery mode","audio-group-primary":"first available (in order)","audio-group-fanout":"all listed nodes","audio-group-targets":"exact target nodes","audio-group-local":"this node","audio-group-unavailable-target":"not currently discovered","audio-group-no-targets":"No node with an available instanceId. A group cannot use names, wildcards, or “all”.","audio-group-new":"new group","audio-group-edit":"edit","audio-group-delete":"delete","audio-group-save":"save group","audio-group-cancel":"cancel","audio-group-invalid":"A group needs a valid name and at least one exact nodeId.","audio-group-save-failed":"Could not save audio group.","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","cell-switcher-refreshing":"refreshing cells…","cell-switcher-empty-active":"no verified active cells","cell-switcher-not-confirmed":"status not confirmed","cell-switcher-not-active":"this cell is no longer active","cell-switcher-select":"select a cell","cell-switcher-open":"open cell","cell-switcher-show-all":"all","cell-switcher-show-active":"active","cell-switcher-close":"close cell switcher","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","selection-held":"highlight gone, text still held","invite-hub-only":"An invite is minted on the hub. Admitting a new node is the one thing a connected node cannot ask on another’s behalf: open NexusCrew on the hub and create the invite there.","row-private":"private","node-detail-open":"open details","node-detail-reach":"Reachability","node-detail-route":"path","node-detail-ssh":"SSH","node-detail-transport":"transport","node-detail-owner":"owner","node-detail-authority":"What this node can do","authority-owner-equivalent":"Authority equal to yours: a paired node can do on this machine everything you can do.","authority-routed":"Not paired with this machine: its authority lives on the hub that routes it.","authority-no-grants":"The only per-node power that exists is the choice of cells, below. Within those cells the authority stays full.","authority-no-grants-elsewhere":"The only per-node power that exists is the choice of cells, and it is set on the installation that owns them — not here.","node-detail-network-view":"What it sees of this network","node-detail-command":"Command","vl-no-commands":"The device declares no commands available.","vl-events-title":"Session","vl-events-empty":"No events in memory: the session has not spoken yet, or what it said has left the buffer. The history stays on the device.","vl-events-gap":"events not received:","vl-events-truncated":"content truncated by the device","vl-events-turn-end":"— end of turn —","vl-events-done":"— turn complete —","vl-events-writer-epoch":"— writer changed —","vl-events-tool":"tool","vl-events-tool-ok":"finished","vl-events-tool-failed":"failed","vl-events-usage":"usage updated","vl-events-stale":"Refresh failed: what you see may not be the latest.","vl-cmd-phase-submitted":"sent, awaiting confirmation","vl-cmd-phase-inflight":"in progress","vl-cmd-phase-done-ok":"completed","vl-cmd-phase-done-error":"failed","vl-cmd-status":"status","vl-cmd-health":"health","vl-cmd-start":"start","vl-cmd-stop":"stop","vl-cmd-restart":"restart","vl-cmd-version":"version","vl-cmd-capabilities":"capabilities","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"write the prompt for the device session…","vl-prompt-send":"send prompt","vl-cmd-unpair":"unpair","node-grant-none":"No node chosen: shared, but towards nobody.","node-grant-unknown":"no longer in the inventory","node-grant-remove":"remove","node-grant-add":"Add a node","node-grant-search":"Search the nodes","node-grant-no-candidates":"No node matches.","cell-scope":"Cells this node can see","cell-scope-help":"Applies to what this node lists and to what it can act on, terminal included. Within the granted cells it remains a fully paired node: this is not a sandbox.","cell-scope-all":"every cell","cell-scope-none":"no cell","cell-scope-selected":"selected cells","cell-scope-none-granted":"No cell chosen: this node sees none of them.","cell-scope-unknown":"cell no longer exists","cell-scope-add":"Add a cell","cell-scope-search":"Search the cells","cell-scope-no-candidates":"No cell matches.","cell-scope-reset-warning":"Switching mode clears the list: coming back to “selected cells” means choosing them again.","cell-scope-list-unavailable":"Cell list unavailable right now: the grants below still hold, but we cannot tell whether they still exist.","single-view":"single view",retract:"retract","keybar-expand":"expand the key bar","keybar-retract":"retract the key bar","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 one-time invitation. It needs this device’s SSH address, reachable by whoever will use it.","invite-target-local":"The new device will join","invite-target-this":"this device","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","host-lease-live":"host live: supervisión activa","host-lease-grace":"host live: supervisión en recuperación (grace)","host-lease-expired":"host live: supervisión caducada","host-lease-none":"host live: nunca supervisada","host-lease-unavailable":"host live: garantía de supervisión no disponible en este nodo","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",panel:"panel","panel-none":"Ningún panel configurado para esta celda.","panel-checking":"Abriendo el panel…","panel-not-granted":"Este nodo no concede el panel a quien lo pide: el acceso se concede en el nodo que posee la celda, no reintentando aquí.","panel-denied":"Entrada al panel rechazada: el billete ya no es válido. Reintenta: se pedirá un billete nuevo.","cell-peek":"Echa un vistazo sin cambiar de celda","cell-tele-ctx":"contexto","cell-tele-free":"libre","cell-tele-5h":"5h usados","cell-tele-7d":"7d usados","cell-activity":"actividad","cell-activity-now":"ahora","cell-peek-preview":"Vista previa","cell-peek-stream":"Flujo","cell-peek-panel":"Panel","cell-peek-vuoto":"No hay vista previa para esta celda.","panel-node-refused":"El nodo que posee la celda rechaza la petición: está en solo lectura, o su política bloquea esta operación. Reintentar aquí no cambia el resultado.","panel-unauthorized":"Credencial no válida para este nodo: se corrige donde está configurada, no reintentando desde aquí.","panel-unreachable":"El panel no es accesible a través de este nodo: reintenta en un momento.","panel-timeout":"El panel no respondió a tiempo: servicio lento en arrancar o sobrecargado. Reintenta en un momento.","panel-retry":"Reintentar","live-host-not-granted":"Este nodo no concede la designación de celda anfitriona Live a quien la pide: se concede en el nodo que posee la celda (nodes live-host <nodo> on), no reintentando aquí.","live-host-error":"La designación de celda anfitriona Live no funcionó: reintenta en un momento.",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í","expand-owner":"expandir decks de {owner}","collapse-owner":"comprimir decks de {owner}","owner-deck-count-one":"{count} deck","owner-deck-count-many":"{count} decks","dot-working":"en uso (ventana activa)","dot-on":"abierta en segundo plano","dot-neutral":"no abierta","dot-warn":"nodo sin conexión","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.","pair-authkeys-title":"Línea que hay que sustituir en ~/.ssh/authorized_keys del peer","pair-authkeys-hint":"Sin esta línea el reenvío del panel sigue rechazado: el túnel parece activo y el panel no responde.","pair-authkeys-copy":"Copiar la línea","pair-authkeys-copied":"Línea copiada","tab-system":"sistema","tab-fleet":"flota","tab-audio":"audio","system-general":"general","system-diagnostics":"diagnóstico","system-this-node":"este nodo","system-updates":"actualizaciones","system-security":"seguridad","system-local-data":"datos locales del navegador","system-terminal":"terminal","alternate-screen":"pantalla alternativa","alternate-screen-help":"Mantiene el comportamiento estándar de tmux para las nuevas sesiones NexusCrew. Una aplicación que sigue el ratón se desplaza sola; las demás recorren el historial de tmux. No modifica las celdas ya activas.","tab-input":"entrada","tab-diagnostics":"diagnóstico","input-settings-local":"Preferencias locales de este navegador. Se aplican de inmediato a la vista única y a los decks sin cambiar el nodo remoto.","terminal-keyboard-gesture":"Abrir el teclado virtual desde el terminal","terminal-keyboard-double-tap":"Doble toque (predeterminado)","terminal-keyboard-single-tap":"Toque único","terminal-keyboard-never":"Nunca desde el terminal","terminal-keyboard-gesture-help":"El teclado auxiliar y STT usan los controles separados de abajo. El ratón y el teclado físico siguen disponibles.","keybar-ime-lock":"Teclado auxiliar: mantener cerrado el teclado virtual","keybar-ime-lock-help":"ESC, flechas, PgUp/PgDn, Enter y menú envían directamente al PTY sin enfocar un campo de texto.","voice-ime-lock":"Micrófono STT: mantener cerrado el teclado virtual","voice-ime-lock-help":"Tocar el micrófono inicia o detiene la voz sin enfocar el compositor.","keybar-enter-show":"Mostrar Enter vertical en el teclado auxiliar","keybar-enter-show-help":"Enter queda a la derecha de PgUp/PgDn y ocupa las dos filas.","keybar-layout":"Distribución del teclado auxiliar","keybar-layout-full":"Completo (predeterminado)","keybar-layout-compact":"Compacto","keybar-layout-help":"Compacto: una fila con un botón expandir que alcanza el conjunto completo sin cambiar la preferencia.","input-settings-reset":"restaurar valores de entrada","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":"Se ejecuta mediante una shell de inicio interactiva (-lic), con PATH y alias del usuario. La celda se detiene al terminar; los fallos inmediatos se notifican.","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 ni se exporta. Si el nodo es remoto, el valor viaja hasta él por el canal emparejado.","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-credential-source-nexuscrew-store":"almacén NexusCrew","fleet-credential-source-unreadable":"no verificable","fleet-credential-source-login":"login del cliente","fleet-credential-source-none":"ninguna","fleet-credential-source-policy":"origen de credencial","fleet-credential-source-policy-auto":"auto (precedencia legacy)","fleet-credential-source-policy-nexuscrew-store":"solo almacén NexusCrew","fleet-credential-source-policy-environment":"solo entorno","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: nunca se vuelve a leer desde la red ni entra en motores o copias. Si el nodo seleccionado es remoto, el valor llega a él por el canal emparejado.","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, pero sus herramientas MCP se heredan.","fleet-provider-notice-alibaba-token-plan":"Token Plan Personal usa solo ALIBABA_CODE_API_KEY de la capa local de credenciales; qwen3.8-max es el modelo predeterminado y no se usa fallback OpenAI/PAYG.","fleet-provider-notice-kimi-native":'Kimi Code CLI nativo usa el login del CLI (device-code) y su propia configuración: NexusCrew no lee ni copia credenciales. Distinto del proveedor "Kimi Code" de Claude Code, que sigue siendo la ruta K3 gestionada.',"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.","cell-prompt":"Prompt de arranque de la celda","cell-prompt-help":"Se envía a la celda al arrancar: es su encargo permanente. Vacío = sin prompt, la celda solo arranca.","fleet-boot":"inicio automático","fleet-remote-control":"control remoto","cell-mcp":"Herramientas MCP","cell-mcp-all":"todas","cell-mcp-none":"ninguna","cell-mcp-some":"elegidas","cell-mcp-inert":"Para este cliente, las herramientas MCP las registra el cliente en su propia config, no NexusCrew: la selección aquí no tiene efecto.","cell-mcp-help":"«Todas» es el comportamiento de siempre. «Ninguna» es la única exclusión CIERTA: quita toda herramienta y no depende de dónde estén definidos los servidores — es lo que hace falta para una celda en la que no se confía. Con «elegidas» se concede por nombre, pero la lista solo cubre los servidores que este nodo puede enumerar: los plugins y conectores no aparecen y seguirían disponibles.","fleet-model-override":"modelo alternativo","fleet-ready":"listo","fleet-not-ready":"no configurado","fleet-engines":"Motores","fleet-cells":"Celdas / sesiones cloud","fleet-models":"Modelos declarados","fleet-no-models":"Ningún modelo declarado: se usa el catálogo interno.","model-editor-engine":"Perfil","model-editor-id":"Id del modelo","model-editor-id-help":"El id exacto que espera el proveedor. Perfil e id no se cambian después: se retira y se vuelve a declarar.","model-editor-context":"Ventana de contexto (tokens)","model-editor-max-tokens":"Máximo de tokens de salida","model-editor-reasoning":"Admite razonamiento extendido","model-test":"Probar contra la API","model-test-running":"Probando…","model-test-ok":"responde","model-test-unknown-model":"el proveedor no conoce este id","model-test-auth":"credencial ausente o rechazada","model-test-unreachable":"endpoint inalcanzable","model-test-unverified":"no verificado","model-test-unverified-help":"No significa que falle: este proveedor no expone la lista de modelos, así que la prueba no pudo decir ni sí ni no.","model-remove":"Retirar","model-in-use":"en uso","fleet-backup":"copia / restauración","fleet-backup-help":"Exporta o restaura selectivamente motores, celdas, modelos declarados 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-invalid-model":"la copia contiene un modelo no válido","fleet-backup-duplicate-model":"la copia contiene modelos 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.","fleet-recovery-kimi-code-consent-yes":"Kimi Code: confirma la clave API personalizada (Yes) en el terminal de la celda, luego reinicia la celda.","fleet-recovery-kimi-code-config-custom-api-key":'Kimi Code: en el terminal de la celda abre /config y activa "Use custom API key", luego reinicia la celda. Si la clave cambió, actualiza la credencial y reintenta.',"fleet-recovery-kimi-cli-login":"Kimi Code CLI: en el terminal de la celda ejecuta /login (código de dispositivo Kimi) o /provider, luego reinicia la celda.","fleet-recovery-client-terminal-dialog":"Completa el diálogo mostrado en el terminal de la celda, luego reinicia la celda.","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-group-vl":"Nodos VL","vl-owners-unavailable":"Owners VL no alcanzados","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-off-hub-reconcile-pending":"Estado privado guardado; la revocación en el hub sigue pendiente.","fleet-cell-label":"nombre legible (opcional)","fleet-panel-url":"URL del panel (opcional)","fleet-panel-url-help":"Endpoint del panel gráfico de la celda (p. ej. el noVNC de un contenedor): solo http/https hacia un host loopback — el proxy resuelve el destino en la máquina que aloja la celda.","fleet-panel-url-invalid":"El panel no es un port-forward: quien lo abre elige qué celda, nunca dónde conectarse. La dirección se resuelve en la máquina que aloja la celda, así que debe ser alcanzable allí en loopback — 127.0.0.1, localhost o [::1]. La dirección de un contenedor (p. ej. 172.17.0.2) no lo es.","share-off-local-reconcile-pending":"Revocación confirmada por el hub; el túnel local aún debe reconciliarse.","share-reverse-pool-pending":"El canal inverso no se apagó de forma demostrable: queda en cuarentena, no cerrado.","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","peer-vl-federated":"Nodo VL: federado","row-vl-federated":"federado","node-connected-client":"cliente conectado","transport-used":"en uso","tunnel-up":"túnel activo","tunnel-down":"túnel caído","vl-poll-online":"en línea (poll)","vl-poll-offline":"sin respuesta","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-dismiss":"Descartar la pregunta","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","notification-speech-enable":"leer las notificaciones en voz alta","notification-speech-help":"Usa la voz del navegador solo para notificaciones nuevas mientras esta PWA está visible y en primer plano. Con la aplicación cerrada permanece la notificación del sistema.","notification-speech-test":"probar voz","notification-speech-testing":"probando voz…","notification-speech-preview":"NexusCrew. Las notificaciones por voz están activas.","notification-speech-preview-ok":"Prueba de voz completada.","notification-speech-preview-failed":"El navegador no inició la prueba de voz. Interactúa con la página y vuelve a intentarlo.","notification-speech-needs-test":"Para esta sesión de la aplicación, pulsa “probar voz” antes de recibir avisos hablados.","notification-speech-unsupported":"La síntesis de voz no está disponible en este navegador.","audio-title":"Audio nativo del nodo","audio-help":"El consentimiento y los controles valen solo para este dispositivo. Compartir y visibilidad no autorizan sonidos.","audio-consent":"permitir TTS en este nodo","audio-consent-help":"Permite que celdas autorizadas, locales o remotas, entreguen un comando de voz. Puedes revocarlo en cualquier momento.","audio-capability":"Capacidad local","audio-loading":"leyendo el estado de audio local…","audio-adapter":"adaptador","audio-adapter-none":"ninguno","audio-installed":"instalado","audio-installed-yes":"sí","audio-installed-no":"no","audio-liveness":"disponibilidad","audio-liveness-ready":"listo para aceptar","audio-liveness-unavailable":"no disponible","audio-languages":"idiomas declarados","audio-limits":"límites","audio-test":"probar audio local","audio-testing":"probando audio…","audio-stop":"detener audio local","audio-stopping":"deteniendo audio…","audio-test-needs-consent":"Activa el consentimiento local antes de probar la voz.","audio-unavailable":"No hay un adaptador TTS nativo disponible en este nodo.","audio-test-accepted":"El nodo aceptó la prueba. No demuestra que alguien la haya oído.","audio-test-refused":"El nodo rechazó la prueba.","audio-test-unknown":"Resultado de prueba desconocido: el nodo no pudo confirmar el inicio.","audio-stop-stopped":"Audio local detenido.","audio-stop-idle":"No hay enunciado local que detener.","audio-groups-title":"Grupos de audio compartido","audio-groups-help":"Decide en qué dispositivos se oye la voz cuando habla una celda. Un grupo es una preferencia local de entrega, no un consentimiento. Cada nodo conserva su consentimiento, ACL, disponibilidad y Stop local.","audio-groups-empty":"Sin grupos: la voz sale solo por este nodo.","audio-group-name":"nombre del grupo","audio-group-mode":"modo de entrega","audio-group-primary":"primero disponible (en orden)","audio-group-fanout":"todos los nodos enumerados","audio-group-targets":"nodos destino exactos","audio-group-local":"este nodo","audio-group-unavailable-target":"no detectado ahora","audio-group-no-targets":"No hay ningún nodo con instanceId disponible. Un grupo no puede usar nombres, comodines ni “todos”.","audio-group-new":"nuevo grupo","audio-group-edit":"editar","audio-group-delete":"eliminar","audio-group-save":"guardar grupo","audio-group-cancel":"cancelar","audio-group-invalid":"El grupo necesita un nombre válido y al menos un nodeId exacto.","audio-group-save-failed":"No se pudo guardar el grupo de audio.","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","cell-switcher-refreshing":"actualizando celdas…","cell-switcher-empty-active":"no hay celdas activas verificadas","cell-switcher-not-confirmed":"estado sin confirmar","cell-switcher-not-active":"esta celda ya no está activa","cell-switcher-select":"selecciona una celda","cell-switcher-open":"abrir celda","cell-switcher-show-all":"todas","cell-switcher-show-active":"activas","cell-switcher-close":"cerrar selector de celdas","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","selection-held":"resaltado perdido, texto aún retenido","invite-hub-only":"Una invitación se acuña en el hub. Admitir un nodo nuevo es lo único que un nodo conectado no puede pedir en nombre de otro: abre NexusCrew en el hub y créala allí.","row-private":"privado","node-detail-open":"abrir el detalle","node-detail-reach":"Alcanzabilidad","node-detail-route":"ruta","node-detail-ssh":"SSH","node-detail-transport":"transporte","node-detail-owner":"propietario","node-detail-authority":"Qué puede hacer este nodo","authority-owner-equivalent":"Autoridad igual a la tuya: un nodo emparejado puede hacer en esta máquina todo lo que puedes hacer tú.","authority-routed":"No está emparejado con esta máquina: su autoridad vive en el hub que lo enruta.","authority-no-grants":"El único poder por nodo que existe es la elección de celdas, más abajo. Dentro de esas celdas la autoridad sigue siendo plena.","authority-no-grants-elsewhere":"El único poder por nodo que existe es la elección de celdas, y se configura en la instalación que las posee — no aquí.","node-detail-network-view":"Qué ve de esta red","node-detail-command":"Comando","vl-no-commands":"El dispositivo no declara comandos disponibles.","vl-events-title":"Sesión","vl-events-empty":"Ningún evento en memoria: la sesión aún no ha hablado, o lo que dijo ha salido del búfer. El historial queda en el dispositivo.","vl-events-gap":"eventos no recibidos:","vl-events-truncated":"contenido truncado por el dispositivo","vl-events-turn-end":"— fin del turno —","vl-events-done":"— fin de la respuesta —","vl-events-writer-epoch":"— cambio de escritor —","vl-events-tool":"herramienta","vl-events-tool-ok":"terminada","vl-events-tool-failed":"fallida","vl-events-usage":"consumo actualizado","vl-events-stale":"Actualización fallida: puede que no estés viendo lo último.","vl-cmd-phase-submitted":"enviado, a la espera de confirmación","vl-cmd-phase-inflight":"en curso","vl-cmd-phase-done-ok":"completado","vl-cmd-phase-done-error":"fallido","vl-cmd-status":"estado","vl-cmd-health":"salud","vl-cmd-start":"iniciar","vl-cmd-stop":"detener","vl-cmd-restart":"reiniciar","vl-cmd-version":"versión","vl-cmd-capabilities":"capacidades","vl-cmd-logs":"logs","vl-cmd-prompt":"prompt","vl-prompt-placeholder":"escribe el prompt para la sesión del dispositivo…","vl-prompt-send":"enviar prompt","vl-cmd-unpair":"desemparejar","node-grant-none":"Ningún nodo elegido: compartido, pero hacia nadie.","node-grant-unknown":"ya no está en el inventario","node-grant-remove":"quitar","node-grant-add":"Añadir un nodo","node-grant-search":"Buscar entre los nodos","node-grant-no-candidates":"Ningún nodo coincide.","cell-scope":"Celdas visibles para este nodo","cell-scope-help":"Se aplica a lo que este nodo lista y a lo que puede tocar, incluido el terminal. Dentro de las celdas concedidas sigue siendo un nodo emparejado por completo: no es un sandbox.","cell-scope-all":"todas las celdas","cell-scope-none":"ninguna celda","cell-scope-selected":"celdas seleccionadas","cell-scope-none-granted":"Ninguna celda elegida: este nodo no ve ninguna.","cell-scope-unknown":"la celda ya no existe","cell-scope-add":"Añadir una celda","cell-scope-search":"Buscar entre las celdas","cell-scope-no-candidates":"Ninguna celda coincide.","cell-scope-reset-warning":"Al cambiar de modo la lista se borra: volver a «celdas seleccionadas» obliga a elegirlas de nuevo.","cell-scope-list-unavailable":"Lista de celdas no disponible ahora: las concesiones de abajo siguen vigentes, pero no se puede saber si aún existen.","single-view":"vista única",retract:"reducir","keybar-expand":"ampliar la barra de teclas","keybar-retract":"reducir la barra de teclas","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 de un solo uso. Hace falta la dirección SSH de este dispositivo, alcanzable por quien la use.","invite-target-local":"El nuevo dispositivo entrará en","invite-target-this":"este dispositivo","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 Bl(){const e=Cy(),t=e?e.getItem(ky):null;return df.includes(t)?t:Rl}function zx(e){const t=Cy();if(t)try{t.setItem(ky,e)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(Gd))}function f(e){const t=Bl(),n=vl[t]||vl[Rl];return Object.prototype.hasOwnProperty.call(n,e)?n[e]:Object.prototype.hasOwnProperty.call(vl[Rl],e)?vl[Rl][e]:e}function $x(e){return typeof window>"u"?()=>{}:(window.addEventListener(Gd,e),()=>window.removeEventListener(Gd,e))}const Ey=df;function $n(){return[C.useSyncExternalStore($x,Bl,Bl),zx]}function zl({cell:e,token:t,route:n=[],onConfirm:s,onClose:o}){var L,A;$n();const a=!!(e&&e.active),u=Array.isArray(n)?n.join("/"):"",[h,p]=C.useState([]),[m,v]=C.useState(!1);C.useEffect(()=>{let x=!0;return(async()=>{if(t)try{const I=await Ls(t,u?u.split("/"):[]);if(!x)return;if(v(I.provider==="builtin"&&(I.capabilities||[]).includes("edit")),I.provider==="builtin"&&(I.capabilities||[]).includes("definitions")){const T=await ec(t,u?u.split("/"):[]);if(!x)return;const M=new Map((I.engines||[]).map(O=>[O.id,O]));p((T.engines||[]).map(O=>{var H,se,ee,le,ve,de,fe;return{id:O.id,label:O.label||O.id,client:((H=O.managed)==null?void 0:H.client)||"",models:[...new Set([...((se=M.get(O.id))==null?void 0:se.models)||[],...((ee=O.managedInfo)==null?void 0:ee.models)||[]])].filter(Boolean),defaultModel:((le=O.managed)==null?void 0:le.model)||((ve=O.managedInfo)==null?void 0:ve.defaultModel)||"",policyDefault:((de=O.managed)==null?void 0:de.permissionPolicy)||((fe=O.managed)!=null&&fe.client&&O.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{x=!1}},[t,u]);const w=(e==null?void 0:e.engine)||((L=h[0])==null?void 0:L.id)||"",y=x=>(e==null?void 0:e.models)&&e.models[x]||"",S=x=>{const I=(e==null?void 0:e.permissionPolicies)&&e.permissionPolicies[x];if(I==="standard"||I==="unsafe")return I;const T=h.find(M=>M.id===x);return T?T.policyDefault:"standard"},[k,E]=C.useState(w),[b,j]=C.useState((e==null?void 0:e.model)||""),N=(e==null?void 0:e.permissionPolicy)==="standard"||(e==null?void 0:e.permissionPolicy)==="unsafe"?e.permissionPolicy:((A=e==null?void 0:e.permissionPolicies)==null?void 0:A[e==null?void 0:e.engine])||"",[z,D]=C.useState(N),[U,W]=C.useState((e==null?void 0:e.boot)??!0),[K,te]=C.useState(!1),[G,Q]=C.useState(null);C.useEffect(()=>{h.length&&(E(x=>x||w),j(x=>x||y((e==null?void 0:e.engine)||w)||""),D(x=>x==="standard"||x==="unsafe"?x:S((e==null?void 0:e.engine)||w)))},[h.length]);const q=C.useMemo(()=>h.find(x=>x.id===k)||null,[h,k]),F=!!(q&&["claude","codex","codex-vl","agy","kimi"].includes(q.client)),R=(q==null?void 0:q.client)==="shell";function B(x){E(x);const I=h.find(T=>T.id===x);j(y(x)||(I==null?void 0:I.defaultModel)||""),D(S(x))}async function $(x){x.preventDefault(),te(!0),Q(null);try{if(a)await s({action:"down",boot:U});else{const I=z==="standard"||z==="unsafe"?z:(q==null?void 0:q.policyDefault)||"standard";await s({action:"up",...m?{engine:k,model:b||"",...F?{permissionPolicy:I}:(q==null?void 0:q.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:U})}o()}catch(I){Q(String(I&&I.message||I)),te(!1)}}return l.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:o,children:l.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:x=>x.stopPropagation(),onSubmit:$,children:[l.jsxs("div",{className:"nc-sheet-head",children:[l.jsx("b",{children:e==null?void 0:e.cell}),l.jsx("span",{className:"nc-sheet-state",children:f(a?"state-on":"state-off")})]}),a?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:f("engine")}),l.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&l.jsxs("small",{children:[f("model"),": ",e.model]}),l.jsx("small",{children:f("power-on-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:U,onChange:x=>W(x.target.checked)}),f("remove-boot")]})]}):l.jsxs(l.Fragment,{children:[m&&h.length>0?l.jsxs("div",{className:"nc-launch-fields",children:[l.jsxs("label",{className:"nc-field",children:[f("engine"),l.jsx("select",{value:k,onChange:x=>B(x.target.value),children:h.map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))})]}),!R&&l.jsxs("label",{className:"nc-field",children:[f("model"),l.jsx("input",{value:b,list:"nc-launch-models",placeholder:f("model-default"),onChange:x=>j(x.target.value)}),l.jsx("datalist",{id:"nc-launch-models",children:((q==null?void 0:q.models)||[]).map(x=>l.jsx("option",{value:x},x))})]}),F?l.jsxs("label",{className:"nc-field",children:[f("permissions"),l.jsxs("select",{value:z,onChange:x=>D(x.target.value),children:[l.jsx("option",{value:"standard",children:f("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:f("fleet-unsafe-permissions")})]})]}):l.jsx("small",{className:"nc-note",children:f("fleet-standard-permissions")}),F&&z==="unsafe"&&l.jsx("small",{className:"nc-err",children:f("fleet-unsafe-warning")}),l.jsx("small",{className:"nc-note",children:f(R?"fleet-shell-launch-help":"launch-engine-help")})]}):l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:f("engine")}),l.jsx("b",{children:(e==null?void 0:e.engine)||"—"}),(e==null?void 0:e.model)&&l.jsxs("small",{children:[f("model"),": ",e.model]}),l.jsx("small",{children:f("launch-unavailable-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:U,onChange:x=>W(x.target.checked)}),f("boot-persist")]})]}),G&&l.jsx("div",{className:"nc-err",children:G}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:o,disabled:K,children:f("cancel")}),l.jsx("button",{type:"submit",className:"nc-btn primary",disabled:K,children:f(a?"power-off":"save-and-start")})]})]})})}const Hg=/^[a-z0-9-]{1,32}$/;function Qo(e,t){const n=Array.isArray(e)?e:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${t}`:String(t)}function Fx(e,t,n){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]||n)}return s}function Ug(e,t,n){return!e||!Array.isArray(e.cells)?[]:e.cells.map(s=>({...s,route:t,key:`${n}:${s.tmuxSession||s.cell}`}))}function Wg({nodes:e,topology:t,remote:n,down:s,fleet:o,aliases:a}={}){var m,v,w,y;const u=[],h=new Set,p=new Set;for(const S of Array.isArray(e)?e:[]){if(!S||typeof S.name!="string"||!Hg.test(S.name)||S.direction==="inbound"&&S.shared!==!0)continue;const k=[S.name],E=S.name;h.add(E);const b=((m=S.tunnel)==null?void 0:m.status)||"unknown",j=b==="up",N={name:S.name,label:S.label||S.name,originalLabel:S.label||S.name,alias:null,route:k,direct:!0,instanceId:S.nodeId||null,shared:S.shared===!0,tunnelStatus:b,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:S.health||null,direction:S.direction||"outbound",roles:S.roles||null,rolesKnown:S.rolesKnown===!0};if(S.nodeId&&p.add(S.nodeId),!S.nodeId&&S.paired===!1){u.push({...N,status:"needs-repair",downSince:s&&s[E]||null});continue}if(((v=S.health)==null?void 0:v.auth)==="failed"||b==="degraded"&&((w=S.health)==null?void 0:w.status)==="degraded"){u.push({...N,status:"needs-repair",downSince:s&&s[E]||null});continue}if(b==="passive"||((y=S.health)==null?void 0:y.status)==="passive"){u.push({...N,status:"passive",downSince:null});continue}if(!j){u.push({...N,status:"down",downSince:s&&s[E]||null});continue}const z=n&&(n[E]||n[S.name])||null,D=o&&(o[E]||o[S.name]),U=!!(z&&!z.error&&Array.isArray(z.sessions)),W=!!(D&&D.available===!0&&Array.isArray(D.cells));if(!U&&!W){u.push({...N,status:"unreachable"});continue}const K=(U?z.sessions:[]).filter(Q=>Q&&typeof Q.name=="string"&&Q.name).map(Q=>({...Q,node:E,route:k,key:`${E}:${Q.name}`})),te=Ug(D,k,E),G=new Set(te.map(Q=>Q.tmuxSession).filter(Boolean));u.push({...N,status:"up",sessions:K,cells:te,unmanaged:K.filter(Q=>!G.has(Q.name)),fleetAvailable:!!(D&&D.available),capabilities:D&&D.capabilities||[],engines:D&&D.engines||[],fleetProvider:D&&D.provider||null,sessionsAvailable:U,inventoryPartial:!U})}for(const S of Array.isArray(t)?t:[]){if(!S||!Array.isArray(S.route)||S.route.length<1||S.route.some(G=>!Hg.test(G)))continue;const k=S.route.join("/");if(h.has(k)||S.instanceId&&p.has(S.instanceId))continue;S.instanceId&&p.add(S.instanceId);const E=S.label||S.route.join(" › "),b=S.instanceId&&a&&typeof a[S.instanceId]=="string"?a[S.instanceId]:null,j={name:S.name,label:b||E,originalLabel:E,alias:b,route:[...S.route],direct:!1,instanceId:S.instanceId||null,shared:!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:S.health||null,lastSeen:S.lastSeen||null};if(S.stale){u.push({...j,status:"offline",downSince:s&&s[k]||S.lastSeen||null});continue}const N=n&&n[k]||null,z=o&&o[k],D=!!(N&&!N.error&&Array.isArray(N.sessions)),U=!!(z&&z.available===!0&&Array.isArray(z.cells));if(!D&&!U){u.push({...j,status:"unreachable",downSince:s&&s[k]||null});continue}const W=(D?N.sessions:[]).filter(G=>G&&typeof G.name=="string"&&G.name).map(G=>({...G,node:k,route:S.route,key:`${k}:${G.name}`})),K=Ug(z,S.route,k),te=new Set(K.map(G=>G.tmuxSession).filter(Boolean));u.push({...j,status:"up",sessions:W,cells:K,unmanaged:W.filter(G=>!te.has(G.name)),fleetAvailable:!!(z&&z.available),capabilities:z&&z.capabilities||[],engines:z&&z.engines||[],fleetProvider:z&&z.provider||null,lastSeen:S.lastSeen||null,sessionsAvailable:D,inventoryPartial:!D})}return u.sort((S,k)=>S.label.localeCompare(k.label))}function Ny(e,t={}){if(!e||typeof e!="object")return null;const n=typeof e.nodeId=="string"?e.nodeId:"";if(!n)return null;const s=typeof e.label=="string"&&e.label.trim()||typeof e.cell=="string"&&e.cell.trim()||n,o=Array.isArray(t.route)?[...t.route]:[];return{kind:"vl",nodeId:n,name:n,label:s,cell:e.cell??null,paired:!!e.pairedAt,online:!!e.online,lastSeen:e.lastSeen??null,generation:e.generation??null,version:e.version??null,health:e.health??null,session:e.session??null,capabilities:Array.isArray(e.capabilities)?e.capabilities:[],inflight:e.inflight??null,lastAck:e.lastAck??null,canManage:!!e.canManage,route:o,isLocal:o.length===0,ownerInstanceId:typeof t.instanceId=="string"?t.instanceId:null,ownerLabel:typeof t.label=="string"&&t.label?t.label:null}}function Hx(e){var n;const t=[];for(const s of Array.isArray(e)?e:[]){if(!s||s.kind!=="vl"||!s.nodeId)continue;const o=s.online===!0,a=o&&((n=s.session)==null?void 0:n.attached)===!0,u=s.ownerInstanceId||"local";t.push({kind:"vl",name:`vl-${s.nodeId.slice(0,8)}`,label:s.label,route:Array.isArray(s.route)?[...s.route]:[],instanceId:null,direct:!1,status:o?"up":"offline",downSince:o?null:s.lastSeen??null,sessions:a?[{key:`vl:${u}:${s.nodeId}`,name:s.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:s.health??null,peer:s})}return t}function jy(e,t){const n=e&&Array.isArray(e.nodes)?e.nodes:[],s=new Set([t]),o=[];for(const a of n){const u=a&&typeof a.instanceId=="string"?a.instanceId:"";if(!u||s.has(u)||a.stale===!0||!Array.isArray(a.route)||a.route.length===0)continue;s.add(u);const h=typeof a.label=="string"&&a.label||typeof a.name=="string"&&a.name||a.route.join(" › ");o.push({instanceId:u,route:[...a.route],label:h})}return o}const Ux=4e3;function hf(e,t=!0,n=0){const[s,o]=C.useState([]),a=C.useRef({});return C.useEffect(()=>{if(!t||!e){o([]);return}let u=!0;async function h(){var D;let m=[],v=[],w={},y="";if(await Promise.all([Q0(e).then(U=>{m=Array.isArray(U.nodes)?U.nodes:[]}).catch(()=>{}),yy(e).then(U=>{v=Array.isArray(U.nodes)?U.nodes:[]}).catch(()=>{}),ix(e).then(U=>{w=U&&typeof U.aliasesByInstanceId=="object"?U.aliasesByInstanceId:{}}).catch(()=>{}),en("/api/config",e).then(U=>U.json()).then(U=>{y=U&&typeof U.instanceId=="string"?U.instanceId:""}).catch(()=>{})]),!u)return;const S=[{instanceId:y||null,route:[],label:null},...jy({nodes:v},y)],k=[];if(await Promise.all(S.map(async U=>{try{const W=await _y(e,U.route);for(const K of W.nodes||[]){const te=Ny(K,U);te&&k.push(te)}}catch{}})),!u)return;const E={},b={},j=new Set(m.map(U=>U.name)),N=[];for(const U of m)((D=U.tunnel)==null?void 0:D.status)==="up"&&(U.nodeId||U.paired!==!1)&&(U.direction!=="inbound"||U.shared===!0)&&N.push([U.name]);for(const U of v)!U.stale&&Array.isArray(U.route)&&U.route.length>0&&!(U.route.length===1&&j.has(U.route[0]))&&N.push(U.route);if(await Promise.all(N.map(async U=>{const W=U.join("/");try{E[W]=await lf(e,U)}catch{E[W]={error:"unreachable"}}try{b[W]=await Ls(e,U)}catch{b[W]={available:!1}}})),!u)return;const z=Wg({nodes:m,topology:v,remote:E,fleet:b,aliases:w,down:a.current});a.current=Fx(a.current,z,Math.floor(Date.now()/1e3)),o([...Wg({nodes:m,topology:v,remote:E,fleet:b,aliases:w,down:a.current}),...Hx(k)])}h();const p=setInterval(h,Ux);return()=>{u=!1,clearInterval(p)}},[e,t,n]),s}const Kg=52,qg=14;function Li({position:e,itemKey:t,label:n,onMove:s,onStep:o,canMove:a=()=>!0,scope:u="roster"}){const h=C.useRef(null),p=C.useRef(0),[m,v]=C.useState(!1),w=()=>{var j,N,z,D;const b=h.current;(N=(j=b==null?void 0:b.over)==null?void 0:j.classList)==null||N.remove("nc-roster-over"),(D=(z=b==null?void 0:b.source)==null?void 0:z.classList)==null||D.remove("nc-roster-dragging"),p.current&&cancelAnimationFrame(p.current),p.current=0},y=(b=!1)=>{const j=h.current;if(!j)return;const N=j.target;w(),h.current=null,v(!1);try{j.handle.releasePointerCapture(j.pointerId)}catch{}b&&N&&N!==t&&a(t,N)&&s(t,N)},S=(b,j)=>{var te,G,Q,q,F,R,B,$,L;const N=h.current;if(!N)return;N.x=b,N.y=j;const z=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",D=(G=(te=document.elementFromPoint(b,j))==null?void 0:te.closest)==null?void 0:G.call(te,z),U=u==="node"?(Q=D==null?void 0:D.dataset)==null?void 0:Q.nodeOrderKey:(q=D==null?void 0:D.dataset)==null?void 0:q.rosterKey,K=(u==="node"||((F=D==null?void 0:D.dataset)==null?void 0:F.position)===e)&&U&&U!==t&&a(t,U);N.over!==(K?D:null)&&((B=(R=N.over)==null?void 0:R.classList)==null||B.remove("nc-roster-over"),N.over=K?D:null,(L=($=N.over)==null?void 0:$.classList)==null||L.add("nc-roster-over")),N.target=K?U:null},k=()=>{const b=h.current;if(!b){p.current=0;return}const j=b.container;if(j){const N=j.getBoundingClientRect(),z=b.y<N.top+Kg?-qg:b.y>N.bottom-Kg?qg:0;z&&(j.scrollTop+=z,S(b.x,b.y))}p.current=requestAnimationFrame(k)};C.useEffect(()=>{const b=N=>{N.key==="Escape"&&h.current&&(N.preventDefault(),y(!1))},j=()=>y(!1);return window.addEventListener("keydown",b),window.addEventListener("blur",j),()=>{window.removeEventListener("keydown",b),window.removeEventListener("blur",j),w(),h.current=null}},[t,e,u]);const E=b=>{var D;if(b.pointerType==="mouse"&&b.button!==0)return;b.preventDefault(),b.stopPropagation(),b.currentTarget.focus({preventScroll:!0});const j=u==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",N=b.currentTarget.closest(j),z=b.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");h.current={pointerId:b.pointerId,handle:b.currentTarget,source:N,container:z,target:null,over:null,x:b.clientX,y:b.clientY},(D=N==null?void 0:N.classList)==null||D.add("nc-roster-dragging");try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}v(!0),p.current=requestAnimationFrame(k)};return l.jsx("button",{type:"button",className:`nc-roster-handle${m?" active":""}`,"aria-label":`${f("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:f("reorder-help"),onClick:b=>{b.preventDefault(),b.stopPropagation()},onDragStart:b=>b.preventDefault(),onKeyDown:b=>{b.key!=="ArrowUp"&&b.key!=="ArrowDown"||(b.preventDefault(),b.stopPropagation(),o(b.key==="ArrowUp"?-1:1))},onPointerDown:E,onPointerMove:b=>{!h.current||b.pointerId!==h.current.pointerId||(b.preventDefault(),b.stopPropagation(),S(b.clientX,b.clientY))},onPointerUp:b=>{!h.current||b.pointerId!==h.current.pointerId||(b.preventDefault(),b.stopPropagation(),y(!0))},onPointerCancel:()=>y(!1),onLostPointerCapture:()=>{h.current&&y(!1)},children:"↕"})}const ff="nc_pins";function Ju(){try{const e=JSON.parse(localStorage.getItem(ff));return Array.isArray(e)?e:[]}catch{return[]}}function Ry(e){try{return localStorage.setItem(ff,JSON.stringify(e)),null}catch(t){return t instanceof Error?t:new Error(String(t))}}function Wx(e,t){const n=e.includes(t)?e.filter(s=>s!==t):[...e,t];return{next:n,error:Ry(n)}}function Vg(e,t){if(!Array.isArray(e)||!e.includes(t))return{next:Array.isArray(e)?e:[],error:null};const n=e.filter(s=>s!==t);return{next:n,error:Ry(n)}}function Kx(e,t,n){if(!e.includes(t)||!e.includes(n)||t===n)return e;const s=[...e],o=s.indexOf(t),a=s.indexOf(n);s.splice(o,1);const u=s.indexOf(n);s.splice(o<a?u+1:u,0,t);try{localStorage.setItem(ff,JSON.stringify(s))}catch{}return s}function qx(e,t,n){const s=e.indexOf(t);return[s===-1?1e9:s,-(n||0)]}function Vx(e,t){return e[0]-t[0]||e[1]-t[1]}function pf(){const[e,t]=C.useState(Ju),[n,s]=C.useState(Ix),[o,a]=C.useState(Tx),[u,h]=C.useState(null),p=j=>t(N=>Wx(N,j).next),m=j=>{const N=Vg(Ju(),j);return t(N.next),h(N.error?{key:j,message:N.error.message||String(N.error)}:null),N.error},v=()=>{if(!u)return;const j=Vg(Ju(),u.key);t(j.next),h(j.error?{...u,message:j.error.message||String(j.error)}:null)},w=()=>h(null),y=j=>$g(n,j),S=(j,N)=>s(z=>{const D={...z,[j]:{...$g(z,j),...N}};return Ox(D)}),k=(j,N)=>e.includes(j)===e.includes(N);function E(j,N,z,D){const U=e.includes(N),W=e.includes(z);if(U===W){if(U){t(K=>Kx(K,N,z));return}a(K=>{var Q;const te=((Q=D.find(q=>q.key===N))==null?void 0:Q.technical)===!0,G=js(D,e,te?"technical":"all",Ji(K,j)).map(q=>q.key);return Mx(Dx(K,j,N,z,G))})}}function b(j,N,z,D){var Q;const U=((Q=D.find(q=>q.key===N))==null?void 0:Q.technical)===!0,W=e.includes(N),K=js(D,e,U?"technical":"all",Ji(o,j)).map(q=>q.key).filter(q=>e.includes(q)===W),te=K.indexOf(N),G=K[te+z];te>=0&&G&&E(j,N,G,D)}return{pins:e,views:n,orders:o,togglePin:p,removePin:m,pinError:u,retryPinPersist:v,clearPinError:w,viewFor:y,updateView:S,canMoveRoster:k,moveRoster:E,stepRoster:b}}const Py="nc_node_order_v1",Yx=/^[a-f0-9]{16,64}$/;function Xs(e){if(Yx.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(n=>typeof n=="string"&&n):[];return t.length?`route:${t.map(encodeURIComponent).join("/")}`:typeof(e==null?void 0:e.name)=="string"&&e.name?`name:${encodeURIComponent(e.name)}`:""}function Yg(e=globalThis.localStorage){try{const t=JSON.parse(e.getItem(Py));return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):[]}catch{return[]}}function Gx(e,t=globalThis.localStorage){try{t.setItem(Py,JSON.stringify(e))}catch{}return e}function Gg(e=[],t=[]){const n=new Map(t.map((s,o)=>[s,o]));return e.map((s,o)=>({group:s,index:o})).sort((s,o)=>{const a=n.has(Xs(s.group))?n.get(Xs(s.group)):Number.MAX_SAFE_INTEGER,u=n.has(Xs(o.group))?n.get(Xs(o.group)):Number.MAX_SAFE_INTEGER;return a-u||s.index-o.index}).map(({group:s})=>s)}function Xx(e,t,n,s=[]){if(!t||!n||t===n)return e;const o=s.map(Xs).filter(Boolean);if(!o.includes(t)||!o.includes(n))return e;const a=[...e.filter(m=>o.includes(m)),...o.filter(m=>!e.includes(m))],u=a.indexOf(t),h=a.indexOf(n);a.splice(u,1);const p=a.indexOf(n);return a.splice(u<h?p+1:p,0,t),a}const Xd="nexuscrew-node-preferences";function Qx(){try{window.dispatchEvent(new Event(Xd))}catch{}}function Ay(){const[e,t]=C.useState(Yg);C.useEffect(()=>{const a=()=>t(Yg());return window.addEventListener("storage",a),window.addEventListener(Xd,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(Xd,a)}},[]);const n=a=>Gg(a,e),s=(a,u,h)=>t(p=>{const m=Xx(p,a,u,h);return Gx(m),Qx(),m});return{order:e,groupsFor:n,moveNode:s,stepNode:(a,u,h)=>{const p=Gg(h,e).map(Xs),m=p.indexOf(a),v=p[m+u];m>=0&&v&&s(a,v,h)},nodeKey:Xs}}const Jx="none",Ly="favorite",mf="live";function Qd({hostCell:e,pins:t=[],item:n}){const s=n&&n.value&&typeof n.value.cell=="string"?n.value.cell:null;return s!=null&&e===s?mf:Array.isArray(t)&&n&&t.includes(n.key)?Ly:Jx}function Ty(e){return e===mf?"clearAndUnpin":e===Ly?"designate":"addPin"}const Zx=Object.freeze(["live","grace","expired","none","unavailable"]);function Jd(e,t){return e!==mf||!Zx.includes(t)?null:`host-lease-${t}`}const ek="local";function Vo(e){return Array.isArray(e)&&e.length?e.join("/"):ek}function Xg(e){return(e&&e.data&&typeof e.data=="object"?e.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":"live-host-error"}function My({pinError:e,onRetry:t,onDismiss:n}){return e?l.jsxs("div",{className:"nc-pin-error",role:"alert",children:[l.jsx("span",{className:"nc-pin-error-text",children:"★ preferenza non salvata"}),l.jsx("button",{type:"button",className:"nc-pin-error-retry",onClick:t,children:"riprova"}),l.jsx("button",{type:"button",className:"nc-pin-error-close",onClick:n,"aria-label":"chiudi avviso",children:"×"})]}):null}function Br(e,t=Math.floor(Date.now()/1e3)){if(!e)return"";const n=t-e;return n<0||n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function Xi(e){return e.status==="passive"?f("node-passive"):e.status==="down"?e.downSince?f("tunnel-down-since").replace("{t}",Br(e.downSince)):f("tunnel-down"):e.status==="unreachable"?f("node-unreachable"):e.status==="offline"?e.lastSeen?f("node-offline-seen").replace("{t}",Br(e.lastSeen)):f("node-offline"):e.status==="needs-repair"?f("node-needs-repair"):""}function Dy(e,{passive:t=null}={}){return e?e.status==="passive"?t:e.status==="healthy"?"on":"warn":null}function Yo(e){return e&&(e.detail||e.status)||""}const tk="restrict,port-forwarding,permitopen=";function nk(e){const t=e&&typeof e.hint=="string"&&e.hint.trim()||"",n=e&&typeof e.authorizedKeys=="string"&&e.authorizedKeys.trim()||"";if(n){const o=t.indexOf(n);return{note:o>=0?t.slice(0,o).replace(/[:\s]+$/,""):t,line:n}}if(!t)return null;const s=t.indexOf(tk);return s<0?{note:t,line:""}:{note:t.slice(0,s).replace(/[:\s]+$/,""),line:t.slice(s).trim()}}function $l(e,t,n=globalThis.localStorage){if(!(e!=null&&e.outbox)||e.outbox.count<1)return!1;const s=Number(n.getItem(hy(t))||0);return e.outbox.latest>s}function gf(e,t={}){const n=e||{};if(!n.tmux){const s=`${n.engine||""}${n.key?`·${n.key}`:""}`,o=[s,n.model&&n.model!==s?n.model:""].filter(Boolean).join(" · ");return{working:!1,subtitle:String(o||f("cell-off")).trim()}}if(t.working===!0){const s=f("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:f("cell-idle")}:{working:!1,subtitle:String(t.preview||n.preview||f("cell-on")).trim()}}function Iy(e,t){return[...new Set([e.engine,e.model,e.key,t.preview,e.preview,t.status].filter(Boolean).map(String))].join(" ")}function vf(e,t,n,s=globalThis.localStorage){return[...(Array.isArray(e)?e:[]).map(o=>{const a=n.get(o.tmuxSession)||{},u=Qo([],o.tmuxSession),h=gf(o,a);return{type:"cell",value:o,key:u,label:o.cell,live:!!o.tmux,fresh:$l(a,u,s),activity:a.activity||0,working:h.working,subtitle:h.subtitle,searchText:Iy(o,a)}}),...(Array.isArray(t)?t:[]).map(o=>{const a=Qo([],o.name);return{type:"session",value:o,key:a,label:o.name,live:!0,technical:o.technical===!0,fresh:$l(o,a,s),activity:o.activity||0,searchText:`${o.preview||""} ${o.cmd||""}`}})]}function Fl(e,t=globalThis.localStorage){const n=e||{},s=Array.isArray(n.route)?n.route:[],o=new Map((n.sessions||[]).map(u=>[u.name,u])),a=[...(n.cells||[]).map(u=>{const h=o.get(u.tmuxSession)||{},p=Qo(s,u.tmuxSession||u.cell),m=gf(u,h);return{type:"cell",value:u,key:p,label:u.cell,live:!!u.tmux,fresh:$l(h,p,t),activity:h.activity||u.activity||0,working:m.working,subtitle:m.subtitle,searchText:Iy(u,h)}}),...(n.unmanaged||[]).map(u=>{const h=Qo(s,u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:$l(u,h,t),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})];return{route:s,rawItems:a}}const _f=9,Hl=.2,ik=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,zr=/^[a-f0-9]{16,64}$/,Zd=e=>ik.test(e)&&new Set(e.split("/")).size===e.split("/").length;function As(e){if(typeof e=="string"&&e){const t=e.indexOf(":");if(t<0)return{session:e};const n=e.slice(0,t),s=e.slice(t+1);return!Zd(n)||!s?null:{session:s,node:n}}if(e&&typeof e=="object"&&typeof e.session=="string"&&e.session){const t=e.ownerId===void 0?void 0:typeof e.ownerId=="string"&&zr.test(e.ownerId)?e.ownerId:null;return t===null?null:e.node===void 0||e.node===null||e.node===""?{session:e.session,...t?{ownerId:t}:{}}:typeof e.node=="string"&&Zd(e.node)?{session:e.session,node:e.node,...t?{ownerId:t}:{}}:null}return null}function ii(e){const t=As(e);return t?t.node?`${t.node}:${t.session}`:t.session:""}const Oy=9,By=24,ia=11,sk=e=>{const t=Number(e);return t>=Oy&&t<=By?t:ia};function Dr(){return{columns:[]}}function Di(e){return e.columns.flatMap(t=>t.tiles.map(n=>ii(n)))}function rk(e){const t=[],n=Math.max(0,...e.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const o of e.columns)o.tiles[s]&&t.push(ii(o.tiles[s]));return t}const Wr=e=>({columns:e.columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))});function yf(e,t,n,s){const o=As(t);if(!o||Di(e).includes(ii(o))||Di(e).length>=_f)return e;const a=Wr(e),u={session:o.session,height:1,fontSize:ia,...s||{}};if(o.node&&(u.node=o.node),o.ownerId&&(u.ownerId=o.ownerId),n==="end")return a.columns.push({width:1,tiles:[u]}),a;if(n&&typeof n.col=="number"&&typeof n.row=="number"&&a.columns[n.col])return a.columns[n.col].tiles.splice(n.row,0,u),a;if(n&&typeof n.col=="number"){const h=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(h,0,{width:1,tiles:[u]}),a}return a.columns.push({width:1,tiles:[u]}),a}function zy(e,t){const n=ii(t);if(!n||Di(e).includes(n)||Di(e).length>=_f)return e;const s=Di(e).length+1,o=Math.ceil(Math.sqrt(s));if(e.columns.length>=o){let v=0;for(let w=1;w<e.columns.length;w+=1)e.columns[w].tiles.length<e.columns[v].tiles.length&&(v=w);return yf(e,t,{col:v,row:e.columns[v].tiles.length})}const a=[...rk(e),n],u=new Map(e.columns.flatMap(v=>v.tiles.map(w=>[ii(w),w]))),h=As(t),p=e.columns.length?e.columns.reduce((v,w)=>v+(Number(w.width)||1),0)/e.columns.length:1,m=Array.from({length:o},(v,w)=>{var y;return{width:((y=e.columns[w])==null?void 0:y.width)||p,tiles:[]}});return a.forEach((v,w)=>{const y=As(v);if(!y)return;const S=u.get(v)||(v===n?h:{})||{},k={session:y.session,height:S.height||1,fontSize:S.fontSize||ia};y.node&&(k.node=y.node),S.ownerId&&(k.ownerId=S.ownerId),S.unavailable===!0&&(k.unavailable=!0),m[w%o].tiles.push(k)}),{columns:m.filter(v=>v.tiles.length)}}function Ul(e,t){const n=ii(t),s=Wr(e);for(const o of s.columns)o.tiles=o.tiles.filter(a=>ii(a)!==n);return s.columns=s.columns.filter(o=>o.tiles.length>0),s}function ok(e,t,n){const s=ii(t);if(!Di(e).includes(s))return e;const o=e.columns.flatMap(a=>a.tiles).find(a=>ii(a)===s);return yf(Ul(e,s),s,n,{fontSize:o.fontSize,height:o.height,...o.ownerId?{ownerId:o.ownerId}:{},...o.unavailable===!0?{unavailable:!0}:{}})}function ak(e,t){if(!(t instanceof Map)||t.size===0)return e;let n=!1;const s=Wr(e);for(const o of s.columns)for(const a of o.tiles){const u=t.get(ii(a));if(!u)continue;const h=As(u);h&&(a.session=h.session,h.node?a.node=h.node:delete a.node,h.ownerId&&(a.ownerId=h.ownerId),n=!0)}return n?Js(s):e}function lk(e,t,n){const s=Wr(e);return s.columns[t]&&(s.columns[t].width=Math.max(Hl,Number(n)||1)),s}function ck(e,t,n,s){const o=Wr(e),a=o.columns[t]&&o.columns[t].tiles[n];return a&&(a.height=Math.max(Hl,Number(s)||1)),o}function uk(e,t,n,s){if(!(e.columns[t]&&e.columns[t].tiles[n]))return e;const a=Wr(e),u=a.columns[t].tiles[n],h=Number(u.fontSize)||ia;return u.fontSize=Math.max(Oy,Math.min(By,h+(Number(s)||0))),a}function dk(e,t,n,s){const o=e.columns[t];if(!o||!o.tiles[n])return null;switch(s){case"left":return{col:t};case"right":return{col:t+1};case"top":return{col:t,row:n};case"bottom":return{col:t,row:n+1};default:return null}}function Qg(e){for(const t of[.25,.5,.75])if(Math.abs(e-t)<=.03)return t;return e}function Js(e){if(!e||!Array.isArray(e.columns))return Dr();const t=e.columns.map(s=>({width:Math.max(Hl,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"&&Zd(o.node)).filter(o=>o.ownerId==null||typeof o.ownerId=="string"&&zr.test(o.ownerId)).map(o=>{const a={session:o.session,height:Math.max(Hl,Number(o.height)||1),fontSize:sk(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),n=new Set;for(const s of t)s.tiles=s.tiles.filter(o=>!n.has(ii(o))&&n.add(ii(o))&&n.size<=_f);return{columns:t.filter(s=>s.tiles.length>0)}}const $y=/^[a-z0-9-]{1,32}$/,hk=/^[A-Za-z0-9._-]{1,32}$/,fk=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,pk=320;function eh(e){return typeof e=="string"&&$y.test(e)}const mk=64;function $r(e){if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&t.length<=mk&&!/[\x00-\x1f\x7f]/.test(t)}function Rs(e){return String(e??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function Fy(e){if(typeof e!="string"||!e||e.length>pk||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:hk.test(e.slice(0,t))&&fk.test(e.slice(t+1))}function Jg(e){if(e===""||e===null||e===void 0)return null;const t=String(e).trim();if(!/^[0-9]{1,5}$/.test(t))return;const n=Number(t);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function gk({name:e,ssh:t,sshPort:n,remotePort:s}={}){const o=typeof e=="string"?e.trim():e,a=typeof t=="string"?t.trim():t;if(!eh(o))return{ok:!1,error:"err-node-name"};if(!Fy(a))return{ok:!1,error:"err-ssh"};const u=Jg(n);if(u===void 0)return{ok:!1,error:"err-ssh-port"};const h=Jg(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 vk(e,t){if(!e||!t||t<e)return null;const n=Math.floor((t-e)/1e3);return n<60?"ora":n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}g`}function th(e,t){const n=!!(e&&e.status==="up"),s=!!(e&&e.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?vk(e.since,t):null}}const _k=new Set(["v","instanceId","port","label","invite"]),yk=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function wk(e){const t=String(e).replace(/-/g,"+").replace(/_/g,"/"),n=t+"=".repeat((4-t.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),o=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(o):Buffer.from(o).toString("utf8")}function bk(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 n;try{n=JSON.parse(wk(t))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?_k:n.v===2?yk:null;if(!s)return{ok:!1};for(const u of Object.keys(n))if(!s.has(u))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const o=Number(n.port);if(!Number.isInteger(o)||o<1||o>65535)return{ok:!1};if(typeof n.label!="string")return{ok:!1};if(typeof n.invite!="string"||!n.invite)return{ok:!1};const a={ok:!0,version:n.v,label:n.label,invite:n.invite,instanceId:n.instanceId,port:o};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!$y.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!Fy(n.ssh))return{ok:!1};a.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const u=Number(n.sshPort);if(!Number.isInteger(u)||u<1||u>65535)return{ok:!1};a.sshPort=u}}return a}function Sk(e,t,n=new Set){if(!t||!t.ok)return e;const s={...e},o=(a,u)=>{u==null||u===""||n.has(a)||(s[a]=u)};return o("label",t.label),t.version===2&&(o("name",t.name||(t.ssh?Rs(t.label):"")),o("ssh",t.ssh),t.sshPort!==void 0&&o("sshPort",String(t.sshPort))),s}const xk=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],kk=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function wf(e){const t=e&&typeof e=="object"?e.actionRequired:null;return!t||typeof t!="object"||!xk.includes(t.code)||!kk.includes(t.recovery)?null:{code:t.code,recovery:t.recovery,text:f(`fleet-recovery-${t.recovery}`)}}let nh={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function Zg(){return nh}function Hy(e={}){return nh={sessions:Array.isArray(e.sessions)?e.sessions:[],cells:Array.isArray(e.cells)?e.cells:[],nodeGroups:Array.isArray(e.nodeGroups)?e.nodeGroups:[],localNodeId:typeof e.localNodeId=="string"?e.localNodeId:"",localFresh:e.localFresh===!0,refreshedAt:Number.isFinite(e.refreshedAt)?e.refreshedAt:0},nh}const jr=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function Ck({onPick:e,token:t,onSettings:n,onOpenVlSession:s,hostByRoute:o={},onDesignateCell:a,onClearHostCell:u}){const[h,p]=$n(),m=hf(t),[v,w]=C.useState(null),[y,S]=C.useState(null),[k,E]=C.useState(""),[b,j]=C.useState(""),[N,z]=C.useState({bind:"127.0.0.1",port:""}),[D,U]=C.useState(""),[W,K]=C.useState([]),[te,G]=C.useState([]),[Q,q]=C.useState({}),[F,R]=C.useState(new Set),[B,$]=C.useState(null),[L,A]=C.useState(null),{pins:x,orders:I,togglePin:T,removePin:M,pinError:O,retryPinPersist:H,clearPinError:se,viewFor:ee,updateView:le,canMoveRoster:ve,moveRoster:de,stepRoster:fe}=pf(),He=Z=>o[Vo(Z)]||{};function st(Z,we,Oe,je){const tt=Ty(Oe);if(tt==="addPin"){T(Z.key);return}if(tt==="designate"){a&&a(we.cell,je);return}if(tt==="clearAndUnpin"){if(!u)return;Promise.resolve(u(je)).then(Ye=>{Ye&&M(Z.key)})}}const{groupsFor:lt,moveNode:Ee,stepNode:xt,nodeKey:qt}=Ay(),ze=lt(m);C.useEffect(()=>{Hy({sessions:v||[],cells:W,nodeGroups:m,localNodeId:D})},[v,W,m,D]),C.useEffect(()=>{const Z=new Map;for(const we of W)Z.set(jr(we.cell),!!we.boot);for(const we of m){const Oe=we.route||[we.name];for(const je of we.cells||[])Z.set(jr(je.cell,Oe),!!je.boot)}q(we=>{let Oe=!1;const je={...we};for(const[tt,Ye]of Object.entries(we))Z.has(tt)&&Z.get(tt)===Ye&&(delete je[tt],Oe=!0);return Oe?je:we})},[W,m]);async function Rt(){try{const we=await(await en("/api/sessions",t)).json();we.error?(S(we.error),w([])):(S(null),w(we.sessions||[]))}catch(Z){S(String(Z)),w([])}try{const Z=await Ls(t);K(Z.available?Z.cells||[]:[]),G(Z.available?Z.capabilities||[]:[])}catch{K([]),G([])}}C.useEffect(()=>{Rt(),en("/api/config",t).then(we=>we.json()).then(we=>{j(we.version||""),z({bind:we.bind||"127.0.0.1",port:we.port||""}),U(zr.test(String(we.instanceId||""))?we.instanceId:"")}).catch(()=>{});const Z=setInterval(Rt,4e3);return()=>clearInterval(Z)},[]);async function gt(){if(!N.port)return;const Z=`http://${N.bind}:${N.port}/#token=${t}`;try{await navigator.clipboard.writeText(Z)}catch{}}function Mt(Z,we,Oe){const je=jr(Z,we);q(tt=>({...tt,[je]:!!Oe}))}function ht(Z,we=[]){const Oe=jr(Z.cell,we);return Object.prototype.hasOwnProperty.call(Q,Oe)?Q[Oe]:!!Z.boot}async function bt(Z,we,Oe=[]){Z.stopPropagation();const je=jr(we.cell,Oe),tt=!ht(we,Oe);Mt(we.cell,Oe,tt),R(Ye=>new Set(Ye).add(je));try{await fy(t,{cell:we.cell,enabled:tt},Oe),Oe.length||K(Ye=>Ye.map(pt=>pt.cell===we.cell?{...pt,boot:tt}:pt))}catch(Ye){q(pt=>{const yt={...pt};return delete yt[je],yt}),S(String((Ye==null?void 0:Ye.message)||Ye))}finally{R(Ye=>{const pt=new Set(Ye);return pt.delete(je),pt})}}async function Bt(Z){if(!B)return;const{cell:we}=B,Oe=Array.isArray(B.route)?B.route:[];if(Z.action==="up"){const je=await rf(t,{cell:we,boot:!!Z.boot,...Z.engine?{engine:Z.engine}:{},...Z.model!==void 0?{model:Z.model}:{},...Z.permissionPolicy?{permissionPolicy:Z.permissionPolicy}:{}},Oe),tt=wf(je);tt&&S(tt.text),Mt(we,Oe,!!Z.boot)}else await Ol(t,{cell:we,boot:!!Z.boot},Oe),Z.boot&&Mt(we,Oe,!1);Rt()}async function kt(Z,we=[]){try{await of(t,Z,we)}catch{return}Rt()}async function Dt(Z,we,Oe=[]){try{await gy(t,Z,we,Oe)}catch{return}Rt()}async function Lt(Z){if(!(!(Z!=null&&Z.direct)||L)){A(Z.name);try{await uf(t,Z.name,Z.tunnelStatus==="up"?"down":"up")}catch{}A(null)}}async function Ct(Z){if(!(Z!=null&&Z.direct))return;const we=window.prompt(f("rename-node-prompt"),Z.label||Z.name);if(we===null)return;const Oe=String(we).trim();if(!$r(Oe)){window.alert(f("rename-node-invalid"));return}try{await wy(t,Z.name,Oe)}catch(je){window.alert(String((je==null?void 0:je.message)||je))}}const ye=C.useMemo(()=>new Map((v||[]).map(Z=>[Z.name,Z])),[v]),ce=C.useMemo(()=>new Set(W.map(Z=>Z.tmuxSession)),[W]),Le=C.useMemo(()=>(v||[]).filter(Z=>!ce.has(Z.name)),[v,ce]),qe=C.useMemo(()=>vf(W,Le,ye),[W,Le,ye]),ie=ee("local"),_e=C.useMemo(()=>js(qe,x,ie.filter,Ji(I,"local")).filter(Z=>Fg(Z,k)),[qe,x,ie.filter,k,I]),Ce=ze.reduce((Z,we)=>Z+(we.cells||[]).length+(we.unmanaged||[]).filter(Oe=>!Oe.technical).length,0),Ue=js(qe,x,"all",Ji(I,"local")).length+Ce,Ve=qe.filter(Z=>Z.live).length+ze.reduce((Z,we)=>Z+Fl(we).rawItems.filter(Oe=>Oe.live).length,0),ft=(v||[]).filter(Z=>Z.attached).length+ze.reduce((Z,we)=>Z+(we.sessions||[]).filter(Oe=>Oe.attached).length,0),Et=Math.min(ft,Ve),St=N.port?`${N.bind}:${N.port}`:N.bind;function Nt(Z,we=null,Oe=qe){var re,xe;const je=Array.isArray(we==null?void 0:we.route)?we.route:[],tt=je.join("/"),Ye=tt||"local",pt=je.length?we==null?void 0:we.instanceId:D,yt=(ge,Ae)=>e({session:ge,...tt?{node:tt}:{},...zr.test(String(pt||""))?{ownerId:pt}:{},...typeof Ae=="string"&&Ae?{cellName:Ae}:{}}),gn=ve;if(Z.type==="cell"){const ge=Z.value,Ae=He(je),Ge=Qd({hostCell:Ae.hostCell??null,pins:x,item:Z}),rt=je.length?((we==null?void 0:we.sessions)||[]).find(nn=>nn.name===ge.tmuxSession):ye.get(ge.tmuxSession),Pe=Jd(Ge,Ae.hostLease??null),J=ge.degraded?f("cell-degraded"):Z.working?Z.subtitle:ge.tmux?f("cell-idle"):f("cell-off"),pe=Pe?`${J} · ${f(Pe)}`:J,Me=je.length===0||((we==null?void 0:we.capabilities)||[]).includes(ge.active?"down":"up"),ot=je.length===0?te.includes("boot"):((we==null?void 0:we.capabilities)||[]).includes("boot"),Xe=ht(ge,je),vt=jr(ge.cell,je),Pt=`${f(Xe?"boot-disable":"boot-enable")} ${ge.cell}`;return l.jsxs("div",{className:"nc-mcard","data-roster-key":Z.key,"data-position":Ye,children:[l.jsx(Li,{position:Ye,itemKey:Z.key,label:ge.cell,canMove:gn,onMove:(nn,Dn)=>de(Ye,nn,Dn,Oe),onStep:nn=>fe(Ye,Z.key,nn,Oe)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>ge.tmux&&yt(ge.tmuxSession,ge.cell),title:pe,"aria-label":`${ge.cell}, ${pe}`,children:[l.jsx("span",{className:`dot ${ge.degraded?"warn":ge.tmux?`on${Z.working?" working":""}`:""}`}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:ge.cell}),l.jsx("small",{title:Z.subtitle,children:Z.subtitle})]})]}),Z.activity?l.jsx("span",{className:"nc-rel",children:Br(Z.activity)}):null,Z.fresh&&((re=rt==null?void 0:rt.outbox)==null?void 0:re.count)>0&&l.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:rt.outbox.count}),l.jsx("button",{className:`nc-act pin${Ge==="live"?" live":Ge==="favorite"?" on":""}`,"aria-label":`${Ge==="live"?"live host":f("pin")} ${ge.cell}`,title:Ge==="live"?"live host":f("pin"),onClick:()=>st(Z,ge,Ge,je),children:Ge==="none"?"☆":"★"}),ot&&l.jsx("button",{className:`nc-act boot${Xe?" on":""}`,disabled:F.has(vt),onClick:nn=>bt(nn,ge,je),title:Pt,"aria-label":Pt,children:l.jsx(at,{name:"boot",size:16})}),Me&&l.jsx("button",{className:`nc-act power${ge.tmux?" on":""}${ge.degraded?" warn":""}`,onClick:()=>$(je.length?{...ge,boot:Xe,route:je,availableEngines:(we==null?void 0:we.engines)||[]}:{...ge,boot:Xe}),title:ge.active?f("power-off"):f("power-on"),"aria-label":`${ge.active?f("power-off"):f("power-on")} ${ge.cell}`,children:l.jsx(at,{name:"power",size:16})})]},Z.key)}const Y=Z.value;return l.jsxs("div",{className:"nc-mcard","data-roster-key":Z.key,"data-position":Ye,children:[l.jsx(Li,{position:Ye,itemKey:Z.key,label:Y.name,canMove:gn,onMove:(ge,Ae)=>de(Ye,ge,Ae,Oe),onStep:ge=>fe(Ye,Z.key,ge,Oe)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>yt(Y.name),children:[l.jsx("span",{className:Y.attached?"dot on":"dot"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Y.name}),l.jsx("small",{children:Y.preview?Y.preview:Y.cmd?Y.cmd:f("windows").replace("{n}",String(Y.windows||0))})]})]}),Z.activity?l.jsx("span",{className:"nc-rel",children:Br(Z.activity)}):null,Z.fresh&&((xe=Y.outbox)==null?void 0:xe.count)>0&&l.jsx("span",{className:"nc-badge",title:f("new-files-outbox"),children:Y.outbox.count}),l.jsx("button",{className:`nc-act pin${x.includes(Z.key)?" on":""}`,"aria-label":`${f("pin")} ${Y.name}`,title:f("pin"),onClick:()=>T(Z.key),children:x.includes(Z.key)?"★":"☆"}),l.jsx("button",{className:`nc-act technical${Y.technical?" on":""}`,title:Y.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${Y.technical?f("mark-normal"):f("mark-technical")} ${Y.name}`,onClick:()=>Dt(Y.name,!Y.technical,je),children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),"aria-label":`${f("terminate")} ${Y.name}`,onClick:()=>{window.confirm(f("terminate-confirm").replace("{name}",Y.name))&&kt(Y.name,je)},children:"⋯"})]},Z.key)}return l.jsxs("div",{className:"nc-home",children:[l.jsxs("header",{className:"nc-home-head",children:[l.jsxs("div",{className:"nc-wordmark",children:["NexusCrew",l.jsx("span",{className:"nc-cursor"})]}),l.jsxs("div",{className:"nc-home-sub",children:[f("fleet-tmux")," · ",Ve," ",f("sessions"),Et>0&&` · ${Et} attached`]}),l.jsxs("span",{className:"nc-head-actions",children:[l.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:f("settings"),children:l.jsx(at,{name:"gear",size:18})}),l.jsx("button",{className:"nc-refresh",onClick:Rt,title:f("refresh"),children:l.jsx(at,{name:"refresh",size:18})})]})]}),l.jsxs("main",{className:"nc-home-scroll",children:[l.jsx(My,{pinError:O,onRetry:H,onDismiss:se}),Ue>8&&l.jsx("input",{className:"nc-filter",type:"search",placeholder:f("filter-placeholder"),"aria-label":f("filter-placeholder"),value:k,onChange:Z=>E(Z.target.value)}),y&&l.jsx("div",{className:"nc-err",children:y}),l.jsxs("section",{className:"nc-group","data-position":"local",children:[l.jsx(Zu,{label:f("position-local"),count:_e.length,state:ie,dotClass:"on",onToggle:()=>le("local",{open:!ie.open}),onFilter:Z=>le("local",{filter:Z})}),ie.open&&_e.map(Z=>Nt(Z,null,qe)),ie.open&&v===null&&l.jsx("div",{className:"nc-empty",children:f("loading-fleet")}),ie.open&&v!==null&&_e.length===0&&!y&&l.jsx("div",{className:"nc-empty",children:k?f("no-match").replace("{q}",k):f("no-sessions-short")})]}),ze.map(Z=>{const Oe=Dy(Z.health,{passive:"warn"})||(Z.status==="up"?"on":Z.status==="passive"?"":"warn"),je=Z.health?Yo(Z.health):Z.status==="up"?"":Xi(Z),Ye=(Z.route&&Z.route.length?Z.route:[Z.name]).join("/"),pt=ee(Ye);if(Z.kind==="vl")return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":Ye,"data-node-order-key":qt(Z),children:[l.jsx(Zu,{label:Z.label||Z.name,count:Z.sessions.length,state:pt,dotClass:Oe,dotTitle:je,detail:Z.status==="up"?"":Xi(Z),onToggle:()=>le(Ye,{open:!pt.open}),onFilter:xe=>le(Ye,{filter:xe})}),Z.status==="up"&&pt.open&&Z.sessions.map(xe=>l.jsx("div",{className:"nc-mcard nc-vl-session-row",children:l.jsxs("button",{className:"nc-mcard-main",onClick:()=>s&&s(Z.peer),"aria-label":`${Z.label||Z.name}: ${xe.name}`,children:[l.jsx("span",{className:"dot on"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:xe.name}),l.jsx("small",{children:f("vl-events-title")})]})]})},xe.key)),Z.status==="up"&&pt.open&&Z.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]},`nodo-vl-${Ye}-${Z.name}`);const{rawItems:yt}=Fl(Z),gn=js(yt,x,pt.filter,Ji(I,Ye)).filter(xe=>Fg(xe,k)),Y=Z.direct&&Z.health&&Z.health.managed!==!1?l.jsx("button",{type:"button",className:`nc-act power${Z.tunnelStatus==="up"?" on":""}`,disabled:L===Z.name,title:Z.tunnelStatus==="up"?f("power-off"):f("power-on"),"aria-label":`${Z.tunnelStatus==="up"?f("power-off"):f("power-on")} ${Z.label||Z.name}`,onClick:()=>Lt(Z),children:l.jsx(at,{name:"power",size:15})}):null,re=l.jsxs("span",{className:"nc-node-actions",children:[l.jsx(Li,{scope:"node",position:"nodes",itemKey:qt(Z),label:Z.label||Z.name,onMove:(xe,ge)=>Ee(xe,ge,m),onStep:xe=>xt(qt(Z),xe,m)}),Z.direct&&l.jsx("button",{type:"button",className:"nc-node-rename",title:f("rename-node"),"aria-label":`${f("rename-node")} ${Z.label||Z.name}`,onClick:()=>Ct(Z),children:"✎"}),Y]});return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":Ye,"data-node-order-key":qt(Z),children:[l.jsx(Zu,{label:Z.label||Z.name,count:gn.length,state:pt,dotClass:Oe,dotTitle:je,detail:Z.status==="up"?"":Z.health&&Yo(Z.health)||Xi(Z),onToggle:()=>le(Ye,{open:!pt.open}),onFilter:xe=>le(Ye,{filter:xe}),onRename:Z.direct?()=>Ct(Z):null,action:re}),Z.status==="up"&&pt.open&&gn.map(xe=>Nt(xe,Z,yt)),Z.status==="up"&&pt.open&&gn.length===0&&l.jsx("div",{className:"nc-empty",children:k?f("no-match").replace("{q}",k):f("no-sessions-short")})]},`nodo-${Ye}`)}),l.jsxs("footer",{className:"nc-home-foot",onClick:gt,title:f("copy-url"),children:[l.jsxs("span",{className:"nc-home-meta",children:[b&&l.jsxs("span",{className:"nc-home-version",children:["v",b]}),l.jsxs("span",{className:"nc-home-endpoint",children:[St," · ",f("ssh-only")]})]}),l.jsx("span",{className:"nc-lang",onClick:Z=>Z.stopPropagation(),children:Ey.map((Z,we)=>l.jsxs("span",{children:[we>0&&" · ",l.jsx("button",{className:`nc-lang-btn${h===Z?" on":""}`,onClick:()=>p(Z),title:Z,children:Z.toUpperCase()})]},Z))})]})]}),l.jsx("button",{className:"nc-fab",onClick:()=>n("fleet",!0),title:f("fleet-new-cell"),"aria-label":f("fleet-new-cell"),children:"+"}),B&&l.jsx(zl,{cell:B,token:t,route:Array.isArray(B.route)?B.route:[],onConfirm:Bt,onClose:()=>$(null)})]})}function Zu({label:e,count:t,state:n,dotClass:s="",dotTitle:o="",detail:a="",onToggle:u,onFilter:h,onRename:p=null,action:m=null}){return l.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:p?v=>{v.preventDefault(),p()}:void 0,children:[l.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:u,"aria-expanded":n.open,"aria-label":`${e} · ${f("node-sessions").replace("{n}",String(t))}`,children:[l.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),l.jsx("span",{className:`dot ${s}`,title:o}),l.jsxs("span",{className:"nc-mobile-position-copy",children:[l.jsx("b",{children:e}),l.jsx("small",{children:a||f("node-sessions").replace("{n}",String(t))})]})]}),l.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${e} · ${f("filter-placeholder")}`,title:f(`view-${n.filter}`),onChange:v=>h(v.target.value),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]}),m]})}/**
|
|
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 Uy=Object.defineProperty,Ek=Object.getOwnPropertyDescriptor,Nk=(e,t)=>{for(var n in t)Uy(e,n,{get:t[n],enumerable:!0})},tn=(e,t,n,s)=>{for(var o=s>1?void 0:s?Ek(t,n):t,a=e.length-1,u;a>=0;a--)(u=e[a])&&(o=(s?u(t,n,o):u(o))||o);return s&&o&&Uy(t,n,o),o},De=(e,t)=>(n,s)=>t(n,s,e),ev="Terminal input",ih={get:()=>ev,set:e=>ev=e},tv="Too much output to announce, navigate to rows manually to read",sh={get:()=>tv,set:e=>tv=e};function jk(e){return e.replace(/\r?\n/g,"\r")}function Rk(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Pk(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Ak(e,t,n,s){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");Wy(o,t,n,s)}}function Wy(e,t,n,s){e=jk(e),e=Rk(e,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function Ky(e,t,n){let s=n.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 nv(e,t,n,s,o){Ky(e,t,n),o&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Cs(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function nc(e,t=0,n=e.length){let s="";for(let o=t;o<n;++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 Lk=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o=0;if(this._interim){let 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<n;++a){let u=e.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=n)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}},Tk=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let s=0,o,a,u,h,p=0,m=0;if(this.interim[0]){let y=!1,S=this.interim[0];S&=(S&224)===192?31:(S&240)===224?15:7;let k=0,E;for(;(E=this.interim[++k]&63)&&k<4;)S<<=6,S|=E;let b=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,j=b-k;for(;m<j;){if(m>=n)return 0;if(E=e[m++],(E&192)!==128){m--,y=!0;break}else this.interim[k++]=E,S<<=6,S|=E&63}y||(b===2?S<128?m--:t[s++]=S:b===3?S<2048||S>=55296&&S<=57343||S===65279||(t[s++]=S):S<65536||S>1114111||(t[s++]=S)),this.interim.fill(0)}let v=n-4,w=m;for(;w<n;){for(;w<v&&!((o=e[w])&128)&&!((a=e[w+1])&128)&&!((u=e[w+2])&128)&&!((h=e[w+3])&128);)t[s++]=o,t[s++]=a,t[s++]=u,t[s++]=h,w+=4;if(o=e[w++],o<128)t[s++]=o;else if((o&224)===192){if(w>=n)return this.interim[0]=o,s;if(a=e[w++],(a&192)!==128){w--;continue}if(p=(o&31)<<6|a&63,p<128){w--;continue}t[s++]=p}else if((o&240)===224){if(w>=n)return this.interim[0]=o,s;if(a=e[w++],(a&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[w++],(u&192)!==128){w--;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(w>=n)return this.interim[0]=o,s;if(a=e[w++],(a&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=a,s;if(u=e[w++],(u&192)!==128){w--;continue}if(w>=n)return this.interim[0]=o,this.interim[1]=a,this.interim[2]=u,s;if(h=e[w++],(h&192)!==128){w--;continue}if(p=(o&7)<<18|(a&63)<<12|(u&63)<<6|h&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},qy="",Ns=" ",sa=class Vy{constructor(){this.fg=0,this.bg=0,this.extended=new Wl}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 Vy;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}},Wl=class Yy{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Yy(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mi=class Gy extends sa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Wl,this.combinedData=""}static fromCharData(t){let n=new Gy;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Cs(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(s-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},iv="di$target",rh="di$dependencies",ed=new Map;function Mk(e){return e[rh]||[]}function Cn(e){if(ed.has(e))return ed.get(e);let t=function(n,s,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Dk(t,n,o)};return t._id=e,ed.set(e,t),t}function Dk(e,t,n){t[iv]===t?t[rh].push({id:e,index:n}):(t[rh]=[{id:e,index:n}],t[iv]=t)}var Fn=Cn("BufferService"),Xy=Cn("CoreMouseService"),nr=Cn("CoreService"),Ik=Cn("CharsetService"),bf=Cn("InstantiationService"),Qy=Cn("LogService"),Hn=Cn("OptionsService"),Jy=Cn("OscLinkService"),Ok=Cn("UnicodeService"),ra=Cn("DecorationService"),oh=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){var v;let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let s=[],o=this._optionsService.rawOptions.linkHandler,a=new mi,u=n.getTrimmedLength(),h=-1,p=-1,m=!1;for(let w=0;w<u;w++)if(!(p===-1&&!n.hasContent(w))){if(n.loadCell(w,a),a.hasExtendedAttrs()&&a.extended.urlId)if(p===-1){p=w,h=a.extended.urlId;continue}else m=a.extended.urlId!==h;else p!==-1&&(m=!0);if(m||p!==-1&&w===u-1){let y=(v=this._oscLinkService.getLinkData(h))==null?void 0:v.uri;if(y){let S={start:{x:p+1,y:e},end:{x:w+(!m&&w===u-1?1:0),y:e}},k=!1;if(!(o!=null&&o.allowNonHttpProtocols))try{let E=new URL(y);["http:","https:"].includes(E.protocol)||(k=!0)}catch{k=!0}k||s.push({text:y,range:S,activate:(E,b)=>o?o.activate(E,b,S):Bk(E,b),hover:(E,b)=>{var j;return(j=o==null?void 0:o.hover)==null?void 0:j.call(o,E,b,S)},leave:(E,b)=>{var j;return(j=o==null?void 0:o.leave)==null?void 0:j.call(o,E,b,S)}})}m=!1,a.hasExtendedAttrs()&&a.extended.urlId?(p=w,h=a.extended.urlId):(p=-1,h=-1)}}t(s)}};oh=tn([De(0,Fn),De(1,Hn),De(2,Jy)],oh);function Bk(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
52
|
+
|
|
53
|
+
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var ic=Cn("CharSizeService"),Zi=Cn("CoreBrowserService"),Sf=Cn("MouseService"),es=Cn("RenderService"),zk=Cn("SelectionService"),Zy=Cn("CharacterJoinerService"),Kr=Cn("ThemeService"),ew=Cn("LinkProviderService"),$k=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?sv.isErrorNoTelemetry(e)?new sv(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)}},Fk=new $k;function Pl(e){Hk(e)||Fk.onUnexpectedError(e)}var ah="Canceled";function Hk(e){return e instanceof Uk?!0:e instanceof Error&&e.name===ah&&e.message===ah}var Uk=class extends Error{constructor(){super(ah),this.name=this.message}};function Wk(e){return new Error(`Illegal argument: ${e}`)}var sv=class lh extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof lh)return t;let n=new lh;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},ch=class tw extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,tw.prototype)}};function ti(e,t=0){return e[e.length-(1+t)]}var Kk;(e=>{function t(a){return a<0}e.isLessThan=t;function n(a){return a<=0}e.isLessThanOrEqual=n;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})(Kk||(Kk={}));function qk(e,t){let n=this,s=!1,o;return function(){return s||(s=!0,t||(o=e.apply(n,arguments))),o}}var nw;(e=>{function t(D){return D&&typeof D=="object"&&typeof D[Symbol.iterator]=="function"}e.is=t;let n=Object.freeze([]);function s(){return n}e.empty=s;function*o(D){yield D}e.single=o;function a(D){return t(D)?D:o(D)}e.wrap=a;function u(D){return D||n}e.from=u;function*h(D){for(let U=D.length-1;U>=0;U--)yield D[U]}e.reverse=h;function p(D){return!D||D[Symbol.iterator]().next().done===!0}e.isEmpty=p;function m(D){return D[Symbol.iterator]().next().value}e.first=m;function v(D,U){let W=0;for(let K of D)if(U(K,W++))return!0;return!1}e.some=v;function w(D,U){for(let W of D)if(U(W))return W}e.find=w;function*y(D,U){for(let W of D)U(W)&&(yield W)}e.filter=y;function*S(D,U){let W=0;for(let K of D)yield U(K,W++)}e.map=S;function*k(D,U){let W=0;for(let K of D)yield*U(K,W++)}e.flatMap=k;function*E(...D){for(let U of D)yield*U}e.concat=E;function b(D,U,W){let K=W;for(let te of D)K=U(K,te);return K}e.reduce=b;function*j(D,U,W=D.length){for(U<0&&(U+=D.length),W<0?W+=D.length:W>D.length&&(W=D.length);U<W;U++)yield D[U]}e.slice=j;function N(D,U=Number.POSITIVE_INFINITY){let W=[];if(U===0)return[W,D];let K=D[Symbol.iterator]();for(let te=0;te<U;te++){let G=K.next();if(G.done)return[W,e.empty()];W.push(G.value)}return[W,{[Symbol.iterator](){return K}}]}e.consume=N;async function z(D){let U=[];for await(let W of D)U.push(W);return Promise.resolve(U)}e.asyncToArray=z})(nw||(nw={}));function er(e){if(nw.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Vk(...e){return Kt(()=>er(e))}function Kt(e){return{dispose:qk(()=>{e()})}}var iw=class sw{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?sw.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)}};iw.DISABLE_DISPOSED_WARNING=!1;var Ps=iw,dt=class{constructor(){this._store=new Ps,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)}};dt.None=Object.freeze({dispose(){}});var Fr=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}},Qi=typeof window=="object"?window:globalThis,uh=class dh{constructor(t){this.element=t,this.next=dh.Undefined,this.prev=dh.Undefined}};uh.Undefined=new uh(void 0);var Gt=uh,rv=class{constructor(){this._first=Gt.Undefined,this._last=Gt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Gt.Undefined}clear(){let e=this._first;for(;e!==Gt.Undefined;){let t=e.next;e.prev=Gt.Undefined,e.next=Gt.Undefined,e=t}this._first=Gt.Undefined,this._last=Gt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new Gt(e);if(this._first===Gt.Undefined)this._first=n,this._last=n;else if(t){let o=this._last;this._last=n,n.prev=o,o.next=n}else{let o=this._first;this._first=n,n.next=o,o.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first!==Gt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Gt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Gt.Undefined&&e.next!==Gt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===Gt.Undefined&&e.next===Gt.Undefined?(this._first=Gt.Undefined,this._last=Gt.Undefined):e.next===Gt.Undefined?(this._last=this._last.prev,this._last.next=Gt.Undefined):e.prev===Gt.Undefined&&(this._first=this._first.next,this._first.prev=Gt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Gt.Undefined;)yield e.element,e=e.next}},Yk=globalThis.performance&&typeof globalThis.performance.now=="function",Gk=class rw{static create(t){return new rw(t)}constructor(t){this._now=Yk&&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}},Rn;(e=>{e.None=()=>dt.None;function t(F,R){return w(F,()=>{},0,void 0,!0,void 0,R)}e.defer=t;function n(F){return(R,B=null,$)=>{let L=!1,A;return A=F(x=>{if(!L)return A?A.dispose():L=!0,R.call(B,x)},null,$),L&&A.dispose(),A}}e.once=n;function s(F,R,B){return m(($,L=null,A)=>F(x=>$.call(L,R(x)),null,A),B)}e.map=s;function o(F,R,B){return m(($,L=null,A)=>F(x=>{R(x),$.call(L,x)},null,A),B)}e.forEach=o;function a(F,R,B){return m(($,L=null,A)=>F(x=>R(x)&&$.call(L,x),null,A),B)}e.filter=a;function u(F){return F}e.signal=u;function h(...F){return(R,B=null,$)=>{let L=Vk(...F.map(A=>A(x=>R.call(B,x))));return v(L,$)}}e.any=h;function p(F,R,B,$){let L=B;return s(F,A=>(L=R(L,A),L),$)}e.reduce=p;function m(F,R){let B,$={onWillAddFirstListener(){B=F(L.fire,L)},onDidRemoveLastListener(){B==null||B.dispose()}},L=new Re($);return R==null||R.add(L),L.event}function v(F,R){return R instanceof Array?R.push(F):R&&R.add(F),F}function w(F,R,B=100,$=!1,L=!1,A,x){let I,T,M,O=0,H,se={leakWarningThreshold:A,onWillAddFirstListener(){I=F(le=>{O++,T=R(T,le),$&&!M&&(ee.fire(T),T=void 0),H=()=>{let ve=T;T=void 0,M=void 0,(!$||O>1)&&ee.fire(ve),O=0},typeof B=="number"?(clearTimeout(M),M=setTimeout(H,B)):M===void 0&&(M=0,queueMicrotask(H))})},onWillRemoveListener(){L&&O>0&&(H==null||H())},onDidRemoveLastListener(){H=void 0,I.dispose()}},ee=new Re(se);return x==null||x.add(ee),ee.event}e.debounce=w;function y(F,R=0,B){return e.debounce(F,($,L)=>$?($.push(L),$):[L],R,void 0,!0,void 0,B)}e.accumulate=y;function S(F,R=($,L)=>$===L,B){let $=!0,L;return a(F,A=>{let x=$||!R(A,L);return $=!1,L=A,x},B)}e.latch=S;function k(F,R,B){return[e.filter(F,R,B),e.filter(F,$=>!R($),B)]}e.split=k;function E(F,R=!1,B=[],$){let L=B.slice(),A=F(T=>{L?L.push(T):I.fire(T)});$&&$.add(A);let x=()=>{L==null||L.forEach(T=>I.fire(T)),L=null},I=new Re({onWillAddFirstListener(){A||(A=F(T=>I.fire(T)),$&&$.add(A))},onDidAddFirstListener(){L&&(R?setTimeout(x):x())},onDidRemoveLastListener(){A&&A.dispose(),A=null}});return $&&$.add(I),I.event}e.buffer=E;function b(F,R){return(B,$,L)=>{let A=R(new N);return F(function(x){let I=A.evaluate(x);I!==j&&B.call($,I)},void 0,L)}}e.chain=b;let j=Symbol("HaltChainable");class N{constructor(){this.steps=[]}map(R){return this.steps.push(R),this}forEach(R){return this.steps.push(B=>(R(B),B)),this}filter(R){return this.steps.push(B=>R(B)?B:j),this}reduce(R,B){let $=B;return this.steps.push(L=>($=R($,L),$)),this}latch(R=(B,$)=>B===$){let B=!0,$;return this.steps.push(L=>{let A=B||!R(L,$);return B=!1,$=L,A?L:j}),this}evaluate(R){for(let B of this.steps)if(R=B(R),R===j)break;return R}}function z(F,R,B=$=>$){let $=(...I)=>x.fire(B(...I)),L=()=>F.on(R,$),A=()=>F.removeListener(R,$),x=new Re({onWillAddFirstListener:L,onDidRemoveLastListener:A});return x.event}e.fromNodeEventEmitter=z;function D(F,R,B=$=>$){let $=(...I)=>x.fire(B(...I)),L=()=>F.addEventListener(R,$),A=()=>F.removeEventListener(R,$),x=new Re({onWillAddFirstListener:L,onDidRemoveLastListener:A});return x.event}e.fromDOMEventEmitter=D;function U(F){return new Promise(R=>n(F)(R))}e.toPromise=U;function W(F){let R=new Re;return F.then(B=>{R.fire(B)},()=>{R.fire(void 0)}).finally(()=>{R.dispose()}),R.event}e.fromPromise=W;function K(F,R){return F(B=>R.fire(B))}e.forward=K;function te(F,R,B){return R(B),F($=>R($))}e.runAndSubscribe=te;class G{constructor(R,B){this._observable=R,this._counter=0,this._hasChanged=!1;let $={onWillAddFirstListener:()=>{R.addObserver(this)},onDidRemoveLastListener:()=>{R.removeObserver(this)}};this.emitter=new Re($),B&&B.add(this.emitter)}beginUpdate(R){this._counter++}handlePossibleChange(R){}handleChange(R,B){this._hasChanged=!0}endUpdate(R){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function Q(F,R){return new G(F,R).emitter.event}e.fromObservable=Q;function q(F){return(R,B,$)=>{let L=0,A=!1,x={beginUpdate(){L++},endUpdate(){L--,L===0&&(F.reportChanges(),A&&(A=!1,R.call(B)))},handlePossibleChange(){},handleChange(){A=!0}};F.addObserver(x),F.reportChanges();let I={dispose(){F.removeObserver(x)}};return $ instanceof Ps?$.add(I):Array.isArray($)&&$.push(I),I}}e.fromObservableLight=q})(Rn||(Rn={}));var hh=class fh{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${fh._idPool++}`,fh.all.add(this)}start(t){this._stopWatch=new Gk,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}}};hh.all=new Set,hh._idPool=0;var Xk=hh,Qk=-1,ow=class aw{constructor(t,n,s=(aw._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let o=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,o+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,u]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${u}):`;console.warn(h),console.warn(a);let p=new e1(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,n=0;for(let[s,o]of this._stacks)(!t||n<o)&&(t=[s,o],n=o);return t}};ow._idPool=1;var Jk=ow,Zk=class lw{constructor(t){this.value=t}static create(){let t=new Error;return new lw(t.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
+
`).slice(2).join(`
|
|
59
|
+
`))}},e1=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},t1=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},n1=0,td=class{constructor(e){this.value=e,this.id=n1++}},i1=2,s1,Re=class{constructor(e){var t,n,s,o;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Jk((e==null?void 0:e.onListenerError)??Pl,((n=this._options)==null?void 0:n.leakWarningThreshold)??Qk):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Xk(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var e,t,n,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||n.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,n)=>{var u,h,p,m,v;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let w=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(w);let y=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],S=new t1(`${w}. HINT: Stack shows most frequent listener (${y[1]}-times)`,y[0]);return(((u=this._options)==null?void 0:u.onListenerError)||Pl)(S),dt.None}if(this._disposed)return dt.None;t&&(e=e.bind(t));let s=new td(e),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Zk.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof td?(this._deliveryQueue??(this._deliveryQueue=new r1),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,(v=(m=this._options)==null?void 0:m.onDidAddFirstListener)==null||v.call(m,this)),this._size++;let a=Kt(()=>{o==null||o(),this._removeListener(s)});return n instanceof Ps?n.add(a):Array.isArray(n)&&n.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,n=t.indexOf(e);if(n===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*i1<=t.length){let p=0;for(let m=0;m<t.length;m++)t[m]?t[p++]=t[m]:s&&(this._deliveryQueue.end--,p<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=p}}_deliver(e,t){var s;if(!e)return;let n=((s=this._options)==null?void 0:s.onListenerError)||Pl;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,n,s,o;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(n=this._perfMon)==null||n.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof td)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}},r1=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ph=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Re,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Re,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,n){if(this.getZoomLevel(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),t)}setFullscreen(t,n){if(this.isFullscreen(n)===t)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};ph.INSTANCE=new ph;var xf=ph;function o1(e,t,n){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",n)}xf.INSTANCE.onDidChangeZoomLevel;function a1(e){return xf.INSTANCE.getZoomFactor(e)}xf.INSTANCE.onDidChangeFullscreen;var qr=typeof navigator=="object"?navigator.userAgent:"",mh=qr.indexOf("Firefox")>=0,l1=qr.indexOf("AppleWebKit")>=0,kf=qr.indexOf("Chrome")>=0,c1=!kf&&qr.indexOf("Safari")>=0;qr.indexOf("Electron/")>=0;qr.indexOf("Android")>=0;var nd=!1;if(typeof Qi.matchMedia=="function"){let e=Qi.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Qi.matchMedia("(display-mode: fullscreen)");nd=e.matches,o1(Qi,e,({matches:n})=>{nd&&t.matches||(nd=n)})}var Mr="en",gh=!1,vh=!1,Al=!1,cw=!1,_l,Ll=Mr,ov=Mr,u1,Si,Zs=globalThis,jn,cy;typeof Zs.vscode<"u"&&typeof Zs.vscode.process<"u"?jn=Zs.vscode.process:typeof process<"u"&&typeof((cy=process==null?void 0:process.versions)==null?void 0:cy.node)=="string"&&(jn=process);var uy,d1=typeof((uy=jn==null?void 0:jn.versions)==null?void 0:uy.electron)=="string",h1=d1&&(jn==null?void 0:jn.type)==="renderer",dy;if(typeof jn=="object"){gh=jn.platform==="win32",vh=jn.platform==="darwin",Al=jn.platform==="linux",Al&&jn.env.SNAP&&jn.env.SNAP_REVISION,jn.env.CI||jn.env.BUILD_ARTIFACTSTAGINGDIRECTORY,_l=Mr,Ll=Mr;let e=jn.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);_l=t.userLocale,ov=t.osLocale,Ll=t.resolvedLanguage||Mr,u1=(dy=t.languagePack)==null?void 0:dy.translationsConfigFile}catch{}cw=!0}else typeof navigator=="object"&&!h1?(Si=navigator.userAgent,gh=Si.indexOf("Windows")>=0,vh=Si.indexOf("Macintosh")>=0,(Si.indexOf("Macintosh")>=0||Si.indexOf("iPad")>=0||Si.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Al=Si.indexOf("Linux")>=0,(Si==null?void 0:Si.indexOf("Mobi"))>=0,Ll=globalThis._VSCODE_NLS_LANGUAGE||Mr,_l=navigator.language.toLowerCase(),ov=_l):console.error("Unable to resolve platform.");var uw=gh,Ii=vh,f1=Al,av=cw,Bi=Si,ws=Ll,p1;(e=>{function t(){return ws}e.value=t;function n(){return ws.length===2?ws==="en":ws.length>=3?ws[0]==="e"&&ws[1]==="n"&&ws[2]==="-":!1}e.isDefaultVariant=n;function s(){return ws==="en"}e.isDefault=s})(p1||(p1={}));var m1=typeof Zs.postMessage=="function"&&!Zs.importScripts;(()=>{if(m1){let e=[];Zs.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,o=e.length;s<o;s++){let a=e[s];if(a.id===n.data.vscodeScheduleAsyncWork){e.splice(s,1),a.callback();return}}});let t=0;return n=>{let s=++t;e.push({id:s,callback:n}),Zs.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var g1=!!(Bi&&Bi.indexOf("Chrome")>=0);Bi&&Bi.indexOf("Firefox")>=0;!g1&&Bi&&Bi.indexOf("Safari")>=0;Bi&&Bi.indexOf("Edg/")>=0;Bi&&Bi.indexOf("Android")>=0;var Rr=typeof navigator=="object"?navigator:{};av||document.queryCommandSupported&&document.queryCommandSupported("copy")||Rr&&Rr.clipboard&&Rr.clipboard.writeText,av||Rr&&Rr.clipboard&&Rr.clipboard.readText;var Cf=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}},id=new Cf,lv=new Cf,cv=new Cf,v1=new Array(230),dw;(e=>{function t(h){return id.keyCodeToStr(h)}e.toString=t;function n(h){return id.strToKeyCode(h)}e.fromString=n;function s(h){return lv.keyCodeToStr(h)}e.toUserSettingsUS=s;function o(h){return cv.keyCodeToStr(h)}e.toUserSettingsGeneral=o;function a(h){return lv.strToKeyCode(h)||cv.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 id.keyCodeToStr(h)}e.toElectronAccelerator=u})(dw||(dw={}));var _1=class hw{constructor(t,n,s,o,a){this.ctrlKey=t,this.shiftKey=n,this.altKey=s,this.metaKey=o,this.keyCode=a}equals(t){return t instanceof hw&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",o=this.metaKey?"1":"0";return`K${t}${n}${s}${o}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new y1([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},y1=class{constructor(e){if(e.length===0)throw Wk("chords");this.chords=e}getHashCode(){let e="";for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function w1(e){if(e.charCode){let n=String.fromCharCode(e.charCode).toUpperCase();return dw.fromString(n)}let t=e.keyCode;if(t===3)return 7;if(mh)switch(t){case 59:return 85;case 60:if(f1)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Ii)return 57;break}else if(l1&&(Ii&&t===93||!Ii&&t===92))return 57;return v1[t]||0}var b1=Ii?256:2048,S1=512,x1=1024,k1=Ii?2048:256,uv=class{constructor(e){var n;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(n=t.getModifierState)==null?void 0:n.call(t,"AltGraph"),this.keyCode=w1(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|=b1),this.altKey&&(t|=S1),this.shiftKey&&(t|=x1),this.metaKey&&(t|=k1),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new _1(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},dv=new WeakMap;function C1(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!=="null"&&n.origin!=="null"&&t.origin!==n.origin)return null}catch{return null}return e.parent}var E1=class{static getSameOriginWindowChain(e){let t=dv.get(e);if(!t){t=[],dv.set(e,t);let n=e,s;do s=C1(n),s?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,s=0,o=this.getSameOriginWindowChain(e);for(let a of o){let u=a.window.deref();if(n+=(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();n+=h.top,s+=h.left}return{top:n,left:s}}},yl=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=E1.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},hv=class{constructor(e,t=0,n=0){var o;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let s=!1;if(kf){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?mh&&!Ii?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")c1&&uw?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?mh&&!Ii?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()}},fw=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),N1;(e=>{function t(n){return n===e.None||n===e.Cancelled||n instanceof j1?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Rn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:fw})})(N1||(N1={}));var j1=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?fw:(this._emitter||(this._emitter=new Re),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Ef=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 ch("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new ch("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},R1=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new ch("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=n.setInterval(()=>{e()},t);this.disposable=Kt(()=>{n.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},P1;(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 n(s){return new Promise(async(o,a)=>{try{await s(o,a)}catch(u){a(u)}})}e.withAsyncBody=n})(P1||(P1={}));var fv=class fi{static fromArray(t){return new fi(n=>{n.emitMany(t)})}static fromPromise(t){return new fi(async n=>{n.emitMany(await t)})}static fromPromises(t){return new fi(async n=>{await Promise.all(t.map(async s=>n.emitOne(await s)))})}static merge(t){return new fi(async n=>{await Promise.all(t.map(async s=>{for await(let o of s)n.emitOne(o)}))})}constructor(t,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new Re,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 Rn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var n;return(n=this._onReturn)==null||n.call(this),{done:!0,value:void 0}}}}static map(t,n){return new fi(async s=>{for await(let o of t)s.emitOne(n(o))})}map(t){return fi.map(this,t)}static filter(t,n){return new fi(async s=>{for await(let o of t)n(o)&&s.emitOne(o)})}filter(t){return fi.filter(this,t)}static coalesce(t){return fi.filter(t,n=>!!n)}coalesce(){return fi.coalesce(this)}static async toPromise(t){let n=[];for await(let s of t)n.push(s);return n}toPromise(){return fi.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())}};fv.EMPTY=fv.fromArray([]);var{getWindow:Mi,getWindowId:A1,onDidRegisterWindow:L1}=(function(){let e=new Map,t={window:Qi,disposables:new Ps};e.set(Qi.vscodeWindowId,t);let n=new Re,s=new Re,o=new Re;function a(u,h){return(typeof u=="number"?e.get(u):void 0)??(h?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:o.event,onDidUnregisterWindow:s.event,registerWindow(u){if(e.has(u.vscodeWindowId))return dt.None;let h=new Ps,p={window:u,disposables:h.add(new Ps)};return e.set(u.vscodeWindowId,p),h.add(Kt(()=>{e.delete(u.vscodeWindowId),s.fire(u)})),h.add(it(u,bn.BEFORE_UNLOAD,()=>{o.fire(u)})),n.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 m;let h=u;if((m=h==null?void 0:h.ownerDocument)!=null&&m.defaultView)return h.ownerDocument.defaultView.window;let p=u;return p!=null&&p.view?p.view.window:Qi},getDocument(u){return Mi(u).document}}})(),T1=class{constructor(e,t,n,s){this._node=e,this._type=t,this._handler=n,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function it(e,t,n,s){return new T1(e,t,n,s)}var pv=function(e,t,n,s){return it(e,t,n,s)},Nf,M1=class extends R1{constructor(e){super(),this.defaultTarget=e&&Mi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},mv=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){Pl(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,s=new Map,o=a=>{n.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(mv.sort),u.shift().execute();s.set(a,!1)};Nf=(a,u,h=0)=>{let p=A1(a),m=new mv(u,h),v=e.get(p);return v||(v=[],e.set(p,v)),v.push(m),n.get(p)||(n.set(p,!0),a.requestAnimationFrame(()=>o(p))),m}})();function D1(e){let t=e.getBoundingClientRect(),n=Mi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}var bn={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"},I1=class{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){let n=Xn(t);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){let n=Xn(t);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(t){let n=Xn(t);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(t){let n=Xn(t);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(t){let n=Xn(t);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(t){let n=Xn(t);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(t){let n=Xn(t);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(t){let n=Xn(t);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(t){let n=Xn(t);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(t){let n=Xn(t);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(t){let n=Xn(t);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){let n=Xn(t);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){let n=Xn(t);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){let n=Xn(t);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,n){this.domNode.classList.toggle(t,n),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,n){this.domNode.setAttribute(t,n)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}};function Xn(e){return typeof e=="number"?`${e}px`:e}function Go(e){return new I1(e)}var pw=class{constructor(){this._hooks=new Ps,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,s,o){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=o;let a=e;try{e.setPointerCapture(t),this._hooks.add(Kt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Mi(e)}this._hooks.add(it(a,bn.POINTER_MOVE,u=>{if(u.buttons!==n){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(it(a,bn.POINTER_UP,u=>this.stopMonitoring(!0)))}};function O1(e,t,n){let s=null,o=null;if(typeof n.value=="function"?(s="value",o=n.value,o.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",o=n.get),!o)throw new Error("not supported");let a=`$memoize$${t}`;n[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 Pi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Pi||(Pi={}));var Ho=class Mn extends dt{constructor(){super(),this.dispatched=!1,this.targets=new rv,this.ignoreTargets=new rv,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Rn.runAndSubscribe(L1,({window:t,disposables:n})=>{n.add(it(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(it(t.document,"touchend",s=>this.onTouchEnd(t,s))),n.add(it(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Qi,disposables:this._store}))}static addTarget(t){if(!Mn.isTouchDevice())return dt.None;Mn.INSTANCE||(Mn.INSTANCE=new Mn);let n=Mn.INSTANCE.targets.push(t);return Kt(n)}static ignoreTarget(t){if(!Mn.isTouchDevice())return dt.None;Mn.INSTANCE||(Mn.INSTANCE=new Mn);let n=Mn.INSTANCE.ignoreTargets.push(t);return Kt(n)}static isTouchDevice(){return"ontouchstart"in Qi||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,o=t.targetTouches.length;s<o;s++){let a=t.targetTouches.item(s);this.activeTouches[a.identifier]={id:a.identifier,initialTarget:a.target,initialTimeStamp:n,initialPageX:a.pageX,initialPageY:a.pageY,rollingTimestamps:[n],rollingPageX:[a.pageX],rollingPageY:[a.pageY]};let u=this.newGestureEvent(Pi.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,n){let s=Date.now(),o=Object.keys(this.activeTouches).length;for(let a=0,u=n.changedTouches.length;a<u;a++){let h=n.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],m=Date.now()-p.initialTimeStamp;if(m<Mn.HOLD_DELAY&&Math.abs(p.initialPageX-ti(p.rollingPageX))<30&&Math.abs(p.initialPageY-ti(p.rollingPageY))<30){let v=this.newGestureEvent(Pi.Tap,p.initialTarget);v.pageX=ti(p.rollingPageX),v.pageY=ti(p.rollingPageY),this.dispatchEvent(v)}else if(m>=Mn.HOLD_DELAY&&Math.abs(p.initialPageX-ti(p.rollingPageX))<30&&Math.abs(p.initialPageY-ti(p.rollingPageY))<30){let v=this.newGestureEvent(Pi.Contextmenu,p.initialTarget);v.pageX=ti(p.rollingPageX),v.pageY=ti(p.rollingPageY),this.dispatchEvent(v)}else if(o===1){let v=ti(p.rollingPageX),w=ti(p.rollingPageY),y=ti(p.rollingTimestamps)-p.rollingTimestamps[0],S=v-p.rollingPageX[0],k=w-p.rollingPageY[0],E=[...this.targets].filter(b=>p.initialTarget instanceof Node&&b.contains(p.initialTarget));this.inertia(t,E,s,Math.abs(S)/y,S>0?1:-1,v,Math.abs(k)/y,k>0?1:-1,w)}this.dispatchEvent(this.newGestureEvent(Pi.End,p.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,n){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(t){if(t.type===Pi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Mn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,t.tapCount=s}else(t.type===Pi.Change||t.type===Pi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let o=0,a=t.initialTarget;for(;a&&a!==s;)o++,a=a.parentElement;n.push([o,s])}n.sort((s,o)=>s[0]-o[0]);for(let[s,o]of n)o.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,s,o,a,u,h,p,m){this.handle=Nf(t,()=>{let v=Date.now(),w=v-s,y=0,S=0,k=!0;o+=Mn.SCROLL_FRICTION*w,h+=Mn.SCROLL_FRICTION*w,o>0&&(k=!1,y=a*o*w),h>0&&(k=!1,S=p*h*w);let E=this.newGestureEvent(Pi.Change);E.translationX=y,E.translationY=S,n.forEach(b=>b.dispatchEvent(E)),k||this.inertia(t,n,v,o,a,u+y,h,p,m+S)})}onTouchMove(t){let n=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(Pi.Change,u.initialTarget);h.translationX=a.pageX-ti(u.rollingPageX),h.translationY=a.pageY-ti(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(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ho.SCROLL_FRICTION=-.005,Ho.HOLD_DELAY=700,Ho.CLEAR_TAP_COUNT_TIME=400,tn([O1],Ho,"isTouchDevice",1);var B1=Ho,jf=class extends dt{onclick(e,t){this._register(it(e,bn.CLICK,n=>t(new yl(Mi(e),n))))}onmousedown(e,t){this._register(it(e,bn.MOUSE_DOWN,n=>t(new yl(Mi(e),n))))}onmouseover(e,t){this._register(it(e,bn.MOUSE_OVER,n=>t(new yl(Mi(e),n))))}onmouseleave(e,t){this._register(it(e,bn.MOUSE_LEAVE,n=>t(new yl(Mi(e),n))))}onkeydown(e,t){this._register(it(e,bn.KEY_DOWN,n=>t(new uv(n))))}onkeyup(e,t){this._register(it(e,bn.KEY_UP,n=>t(new uv(n))))}oninput(e,t){this._register(it(e,bn.INPUT,t))}onblur(e,t){this._register(it(e,bn.BLUR,t))}onfocus(e,t){this._register(it(e,bn.FOCUS,t))}onchange(e,t){this._register(it(e,bn.CHANGE,t))}ignoreGesture(e){return B1.ignoreTarget(e)}},gv=11,z1=class extends jf{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=gv+"px",this.domNode.style.height=gv+"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 pw),this._register(pv(this.bgDomNode,bn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(pv(this.domNode,bn.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new M1),this._pointerdownScheduleRepeatTimer=this._register(new Ef)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Mi(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},$1=class _h{constructor(t,n,s,o,a,u,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,o=o|0,a=a|0,u=u|0,h=h|0),this.rawScrollLeft=o,this.rawScrollTop=h,n<0&&(n=0),o+n>s&&(o=s-n),o<0&&(o=0),a<0&&(a=0),h+a>u&&(h=u-a),h<0&&(h=0),this.width=n,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,n){return new _h(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new _h(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,n){let s=this.width!==t.width,o=this.scrollWidth!==t.scrollWidth,a=this.scrollLeft!==t.scrollLeft,u=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:n,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:o,scrollLeftChanged:a,heightChanged:u,scrollHeightChanged:h,scrollTopChanged:p}}},F1=class extends dt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Re),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new $1(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;t?s=new _v(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let n=this._state.withScrollPosition(e);this._smoothScrolling=_v.start(this._state,n,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},vv=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function sd(e,t){let n=t-e;return function(s){return e+n*W1(s)}}function H1(e,t,n){return function(s){return s<n?e(s/n):t((s-n)/(1-n))}}var _v=class yh{constructor(t,n,s,o){this.from=t,this.to=n,this.duration=o,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,n,s){if(Math.abs(t-n)>2.5*s){let o,a;return t<n?(o=t+.75*s,a=n-.75*s):(o=t-.75*s,a=n+.75*s),H1(sd(t,o),sd(a,n),.33)}return sd(t,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let n=(t-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),o=this.scrollTop(n);return new vv(s,o,!1)}return new vv(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,s){return yh.start(t,n,s)}static start(t,n,s){s=s+10;let o=Date.now()-10;return new yh(t,n,o,s)}};function U1(e){return Math.pow(e,3)}function W1(e){return 1-U1(1-e)}var K1=class extends dt{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Ef)}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":"")))}},q1=140,mw=class extends jf{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 K1(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new pw),this._shouldRender=!0,this.domNode=Go(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(it(this.domNode.domNode,bn.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new z1(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,s){this.slider=Go(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof n=="number"&&this.slider.setWidth(n),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(it(this.slider.domNode,bn.POINTER_DOWN,o=>{o.button===0&&(o.preventDefault(),this._sliderPointerDown(o))})),this.onclick(this.slider.domNode,o=>{o.leftButton&&o.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),o=this._sliderPointerPosition(e);n<=o&&o<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,n=e.offsetY;else{let o=D1(this.domNode.domNode);t=e.pageX-o.left,n=e.pageY-o.top}let s=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,o=>{let a=this._sliderOrthogonalPointerPosition(o),u=Math.abs(a-n);if(uw&&u>q1){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()}},gw=class wh{constructor(t,n,s,o,a,u){this._scrollbarSize=Math.round(n),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 wh(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let n=Math.round(t);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(t){let n=Math.round(t);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let n=Math.round(t);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,n,s,o,a){let u=Math.max(0,s-t),h=Math.max(0,u-2*n),p=o>0&&o>s;if(!p)return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let m=Math.round(Math.max(20,Math.floor(s*h/o))),v=(h-m)/(o-s),w=a*v;return{computedAvailableSize:Math.round(u),computedIsNeeded:p,computedSliderSize:Math.round(m),computedSliderRatio:v,computedSliderPosition:Math.round(w)}}_refreshComputedValues(){let t=wh._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let n=t-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+t;return Math.round(n/this._computedSliderRatio)}},V1=class extends mw{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new gw(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,o.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Y1=class extends mw{constructor(e,t,n){let s=e.getScrollDimensions(),o=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new gw(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}},G1=500,yv=50,X1=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},bh=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,n=0,s=1,o=this._rear;do{let a=o===this._front?t:Math.pow(2,-s);if(t-=a,n+=this._memory[o].score*a,o===this._front)break;o=(this._capacity+o-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(t){if(kf){let n=Mi(t.browserEvent),s=a1(n);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,n,s){let o=null,a=new X1(t,n,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,n){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),n){let o=Math.abs(t.deltaX),a=Math.abs(t.deltaY),u=Math.abs(n.deltaX),h=Math.abs(n.deltaY),p=Math.max(Math.min(o,u),1),m=Math.max(Math.min(a,h),1),v=Math.max(o,u),w=Math.max(a,h);v%p===0&&w%m===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};bh.INSTANCE=new bh;var Q1=bh,J1=class extends jf{constructor(e,t,n){super(),this._onScroll=this._register(new Re),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Re),this.onWillScroll=this._onWillScroll.event,this._options=eC(t),this._scrollable=n,this._register(this._scrollable.onScroll(o=>{this._onWillScroll.fire(o),this._onDidScroll(o),this._onScroll.fire(o)}));let s={onMouseWheel:o=>this._onMouseWheel(o),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Y1(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new V1(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=Go(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Go(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Go(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 Ef),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,Ii&&(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 hv(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=er(this._mouseWheelToDispose),e)){let t=n=>{this._onMouseWheel(new hv(n))};this._mouseWheelToDispose.push(it(this._listenOnDomNode,bn.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var o;if((o=e.browserEvent)!=null&&o.defaultPrevented)return;let t=Q1.INSTANCE;t.acceptStandardWheelEvent(e);let n=!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=!Ii&&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(),m={};if(a){let v=yv*a,w=p.scrollTop-(v<0?Math.floor(v):Math.ceil(v));this._verticalScrollbar.writeScrollPosition(m,w)}if(u){let v=yv*u,w=p.scrollLeft-(v<0?Math.floor(v):Math.ceil(v));this._horizontalScrollbar.writeScrollPosition(m,w)}m=this._scrollable.validateScrollPosition(m),(p.scrollLeft!==m.scrollLeft||p.scrollTop!==m.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(m):this._scrollable.setScrollPositionNow(m),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,s=n?" left":"",o=t?" top":"",a=n||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(),G1)}},Z1=class extends J1{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function eC(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,Ii&&(t.className+=" mac"),t}var Sh=class extends dt{constructor(e,t,n,s,o,a,u,h){super(),this._bufferService=n,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new Re),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new F1({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:m=>Nf(s.window,m)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Z1(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(o.onProtocolChange(m=>{this._scrollableElement.updateOptions({handleMouseWheel:!(m&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Rn.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(Kt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(Kt(()=>this._styleElement.remove())),this._register(Rn.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(m=>this._handleScroll(m)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};Sh=tn([De(2,Fn),De(3,Zi),De(4,Xy),De(5,Kr),De(6,Hn),De(7,es)],Sh);var xh=class extends dt{constructor(e,t,n,s,o){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=s,this._renderService=o,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(a=>this._removeDecoration(a))),this._register(Kt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};xh=tn([De(1,Fn),De(2,Zi),De(3,ra),De(4,es)],xh);var tC=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||"full"]&&t<=e.endBufferLine+this._linePadding[n||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Ni={full:0,left:0,center:0,right:0},bs={full:0,left:0,center:0,right:0},Lo={full:0,left:0,center:0,right:0},Kl=class extends dt{constructor(e,t,n,s,o,a,u,h){var m;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=s,this._renderService=o,this._optionsService=a,this._themeService=u,this._coreBrowserService=h,this._colorZoneStore=new tC,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(m=this._viewportElement.parentElement)==null||m.insertBefore(this._canvas,this._viewportElement),this._register(Kt(()=>{var v;return(v=this._canvas)==null?void 0:v.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);bs.full=this._canvas.width,bs.left=e,bs.center=t,bs.right=e,this._refreshDrawHeightConstants(),Lo.full=1,Lo.left=1,Lo.center=1+bs.left,Lo.right=1+bs.left+bs.center}_refreshDrawHeightConstants(){Ni.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);Ni.left=t,Ni.center=t,Ni.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ni.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ni.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ni.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ni.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(Lo[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ni[e.position||"full"]/2),bs[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ni[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}))}};Kl=tn([De(2,Fn),De(3,ra),De(4,es),De(5,Hn),De(6,Kr),De(7,Zi)],Kl);var me;(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=""))(me||(me={}));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 vw;(e=>e.ST=`${me.ESC}\\`)(vw||(vw={}));var kh=class{constructor(e,t,n,s,o,a){this._textarea=e,this._compositionView=t,this._bufferService=n,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 n;t.start+=this._dataAlreadySent.length,this._isComposing?n=this._textarea.value.substring(t.start,this._compositionPosition.start):n=this._textarea.value.substring(t.start),n.length>0&&this._coreService.triggerDataEvent(n,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,"");this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${me.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),n=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,o=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=o+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=n+"px",this._compositionView.style.lineHeight=n+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let 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)}}};kh=tn([De(2,Fn),De(3,Hn),De(4,nr),De(5,es)],kh);var Sn=0,xn=0,kn=0,Zt=0,wv={css:"#00000000",rgba:0},un;(e=>{function t(o,a,u,h){return h!==void 0?`#${Ks(o)}${Ks(a)}${Ks(u)}${Ks(h)}`:`#${Ks(o)}${Ks(a)}${Ks(u)}`}e.toCss=t;function n(o,a,u,h=255){return(o<<24|a<<16|u<<8|h)>>>0}e.toRgba=n;function s(o,a,u,h){return{css:e.toCss(o,a,u,h),rgba:e.toRgba(o,a,u,h)}}e.toColor=s})(un||(un={}));var Ht;(e=>{function t(p,m){if(Zt=(m.rgba&255)/255,Zt===1)return{css:m.css,rgba:m.rgba};let v=m.rgba>>24&255,w=m.rgba>>16&255,y=m.rgba>>8&255,S=p.rgba>>24&255,k=p.rgba>>16&255,E=p.rgba>>8&255;Sn=S+Math.round((v-S)*Zt),xn=k+Math.round((w-k)*Zt),kn=E+Math.round((y-E)*Zt);let b=un.toCss(Sn,xn,kn),j=un.toRgba(Sn,xn,kn);return{css:b,rgba:j}}e.blend=t;function n(p){return(p.rgba&255)===255}e.isOpaque=n;function s(p,m,v){let w=Ml.ensureContrastRatio(p.rgba,m.rgba,v);if(w)return un.toColor(w>>24&255,w>>16&255,w>>8&255)}e.ensureContrastRatio=s;function o(p){let m=(p.rgba|255)>>>0;return[Sn,xn,kn]=Ml.toChannels(m),{css:un.toCss(Sn,xn,kn),rgba:m}}e.opaque=o;function a(p,m){return Zt=Math.round(m*255),[Sn,xn,kn]=Ml.toChannels(p.rgba),{css:un.toCss(Sn,xn,kn,Zt),rgba:un.toRgba(Sn,xn,kn,Zt)}}e.opacity=a;function u(p,m){return Zt=p.rgba&255,a(p,Zt*m/255)}e.multiplyOpacity=u;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(Ht||(Ht={}));var Xt;(e=>{let t,n;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",n=t.createLinearGradient(0,0,1,1))}catch{}function s(o){if(o.match(/#[\da-f]{3,8}/i))switch(o.length){case 4:return Sn=parseInt(o.slice(1,2).repeat(2),16),xn=parseInt(o.slice(2,3).repeat(2),16),kn=parseInt(o.slice(3,4).repeat(2),16),un.toColor(Sn,xn,kn);case 5:return Sn=parseInt(o.slice(1,2).repeat(2),16),xn=parseInt(o.slice(2,3).repeat(2),16),kn=parseInt(o.slice(3,4).repeat(2),16),Zt=parseInt(o.slice(4,5).repeat(2),16),un.toColor(Sn,xn,kn,Zt);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 Sn=parseInt(a[1]),xn=parseInt(a[2]),kn=parseInt(a[3]),Zt=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),un.toColor(Sn,xn,kn,Zt);if(!t||!n)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=n,t.fillStyle=o,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Sn,xn,kn,Zt]=t.getImageData(0,0,1,1).data,Zt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:un.toRgba(Sn,xn,kn,Zt),css:o}}e.toColor=s})(Xt||(Xt={}));var zn;(e=>{function t(s){return n(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function n(s,o,a){let u=s/255,h=o/255,p=a/255,m=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),v=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),w=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+v*.7152+w*.0722}e.relativeLuminance2=n})(zn||(zn={}));var Ml;(e=>{function t(u,h){if(Zt=(h&255)/255,Zt===1)return h;let p=h>>24&255,m=h>>16&255,v=h>>8&255,w=u>>24&255,y=u>>16&255,S=u>>8&255;return Sn=w+Math.round((p-w)*Zt),xn=y+Math.round((m-y)*Zt),kn=S+Math.round((v-S)*Zt),un.toRgba(Sn,xn,kn)}e.blend=t;function n(u,h,p){let m=zn.relativeLuminance(u>>8),v=zn.relativeLuminance(h>>8);if(Yi(m,v)<p){if(v<m){let S=s(u,h,p),k=Yi(m,zn.relativeLuminance(S>>8));if(k<p){let E=o(u,h,p),b=Yi(m,zn.relativeLuminance(E>>8));return k>b?S:E}return S}let w=o(u,h,p),y=Yi(m,zn.relativeLuminance(w>>8));if(y<p){let S=s(u,h,p),k=Yi(m,zn.relativeLuminance(S>>8));return y>k?w:S}return w}}e.ensureContrastRatio=n;function s(u,h,p){let m=u>>24&255,v=u>>16&255,w=u>>8&255,y=h>>24&255,S=h>>16&255,k=h>>8&255,E=Yi(zn.relativeLuminance2(y,S,k),zn.relativeLuminance2(m,v,w));for(;E<p&&(y>0||S>0||k>0);)y-=Math.max(0,Math.ceil(y*.1)),S-=Math.max(0,Math.ceil(S*.1)),k-=Math.max(0,Math.ceil(k*.1)),E=Yi(zn.relativeLuminance2(y,S,k),zn.relativeLuminance2(m,v,w));return(y<<24|S<<16|k<<8|255)>>>0}e.reduceLuminance=s;function o(u,h,p){let m=u>>24&255,v=u>>16&255,w=u>>8&255,y=h>>24&255,S=h>>16&255,k=h>>8&255,E=Yi(zn.relativeLuminance2(y,S,k),zn.relativeLuminance2(m,v,w));for(;E<p&&(y<255||S<255||k<255);)y=Math.min(255,y+Math.ceil((255-y)*.1)),S=Math.min(255,S+Math.ceil((255-S)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),E=Yi(zn.relativeLuminance2(y,S,k),zn.relativeLuminance2(m,v,w));return(y<<24|S<<16|k<<8|255)>>>0}e.increaseLuminance=o;function a(u){return[u>>24&255,u>>16&255,u>>8&255,u&255]}e.toChannels=a})(Ml||(Ml={}));function Ks(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Yi(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var nC=class extends sa{constructor(e,t,n){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ql=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new mi}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],s=t.translateToString(!0),o=0,a=0,u=0,h=t.getFg(0),p=t.getBg(0);for(let m=0;m<t.getTrimmedLength();m++)if(t.loadCell(m,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==p){if(m-o>1){let v=this._getJoinedRanges(s,u,a,t,o);for(let w=0;w<v.length;w++)n.push(v[w])}o=m,u=a,h=this._workCell.fg,p=this._workCell.bg}a+=this._workCell.getChars().length||Ns.length}if(this._bufferService.cols-o>1){let m=this._getJoinedRanges(s,u,a,t,o);for(let v=0;v<m.length;v++)n.push(m[v])}return n}_getJoinedRanges(e,t,n,s,o){let a=e.substring(t,n),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 m=0;m<p.length;m++)ql._mergeRanges(u,p[m])}catch(p){console.error(p)}return this._stringRangesToCellRanges(u,s,o),u}_stringRangesToCellRanges(e,t,n){let s=0,o=!1,a=0,u=e[s];if(u){for(let h=n;h<this._bufferService.cols;h++){let p=t.getWidth(h),m=t.getString(h).length||Ns.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+=m}}u&&(u[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t[1]<=o[0])return e[s-1][1]=t[1],e;if(t[1]<=o[1])return e[s-1][1]=Math.max(t[1],o[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=o[0])return e.splice(s,0,t),e;if(t[1]<=o[1])return o[0]=Math.min(t[0],o[0]),e;t[0]<o[1]&&(o[0]=Math.min(t[0],o[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};ql=tn([De(0,Fn)],ql);function iC(e){return 57508<=e&&e<=57558}function sC(e){return 9472<=e&&e<=9631}function rC(e){return iC(e)||sC(e)}function oC(){return{css:{canvas:wl(),cell:wl()},device:{canvas:wl(),cell:wl(),char:{width:0,height:0,left:0,top:0}}}}function wl(){return{width:0,height:0}}var Ch=class{constructor(e,t,n,s,o,a,u){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=s,this._coreService=o,this._decorationService=a,this._themeService=u,this._workCell=new mi,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,s,o,a,u,h,p,m,v){let w=[],y=this._characterJoinerService.getJoinedCharacters(t),S=this._themeService.colors,k=e.getNoBgTrimmedLength();n&&k<a+1&&(k=a+1);let E,b=0,j="",N=0,z=0,D=0,U=0,W=!1,K=0,te=!1,G=0,Q=0,q=[],F=m!==-1&&v!==-1;for(let R=0;R<k;R++){e.loadCell(R,this._workCell);let B=this._workCell.getWidth();if(B===0)continue;let $=!1,L=R>=Q,A=R,x=this._workCell;if(y.length>0&&R===y[0][0]&&L){let Ee=y.shift(),xt=this._isCellInSelection(Ee[0],t);for(N=Ee[0]+1;N<Ee[1];N++)L&&(L=xt===this._isCellInSelection(N,t));L&&(L=!n||a<Ee[0]||a>=Ee[1]),L?($=!0,x=new nC(this._workCell,e.translateToString(!0,Ee[0],Ee[1]),Ee[1]-Ee[0]),A=Ee[1]-1,B=x.getWidth()):Q=Ee[1]}let I=this._isCellInSelection(R,t),T=n&&R===a,M=F&&R>=m&&R<=v,O=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,Ee=>{O=!0});let H=x.getChars()||Ns;if(H===" "&&(x.isUnderline()||x.isOverline())&&(H=" "),G=B*h-p.get(H,x.isBold(),x.isItalic()),!E)E=this._document.createElement("span");else if(b&&(I&&te||!I&&!te&&x.bg===z)&&(I&&te&&S.selectionForeground||x.fg===D)&&x.extended.ext===U&&M===W&&G===K&&!T&&!$&&!O&&L){x.isInvisible()?j+=Ns:j+=H,b++;continue}else b&&(E.textContent=j),E=this._document.createElement("span"),b=0,j="";if(z=x.bg,D=x.fg,U=x.extended.ext,W=M,K=G,te=I,$&&a>=R&&a<=A&&(a=R),!this._coreService.isCursorHidden&&T&&this._coreService.isCursorInitialized){if(q.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&q.push("xterm-cursor-blink"),q.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(o)switch(o){case"outline":q.push("xterm-cursor-outline");break;case"block":q.push("xterm-cursor-block");break;case"bar":q.push("xterm-cursor-bar");break;case"underline":q.push("xterm-cursor-underline");break}}if(x.isBold()&&q.push("xterm-bold"),x.isItalic()&&q.push("xterm-italic"),x.isDim()&&q.push("xterm-dim"),x.isInvisible()?j=Ns:j=x.getChars()||Ns,x.isUnderline()&&(q.push(`xterm-underline-${x.extended.underlineStyle}`),j===" "&&(j=" "),!x.isUnderlineColorDefault()))if(x.isUnderlineColorRGB())E.style.textDecorationColor=`rgb(${sa.toColorRGB(x.getUnderlineColor()).join(",")})`;else{let Ee=x.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&x.isBold()&&Ee<8&&(Ee+=8),E.style.textDecorationColor=S.ansi[Ee].css}x.isOverline()&&(q.push("xterm-overline"),j===" "&&(j=" ")),x.isStrikethrough()&&q.push("xterm-strikethrough"),M&&(E.style.textDecoration="underline");let se=x.getFgColor(),ee=x.getFgColorMode(),le=x.getBgColor(),ve=x.getBgColorMode(),de=!!x.isInverse();if(de){let Ee=se;se=le,le=Ee;let xt=ee;ee=ve,ve=xt}let fe,He,st=!1;this._decorationService.forEachDecorationAtCell(R,t,void 0,Ee=>{Ee.options.layer!=="top"&&st||(Ee.backgroundColorRGB&&(ve=50331648,le=Ee.backgroundColorRGB.rgba>>8&16777215,fe=Ee.backgroundColorRGB),Ee.foregroundColorRGB&&(ee=50331648,se=Ee.foregroundColorRGB.rgba>>8&16777215,He=Ee.foregroundColorRGB),st=Ee.options.layer==="top")}),!st&&I&&(fe=this._coreBrowserService.isFocused?S.selectionBackgroundOpaque:S.selectionInactiveBackgroundOpaque,le=fe.rgba>>8&16777215,ve=50331648,st=!0,S.selectionForeground&&(ee=50331648,se=S.selectionForeground.rgba>>8&16777215,He=S.selectionForeground)),st&&q.push("xterm-decoration-top");let lt;switch(ve){case 16777216:case 33554432:lt=S.ansi[le],q.push(`xterm-bg-${le}`);break;case 50331648:lt=un.toColor(le>>16,le>>8&255,le&255),this._addStyle(E,`background-color:#${bv((le>>>0).toString(16),"0",6)}`);break;case 0:default:de?(lt=S.foreground,q.push("xterm-bg-257")):lt=S.background}switch(fe||x.isDim()&&(fe=Ht.multiplyOpacity(lt,.5)),ee){case 16777216:case 33554432:x.isBold()&&se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(se+=8),this._applyMinimumContrast(E,lt,S.ansi[se],x,fe,void 0)||q.push(`xterm-fg-${se}`);break;case 50331648:let Ee=un.toColor(se>>16&255,se>>8&255,se&255);this._applyMinimumContrast(E,lt,Ee,x,fe,He)||this._addStyle(E,`color:#${bv(se.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(E,lt,S.foreground,x,fe,He)||de&&q.push("xterm-fg-257")}q.length&&(E.className=q.join(" "),q.length=0),!T&&!$&&!O&&L?b++:E.textContent=j,G!==this.defaultSpacing&&(E.style.letterSpacing=`${G}px`),w.push(E),R=A}return E&&b&&(E.textContent=j),w}_applyMinimumContrast(e,t,n,s,o,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||rC(s.getCode()))return!1;let u=this._getContrastCache(s),h;if(!o&&!a&&(h=u.getColor(t.rgba,n.rgba)),h===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=Ht.ensureContrastRatio(o||t,a||n,p),u.setColor((o||t).rgba,(a||n).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 n=this._selectionStart,s=this._selectionEnd;return!n||!s?!1:this._columnSelectMode?n[0]<=s[0]?e>=n[0]&&t>=n[1]&&e<s[0]&&t<=s[1]:e<n[0]&&t>=n[1]&&e>=s[0]&&t<=s[1]:t>n[1]&&t<s[1]||n[1]===s[1]&&t===n[1]&&e>=n[0]&&e<s[0]||n[1]<s[1]&&t===s[1]&&e<s[0]||n[1]<s[1]&&t===n[1]&&e>=n[0]}};Ch=tn([De(1,Zy),De(2,Hn),De(3,Zi),De(4,nr),De(5,ra),De(6,Kr)],Ch);function bv(e,t,n){for(;e.length<n;)e=t+e;return e}var aC=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let n=e.createElement("span");n.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontStyle="italic";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontWeight="bold",a.style.fontStyle="italic",this._measureElements=[n,s,o,a],this._container.appendChild(n),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,n,s){e===this._font&&t===this._fontSize&&n===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,n){let s=0;if(!t&&!n&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let u=this._measure(e,0);return u>0&&(this._flat[s]=u),u}let o=e;t&&(o+="B"),n&&(o+="I");let a=this._holey.get(o);if(a===void 0){let u=0;t&&(u|=1),n&&(u|=2),a=this._measure(e,u),a>0&&this._holey.set(o,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},lC=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,s=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let o=e.buffers.active.ydisp,a=t[1]-o,u=n[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=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function cC(){return new lC}var rd="xterm-dom-renderer-owner-",hi="xterm-rows",bl="xterm-fg-",Sv="xterm-bg-",To="xterm-focus",Sl="xterm-selection",uC=1,Eh=class extends dt{constructor(e,t,n,s,o,a,u,h,p,m,v,w,y,S){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=s,this._viewportElement=o,this._helperContainer=a,this._linkifier2=u,this._charSizeService=p,this._optionsService=m,this._bufferService=v,this._coreService=w,this._coreBrowserService=y,this._themeService=S,this._terminalClass=uC++,this._rowElements=[],this._selectionRenderModel=cC(),this.onRequestRedraw=this._register(new Re).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(hi),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(Sl),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=oC(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(k=>this._injectCss(k))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(Ch,document),this._element.classList.add(rd+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(k=>this._handleLinkHover(k))),this._register(this._linkifier2.onHideLinkUnderline(k=>this._handleLinkLeave(k))),this._register(Kt(()=>{this._element.classList.remove(rd+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new aC(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let n of this._rowElements)n.style.width=`${this.dimensions.css.canvas.width}px`,n.style.height=`${this.dimensions.css.cell.height}px`,n.style.lineHeight=`${this.dimensions.css.cell.height}px`,n.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${hi} 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} .${hi} { 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} .${hi} .xterm-dim { color: ${Ht.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,o=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${o} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${hi}.${To} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${hi}.${To} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${hi}.${To} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${o} 1s step-end infinite;}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${hi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Sl} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Sl} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Sl} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[a,u]of e.ansi.entries())t+=`${this._terminalSelector} .${bl}${a} { color: ${u.css}; }${this._terminalSelector} .${bl}${a}.xterm-dim { color: ${Ht.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${Sv}${a} { background-color: ${u.css}; }`;t+=`${this._terminalSelector} .${bl}257 { color: ${Ht.opaque(e.background).css}; }${this._terminalSelector} .${bl}257.xterm-dim { color: ${Ht.multiplyOpacity(Ht.opaque(e.background),.5).css}; }${this._terminalSelector} .${Sv}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let n=this._rowElements.length;n<=t;n++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(To),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(To),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,o=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(n){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,m=a===o?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(a,p,m));let v=u-a-1;if(h.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,v)),a!==u){let w=o===u?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(u,0,w))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,n,s=1){let o=this._document.createElement("div"),a=t*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(n-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 n=this._bufferService.buffer,s=n.ybase+n.y,o=Math.min(n.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 m=p+n.ydisp,v=this._rowElements[p],w=n.lines.get(m);if(!v||!w)break;v.replaceChildren(...this._rowFactory.createRow(w,m,m===s,u,h,o,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${rd}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,s,o,a){n<0&&(e=0),s<0&&(t=0);let u=this._bufferService.rows-1;n=Math.max(Math.min(n,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,m=Math.min(h.x,o-1),v=this._optionsService.rawOptions.cursorBlink,w=this._optionsService.rawOptions.cursorStyle,y=this._optionsService.rawOptions.cursorInactiveStyle;for(let S=n;S<=s;++S){let k=S+h.ydisp,E=this._rowElements[S],b=h.lines.get(k);if(!E||!b)break;E.replaceChildren(...this._rowFactory.createRow(b,k,k===p,w,y,m,v,this.dimensions.css.cell.width,this._widthCache,a?S===n?e:0:-1,a?(S===s?t:o)-1:-1))}}};Eh=tn([De(7,bf),De(8,ic),De(9,Hn),De(10,Fn),De(11,nr),De(12,Zi),De(13,Kr)],Eh);var Nh=class extends dt{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Re),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new hC(this._optionsService))}catch{this._measureStrategy=this._register(new dC(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())}};Nh=tn([De(2,Hn)],Nh);var _w=class extends dt{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)}},dC=class extends _w{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},hC=class extends _w{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}},fC=class extends dt{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new pC(this._window)),this._onDprChange=this._register(new Re),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Re),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Rn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(it(this._textarea,"focus",()=>this._isFocused=!0)),this._register(it(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}},pC=class extends dt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Fr),this._onDprChange=this._register(new Re),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(Kt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=it(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)}},mC=class extends dt{constructor(){super(),this.linkProviders=[],this._register(Kt(()=>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 Rf(e,t,n){let s=n.getBoundingClientRect(),o=e.getComputedStyle(n),a=parseInt(o.getPropertyValue("padding-left")),u=parseInt(o.getPropertyValue("padding-top"));return[t.clientX-s.left-a,t.clientY-s.top-u]}function gC(e,t,n,s,o,a,u,h,p){if(!a)return;let m=Rf(e,t,n);if(m)return m[0]=Math.ceil((m[0]+(p?u/2:0))/u),m[1]=Math.ceil(m[1]/h),m[0]=Math.min(Math.max(m[0],1),s+(p?1:0)),m[1]=Math.min(Math.max(m[1],1),o),m}var jh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,s,o){return gC(window,e,t,n,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,o)}getMouseReportCoords(e,t){let n=Rf(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};jh=tn([De(0,es),De(1,ic)],jh);var vC=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},yw={};Nk(yw,{getSafariVersion:()=>yC,isChromeOS:()=>xw,isFirefox:()=>ww,isIpad:()=>wC,isIphone:()=>bC,isLegacyEdge:()=>_C,isLinux:()=>Pf,isMac:()=>Vl,isNode:()=>sc,isSafari:()=>bw,isWindows:()=>Sw});var sc=typeof process<"u"&&"title"in process,oa=sc?"node":navigator.userAgent,aa=sc?"node":navigator.platform,ww=oa.includes("Firefox"),_C=oa.includes("Edge"),bw=/^((?!chrome|android).)*safari/i.test(oa);function yC(){if(!bw)return 0;let e=oa.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Vl=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(aa),wC=aa==="iPad",bC=aa==="iPhone",Sw=["Windows","Win16","Win32","WinCE"].includes(aa),Pf=aa.indexOf("Linux")>=0,xw=/\bCrOS\b/.test(oa),kw=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,n=0,s=e.timeRemaining(),o=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),o=e.timeRemaining(),n*1.5>o){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=o}this.clear()}},SC=class extends kw{_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())}}},xC=class extends kw{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Yl=!sc&&"requestIdleCallback"in window?xC:SC,kC=class{constructor(){this._queue=new Yl}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Rh=class extends dt{constructor(e,t,n,s,o,a,u,h,p){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=s,this._coreService=o,this._coreBrowserService=h,this._renderer=this._register(new Fr),this._pausedResizeTask=new kC,this._observerDisposable=this._register(new Fr),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 Re),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Re),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Re),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Re),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new vC((m,v)=>this._renderRows(m,v),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new CC(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(Kt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var m;return(m=this._renderer.value)==null?void 0:m.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(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(m=>this._registerIntersectionObserver(m,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let n=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=Kt(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var n;return(n=this._renderer.value)==null?void 0:n.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,n){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,n)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Rh=tn([De(2,Hn),De(3,ic),De(4,nr),De(5,ra),De(6,Fn),De(7,Zi),De(8,Kr)],Rh);var CC=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function EC(e,t,n,s){let o=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return RC(o,a,e,t,n,s)+rc(a,t,n,s)+PC(o,a,e,t,n,s);let u;if(a===t)return u=o>e?"D":"C",Zo(Math.abs(o-e),Jo(u,s));u=a>t?"D":"C";let h=Math.abs(a-t),p=jC(a>t?e:o,n)+(h-1)*n.cols+1+NC(a>t?o:e);return Zo(p,Jo(u,s))}function NC(e,t){return e-1}function jC(e,t){return t.cols-e}function RC(e,t,n,s,o,a){return rc(t,s,o,a).length===0?"":Zo(Ew(e,t,e,t-tr(t,o),!1,o).length,Jo("D",a))}function rc(e,t,n,s){let o=e-tr(e,n),a=t-tr(t,n),u=Math.abs(o-a)-AC(e,t,n);return Zo(u,Jo(Cw(e,t),s))}function PC(e,t,n,s,o,a){let u;rc(t,s,o,a).length>0?u=s-tr(s,o):u=t;let h=s,p=LC(e,t,n,s,o,a);return Zo(Ew(e,u,n,h,p==="C",o).length,Jo(p,a))}function AC(e,t,n){var u;let s=0,o=e-tr(e,n),a=t-tr(t,n);for(let h=0;h<Math.abs(o-a);h++){let p=Cw(e,t)==="A"?-1:1;(u=n.buffer.lines.get(o+p*h))!=null&&u.isWrapped&&s++}return s}function tr(e,t){let n=0,s=t.buffer.lines.get(e),o=s==null?void 0:s.isWrapped;for(;o&&e>=0&&e<t.rows;)n++,s=t.buffer.lines.get(--e),o=s==null?void 0:s.isWrapped;return n}function LC(e,t,n,s,o,a){let u;return rc(n,s,o,a).length>0?u=s-tr(s,o):u=t,e<n&&u<=s||e>=n&&u<s?"C":"D"}function Cw(e,t){return e>t?"A":"B"}function Ew(e,t,n,s,o,a){let u=e,h=t,p="";for(;(u!==n||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 Jo(e,t){let n=t?"O":"[";return me.ESC+n+e}function Zo(e,t){e=Math.floor(e);let n="";for(let s=0;s<e;s++)n+=t;return n}var TC=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 xv(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 od=50,MC=15,DC=50,IC=500,OC=" ",BC=new RegExp(OC,"g"),Ph=class extends dt{constructor(e,t,n,s,o,a,u,h,p){super(),this._element=e,this._screenElement=t,this._linkifier=n,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 mi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Re),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Re),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Re),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Re),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=m=>this._handleMouseMove(m),this._mouseUpListener=m=>this._handleMouseUp(m),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(m=>this._handleTrim(m)),this._register(this._bufferService.buffers.onBufferActivate(m=>this._handleBufferActivate(m))),this.enable(),this._model=new TC(this._bufferService),this._activeSelectionMode=0,this._register(Kt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(m=>{m.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let n=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let o=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let u=e[1];u<=t[1];u++){let h=n.translateBufferLineToString(u,!0,o,a);s.push(h)}}else{let o=e[1]===t[1]?t[0]:void 0;s.push(n.translateBufferLineToString(e[1],!0,e[0],o));for(let a=e[1]+1;a<=t[1]-1;a++){let u=n.lines.get(a),h=n.translateBufferLineToString(a,!0);u!=null&&u.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let a=n.lines.get(t[1]),u=n.translateBufferLineToString(t[1],!0,0,t[0]);a&&a.isWrapped?s[s.length-1]+=u:s.push(u)}}return s.map(o=>o.replace(BC," ")).join(Sw?`\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())),Pf&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s||!t?!1:this._areCoordsInSelection(t,n,s)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!n||!s?!1:this._areCoordsInSelection([e,t],n,s)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var o,a;let n=(a=(o=this._linkifier.currentLink)==null?void 0:o.link)==null?void 0:a.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=xv(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Rf(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-od),od),t/=od,t/Math.abs(t)+Math.round(t*(MC-1)))}shouldForceSelection(e){return Vl?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(),DC)}_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&&!(Vl&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let s=n.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<IC&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let s=EC(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let s=0;t>=s;s++){let o=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:o>1&&t!==s&&(n+=o-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let o=this._bufferService.buffer,a=o.lines.get(e[1]);if(!a)return;let u=o.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(a,e[0]),p=h,m=e[0]-h,v=0,w=0,y=0,S=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;p<u.length&&u.charAt(p+1)===" ";)p++}else{let b=e[0],j=e[0];a.getWidth(b)===0&&(v++,b--),a.getWidth(j)===2&&(w++,j++);let N=a.getString(j).length;for(N>1&&(S+=N-1,p+=N-1);b>0&&h>0&&!this._isCharWordSeparator(a.loadCell(b-1,this._workCell));){a.loadCell(b-1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===0?(v++,b--):z>1&&(y+=z-1,h-=z-1),h--,b--}for(;j<a.length&&p+1<u.length&&!this._isCharWordSeparator(a.loadCell(j+1,this._workCell));){a.loadCell(j+1,this._workCell);let z=this._workCell.getChars().length;this._workCell.getWidth()===2?(w++,j++):z>1&&(S+=z-1,p+=z-1),p++,j++}}p++;let k=h+m-v+y,E=Math.min(this._bufferService.cols,p-h+v+w-y-S);if(!(!t&&u.slice(h,p).trim()==="")){if(n&&k===0&&a.getCodePoint(0)!==32){let b=o.lines.get(e[1]-1);if(b&&a.isWrapped&&b.getCodePoint(this._bufferService.cols-1)!==32){let j=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(j){let N=this._bufferService.cols-j.start;k-=N,E+=N}}}if(s&&k+E===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let b=o.lines.get(e[1]+1);if(b!=null&&b.isWrapped&&b.getCodePoint(0)!==32){let j=this._getWordAt([0,e[1]+1],!1,!1,!0);j&&(E+=j.length)}}return{start:k,length:E}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=xv(n,this._bufferService.cols)}};Ph=tn([De(3,Fn),De(4,nr),De(5,Sf),De(6,Hn),De(7,es),De(8,Zi)],Ph);var kv=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Cv=class{constructor(){this._color=new kv,this._css=new kv}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},fn=Object.freeze((()=>{let e=[Xt.toColor("#2e3436"),Xt.toColor("#cc0000"),Xt.toColor("#4e9a06"),Xt.toColor("#c4a000"),Xt.toColor("#3465a4"),Xt.toColor("#75507b"),Xt.toColor("#06989a"),Xt.toColor("#d3d7cf"),Xt.toColor("#555753"),Xt.toColor("#ef2929"),Xt.toColor("#8ae234"),Xt.toColor("#fce94f"),Xt.toColor("#729fcf"),Xt.toColor("#ad7fa8"),Xt.toColor("#34e2e2"),Xt.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=t[n/36%6|0],o=t[n/6%6|0],a=t[n%6];e.push({css:un.toCss(s,o,a),rgba:un.toRgba(s,o,a)})}for(let n=0;n<24;n++){let s=8+n*10;e.push({css:un.toCss(s,s,s),rgba:un.toRgba(s,s,s)})}return e})()),Vs=Xt.toColor("#ffffff"),Uo=Xt.toColor("#000000"),Ev=Xt.toColor("#ffffff"),Nv=Uo,Mo={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},zC=Vs,Ah=class extends dt{constructor(e){super(),this._optionsService=e,this._contrastCache=new Cv,this._halfContrastCache=new Cv,this._onChangeColors=this._register(new Re),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Vs,background:Uo,cursor:Ev,cursorAccent:Nv,selectionForeground:void 0,selectionBackgroundTransparent:Mo,selectionBackgroundOpaque:Ht.blend(Uo,Mo),selectionInactiveBackgroundTransparent:Mo,selectionInactiveBackgroundOpaque:Ht.blend(Uo,Mo),scrollbarSliderBackground:Ht.opacity(Vs,.2),scrollbarSliderHoverBackground:Ht.opacity(Vs,.4),scrollbarSliderActiveBackground:Ht.opacity(Vs,.5),overviewRulerBorder:Vs,ansi:fn.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,Vs),t.background=At(e.background,Uo),t.cursor=Ht.blend(t.background,At(e.cursor,Ev)),t.cursorAccent=Ht.blend(t.background,At(e.cursorAccent,Nv)),t.selectionBackgroundTransparent=At(e.selectionBackground,Mo),t.selectionBackgroundOpaque=Ht.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=At(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Ht.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?At(e.selectionForeground,wv):void 0,t.selectionForeground===wv&&(t.selectionForeground=void 0),Ht.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Ht.opacity(t.selectionBackgroundTransparent,.3)),Ht.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Ht.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=At(e.scrollbarSliderBackground,Ht.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=At(e.scrollbarSliderHoverBackground,Ht.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=At(e.scrollbarSliderActiveBackground,Ht.opacity(t.foreground,.5)),t.overviewRulerBorder=At(e.overviewRulerBorder,zC),t.ansi=fn.slice(),t.ansi[0]=At(e.black,fn[0]),t.ansi[1]=At(e.red,fn[1]),t.ansi[2]=At(e.green,fn[2]),t.ansi[3]=At(e.yellow,fn[3]),t.ansi[4]=At(e.blue,fn[4]),t.ansi[5]=At(e.magenta,fn[5]),t.ansi[6]=At(e.cyan,fn[6]),t.ansi[7]=At(e.white,fn[7]),t.ansi[8]=At(e.brightBlack,fn[8]),t.ansi[9]=At(e.brightRed,fn[9]),t.ansi[10]=At(e.brightGreen,fn[10]),t.ansi[11]=At(e.brightYellow,fn[11]),t.ansi[12]=At(e.brightBlue,fn[12]),t.ansi[13]=At(e.brightMagenta,fn[13]),t.ansi[14]=At(e.brightCyan,fn[14]),t.ansi[15]=At(e.brightWhite,fn[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<n;s++)t.ansi[s+16]=At(e.extendedAnsi[s],fn[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()}}};Ah=tn([De(0,Hn)],Ah);function At(e,t){if(e!==void 0)try{return Xt.toColor(e)}catch{}return t}var $C=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},FC=class{constructor(){this._services=new $C,this._services.set(bf,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Mk(e).sort((a,u)=>a.index-u.index),s=[];for(let a of n){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=n.length>0?n[0].index:t.length;if(t.length!==o)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${o+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},HC={trace:0,debug:1,info:2,warn:3,error:4,off:5},UC="xterm.js: ",Lh=class extends dt{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=HC[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":UC)+t,...n)}trace(e,...t){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Lh=tn([De(0,Hn)],Lh);var jv=class extends dt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Re),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Re),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Re),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+n.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<n.length;s++)this._array[this._getCyclicIndex(e+s)]=n[s];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let s=this._length+n.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let o=t-1;o>=0;o--)this.set(e+o+n,this.get(e+o));let s=e+t+n-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+n,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ut=3,cn=Object.freeze(new sa),xl=0,ad=2,Wo=class Nw{constructor(t,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ut);let o=n||mi.fromCharData([0,qy,1,0]);for(let a=0;a<t;++a)this.setCell(a,o);this.length=t}get(t){let n=this._data[t*ut+0],s=n&2097151;return[this._data[t*ut+1],n&2097152?this._combined[t]:s?Cs(s):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,n){this._data[t*ut+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*ut+0]=t|2097152|n[2]<<22):this._data[t*ut+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*ut+0]>>22}hasWidth(t){return this._data[t*ut+0]&12582912}getFg(t){return this._data[t*ut+1]}getBg(t){return this._data[t*ut+2]}hasContent(t){return this._data[t*ut+0]&4194303}getCodePoint(t){let n=this._data[t*ut+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*ut+0]&2097152}getString(t){let n=this._data[t*ut+0];return n&2097152?this._combined[t]:n&2097151?Cs(n&2097151):""}isProtected(t){return this._data[t*ut+2]&536870912}loadCell(t,n){return xl=t*ut,n.content=this._data[xl+0],n.fg=this._data[xl+1],n.bg=this._data[xl+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*ut+0]=n.content,this._data[t*ut+1]=n.fg,this._data[t*ut+2]=n.bg}setCellFromCodepoint(t,n,s,o){o.bg&268435456&&(this._extendedAttrs[t]=o.extended),this._data[t*ut+0]=n|s<<22,this._data[t*ut+1]=o.fg,this._data[t*ut+2]=o.bg}addCodepointToCell(t,n,s){let o=this._data[t*ut+0];o&2097152?this._combined[t]+=Cs(n):o&2097151?(this._combined[t]=Cs(o&2097151)+Cs(n),o&=-2097152,o|=2097152):o=n|1<<22,s&&(o&=-12582913,o|=s<<22),this._data[t*ut+0]=o}insertCells(t,n,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length-t){let o=new mi;for(let a=this.length-t-n-1;a>=0;--a)this.setCell(t+n+a,this.loadCell(t+a,o));for(let a=0;a<n;++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,n,s){if(t%=this.length,n<this.length-t){let o=new mi;for(let a=0;a<this.length-t-n;++a)this.setCell(t+a,this.loadCell(t+n+a,o));for(let a=this.length-n;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,n,s,o=!1){if(o){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);t<n&&t<this.length;)this.setCell(t++,s)}resize(t,n){if(t===this.length)return this._data.length*4*ad<this._data.buffer.byteLength;let s=t*ut;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let o=new Uint32Array(s);o.set(this._data),this._data=o}for(let o=this.length;o<t;++o)this.setCell(o,n)}else{this._data=this._data.subarray(0,s);let o=Object.keys(this._combined);for(let 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*ad<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ad<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new Nw(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ut+0]&4194303)return t+(this._data[t*ut+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ut+0]&4194303||this._data[t*ut+2]&50331648)return t+(this._data[t*ut+0]>>22);return 0}copyCellsFrom(t,n,s,o,a){let u=t._data;if(a)for(let p=o-1;p>=0;p--){for(let m=0;m<ut;m++)this._data[(s+p)*ut+m]=u[(n+p)*ut+m];u[(n+p)*ut+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}else for(let p=0;p<o;p++){for(let m=0;m<ut;m++)this._data[(s+p)*ut+m]=u[(n+p)*ut+m];u[(n+p)*ut+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[n+p])}let h=Object.keys(t._combined);for(let p=0;p<h.length;p++){let m=parseInt(h[p],10);m>=n&&(this._combined[m-n+s]=t._combined[m])}}translateToString(t,n,s,o){n=n??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),o&&(o.length=0);let a="";for(;n<s;){let u=this._data[n*ut+0],h=u&2097151,p=u&2097152?this._combined[n]:h?Cs(h):Ns;if(a+=p,o)for(let m=0;m<p.length;++m)o.push(n);n+=u>>22||1}return o&&o.push(n),a}};function WC(e,t,n,s,o,a){let u=[];for(let h=0;h<e.length-1;h++){let p=h,m=e.get(++p);if(!m.isWrapped)continue;let v=[e.get(h)];for(;p<e.length&&m.isWrapped;)v.push(m),m=e.get(++p);if(!a&&s>=h&&s<p){h+=v.length-1;continue}let w=0,y=ea(v,w,t),S=1,k=0;for(;S<v.length;){let b=ea(v,S,t),j=b-k,N=n-y,z=Math.min(j,N);v[w].copyCellsFrom(v[S],k,y,z,!1),y+=z,y===n&&(w++,y=0),k+=z,k===b&&(S++,k=0),y===0&&w!==0&&v[w-1].getWidth(n-1)===2&&(v[w].copyCellsFrom(v[w-1],n-1,y++,1,!1),v[w-1].setCell(n-1,o))}v[w].replaceCells(y,n,o);let E=0;for(let b=v.length-1;b>0&&(b>w||v[b].getTrimmedLength()===0);b--)E++;E>0&&(u.push(h+v.length-E),u.push(E)),h+=v.length-1}return u}function KC(e,t){let n=[],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 n.push(u);return{layout:n,countRemoved:a}}function qC(e,t){let n=[];for(let s=0;s<t.length;s++)n.push(e.get(t[s]));for(let s=0;s<n.length;s++)e.set(s,n[s]);e.length=t.length}function VC(e,t,n){let s=[],o=e.map((p,m)=>ea(e,m,t)).reduce((p,m)=>p+m),a=0,u=0,h=0;for(;h<o;){if(o-h<n){s.push(o-h);break}a+=n;let p=ea(e,u,t);a>p&&(a-=p,u++);let m=e[u].getWidth(a-1)===2;m&&a--;let v=m?n-1:n;s.push(v),h+=v}return s}function ea(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,o=e[t+1].getWidth(0)===2;return s&&o?n-1:n}var jw=class Rw{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Rw._nextId++,this._onDispose=this.register(new Re),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}};jw._nextId=1;var YC=jw,mn={},Ys=mn.B;mn[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:"≥","{":"π","|":"≠","}":"£","~":"·"};mn.A={"#":"£"};mn.B=void 0;mn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};mn.C=mn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};mn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};mn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};mn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};mn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};mn.E=mn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};mn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};mn.H=mn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};mn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Rv=4294967295,Pv=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=cn.clone(),this.savedCharset=Ys,this.markers=[],this._nullCell=mi.fromCharData([0,qy,1,0]),this._whitespaceCell=mi.fromCharData([0,Ns,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Yl,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new jv(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 Wl),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 Wl),this._whitespaceCell}getBlankLine(e,t){return new Wo(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>Rv?Rv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=cn);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 jv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(cn),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,n);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 Wo(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new Wo(e,n)));else for(let u=this._rows;u>t;u--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(o<this.lines.maxLength){let u=this.lines.length-o;u>0&&(this.lines.trimStart(u),this.ybase=Math.max(this.ybase-u,0),this.ydisp=Math.max(this.ydisp-u,0),this.savedY=Math.max(this.savedY-u,0)),this.lines.maxLength=o}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),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,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=WC(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(cn),n);if(s.length>0){let o=KC(this.lines,s);qC(this.lines,o.layout),this._reflowLargerAdjustViewport(e,t,o.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let s=this.getNullCell(cn),o=n;for(;o-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Wo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(cn),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(!n){let z=this.ybase+this.y;if(z>=u&&z<u+p.length)continue}let m=p[p.length-1].getTrimmedLength(),v=VC(p,this._cols,e),w=v.length-p.length,y;this.ybase===0&&this.y!==this.lines.length-1?y=Math.max(0,this.y-this.lines.maxLength+w):y=Math.max(0,this.lines.length-this.lines.maxLength+w);let S=[];for(let z=0;z<w;z++){let D=this.getBlankLine(cn,!0);S.push(D)}S.length>0&&(o.push({start:u+p.length+a,newLines:S}),a+=S.length),p.push(...S);let k=v.length-1,E=v[k];E===0&&(k--,E=v[k]);let b=p.length-w-1,j=m;for(;b>=0;){let z=Math.min(j,E);if(p[k]===void 0)break;if(p[k].copyCellsFrom(p[b],j-z,E-z,z,!0),E-=z,E===0&&(k--,E=v[k]),j-=z,j===0){b--;let D=Math.max(b,0);j=ea(p,D,this._cols)}}for(let z=0;z<p.length;z++)v[z]<e&&p[z].setCell(v[z],s);let N=w-y;for(;N-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+w,this.ybase+t-1)}if(o.length>0){let u=[],h=[];for(let E=0;E<this.lines.length;E++)h.push(this.lines.get(E));let p=this.lines.length,m=p-1,v=0,w=o[v];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let y=0;for(let E=Math.min(this.lines.maxLength-1,p+a-1);E>=0;E--)if(w&&w.start>m+y){for(let b=w.newLines.length-1;b>=0;b--)this.lines.set(E--,w.newLines[b]);E++,u.push({index:m+1,amount:w.newLines.length}),y+=w.newLines.length,w=o[++v]}else this.lines.set(E,h[m--]);let S=0;for(let E=u.length-1;E>=0;E--)u[E].index+=S,this.lines.onInsertEmitter.fire(u[E]),S+=u[E].amount;let k=Math.max(0,p+a-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}translateBufferLineToString(e,t,n=0,s){let o=this.lines.get(e);return o?o.translateToString(t,n,s):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new YC(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},GC=class extends dt{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Re),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 Pv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Pv(!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)}},Pw=2,Aw=1,Th=class extends dt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Re),this.onResize=this._onResize.event,this._onScroll=this._register(new Re),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Pw),this.rows=Math.max(e.rawOptions.rows||0,Aw),this.buffers=this._register(new GC(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=n.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let o=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let u=n.lines.isFull;a===n.lines.length-1?u?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(a+1,0,s.clone()),u?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let u=a-o+1;n.lines.shiftElements(o+1,u-1,-1),n.lines.set(a,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),s!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Th=tn([De(0,Hn)],Th);var Pr={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:Vl,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},XC=["normal","bold","100","200","300","400","500","600","700","800","900"],QC=class extends dt{constructor(e){super(),this._onOptionChange=this._register(new Re),this.onOptionChange=this._onOptionChange.event;let t={...Pr};for(let n in e)if(n in t)try{let s=e[n];t[n]=this._sanitizeAndValidateOption(n,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Kt(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in Pr))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,s)=>{if(!(n in Pr))throw new Error(`No option with key "${n}"`);s=this._sanitizeAndValidateOption(n,s),this.rawOptions[n]!==s&&(this.rawOptions[n]=s,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let s={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Pr[e]),!JC(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Pr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=XC.includes(t)?t:Pr[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 JC(e){return e==="block"||e==="underline"||e==="bar"}function Ko(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let s in e)n[s]=t<=1?e[s]:e[s]&&Ko(e[s],t-1);return n}var Av=Object.freeze({insertMode:!1}),Lv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Mh=class extends dt{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Re),this.onData=this._onData.event,this._onUserInput=this._register(new Re),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Re),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Re),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ko(Av),this.decPrivateModes=Ko(Lv)}reset(){this.modes=Ko(Av),this.decPrivateModes=Ko(Lv)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Mh=tn([De(0,Fn),De(1,Qy),De(2,Hn)],Mh);var Tv={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 ld(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var cd=String.fromCharCode,Mv={DEFAULT:e=>{let t=[ld(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${cd(t[0])}${cd(t[1])}${cd(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ld(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${ld(e,!0)};${e.x};${e.y}${t}`}},Dh=class extends dt{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Re),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Tv))this.addProtocol(s,Tv[s]);for(let s of Object.keys(Mv))this.addEncoding(s,Mv[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let s=t/n,o=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(o/=s+0,Math.abs(e.deltaY)<50&&(o*=.3),this._wheelPartialScroll+=o,o=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(o*=this._bufferService.rows),o}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};Dh=tn([De(0,Fn),De(1,nr),De(2,Hn)],Dh);var ud=[[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]],ZC=[[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]],pn;function eE(e,t){let n=0,s=t.length-1,o;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=n;)if(o=n+s>>1,e>t[o][1])n=o+1;else if(e<t[o][0])s=o-1;else return!0;return!1}var tE=class{constructor(){if(this.version="6",!pn){pn=new Uint8Array(65536),pn.fill(1),pn[0]=0,pn.fill(0,1,32),pn.fill(0,127,160),pn.fill(2,4352,4448),pn[9001]=2,pn[9002]=2,pn.fill(2,11904,42192),pn[12351]=1,pn.fill(2,44032,55204),pn.fill(2,63744,64256),pn.fill(2,65040,65050),pn.fill(2,65072,65136),pn.fill(2,65280,65377),pn.fill(2,65504,65511);for(let e=0;e<ud.length;++e)pn.fill(0,ud[e][0],ud[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?pn[e]:eE(e,ZC)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),s=n===0&&t!==0;if(s){let o=Qs.extractWidth(t);o===0?s=!1:o>n&&(n=o)}return Qs.createPropertyValue(0,n,s)}},Qs=class Dl{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Re,this.onChange=this._onChange.event;let t=new tE;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,s=!1){return(t&16777215)<<3|(n&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,s=0,o=t.length;for(let a=0;a<o;++a){let u=t.charCodeAt(a);if(55296<=u&&u<=56319){if(++a>=o)return n+this.wcwidth(u);let m=t.charCodeAt(a);56320<=m&&m<=57343?u=(u-55296)*1024+m-56320+65536:n+=this.wcwidth(m)}let h=this.charProperties(u,s),p=Dl.extractWidth(h);Dl.extractShouldJoin(h)&&(p-=Dl.extractWidth(s)),n+=p,s=h}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},nE=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 Dv(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var Do=2147483647,iE=256,Lw=class Ih{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>iE)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new Ih;if(!t.length)return n;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let o=t[s];if(Array.isArray(o))for(let a=0;a<o.length;++a)n.addSubParam(o[a]);else n.addParam(o)}return n}clone(){let t=new Ih(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,o))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Do?Do: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>Do?Do:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,o=this._subParamsIdx[n]&255;o-s>0&&(t[n]=this._subParams.slice(s,o))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,o=s[n-1];s[n-1]=~o?Math.min(o*10+t,Do):t}},Io=[],sE=class{constructor(){this._state=0,this._active=Io,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Io}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=Io,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Io,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",nc(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].end(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Io,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,n){this._hitLimit||(this._data+=nc(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},Oo=[],rE=class{constructor(){this._handlers=Object.create(null),this._active=Oo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Oo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let s=n.indexOf(t);s!==-1&&n.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Oo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Oo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",nc(e,t,n));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,s=this._active.length-1,o=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,n=t,o=this._stack.fallThrough,this._stack.paused=!1),!o&&n===!1){for(;s>=0&&(n=this._active[s].unhook(e),n!==!0);s--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,n;s--}for(;s>=0;s--)if(n=this._active[s].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,n}this._active=Oo,this._ident=0}},qo=new Lw;qo.addParam(0);var Iv=class{constructor(e){this._handler=e,this._data="",this._params=qo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():qo,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=nc(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=qo,this._data="",this._hitLimit=!1,n));return this._params=qo,this._data="",this._hitLimit=!1,t}},oE=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,s){this.table[t<<8|e]=n<<4|s}addMany(e,t,n,s){for(let o=0;o<e.length;o++)this.table[t<<8|e[o]]=n<<4|s}},pi=160,aE=(function(){let e=new oE(4095),t=Array.apply(null,Array(256)).map((h,p)=>p),n=(h,p)=>t.slice(h,p),s=n(32,127),o=n(0,24);o.push(25),o.push.apply(o,n(28,32));let a=n(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(n(128,144),u,3,0),e.addMany(n(144,152),u,3,0),e.add(156,u,0,0),e.add(27,u,11,1),e.add(157,u,4,8),e.addMany([152,158,159],u,0,7),e.add(155,u,11,3),e.add(144,u,11,9);return e.addMany(o,0,3,0),e.addMany(o,1,3,1),e.add(127,1,0,1),e.addMany(o,8,0,8),e.addMany(o,3,3,3),e.add(127,3,0,3),e.addMany(o,4,3,4),e.add(127,4,0,4),e.addMany(o,6,3,6),e.addMany(o,5,3,5),e.add(127,5,0,5),e.addMany(o,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(o,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(o,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(o,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(o,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(o,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(o,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(pi,0,2,0),e.add(pi,8,5,8),e.add(pi,6,0,6),e.add(pi,11,0,11),e.add(pi,13,13,13),e})(),lE=class extends dt{constructor(e=aE){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 Lw,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Kt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new sE),this._dcsParser=this._register(new rE),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let o=0;o<e.intermediates.length;++o){let a=e.intermediates.charCodeAt(o);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=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 n<<=8,n|=s,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let s=this._escHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let s=this._csiHandlers[n];return s.push(t),{dispose:()=>{let o=s.indexOf(t);o!==-1&&s.splice(o,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,s,o){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=s,this._parseStack.chunkPos=o}parse(e,t,n){let s=0,o=0,a=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!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(n===!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,n),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,n),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:pi)],o>>4){case 2:for(let y=h+1;;++y){if(y>=t||(s=e[y])<32||s>126&&s<pi){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<pi){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<pi){this._printHandler(e,h,y),h=y-1;break}if(++y>=t||(s=e[y])<32||s>126&&s<pi){this._printHandler(e,h,y),h=y-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position: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],m=p?p.length-1:-1;for(;m>=0&&(u=p[m](this._params),u!==!0);m--)if(u instanceof Promise)return this._preserveStack(3,p,m,o,h),u;m<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let v=this._escHandlers[this._collect<<8|s],w=v?v.length-1:-1;for(;w>=0&&(u=v[w](),u!==!0);w--)if(u instanceof Promise)return this._preserveStack(4,v,w,o,h),u;w<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let y=h+1;;++y)if(y>=t||(s=e[y])===24||s===26||s===27||s>127&&s<pi){this._dcsParser.put(e,h,y),h=y-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 y=h+1;;y++)if(y>=t||(s=e[y])<32||s>127&&s<pi){this._oscParser.put(e,h,y),h=y-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}}},cE=/^([\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})$/,uE=/^[\da-f]+$/;function Ov(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=cE.exec(t);if(n){let s=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/s*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/s*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),uE.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,s=[0,0,0];for(let o=0;o<3;++o){let a=parseInt(t.slice(n*o,n*o+n),16);s[o]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return s}}function dd(e,t){let n=e.toString(16),s=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function dE(e,t=16){let[n,s,o]=e;return`rgb:${dd(n,t)}/${dd(s,t)}/${dd(o,t)}`}var hE={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ss=131072,Bv=10;function zv(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 $v=5e3,Fv=0,fE=class extends dt{constructor(e,t,n,s,o,a,u,h,p=new lE){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,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 Lk,this._utf8Decoder=new Tk,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=cn.clone(),this._eraseAttrDataInternal=cn.clone(),this._onRequestBell=this._register(new Re),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Re),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Re),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Re),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Re),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Re),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Re),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Re),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Re),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Re),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Re),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Re),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Re),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 Oh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(m=>this._activeBuffer=m.activeBuffer)),this._parser.setCsiHandlerFallback((m,v)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(m),params:v.toArray()})}),this._parser.setEscHandlerFallback(m=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(m)})}),this._parser.setExecuteHandlerFallback(m=>{this._logService.debug("Unknown EXECUTE code: ",{code:m})}),this._parser.setOscHandlerFallback((m,v,w)=>{this._logService.debug("Unknown OSC code: ",{identifier:m,action:v,data:w})}),this._parser.setDcsHandlerFallback((m,v,w)=>{v==="HOOK"&&(w=w.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(m),action:v,payload:w})}),this._parser.setPrintHandler((m,v,w)=>this.print(m,v,w)),this._parser.registerCsiHandler({final:"@"},m=>this.insertChars(m)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},m=>this.scrollLeft(m)),this._parser.registerCsiHandler({final:"A"},m=>this.cursorUp(m)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},m=>this.scrollRight(m)),this._parser.registerCsiHandler({final:"B"},m=>this.cursorDown(m)),this._parser.registerCsiHandler({final:"C"},m=>this.cursorForward(m)),this._parser.registerCsiHandler({final:"D"},m=>this.cursorBackward(m)),this._parser.registerCsiHandler({final:"E"},m=>this.cursorNextLine(m)),this._parser.registerCsiHandler({final:"F"},m=>this.cursorPrecedingLine(m)),this._parser.registerCsiHandler({final:"G"},m=>this.cursorCharAbsolute(m)),this._parser.registerCsiHandler({final:"H"},m=>this.cursorPosition(m)),this._parser.registerCsiHandler({final:"I"},m=>this.cursorForwardTab(m)),this._parser.registerCsiHandler({final:"J"},m=>this.eraseInDisplay(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},m=>this.eraseInDisplay(m,!0)),this._parser.registerCsiHandler({final:"K"},m=>this.eraseInLine(m,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},m=>this.eraseInLine(m,!0)),this._parser.registerCsiHandler({final:"L"},m=>this.insertLines(m)),this._parser.registerCsiHandler({final:"M"},m=>this.deleteLines(m)),this._parser.registerCsiHandler({final:"P"},m=>this.deleteChars(m)),this._parser.registerCsiHandler({final:"S"},m=>this.scrollUp(m)),this._parser.registerCsiHandler({final:"T"},m=>this.scrollDown(m)),this._parser.registerCsiHandler({final:"X"},m=>this.eraseChars(m)),this._parser.registerCsiHandler({final:"Z"},m=>this.cursorBackwardTab(m)),this._parser.registerCsiHandler({final:"`"},m=>this.charPosAbsolute(m)),this._parser.registerCsiHandler({final:"a"},m=>this.hPositionRelative(m)),this._parser.registerCsiHandler({final:"b"},m=>this.repeatPrecedingCharacter(m)),this._parser.registerCsiHandler({final:"c"},m=>this.sendDeviceAttributesPrimary(m)),this._parser.registerCsiHandler({prefix:">",final:"c"},m=>this.sendDeviceAttributesSecondary(m)),this._parser.registerCsiHandler({final:"d"},m=>this.linePosAbsolute(m)),this._parser.registerCsiHandler({final:"e"},m=>this.vPositionRelative(m)),this._parser.registerCsiHandler({final:"f"},m=>this.hVPosition(m)),this._parser.registerCsiHandler({final:"g"},m=>this.tabClear(m)),this._parser.registerCsiHandler({final:"h"},m=>this.setMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"h"},m=>this.setModePrivate(m)),this._parser.registerCsiHandler({final:"l"},m=>this.resetMode(m)),this._parser.registerCsiHandler({prefix:"?",final:"l"},m=>this.resetModePrivate(m)),this._parser.registerCsiHandler({final:"m"},m=>this.charAttributes(m)),this._parser.registerCsiHandler({final:"n"},m=>this.deviceStatus(m)),this._parser.registerCsiHandler({prefix:"?",final:"n"},m=>this.deviceStatusPrivate(m)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},m=>this.softReset(m)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},m=>this.setCursorStyle(m)),this._parser.registerCsiHandler({final:"r"},m=>this.setScrollRegion(m)),this._parser.registerCsiHandler({final:"s"},m=>this.saveCursor(m)),this._parser.registerCsiHandler({final:"t"},m=>this.windowOptions(m)),this._parser.registerCsiHandler({final:"u"},m=>this.restoreCursor(m)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},m=>this.insertColumns(m)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},m=>this.deleteColumns(m)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},m=>this.selectProtected(m)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},m=>this.requestMode(m,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},m=>this.requestMode(m,!1)),this._parser.setExecuteHandler(me.BEL,()=>this.bell()),this._parser.setExecuteHandler(me.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(me.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(me.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(me.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(me.BS,()=>this.backspace()),this._parser.setExecuteHandler(me.HT,()=>this.tab()),this._parser.setExecuteHandler(me.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(me.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(m=>(this.setTitle(m),this.setIconName(m),!0))),this._parser.registerOscHandler(1,new ni(m=>this.setIconName(m))),this._parser.registerOscHandler(2,new ni(m=>this.setTitle(m))),this._parser.registerOscHandler(4,new ni(m=>this.setOrReportIndexedColor(m))),this._parser.registerOscHandler(8,new ni(m=>this.setHyperlink(m))),this._parser.registerOscHandler(10,new ni(m=>this.setOrReportFgColor(m))),this._parser.registerOscHandler(11,new ni(m=>this.setOrReportBgColor(m))),this._parser.registerOscHandler(12,new ni(m=>this.setOrReportCursorColor(m))),this._parser.registerOscHandler(104,new ni(m=>this.restoreIndexedColor(m))),this._parser.registerOscHandler(110,new ni(m=>this.restoreFgColor(m))),this._parser.registerOscHandler(111,new ni(m=>this.restoreBgColor(m))),this._parser.registerOscHandler(112,new ni(m=>this.restoreCursorColor(m))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let m in mn)this._parser.registerEscHandler({intermediates:"(",final:m},()=>this.selectCharset("("+m)),this._parser.registerEscHandler({intermediates:")",final:m},()=>this.selectCharset(")"+m)),this._parser.registerEscHandler({intermediates:"*",final:m},()=>this.selectCharset("*"+m)),this._parser.registerEscHandler({intermediates:"+",final:m},()=>this.selectCharset("+"+m)),this._parser.registerEscHandler({intermediates:"-",final:m},()=>this.selectCharset("-"+m)),this._parser.registerEscHandler({intermediates:".",final:m},()=>this.selectCharset("."+m)),this._parser.registerEscHandler({intermediates:"/",final:m},()=>this.selectCharset("/"+m));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(m=>(this._logService.error("Parsing error: ",m),m)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Iv((m,v)=>this.requestStatusString(m,v)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),$v))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${$v} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,s=this._activeBuffer.x,o=this._activeBuffer.y,a=0,u=this._parseStack.paused;if(u){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,o=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ss&&(a=this._parseStack.position+Ss)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,m=>String.fromCharCode(m)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(m=>m.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ss&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ss))),u||this._dirtyRowTracker.clearRange(),e.length>Ss)for(let m=a;m<e.length;m+=Ss){let v=m+Ss<e.length?m+Ss:e.length,w=typeof e=="string"?this._stringDecoder.decode(e.substring(m,v),this._parseBuffer):this._utf8Decoder.decode(e.subarray(m,v),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,w))return this._preserveStack(s,o,w,m),this._logSlowResolvingAsync(n),n}else if(!u){let m=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,o,m,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==o)&&this._onCursorMove.fire();let 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,n){let s,o,a=this._charsetService.charset,u=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,m=this._coreService.modes.insertMode,v=this._curAttrData,w=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&w.getWidth(this._activeBuffer.x-1)===2&&w.setCellFromCodepoint(this._activeBuffer.x-1,0,1,v);let y=this._parser.precedingJoinState;for(let S=t;S<n;++S){if(s=e[S],s<127&&a){let j=a[String.fromCharCode(s)];j&&(s=j.charCodeAt(0))}let k=this._unicodeService.charProperties(s,y);o=Qs.extractWidth(k);let E=Qs.extractShouldJoin(k),b=E?Qs.extractWidth(y):0;if(y=k,u&&this._onA11yChar.fire(Cs(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+o-b>h){if(p){let j=w,N=this._activeBuffer.x-b;for(this._activeBuffer.x=b,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),w=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),b>0&&w instanceof Wo&&w.copyCellsFrom(j,N,0,b,!1);N<h;)j.setCellFromCodepoint(N++,0,1,v)}else if(this._activeBuffer.x=h-1,o===2)continue}if(E&&this._activeBuffer.x){let j=w.getWidth(this._activeBuffer.x-1)?1:2;w.addCodepointToCell(this._activeBuffer.x-j,s,o);for(let N=o-b;--N>=0;)w.setCellFromCodepoint(this._activeBuffer.x++,0,0,v);continue}if(m&&(w.insertCells(this._activeBuffer.x,o-b,this._activeBuffer.getNullCell(v)),w.getWidth(h-1)===2&&w.setCellFromCodepoint(h-1,0,1,v)),w.setCellFromCodepoint(this._activeBuffer.x++,s,o,v),o>0)for(;--o;)w.setCellFromCodepoint(this._activeBuffer.x++,0,0,v)}this._parser.precedingJoinState=y,this._activeBuffer.x<h&&n-t>0&&w.getWidth(this._activeBuffer.x)===0&&!w.hasContent(this._activeBuffer.x)&&w.setCellFromCodepoint(this._activeBuffer.x,0,1,v),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>zv(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Iv(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,n,s=!1,o=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),o),s&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n))!=null&&s.getTrimmedLength()););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let o=this._activeBuffer.lines.length-this._bufferService.rows;o>0&&(this._activeBuffer.lines.trimStart(o),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-o,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-o,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,o=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(o-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(cn));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,s=Qs.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*n),h=0;for(let m=0;m<a.length;){let v=a.codePointAt(m)||0;u[h++]=v,m+=v>65535?2:1}let p=h;for(let m=1;m<n;++m)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(me.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(me.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(me.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(me.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(me.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,Ys),this._charsetService.setgCharset(1,Ys),this._charsetService.setgCharset(2,Ys),this._charsetService.setgCharset(3,Ys);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){(E=>(E[E.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",E[E.SET=1]="SET",E[E.RESET=2]="RESET",E[E.PERMANENTLY_SET=3]="PERMANENTLY_SET",E[E.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:o,activeEncoding:a}=this._coreMouseService,u=this._coreService,{buffers:h,cols:p}=this._bufferService,{active:m,alt:v}=h,w=this._optionsService.rawOptions,y=(E,b)=>(u.triggerDataEvent(`${me.ESC}[${t?"":"?"}${E};${b}$y`),!0),S=E=>E?1:2,k=e.params[0];return t?k===2?y(k,4):k===4?y(k,S(u.modes.insertMode)):k===12?y(k,3):k===20?y(k,S(w.convertEol)):y(k,0):k===1?y(k,S(s.applicationCursorKeys)):k===3?y(k,w.windowOptions.setWinLines?p===80?2:p===132?1:0:0):k===6?y(k,S(s.origin)):k===7?y(k,S(s.wraparound)):k===8?y(k,3):k===9?y(k,S(o==="X10")):k===12?y(k,S(w.cursorBlink)):k===25?y(k,S(!u.isCursorHidden)):k===45?y(k,S(s.reverseWraparound)):k===66?y(k,S(s.applicationKeypad)):k===67?y(k,4):k===1e3?y(k,S(o==="VT200")):k===1002?y(k,S(o==="DRAG")):k===1003?y(k,S(o==="ANY")):k===1004?y(k,S(s.sendFocus)):k===1005?y(k,4):k===1006?y(k,S(a==="SGR")):k===1015?y(k,4):k===1016?y(k,S(a==="SGR_PIXELS")):k===1048?y(k,1):k===47||k===1047||k===1049?y(k,S(m===v)):k===2004?y(k,S(s.bracketedPasteMode)):k===2026?y(k,S(s.synchronizedOutput)):y(k,0)}_updateAttrColor(e,t,n,s,o){return t===2?(e|=50331648,e&=-16777216,e|=sa.fromColorRGB([n,s,o])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let s=[0,0,-1,0,0,0],o=0,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:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return 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=cn.fg,e.bg=cn.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,s=this._curAttrData;for(let o=0;o<t;o++)n=e.params[o],n>=30&&n<=37?(s.fg&=-50331904,s.fg|=16777216|n-30):n>=40&&n<=47?(s.bg&=-50331904,s.bg|=16777216|n-40):n>=90&&n<=97?(s.fg&=-50331904,s.fg|=16777216|n-90|8):n>=100&&n<=107?(s.bg&=-50331904,s.bg|=16777216|n-100|8):n===0?this._processSGR0(s):n===1?s.fg|=134217728:n===3?s.bg|=67108864:n===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(o)?e.getSubParams(o)[0]:1,s)):n===5?s.fg|=536870912:n===7?s.fg|=67108864:n===8?s.fg|=1073741824:n===9?s.fg|=2147483648:n===2?s.bg|=134217728:n===21?this._processUnderline(2,s):n===22?(s.fg&=-134217729,s.bg&=-134217729):n===23?s.bg&=-67108865:n===24?(s.fg&=-268435457,this._processUnderline(0,s)):n===25?s.fg&=-536870913:n===27?s.fg&=-67108865:n===28?s.fg&=-1073741825:n===29?s.fg&=2147483647:n===39?(s.fg&=-67108864,s.fg|=cn.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=cn.bg&16777215):n===38||n===48||n===58?o+=this._extractColor(e,o,s):n===53?s.bg|=1073741824:n===55?s.bg&=-1073741825:n===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):n===100?(s.fg&=-67108864,s.fg|=cn.fg&16777215,s.bg&=-67108864,s.bg|=cn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${me.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${me.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${me.ESC}[?${t};${n}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=cn.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!zv(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(`${me.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Bv&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Bv&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let s=n.shift(),o=n.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(Hv(a))if(o==="?")t.push({type:0,index:a});else{let u=Ov(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 n=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),s,o=n.findIndex(a=>a.startsWith("id="));return o!==-1&&(s=n[o].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let s=0;s<n.length&&!(t>=this._specialColors.length);++s,++t)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let o=Ov(n[s]);o&&this._onColor.fire([{type:1,index:this._specialColors[t],color:o}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let o=parseInt(n[s]);Hv(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,Ys),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(hE[e[0]],mn[e[1]]||Ys),!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=cn.clone(),this._eraseAttrDataInternal=cn.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new mi;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(n);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=u=>(this._coreService.triggerDataEvent(`${me.ESC}${u}${me.ESC}\\`),!0),s=this._bufferService.buffer,o=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[o.cursorStyle]-(o.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Oh=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&&(Fv=e,e=t,t=Fv),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Oh=tn([De(0,Fn)],Oh);function Hv(e){return 0<=e&&e<256}var pE=5e7,Uv=12,mE=50,gE=class extends dt{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 Re),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>pE)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],o=this._action(s,t);if(o){let u=h=>performance.now()-n>=Uv?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(n,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()-n>=Uv)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>mE&&(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()}},Bh=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 n=e,s=this._getEntryIdKey(n),o=this._entriesWithId.get(s);if(o)return this.addLineToLink(o.id,t.ybase+t.y),o.id;let a=t.addMarker(t.ybase+t.y),u={id:this._nextId++,key:this._getEntryIdKey(n),data:n,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 n=this._dataByLinkId.get(e);if(n&&n.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);n.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(n,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Bh=tn([De(0,Fn)],Bh);var Wv=!1,vE=class extends dt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Fr),this._onBinary=this._register(new Re),this.onBinary=this._onBinary.event,this._onData=this._register(new Re),this.onData=this._onData.event,this._onLineFeed=this._register(new Re),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Re),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Re),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Re),this._instantiationService=new FC,this.optionsService=this._register(new QC(e)),this._instantiationService.setService(Hn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Th)),this._instantiationService.setService(Fn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Lh)),this._instantiationService.setService(Qy,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Mh)),this._instantiationService.setService(nr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Dh)),this._instantiationService.setService(Xy,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Qs)),this._instantiationService.setService(Ok,this.unicodeService),this._charsetService=this._instantiationService.createInstance(nE),this._instantiationService.setService(Ik,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Bh),this._instantiationService.setService(Jy,this._oscLinkService),this._inputHandler=this._register(new fE(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Rn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Rn.forward(this._bufferService.onResize,this._onResize)),this._register(Rn.forward(this.coreService.onData,this._onData)),this._register(Rn.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 gE((t,n)=>this._inputHandler.parse(t,n))),this._register(Rn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Re),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&&!Wv&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Wv=!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,Pw),t=Math.max(t,Aw),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(Dv.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Dv(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Kt(()=>{for(let t of e)t.dispose()})}}},_E={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 yE(e,t,n,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=me.ESC+"OA":o.key=me.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?o.key=me.ESC+"OD":o.key=me.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?o.key=me.ESC+"OC":o.key=me.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?o.key=me.ESC+"OB":o.key=me.ESC+"[B");break;case 8:o.key=e.ctrlKey?"\b":me.DEL,e.altKey&&(o.key=me.ESC+o.key);break;case 9:if(e.shiftKey){o.key=me.ESC+"[Z";break}o.key=me.HT,o.cancel=!0;break;case 13:o.key=e.altKey?me.ESC+me.CR:me.CR,o.cancel=!0;break;case 27:o.key=me.ESC,e.altKey&&(o.key=me.ESC+me.ESC),o.cancel=!0;break;case 37:if(e.metaKey)break;a?o.key=me.ESC+"[1;"+(a+1)+"D":t?o.key=me.ESC+"OD":o.key=me.ESC+"[D";break;case 39:if(e.metaKey)break;a?o.key=me.ESC+"[1;"+(a+1)+"C":t?o.key=me.ESC+"OC":o.key=me.ESC+"[C";break;case 38:if(e.metaKey)break;a?o.key=me.ESC+"[1;"+(a+1)+"A":t?o.key=me.ESC+"OA":o.key=me.ESC+"[A";break;case 40:if(e.metaKey)break;a?o.key=me.ESC+"[1;"+(a+1)+"B":t?o.key=me.ESC+"OB":o.key=me.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(o.key=me.ESC+"[2~");break;case 46:a?o.key=me.ESC+"[3;"+(a+1)+"~":o.key=me.ESC+"[3~";break;case 36:a?o.key=me.ESC+"[1;"+(a+1)+"H":t?o.key=me.ESC+"OH":o.key=me.ESC+"[H";break;case 35:a?o.key=me.ESC+"[1;"+(a+1)+"F":t?o.key=me.ESC+"OF":o.key=me.ESC+"[F";break;case 33:e.shiftKey?o.type=2:e.ctrlKey?o.key=me.ESC+"[5;"+(a+1)+"~":o.key=me.ESC+"[5~";break;case 34:e.shiftKey?o.type=3:e.ctrlKey?o.key=me.ESC+"[6;"+(a+1)+"~":o.key=me.ESC+"[6~";break;case 112:a?o.key=me.ESC+"[1;"+(a+1)+"P":o.key=me.ESC+"OP";break;case 113:a?o.key=me.ESC+"[1;"+(a+1)+"Q":o.key=me.ESC+"OQ";break;case 114:a?o.key=me.ESC+"[1;"+(a+1)+"R":o.key=me.ESC+"OR";break;case 115:a?o.key=me.ESC+"[1;"+(a+1)+"S":o.key=me.ESC+"OS";break;case 116:a?o.key=me.ESC+"[15;"+(a+1)+"~":o.key=me.ESC+"[15~";break;case 117:a?o.key=me.ESC+"[17;"+(a+1)+"~":o.key=me.ESC+"[17~";break;case 118:a?o.key=me.ESC+"[18;"+(a+1)+"~":o.key=me.ESC+"[18~";break;case 119:a?o.key=me.ESC+"[19;"+(a+1)+"~":o.key=me.ESC+"[19~";break;case 120:a?o.key=me.ESC+"[20;"+(a+1)+"~":o.key=me.ESC+"[20~";break;case 121:a?o.key=me.ESC+"[21;"+(a+1)+"~":o.key=me.ESC+"[21~";break;case 122:a?o.key=me.ESC+"[23;"+(a+1)+"~":o.key=me.ESC+"[23~";break;case 123:a?o.key=me.ESC+"[24;"+(a+1)+"~":o.key=me.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=me.NUL:e.keyCode>=51&&e.keyCode<=55?o.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?o.key=me.DEL:e.keyCode===219?o.key=me.ESC:e.keyCode===220?o.key=me.FS:e.keyCode===221&&(o.key=me.GS);else if((!n||s)&&e.altKey&&!e.metaKey){let h=(u=_E[e.keyCode])==null?void 0:u[e.shiftKey?1:0];if(h)o.key=me.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,m=String.fromCharCode(p);e.shiftKey&&(m=m.toUpperCase()),o.key=me.ESC+m}else if(e.keyCode===32)o.key=me.ESC+(e.ctrlKey?me.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),o.key=me.ESC+p,o.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(o.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?o.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(o.key=me.US),e.key==="@"&&(o.key=me.NUL));break}return o}var rn=0,wE=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Yl,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Yl,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,n=0,s=new Array(this._array.length+this._insertedValues.length);for(let o=0;o<s.length;o++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(s[o]=e[t],t++):s[o]=this._array[n++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(rn=this._search(t),rn===-1)||this._getKey(this._array[rn])!==t)return!1;do if(this._array[rn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(rn),!0;while(++rn<this._array.length&&this._getKey(this._array[rn])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((o,a)=>o-a),t=0,n=new Array(this._array.length-e.length),s=0;for(let o=0;o<this._array.length;o++)e[t]===o?t++:n[s++]=this._array[o];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(rn=this._search(e),!(rn<0||rn>=this._array.length)&&this._getKey(this._array[rn])===e))do yield this._array[rn];while(++rn<this._array.length&&this._getKey(this._array[rn])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(rn=this._search(e),!(rn<0||rn>=this._array.length)&&this._getKey(this._array[rn])===e))do t(this._array[rn]);while(++rn<this._array.length&&this._getKey(this._array[rn])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let s=t+n>>1,o=this._getKey(this._array[s]);if(o>e)n=s-1;else if(o<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},hd=0,Kv=0,bE=class extends dt{constructor(){super(),this._decorations=new wE(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new Re),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Re),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Kt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new SE(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let s=0,o=0;for(let a of this._decorations.getKeyIterator(t))s=a.options.x??0,o=s+(a.options.width??1),e>=s&&e<o&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(e,t,n,s){this._decorations.forEachByKey(t,o=>{hd=o.options.x??0,Kv=hd+(o.options.width??1),e>=hd&&e<Kv&&(!n||(o.options.layer??"bottom")===n)&&s(o)})}},SE=class extends Ps{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Re),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Re),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=Xt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Xt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},xE=1e3,kE=class{constructor(e,t=xE){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let o=s-this._lastRefreshMs,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)}},qv=20,Gl=class extends dt{constructor(e,t,n,s){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let o=this._coreBrowserService.mainDocument;this._accessibilityContainer=o.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=o.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let 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 kE(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(it(o,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Kt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<qv+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
65
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===qv+1&&(this._liveRegion.textContent+=sh.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,s=n.lines.length.toString();for(let o=e;o<=t;o++){let a=n.lines.get(n.ydisp+o),u=[],h=(a==null?void 0:a.translateToString(!0,void 0,void 0,u))||"",p=(n.ydisp+o+1).toString(),m=this._rowElements[o];m&&(h.length===0?(m.textContent=" ",this._rowColumns.set(m,[0,1])):(m.textContent=h,this._rowColumns.set(m,u)),m.setAttribute("aria-posinset",p),m.setAttribute("aria-setsize",s),this._alignRowWidth(m))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],o=n.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(o===a||e.relatedTarget!==s)return;let u,h;if(t===0?(u=n,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(u=this._rowElements.shift(),h=n,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},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(n.node))return;let o=({node:p,offset:m})=>{let v=p instanceof Text?p.parentNode:p,w=parseInt(v==null?void 0:v.getAttribute("aria-posinset"),10)-1;if(isNaN(w))return console.warn("row is invalid. Race condition?"),null;let y=this._rowColumns.get(v);if(!y)return console.warn("columns is null. Race condition?"),null;let S=m<y.length?y[m]:y.slice(-1)[0]+1;return S>=this._terminal.cols&&(++w,S=0),{row:w,column:S}},a=o(t),u=o(n);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,n=(a=(o=this._rowColumns.get(e))==null?void 0:o.slice(-1))==null?void 0:a[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Gl=tn([De(1,bf),De(2,Zi),De(3,es)],Gl);var zh=class extends dt{constructor(e,t,n,s,o){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=s,this._linkProviderService=o,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Re),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Re),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Kt(()=>{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(it(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(it(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(it(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(it(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let s=0;s<n.length;s++){let o=n[s];if(o.classList.contains("xterm"))break;if(o.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,o;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(u=>{u.link.dispose&&u.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[a,u]of this._linkProviderService.linkProviders.entries())t?(o=this._activeProviderReplies)!=null&&o.get(a)&&(n=this._checkLinkProviderResult(a,e,n)):u.provideLinks(e.y,h=>{var m,v;if(this._isMouseOut)return;let p=h==null?void 0:h.map(w=>({link:w}));(m=this._activeProviderReplies)==null||m.set(a,p),n=this._checkLinkProviderResult(a,e,n),((v=this._activeProviderReplies)==null?void 0:v.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let s=0;s<t.size;s++){let o=t.get(s);if(o)for(let 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 m=h;m<=p;m++){if(n.has(m)){o.splice(a--,1);break}n.add(m)}}}}_checkLinkProviderResult(e,t,n){var a;if(!this._activeProviderReplies)return n;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&&(n=!0,this._handleNewLink(u))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)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){n=!0,this._handleNewLink(h);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&CE(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 n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.pointerCursor},set:n=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>{var n,s;return(s=(n=this._currentLink)==null?void 0:n.state)==null?void 0:s.decorations.underline},set:n=>{var s,o,a;(s=this._currentLink)!=null&&s.state&&((a=(o=this._currentLink)==null?void 0:o.state)==null?void 0:a.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let s=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,o=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=o&&(this._clearCurrentLink(s,o),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,s=this._bufferService.buffer.ydisp,o=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(o)}_linkLeave(e,t,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,o=t.y*this._bufferService.cols+t.x;return n<=o&&o<=s}_positionFromMouseEvent(e,t,n){let s=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,s,o){return{x1:e,y1:t,x2:n,y2:s,cols:this._bufferService.cols,fg:o}}};zh=tn([De(1,Sf),De(2,es),De(3,Fn),De(4,ew)],zh);function CE(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 EE=class extends vE{constructor(e={}){super(e),this._linkifier=this._register(new Fr),this.browser=yw,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Fr),this._onCursorMove=this._register(new Re),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Re),this.onKey=this._onKey.event,this._onRender=this._register(new Re),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Re),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Re),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Re),this.onBell=this._onBell.event,this._onFocus=this._register(new Re),this._onBlur=this._register(new Re),this._onA11yCharEmitter=this._register(new Re),this._onA11yTabEmitter=this._register(new Re),this._onWillOpen=this._register(new Re),this._setup(),this._decorationService=this._instantiationService.createInstance(bE),this._instantiationService.setService(ra,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(mC),this._instantiationService.setService(ew,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(oh)),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(Rn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Rn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Rn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Rn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Kt(()=>{var t,n;this._customKeyEventHandler=void 0,(n=(t=this.element)==null?void 0:t.parentNode)==null||n.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,s="";switch(t.index){case 256:n="foreground",s="10";break;case 257:n="background",s="11";break;case 258:n="cursor",s="12";break;default:n="ansi",s="4;"+t.index}switch(t.type){case 0:let o=Ht.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${me.ESC}]${s};${dE(o)}${vw.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=un.toColor(...t.color));else{let a=n;this._themeService.modifyColors(u=>u[a]=un.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(Gl,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(me.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(me.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,o=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*o,u=this.buffer.y*this._renderService.dimensions.css.cell.height,h=n*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(it(this.element,"copy",t=>{this.hasSelection()&&Pk(t,this._selectionService)}));let e=t=>Ak(t,this.textarea,this.coreService,this.optionsService);this._register(it(this.textarea,"paste",e)),this._register(it(this.element,"paste",e)),ww?this._register(it(this.element,"mousedown",t=>{t.button===2&&nv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(it(this.element,"contextmenu",t=>{nv(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Pf&&this._register(it(this.element,"auxclick",t=>{t.button===1&&Ky(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(it(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(it(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(it(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(it(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(it(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(it(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(it(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(it(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 n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",ih.get()),xw||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(fC,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Zi,this._coreBrowserService),this._register(it(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(it(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Nh,this._document,this._helperContainer),this._instantiationService.setService(ic,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ah),this._instantiationService.setService(Kr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ql),this._instantiationService.setService(Zy,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Rh,this.rows,this.screenElement)),this._instantiationService.setService(es,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(kh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(jh),this._instantiationService.setService(Sf,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(zh,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(Sh,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(Ph,this.element,this.screenElement,s)),this._instantiationService.setService(zk,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(Rn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var a;this._selectionService.refresh(),(a=this._viewport)==null||a.queueSync()})),this._register(this._instantiationService.createInstance(xh,this.screenElement)),this._register(it(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(Gl,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Kl,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Kl,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Eh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(a){var m,v,w,y,S;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 k=a.deltaY;if(k===0||e.coreMouseService.consumeWheelEvent(a,(y=(w=(v=(m=e._renderService)==null?void 0:m.dimensions)==null?void 0:v.device)==null?void 0:w.cell)==null?void 0:y.height,(S=e._coreBrowserService)==null?void 0:S.dpr)===0)return!1;p=k<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=>(n(a),a.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(a)),wheel:a=>(n(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&n(a)},mousemove:a=>{a.buttons||n(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(it(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return n(a),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(a)})),this._register(it(t,"wheel",a=>{var u,h,p,m,v;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,(m=(p=(h=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:m.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return this.cancel(a,!0);let w=me.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(w,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){var n;(n=this._renderService)==null||n.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Wy(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var n;(n=this._selectionService)==null||n.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=yE(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let s=this.rows-1;return this.scrollLines(n.type===2?-s:s),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===me.ETX||n.key===me.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(NE(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var n;(n=this._charSizeService)==null||n.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(cn));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(me.ESC+"[I"):this.coreService.triggerDataEvent(me.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${me.ESC}[4;${n};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),o=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${me.ESC}[6;${o};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function NE(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var jE=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},RE=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new mi)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Vv=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 RE(t)}getNullCell(){return new mi}},PE=class extends dt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Re),this.onBufferChange=this._onBufferChange.event,this._normal=new Vv(this._core.buffers.normal,"normal"),this._alternate=new Vv(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)}},AE=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,s)=>t(n,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},LE=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}},TE=["cols","rows"],ji=0,ME=class extends dt{constructor(e){super(),this._core=this._register(new EE(e)),this._addonManager=this._register(new jE),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],n=(s,o)=>{this._checkReadonlyOptions(s),this._core.options[s]=o};for(let s in this._core.options){let o={get:t.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,o)}}_checkReadonlyOptions(e){if(TE.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 AE(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new LE(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 PE(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
66
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return ih.get()},set promptLabel(e){ih.set(e)},get tooMuchOutput(){return sh.get()},set tooMuchOutput(e){sh.set(e)}}}_verifyIntegers(...e){for(ji of e)if(ji===1/0||isNaN(ji)||ji%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ji of e)if(ji&&(ji===1/0||isNaN(ji)||ji%1!==0||ji<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 DE=2,IE=1,OE=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 w;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:((w=this._terminal.options.overviewRuler)==null?void 0:w.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.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,m=s-h,v=o-p-t;return{cols:Math.max(DE,Math.floor(v/e.css.cell.width)),rows:Math.max(IE,Math.floor(m/e.css.cell.height))}}};function BE(e,t){return e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(t||"")}`:"/ws"}function zE({session:e,node:t,token:n,cols:s,rows:o,readonly:a=!1,takeSize:u,focused:h,onData:p,onExit:m,onFiles:v,retryBaseMs:w=250}){const y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const k=`${location.protocol==="https:"?"wss":"ws"}://${location.host}${BE(t,n)}`;let E=null,b=!1,j=!1,N=null,z=0,D=h;const U=()=>{if(b||j||N)return;const K=Math.min(5e3,Math.max(0,w)*2**Math.min(z++,5));N=setTimeout(()=>{N=null,W()},K)},W=()=>{if(b||j)return;const K=new WebSocket(k);E=K,K.binaryType="arraybuffer",K.onopen=()=>{if(E!==K||b)return;z=0;const te={type:"attach",session:e,token:n,cols:s,rows:o,readonly:a};u!==void 0&&(te.takeSize=u),K.send(JSON.stringify(te)),D!==void 0&&K.send(JSON.stringify({type:"focus",on:!!D}))},K.onmessage=te=>{if(!(E!==K||b))if(typeof te.data=="string"){let G;try{G=JSON.parse(te.data)}catch{return}G.type==="exit"&&(j=!0,m&&m(G.code)),G.type==="files"&&v&&v(G)}else p&&p(new Uint8Array(te.data))},K.onerror=()=>{if(E===K)try{K.close()}catch{}},K.onclose=te=>{E!==K||b||j||[1e3,1002,4401,4404].includes(te==null?void 0:te.code)||U()}};return W(),{sendInput:K=>{if(!E||E.readyState!==1)return!1;try{return E.send(typeof K=="string"?new TextEncoder().encode(K):K),!0}catch{try{E.close()}catch{}return!1}},isReady:()=>!!E&&E.readyState===1,resize:(K,te)=>{s=K,o=te,(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"resize",cols:K,rows:te}))},action:K=>{(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"action",name:K}))},focus:K=>{D=K,(E==null?void 0:E.readyState)===1&&E.send(JSON.stringify({type:"focus",on:!!K}))},close:()=>{if(b=!0,N&&clearTimeout(N),N=null,E)try{E.close()}catch{}},get raw(){return E}}}async function $h(e){const t=String(e||"");if(!t)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.readOnly=!0,n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select();const s=document.execCommand&&document.execCommand("copy");if(n.remove(),s)return!0}catch{}return!1}const $E="\r";function FE(e){const t=String(e||"");let n=t.length;for(;n>0;){const s=t.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return t.slice(0,n)}function HE({isReady:e,paste:t,send:n}){return s=>{if(!s||!e())return!1;try{return t(s)===!1||!e()?!1:n($E)!==!1}catch{return!1}}}function UE(e){return!e||typeof e!="object"?!1:!!e.shiftKey}function WE(e){return!e||typeof e!="object"||String(e.key||"").toLowerCase()!=="c"?!1:!!(e.metaKey||e.ctrlKey&&e.shiftKey)}const KE=450,Yv=8;function qE(e,t,n,s){return Math.abs(Number(n)-Number(e))>Yv||Math.abs(Number(s)-Number(t))>Yv}const VE=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function fd(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 Gv(e){if(!e)return[];const t=Array.from(e.files||[]).filter(Boolean);return t.length?t:Array.from(e.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function YE(e,t=0,n=Date.now()){const s=String((e==null?void 0:e.name)||"").trim();if(s)return s;const o=VE.get(String((e==null?void 0:e.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${t+1}.${o}`}async function Tw({files:e,token:t,session:n,node:s="",paste:o=!0,fetchImpl:a=en,onProgress:u=()=>{},now:h=Date.now()}={}){const p=Array.from(e||[]).filter(Boolean),m=[],v=[];if(!n||!p.length)return{paths:m,errors:v};const w=Qt(s?String(s).split("/"):[]);for(let y=0;y<p.length;y+=1){const S=p[y],k=YE(S,y,h);u({index:y,total:p.length,name:k,state:"uploading"});try{const E=new FormData;E.append("session",n),E.append("paste",o?"true":"false"),E.append("file",S,k);const b=await a(`${w}/files/upload`,t,{method:"POST",body:E}),j=await b.json().catch(()=>({}));if(!b.ok||j.error)throw new Error(j.error||`HTTP ${b.status}`);m.push(j.path),u({index:y,total:p.length,name:k,state:"done",path:j.path})}catch(E){const b=String((E==null?void 0:E.message)||E);v.push({name:k,message:b}),u({index:y,total:p.length,name:k,state:"error",error:b})}}return{paths:m,errors:v}}const GE=420,XE=32;function QE(e){if(!e||typeof e!="object")return!1;const t=String(e.tagName||"").toLowerCase();return t==="textarea"||t==="input"||e.isContentEditable===!0}function Fh({documentRef:e,navigatorRef:t}={}){const n=e||(typeof document<"u"?document:null),s=t||(typeof navigator<"u"?navigator:null);let o=!1;try{s!=null&&s.virtualKeyboard&&typeof s.virtualKeyboard.hide=="function"&&(s.virtualKeyboard.hide(),o=!0)}catch{}const a=n&&n.activeElement;let u=!1;if(QE(a)&&typeof a.blur=="function")try{a.blur(),u=!0}catch{}return{blurred:u,apiRequested:o}}function Mw(e,t,n=!1){const s=e&&e.textarea;if(!s)return null;const a=t==="single-tap"||t==="double-tap"&&n?"text":"none";return s.inputMode=a,s.setAttribute("inputmode",a),a}function JE(e,t){if(!e||!e.textarea)return!1;Mw(e,"double-tap",!0);try{e.focus()}catch{return!1}const n=typeof navigator<"u"?navigator:null;try{n!=null&&n.virtualKeyboard&&typeof n.virtualKeyboard.show=="function"&&n.virtualKeyboard.show()}catch{}return!0}function ZE(e,t,n){return e==="never"?{open:!1,next:null}:e==="single-tap"?{open:!0,next:null}:!n||!Number.isFinite(n.at)||!Number.isFinite(n.x)||!Number.isFinite(n.y)?{open:!1,next:null}:t&&n.at>=t.at&&n.at-t.at<=GE&&Math.hypot(n.x-t.x,n.y-t.y)<=XE?{open:!0,next:null}:{open:!1,next:n}}const eN=24,Xv=80,Dw=8,tN="\x1B[5~",nN="\x1B[6~",iN=64,sN=65;function rN(e,t,n){const s=e==="up"?iN:sN,o=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${s};${o(t)};${o(n)}M`}function oN({alternateScreen:e=!1,readonly:t=!1,mouseTracking:n=!1}={}){return t?"scroll":n?"mouse":e?"page":"scroll"}function aN(e,t){return e==="page"?Number.isFinite(t)&&t>0?Math.max(Xv,t):Xv:Number.isFinite(t)&&t>0?t:eN}function lN({mode:e="scroll",accumulated:t=0,threshold:n=0}={}){const s=aN(e,n);if(!Number.isFinite(t))return{mode:e,up:0,down:0,remainder:0};const o=Math.abs(t);if(o<s)return{mode:e,up:0,down:0,remainder:t};const a=Math.floor(o/s),u=Math.min(a,Dw),h=(t>=0?1:-1)*(o%s);return{mode:e,up:t>0?u:0,down:t<0?u:0,remainder:h}}function cN(e,t=null){const n=[],s=t&&Number.isFinite(t.col)?t.col:1,o=t&&Number.isFinite(t.row)?t.row:1,a=h=>Math.min(Dw,Number.isFinite(h)?Math.max(0,Math.floor(h)):0),u=h=>e.mode==="mouse"?{kind:"input",seq:rN(h,s,o)}:e.mode==="page"?{kind:"input",seq:h==="up"?tN:nN}:{kind:"action",name:h==="up"?"scroll-up":"scroll-down"};for(let h=0;h<a(e.up);h+=1)n.push(u("up"));for(let h=0;h<a(e.down);h+=1)n.push(u("down"));return n}function Af({session:e,node:t,token:n,readonly:s,takeSize:o,focused:a,sendRef:u,composerRef:h,actionRef:p,ctrlRef:m,setCtrlArmed:v,onFiles:w,fontSize:y=13,selectionMode:S=!1,onSelectionModeChange:k,keyboardGesture:E="double-tap"}){const b=C.useRef(null),j=C.useRef(null),N=C.useRef(y);N.current=y;const z=C.useRef(a);z.current=a;const D=C.useRef(S);D.current=S;const U=C.useRef(E);U.current=E;const[W,K]=C.useState(""),[te,G]=C.useState(""),[Q,q]=C.useState(null),[F,R]=C.useState(null),[B,$]=C.useState(!1),L=async()=>{var T,M,O,H;const x=((M=(T=j.current)==null?void 0:T.term)==null?void 0:M.getSelection())||W;if(!x){G(f("copy-empty")),setTimeout(()=>G(""),1500);return}const I=await $h(x);G(f(I?"copied":"copy-manual")),I&&((H=(O=j.current)==null?void 0:O.term)==null||H.clearSelection(),K(""),$(!1),k==null||k(!1)),setTimeout(()=>G(""),1800)},A=C.useRef(L);return A.current=L,C.useEffect(()=>{const x=j.current;x&&x.sock&&x.sock.focus&&x.sock.focus(!!a)},[a]),C.useEffect(()=>{const x=j.current;x&&(x.term.options.fontSize=y,x.fit.fit(),x.sock.resize(x.term.cols,x.term.rows))},[y]),C.useEffect(()=>{var x,I;(I=(x=j.current)==null?void 0:x.setKeyboardGesture)==null||I.call(x,E)},[E]),C.useEffect(()=>{var Dn,In,zi,Gr,rr,ua,Ut;const x=new ME({cursorBlink:!0,fontSize:N.current,scrollback:1e3,theme:{background:"#0a0e0a"}}),I=new OE;x.loadAddon(I),x.open(b.current),I.fit();let T=!1,M=!1;const O=he=>Ke=>{for(const et of Ke){const Ze=Array.isArray(et)?et[0]:et;Ze===1006&&(T=he),Ze===1016&&(M=he)}return!1};(In=(Dn=x.parser)==null?void 0:Dn.registerCsiHandler)==null||In.call(Dn,{prefix:"?",final:"h"},O(!0)),(Gr=(zi=x.parser)==null?void 0:zi.registerCsiHandler)==null||Gr.call(zi,{prefix:"?",final:"l"},O(!1)),(ua=(rr=x.parser)==null?void 0:rr.registerEscHandler)==null||ua.call(rr,{final:"c"},()=>(T=!1,M=!1,!1));const H=()=>{const he=T&&!M&&(x.modes&&x.modes.mouseTrackingMode||"none")!=="none",Ke=b.current;return Ke&&(Ke.dataset.mouseTracking=he?"on":"off"),he},se=new TextDecoder;let ee=U.current==="single-tap",le=null;const ve=()=>{ee=U.current==="single-tap",Mw(x,U.current,ee)},de=he=>{U.current=he,le=null,ve()},fe=()=>U.current==="never"?!1:(ee=!0,JE(x));ve();const He=x.textarea,st=()=>{U.current==="double-tap"&&ve()};He==null||He.addEventListener("blur",st);let lt;try{lt=zE({session:e,node:t,token:n,readonly:s,takeSize:o,focused:z.current,onFiles:w,cols:x.cols,rows:x.rows,onData:he=>x.write(se.decode(he)),onExit:()=>x.write(`\r
|
|
78
|
+
\x1B[33m[sessione finita]\x1B[0m\r
|
|
79
|
+
`)})}catch(he){return x.write(`\r
|
|
80
|
+
\x1B[31m${he.message}\x1B[0m\r
|
|
81
|
+
`),()=>x.dispose()}j.current={term:x,fit:I,sock:lt,setKeyboardGesture:de};let Ee=null;const xt=x.onData(he=>{if(s){Ee&&(Ee.ok=!1);return}if(!Ee&&m&&m.current&&he.length===1){const et=he.charCodeAt(0);let Ze=et;et>=97&&et<=122?Ze=et-96:et>=64&&et<=95?Ze=et-64:et===32&&(Ze=0),he=String.fromCharCode(Ze),m.current=!1,v&&v(!1)}const Ke=lt.sendInput(he);Ee&&(Ee.seen=!0,Ee.ok=Ee.ok&&Ke)});u&&(u.current=he=>lt.sendInput(he)),p&&(p.current=he=>lt.action(he)),h&&(h.current=HE({isReady:()=>!s&<.isReady(),paste:he=>{const Ke={seen:!1,ok:!0};Ee=Ke;try{x.paste(he)}catch{Ke.ok=!1}finally{Ee=null}return Ke.seen&&Ke.ok},send:he=>lt.sendInput(he)}));const qt=x.onSelectionChange(()=>{const he=x.getSelection();he?(K(he),$(!1)):$(!0)});x.attachCustomKeyEventHandler(he=>(he.ctrlKey||he.metaKey)&&he.key.toLowerCase()==="c"&&x.getSelection()?(he.type==="keydown"&&$h(x.getSelection()),!1):!0);const ze=b.current;let Rt=!1;const gt=async he=>{if(!he.length||Rt)return;if(s){q({error:f("settings-readonly")});return}Rt=!0,q({current:0,total:he.length,name:""});const Ke=await Tw({files:he,token:n,session:e,node:t,paste:!0,onProgress:({index:et,total:Ze,name:Tt,state:zt,error:an})=>q({current:et+1,total:Ze,name:Tt,...zt==="error"?{error:an}:{}})});Rt=!1,Ke.errors.length?q({error:Ke.errors.map(et=>`${et.name}: ${et.message}`).join(" · ")}):(q({done:!0,total:Ke.paths.length}),setTimeout(()=>q(null),1600))},Mt=he=>{const Ke=he.clipboardData;if(!fd(Ke))return;const et=Gv(Ke);et.length&&(he.preventDefault(),he.stopPropagation(),gt(et))},ht=he=>{fd(he.dataTransfer)&&(he.preventDefault(),he.stopPropagation())},bt=he=>{fd(he.dataTransfer)&&(he.preventDefault(),he.stopPropagation(),gt(Gv(he.dataTransfer)))};ze.addEventListener("paste",Mt,!0),ze.addEventListener("dragenter",ht,!0),ze.addEventListener("dragover",ht,!0),ze.addEventListener("drop",bt,!0);const Bt=24,kt=(he,Ke)=>{const Ze=(ze.querySelector(".xterm-screen")||ze).getBoundingClientRect(),Tt=Math.floor((he-Ze.left)/Math.max(1,Ze.width)*x.cols)+1,zt=Math.floor((Ke-Ze.top)/Math.max(1,Ze.height)*x.rows)+1;return{col:Math.max(1,Math.min(x.cols,Tt)),row:Math.max(1,Math.min(x.rows,zt))}},Dt=(he,Ke={mode:null,remainder:0},et=null,Ze=null)=>{const Tt=b.current,zt=Tt?Tt.getBoundingClientRect().height:Bt,an=oN({alternateScreen:x.buffer.active.type==="alternate",readonly:s,mouseTracking:H()}),vn=an==="mouse"?"mouse":et||an,fc=Ke.mode===vn?Ke.remainder+he:he,Un=lN({mode:vn,accumulated:fc,threshold:vn==="page"?zt:Bt});for(const Xr of cN(Un,Ze))Xr.kind==="input"?lt.sendInput(Xr.seq):lt.action(Xr.name);return{mode:vn,remainder:Un.remainder}};let Lt=null,Ct=null,ye=null,ce=null,Le=!1,qe=!1,ie={mode:null,remainder:0},_e=null,Ce=null,Ue=null,Ve=!1,ft=0;const Et=()=>{Ue&&clearTimeout(Ue),Ue=null},St=(he,Ke)=>{const Ze=(ze.querySelector(".xterm-screen")||ze).getBoundingClientRect(),Tt=Math.max(0,Math.min(x.cols-1,Math.floor((he-Ze.left)/Math.max(1,Ze.width)*x.cols))),zt=Math.max(0,Math.min(x.rows-1,Math.floor((Ke-Ze.top)/Math.max(1,Ze.height)*x.rows)));return{col:Tt,row:x.buffer.active.viewportY+zt}},Nt=2,Z=he=>{const et=(ze.querySelector(".xterm-screen")||ze).getBoundingClientRect();return Math.max(0,Math.min(x.rows-1,Math.floor((he-et.top)/Math.max(1,et.height)*x.rows)))<Nt?Nt:-Nt},we=(he,Ke)=>{const Tt=(ze.querySelector(".xterm-screen")||ze).getBoundingClientRect().height/Math.max(1,x.rows);return St(he.clientX,he.clientY+Ke*Tt)},Oe=he=>{const et=(ze.querySelector(".xterm-screen")||ze).getBoundingClientRect(),Ze=ze.getBoundingClientRect(),Tt=et.width/Math.max(1,x.cols),zt=et.height/Math.max(1,x.rows),an=Number(x.buffer.active.viewportY)||0,vn=Math.max(0,Math.min(x.rows-1,he.row-an));R({left:`${et.left-Ze.left+he.col*Tt}px`,top:`${et.top-Ze.top+vn*zt}px`,width:`${Tt}px`,height:`${zt}px`})},je=he=>{if(Et(),Ve=!1,Le=!1,qe||he.touches.length!==1){qe=!0,Le=!0,le=null,R(null),ft=0,Lt=null,Ct=null,ye=null,ce=null;return}if(D.current){he.preventDefault(),he.stopPropagation(),ft=Z(he.touches[0].clientY),Ce=we(he.touches[0],ft),x.clearSelection(),Oe(Ce);return}Lt=he.touches[0].clientY,Ct=he.touches[0].clientX,ye=Ct,ce=Lt,ie={mode:null,remainder:0},_e=null;const Ke={x:Ct,y:Lt};Ue=setTimeout(()=>{var an;Ue=null,Ve=!0,Le=!0,le=null,D.current=!0,k==null||k(!0),Ce=St(Ke.x,Ke.y),ft=Z(Ke.y);const et=we({clientX:Ke.x,clientY:Ke.y},ft);x.clearSelection();const Ze=Ce.row*x.cols+Ce.col,Tt=et.row*x.cols+et.col,zt=Ze<=Tt?Ce:et;x.select(zt.col,zt.row,Math.abs(Tt-Ze)+1),Oe(et);try{(an=navigator.vibrate)==null||an.call(navigator,10)}catch{}Lt=null,Ct=null,_e=null,ie={mode:null,remainder:0}},KE)},tt=he=>{if(Ve&&Ce&&he.touches.length===1){he.preventDefault(),he.stopPropagation();const Ze=we(he.touches[0],ft),Tt=Ce.row*x.cols+Ce.col,zt=Ze.row*x.cols+Ze.col,an=Tt<=zt?Ce:Ze;x.select(an.col,an.row,Math.abs(zt-Tt)+1),Oe(Ze);return}if(D.current&&Ce&&he.touches.length===1){he.preventDefault(),he.stopPropagation();const Ze=we(he.touches[0],ft),Tt=Ce.row*x.cols+Ce.col,zt=Ze.row*x.cols+Ze.col,an=Tt<=zt?Ce:Ze;x.select(an.col,an.row,Math.abs(zt-Tt)+1),Oe(Ze);return}if(Lt===null||he.touches.length!==1)return;he.preventDefault(),he.stopPropagation();const Ke=he.touches[0];if(qE(ye,ce,Ke.clientX,Ke.clientY)&&(Le=!0,le=null,Ue&&Et()),_e===null&&(Math.abs(Ke.clientY-Lt)>8||Math.abs(Ke.clientX-Ct)>8)&&(_e=Math.abs(Ke.clientY-Lt)>Math.abs(Ke.clientX-Ct)),!_e)return;const et=Ke.clientY-Lt;Lt=Ke.clientY,ie=Dt(et,ie,"scroll",kt(Ke.clientX,Ke.clientY))},Ye=()=>{Et(),Lt=null,Ct=null,ye=null,ce=null,Ce=null,Ve=!1,Le=!1,qe=!1,ft=0,R(null),ie={mode:null,remainder:0}},pt=he=>{if(qe){le=null,Et(),(!he.touches||he.touches.length===0)&&Ye();return}const Ke=he.changedTouches&&he.changedTouches[0];if(!Le&&!Ve&&!D.current&&Ke){const et={at:Date.now(),x:Ke.clientX,y:Ke.clientY},Ze=ZE(U.current,le,et);le=Ze.next,Ze.open&&fe()}Ye()},yt=()=>{le=null,Ye()};let gn={mode:null,remainder:0};const Y=he=>{he.preventDefault(),he.stopPropagation(),gn=Dt(-he.deltaY,gn,"scroll",kt(he.clientX,he.clientY))};ze.addEventListener("touchstart",je,{passive:!1}),ze.addEventListener("touchmove",tt,{passive:!1,capture:!0}),ze.addEventListener("touchend",pt,{passive:!0}),ze.addEventListener("touchcancel",yt,{passive:!0});const re=()=>{!D.current&&U.current==="double-tap"&&fe()};ze.addEventListener("dblclick",re);const xe=he=>{(D.current||Ve)&&(he.preventDefault(),he.stopPropagation())};ze.addEventListener("contextmenu",xe,!0),ze.addEventListener("wheel",Y,{passive:!1,capture:!0});let ge=null;const Ae=he=>{UE(he)&&(he.preventDefault(),he.stopPropagation(),ge=St(he.clientX,he.clientY),x.clearSelection())},Ge=he=>{var zt;if(!ge){(zt=x.hasSelection)!=null&&zt.call(x)&&H()&&(he.preventDefault(),he.stopPropagation());return}he.preventDefault(),he.stopPropagation();const Ke=St(he.clientX,he.clientY),et=ge.row*x.cols+ge.col,Ze=Ke.row*x.cols+Ke.col,Tt=et<=Ze?ge:Ke;x.select(Tt.col,Tt.row,Math.abs(Ze-et)+1)},rt=he=>{ge&&(he.stopPropagation(),ge=null)};ze.addEventListener("mousedown",Ae,!0),ze.addEventListener("mousemove",Ge,!0),ze.addEventListener("mouseup",rt,!0);const Pe=he=>{!WE(he)||!(j.current&&j.current.term&&j.current.term.getSelection())||(he.preventDefault(),he.stopPropagation(),A.current&&A.current())};ze.addEventListener("keydown",Pe,!0);const J=()=>{I.fit(),lt.resize(x.cols,x.rows)};window.addEventListener("resize",J);const pe=window.visualViewport;let Me=pe&&Number(pe.height);const ot=()=>{const he=pe&&Number(pe.height);ee&&U.current==="double-tap"&&Number.isFinite(Me)&&Number.isFinite(he)&&he>Me+80&&ve(),Me=he,J()};pe&&(pe.addEventListener("resize",ot),pe.addEventListener("scroll",J));const Xe=typeof navigator<"u"?navigator.virtualKeyboard:null,vt=()=>{var he;ee&&U.current==="double-tap"&&Number(((he=Xe==null?void 0:Xe.boundingRect)==null?void 0:he.height)||0)===0&&ve()};(Ut=Xe==null?void 0:Xe.addEventListener)==null||Ut.call(Xe,"geometrychange",vt);let Pt=null,nn=0;return typeof ResizeObserver<"u"&&(Pt=new ResizeObserver(()=>{nn&&cancelAnimationFrame(nn),nn=requestAnimationFrame(J)}),Pt.observe(ze)),()=>{var he;j.current=null,u&&(u.current=()=>!1),h&&(h.current=()=>!1),p&&(p.current=()=>!1),xt.dispose(),qt.dispose(),ze.removeEventListener("touchstart",je),ze.removeEventListener("touchmove",tt,{capture:!0}),ze.removeEventListener("touchend",pt),ze.removeEventListener("touchcancel",yt),ze.removeEventListener("dblclick",re),ze.removeEventListener("contextmenu",xe,!0),Et(),ze.removeEventListener("wheel",Y,{capture:!0}),ze.removeEventListener("mousedown",Ae,!0),ze.removeEventListener("mousemove",Ge,!0),ze.removeEventListener("mouseup",rt,!0),ze.removeEventListener("keydown",Pe,!0),ze.removeEventListener("paste",Mt,!0),ze.removeEventListener("dragenter",ht,!0),ze.removeEventListener("dragover",ht,!0),ze.removeEventListener("drop",bt,!0),window.removeEventListener("resize",J),pe&&(pe.removeEventListener("resize",ot),pe.removeEventListener("scroll",J)),(he=Xe==null?void 0:Xe.removeEventListener)==null||he.call(Xe,"geometrychange",vt),He==null||He.removeEventListener("blur",st),Pt&&Pt.disconnect(),nn&&cancelAnimationFrame(nn),lt.close(),x.dispose()}},[e,t,n,s,o,u,h,p,m,v,w]),l.jsxs("div",{className:`nc-terminal${S?" selecting":""}`,children:[l.jsx("div",{className:"nc-terminal-host",ref:b}),F&&l.jsx("div",{className:"nc-touch-selection-caret",style:F,"aria-hidden":"true"}),Q&&l.jsx("div",{className:`nc-upload-state${Q.error?" error":""}`,role:"status",children:Q.error?Q.error:Q.done?f("attach-uploaded").replace("{n}",String(Q.total||0)):f("attach-upload-progress").replace("{n}",String(Q.current||0)).replace("{total}",String(Q.total||0))}),(W||S)&&l.jsxs("div",{className:"nc-selection-tools",children:[W?l.jsx("button",{type:"button",onClick:L,children:te||f("copy")}):l.jsx("span",{children:f("select-drag")}),W&&B&&l.jsx("span",{className:"nc-selection-held",children:f("selection-held")}),l.jsx("button",{type:"button",onClick:()=>{var x,I;(I=(x=j.current)==null?void 0:x.term)==null||I.clearSelection(),K(""),$(!1),k==null||k(!1)},children:f("cancel")}),te===f("copy-manual")&&l.jsx("textarea",{readOnly:!0,value:W,onFocus:x=>x.target.select()})]})]})}const Qv="",Ot="\x1B",uN=[{label:"↑",seq:Ot+"[A"},{label:"↓",seq:Ot+"[B"},{label:"PGUP",seq:Ot+"[5~"},{label:"PGDN",seq:Ot+"[6~"}],dN=new Set([Ot+"[A",Ot+"[B",Ot+"[C",Ot+"[D",Ot+"[5~",Ot+"[6~"]),hN=350,fN=55;function pN({send:e,action:t,ctrlArmed:n=!1,onCtrl:s,onKeyboard:o,selectionMode:a=!1,onSelectionMode:u,onCellSwitcher:h,cellSwitcherOpen:p=!1,keepKeyboardClosed:m=!0,showEnter:v=!0,keybarLayout:w="full"}){const[y,S]=C.useState(!1),[k,E]=C.useState(!1),[b,j]=C.useState(!1),[N,z]=C.useState(!1),D=w==="compact"&&!N,U=C.useRef({delay:null,interval:null}),W=C.useRef(()=>{}),K=()=>{const I=U.current;I.delay!==null&&clearTimeout(I.delay),I.interval!==null&&clearInterval(I.interval),I.delay=null,I.interval=null};W.current=K,C.useEffect(()=>{const I=()=>{document.visibilityState==="hidden"&&W.current()},T=()=>W.current();return window.addEventListener("blur",T),document.addEventListener("visibilitychange",I),()=>{window.removeEventListener("blur",T),document.removeEventListener("visibilitychange",I),W.current()}},[]),C.useEffect(()=>{w!=="compact"&&z(!1)},[w]);const te=I=>{b?(e(Ot+I),j(!1)):e(I)},G=I=>{m&&Fh(),I()},Q=I=>({onPointerDown:T=>{T.preventDefault(),G(I)},onClick:T=>{T.detail===0&&G(I)}}),q=I=>({onPointerDown:T=>{T.preventDefault(),K(),G(I),!b&&(U.current.delay=setTimeout(()=>{U.current.delay=null,I(),U.current.interval=setInterval(I,fN)},hN))},onPointerUp:K,onPointerLeave:K,onPointerCancel:K,onLostPointerCapture:K,onTouchCancel:K,onClick:T=>{T.detail===0&&G(I)}}),F=(I,T,M)=>l.jsx("button",{type:"button",...dN.has(T)&&!M?q(()=>te(T)):Q(()=>{te(T),M&&M()}),children:I},I),R=(I,T)=>l.jsx("button",{type:"button",...Q(()=>{t(T),E(!1)}),children:I},I),B=h?l.jsx("button",{type:"button","aria-label":f("fleet-cells"),title:f("fleet-cells"),"aria-expanded":p,...Q(h),children:"◫"},"cells"):l.jsx("button",{type:"button",...Q(()=>{o&&o()}),children:"⌨"},"kbd"),$=v&&l.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...Q(()=>te("\r")),children:l.jsx(at,{name:"enter",size:24})}),L=k&&l.jsxs("div",{className:"nc-keymenu",children:[R("←WIN","prev-window"),R("WIN→","next-window"),R("⬅PANE","pane-left"),R("PANE➡","pane-right"),F("SCROLL",Qv+"[",()=>{S(!0),E(!1)}),l.jsx("button",{type:"button",className:a?"armed":"",...Q(()=>{u==null||u(!a),E(!1)}),children:"SELECT"}),F("⌃C","",()=>E(!1)),F("DETACH",Qv+"d",()=>E(!1))]});if(y)return l.jsxs("div",{className:"nc-keybar copy",children:[l.jsx("span",{className:"tag",children:"copy-mode"}),uN.map(I=>F(I.label,I.seq)),F("ESCI (q)","q",()=>S(!1))]});if(D)return l.jsxs("div",{className:"nc-keybar termux",children:[L,l.jsxs("div",{className:`nc-keygrid compact${v?"":" no-enter"}`,children:[l.jsx("div",{className:"nc-keyrows",children:l.jsxs("div",{className:"row",children:[l.jsx("button",{type:"button","aria-label":f("keybar-expand"),title:f("expand"),...Q(()=>z(!0)),children:l.jsx(at,{name:"chevronUp",size:20})},"expand"),B,l.jsx("button",{type:"button",className:k?"armed":"",...Q(()=>E(I=>!I)),children:"☰"},"menu"),F("↑",Ot+"[A"),F("↓",Ot+"[B"),F("←",Ot+"[D"),F("→",Ot+"[C"),F("PGUP",Ot+"[5~"),F("PGDN",Ot+"[6~")]})}),$]})]});const A=w==="compact"&&N,x=A&&l.jsx("button",{type:"button",className:"nc-retract-key","aria-label":f("keybar-retract"),title:f("retract"),...Q(()=>z(!1)),children:l.jsx(at,{name:"chevronDown",size:20})});return l.jsxs("div",{className:`nc-keybar termux${A?" expanded":""}`,children:[L,l.jsxs("div",{className:`nc-keygrid${v?"":" no-enter"}${A?" expanded":""}`,children:[x,l.jsxs("div",{className:"nc-keyrows",children:[l.jsxs("div",{className:"row",children:[F("ESC",Ot),l.jsx("button",{type:"button",className:k?"armed":"",...Q(()=>E(I=>!I)),children:"☰"},"menu"),F("/","/"),F("—","-"),F("HOME",Ot+"[H"),F("↑",Ot+"[A"),F("END",Ot+"[F"),F("PGUP",Ot+"[5~")]}),l.jsxs("div",{className:"row",children:[F("⇥"," "),B,l.jsx("button",{type:"button",className:n?"armed":"",...Q(()=>{s&&s()}),children:"CTRL"},"ctrl"),l.jsx("button",{type:"button",className:b?"armed":"",...Q(()=>j(I=>!I)),children:"ALT"},"alt"),F("←",Ot+"[D"),F("↓",Ot+"[B"),F("→",Ot+"[C"),F("PGDN",Ot+"[6~")]})]}),$]})]})}const mN=e=>e>1048576?`${(e/1048576).toFixed(1)}M`:e>1024?`${(e/1024).toFixed(0)}K`:`${e}B`;function Iw({session:e,node:t,token:n,filesEvent:s,onClose:o}){$n();const a=t?`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_`:"/api",u=t?`${t}:${e}`:e,[h,p]=C.useState("outbox"),[m,v]=C.useState({inbox:[],outbox:[]}),[w,y]=C.useState(""),S=C.useRef(null);async function k(){try{const z=await(await en(`${a}/files?session=${encodeURIComponent(e)}`,n)).json();if(z.error){y(z.error);return}v(z);const D=z.outbox[0]?z.outbox[0].mtime:0;localStorage.setItem(hy(u),String(D))}catch(N){y(String(N))}}C.useEffect(()=>{k()},[e,t]),C.useEffect(()=>{s&&s.session===e&&k()},[s]);async function E(N){for(const z of N){y(`carico ${z.name}…`);const D=new FormData;D.append("session",e),D.append("file",z);try{const W=await(await en(`${a}/files/upload`,n,{method:"POST",body:D})).json();y(W.error?`errore: ${W.error}`:"")}catch(U){y(String(U))}}k()}async function b(N){const z=await en(`${a}/files/download?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(N)}`,n);if(!z.ok){y("errore download");return}const D=await z.blob(),U=URL.createObjectURL(D),W=document.createElement("a");W.href=U,W.download=N,W.click(),URL.revokeObjectURL(U)}async function j(N){await en(`${a}/files?session=${encodeURIComponent(e)}&box=${h}&name=${encodeURIComponent(N)}`,n,{method:"DELETE"}),k()}return l.jsxs("div",{className:"nc-files",children:[l.jsxs("header",{children:[l.jsx("b",{children:t?`${t}:${e}`:e}),l.jsx("button",{onClick:o,title:f("close"),children:l.jsx(at,{name:"x",size:20})})]}),l.jsxs("nav",{children:[l.jsx("button",{className:h==="outbox"?"on":"",onClick:()=>p("outbox"),children:"outbox"}),l.jsx("button",{className:h==="inbox"?"on":"",onClick:()=>p("inbox"),children:"inbox"}),l.jsxs("button",{className:"up",onClick:()=>S.current&&S.current.click(),children:[l.jsx(at,{name:"upload",size:18})," ",f("upload")]}),l.jsx("input",{type:"file",multiple:!0,ref:S,style:{display:"none"},onChange:N=>{E(Array.from(N.target.files||[])),N.target.value=""}})]}),w&&l.jsx("div",{className:"nc-busy",children:w}),l.jsxs("ul",{children:[m[h].map(N=>l.jsxs("li",{children:[l.jsx("span",{className:"name",onClick:()=>b(N.name),children:N.name}),l.jsx("small",{children:mN(N.size)}),l.jsx("button",{onClick:()=>j(N.name),title:f("delete"),children:l.jsx(at,{name:"trash",size:18})})]},N.name)),m[h].length===0&&l.jsx("li",{className:"empty",children:f("empty-files")})]})]})}const oc="nc_composer_v1",Hh="nc-composer-reset",gN=50,Ow=256*1024,Bw=512*1024,vN=768*1024,Jv=2*1024*1024,zw=720*60*60*1e3,Uh=1;function $w(e){const t=Number(e);return Number.isFinite(t)&&t>0?t:0}function Lf(e){if(e!==void 0)return e;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Xl(){return{version:Uh,cells:{}}}function Fw(e){const t=[];for(const s of Array.isArray(e)?e:[]){const o=typeof s=="string"?s:s&&s.text,a=$w(typeof s=="string"?0:s&&s.at);if(!(typeof o!="string"||!o||o.length>Ow)&&!(t.length&&t[t.length-1].text===o)&&(t.push({text:o,at:a}),t.length>=gN))break}let n=0;return t.filter(s=>n+s.text.length>vN?!1:(n+=s.text.length,!0))}function Ql(e){if(!e||typeof e!="object")return null;const t=typeof e.draft=="string"&&e.draft.length<=Bw?e.draft:"",n=Fw(e.history),s=$w(e.updatedAt),o=e.expanded===!0;return!t&&!n.length&&!o?null:{draft:t,history:n,expanded:o,updatedAt:s}}function _N(e){let t;try{t=typeof e=="string"?JSON.parse(e):e}catch{return Xl()}if(!t||typeof t!="object"||t.version!==Uh||!t.cells||typeof t.cells!="object")return Xl();const n=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=Ql(o);a&&(n[s]=a)}return{version:Uh,cells:n}}function Hw(e){const t=Lf(e);if(!t)return Xl();try{return _N(t.getItem(oc))}catch{return Xl()}}function Zv(e){try{return JSON.stringify(e).length}catch{return 1/0}}function yN(e,t,n){for(const[s,o]of Object.entries(e.cells))s!==n&&o.updatedAt>0&&t-o.updatedAt>zw&&delete e.cells[s]}function Uw(e,t){return Object.entries(e.cells).filter(([n])=>n!==t).sort((n,s)=>n[1].updatedAt-s[1].updatedAt).map(([n])=>n)}function wN(e,t){for(;Zv(e)>Jv;){const n=Object.entries(e.cells).filter(([,s])=>s.history.length).sort((s,o)=>s[1].updatedAt-o[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of Uw(e,t)){if(Zv(e)<=Jv)break;delete e.cells[n]}}function Ww(e,t,n){const s=Lf(e);if(!s)return!1;wN(t,n);const o=()=>(s.setItem(oc,JSON.stringify(t)),!0);try{return o()}catch{for(const u of Uw(t,n)){delete t.cells[u];try{return o()}catch{}}return!1}}function la(e,t,n,s){const o=Hw(t);yN(o,n,e);const a=Ql(o.cells[e])||{draft:"",history:[],expanded:!1,updatedAt:0},u=s({...a,history:[...a.history]}),h=Ql(u);return h?o.cells[e]={...h,updatedAt:n}:delete o.cells[e],{ok:Ww(t,o,e),cell:o.cells[e]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function bN({ownerId:e,node:t,session:n}){const s=String(n||"");if(!s)return"";const o=zr.test(String(e||""))?String(e):t?`route:${String(t)}`:"local";return`${encodeURIComponent(o)}:${encodeURIComponent(s)}`}function Bo(e,t,n=Date.now()){if(!e)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=Hw(t),o=Ql(s.cells[e]);return!o||o.updatedAt>0&&n-o.updatedAt>zw?(s.cells[e]&&(delete s.cells[e],Ww(t,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...o,history:[...o.history]}}function e_(e,t,n,s=Date.now()){const o=String(t||"");return!e||o.length>Bw?!1:la(e,n,s,a=>({...a,draft:o})).ok}function t_(e,t,n=Date.now()){return e?la(e,t,n,s=>({...s,draft:""})).ok:!1}function SN(e,t,n,s=Date.now()){return e?la(e,n,s,o=>({...o,expanded:!!t})).ok:!1}function xN(e,t,n,s=Date.now()){const o=String(t||"");return!e||!o||o.length>Ow?!1:la(e,n,s,a=>{const u=a.history.filter(h=>h.text!==o);return u.unshift({text:o,at:s}),{...a,history:Fw(u)}}).ok}function kN(e,t,n=Date.now()){return e?la(e,t,n,s=>({...s,history:[]})).ok:!1}function CN(e){const t=Lf(e);if(!t)return!1;try{return t.removeItem(oc),!0}catch{return!1}}const EN=300;function NN(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function jN({ownerId:e,node:t,session:n,storage:s=NN()}){const o=C.useMemo(()=>bN({ownerId:e,node:t,session:n}),[e,t,n]),a=C.useMemo(()=>Bo(o,s),[]),[u,h]=C.useState(a.draft),[p,m]=C.useState(a.expanded),[v,w]=C.useState(a.history),[y,S]=C.useState(-1),k=C.useRef(o),E=C.useRef(a.draft),b=C.useRef(null),j=C.useRef(a.updatedAt||0),N=C.useRef(a.draft),z=C.useCallback(()=>{b.current&&clearTimeout(b.current),b.current=null},[]),D=C.useCallback(()=>{z(),e_(k.current,E.current,s)},[z,s]),U=C.useCallback(()=>{z(),b.current=setTimeout(()=>{b.current=null,e_(k.current,E.current,s)},EN)},[z,s]),W=C.useCallback(B=>{const $=String(typeof B=="function"?B(E.current):B||"");E.current=$,j.current=Date.now(),N.current=$,S(-1),h($),U()},[U]),K=C.useCallback((B,$)=>{z(),E.current=B,j.current=Date.now(),h(B),S($),U()},[z,U]),te=C.useCallback(()=>{if(!v.length)return!1;const B=Math.min(y+1,v.length-1);return y<0&&(N.current=E.current),K(v[B].text,B),!0},[K,v,y]),G=C.useCallback(()=>{if(y<0)return!1;const B=y-1;return K(B<0?N.current:v[B].text,B),!0},[K,v,y]),Q=C.useCallback(B=>{N.current=E.current;const $=v.findIndex(L=>L.text===B);K(String(B||""),$)},[K,v]),q=C.useCallback(()=>{m(B=>{const $=!B;return SN(k.current,$,s),$})},[s]),F=C.useCallback((B,$,L)=>{if(!B)return;if(xN(B,L,s),!(k.current===B)){Bo(B,s).draft===$&&t_(B,s);return}w(Bo(B,s).history),N.current="",S(-1),E.current===$?(z(),E.current="",j.current=Date.now(),h(""),t_(B,s)):U()},[z,U,s]),R=C.useCallback(()=>{kN(k.current,s),w([]),S(-1),N.current=E.current},[s]);return C.useEffect(()=>{if(k.current===o)return;D(),k.current=o;const B=Bo(o,s);E.current=B.draft,j.current=B.updatedAt||0,N.current=B.draft,h(B.draft),m(B.expanded),w(B.history),S(-1)},[o,D,s]),C.useEffect(()=>{const B=()=>D(),$=()=>{document.visibilityState==="hidden"&&D()};return window.addEventListener("pagehide",B),document.addEventListener("visibilitychange",$),()=>{window.removeEventListener("pagehide",B),document.removeEventListener("visibilitychange",$),D()}},[D]),C.useEffect(()=>{const B=()=>{z(),E.current="",j.current=0,N.current="",h(""),m(!1),w([]),S(-1)},$=A=>{if(A.key!==oc)return;if(A.newValue==null){B();return}const x=Bo(k.current,s);x.updatedAt<j.current||(z(),E.current=x.draft,j.current=x.updatedAt,N.current=x.draft,h(x.draft),m(x.expanded),w(x.history),S(-1))},L=()=>B();return window.addEventListener("storage",$),window.addEventListener(Hh,L),()=>{window.removeEventListener("storage",$),window.removeEventListener(Hh,L)}},[z,s]),{cellKey:o,text:u,setText:W,expanded:p,toggleExpanded:q,history:v,historyCursor:y,recallPrevious:te,recallNext:G,selectHistory:Q,confirmSubmitted:F,clearHistory:R,flush:D}}function Kw({submitText:e,token:t,session:n,node:s,ownerId:o,keepKeyboardClosedOnVoice:a=!0}){$n();const u=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:p,setText:m,expanded:v,toggleExpanded:w,history:y,historyCursor:S,recallPrevious:k,recallNext:E,selectHistory:b,confirmSubmitted:j,clearHistory:N,flush:z}=jN({ownerId:o,node:s,session:n}),[D,U]=C.useState(!1),[W,K]=C.useState(""),[te,G]=C.useState(!1),Q=C.useRef(null),q=C.useRef(null),F=C.useRef(null),[R,B]=C.useState(!1),[$,L]=C.useState({left:0,bottom:0}),[A,x]=C.useState(!1),[I,T]=C.useState(!1),M=C.useRef(null),O=C.useRef(null),H=C.useRef(null),se=C.useRef(null),ee=C.useRef(null),le=C.useRef(null),ve=C.useRef(null),de=C.useRef(!1),[fe,He]=C.useState(!1),[st,lt]=C.useState({left:0,bottom:0,width:320}),Ee=C.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);C.useEffect(()=>{let ye=!1;if(s){G(!1);return}return en(`${u}/voice/status`,t).then(ce=>ce.json()).then(ce=>{ye||G(!!ce.serverSttConfigured)}).catch(()=>{ye||G(!1)}),()=>{ye=!0}},[t,u]);const qt=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||te);async function ze(){const ye=F.current&&typeof F.current.value=="string"?F.current.value:p;Fh(),ye!==p&&m(ye);const ce=ye,Le=FE(ce);if(!Le||I)return;T(!0),K("");let qe=!1;try{qe=!!await e(Le)}catch{qe=!1}qe?j(h,ce,Le):K(f("composer-send-failed")),T(!1)}function Rt(){const ye=M.current&&M.current.getBoundingClientRect();ye&&L({left:Math.max(6,Math.min(ye.left,window.innerWidth-186)),bottom:window.innerHeight-ye.top+6}),B(!0)}function gt(ye){B(!1),ye&&M.current&&M.current.focus()}function Mt(){const ye=H.current&&H.current.getBoundingClientRect();if(ye){const ce=Math.max(220,Math.min(360,window.innerWidth-12));lt({left:Math.max(6,Math.min(ye.right-ce,window.innerWidth-ce-6)),bottom:window.innerHeight-ye.top+6,width:ce})}He(!0)}function ht(ye){He(!1),ye&&H.current&&H.current.focus()}C.useEffect(()=>{if(!R)return;const ye=Le=>{Le.key==="Escape"&>(!0)},ce=Le=>{const qe=O.current&&O.current.contains(Le.target),ie=M.current&&M.current.contains(Le.target);!qe&&!ie&>(!1)};return document.addEventListener("keydown",ye),document.addEventListener("pointerdown",ce),()=>{document.removeEventListener("keydown",ye),document.removeEventListener("pointerdown",ce)}},[R]),C.useEffect(()=>{if(!fe)return;const ye=Le=>{Le.key==="Escape"&&ht(!0)},ce=Le=>{const qe=se.current&&se.current.contains(Le.target),ie=H.current&&H.current.contains(Le.target);!qe&&!ie&&ht(!1)};return document.addEventListener("keydown",ye),document.addEventListener("pointerdown",ce),()=>{document.removeEventListener("keydown",ye),document.removeEventListener("pointerdown",ce)}},[fe]);function bt(ye){if(!(ye.isComposing||de.current||ye.altKey||ye.ctrlKey||ye.metaKey)){if(ye.key==="ArrowUp"&&ye.currentTarget.selectionStart===0&&ye.currentTarget.selectionEnd===0){k()&&ye.preventDefault();return}ye.key==="ArrowDown"&&S>=0&&ye.currentTarget.selectionStart===p.length&&ye.currentTarget.selectionEnd===p.length&&E()&&ye.preventDefault()}}function Bt(ye){gt(!1),ye.current&&ye.current.click()}async function kt(ye){if(!ye.length||!n)return;x(!0),K("");const{paths:ce,errors:Le}=await Tw({files:ye,token:t,session:n,node:s,paste:!1});Le.length&&K(Le.map(qe=>`${qe.name}: ${qe.message}`).join(" · ")),ce.length&&m(qe=>qe+(qe&&!qe.endsWith(" ")?" ":"")+ce.join(" ")),x(!1)}function Dt(){Q.current&&Q.current.stop(),q.current&&q.current.stop(),U(!1)}async function Lt(){K("");const ye=window.SpeechRecognition||window.webkitSpeechRecognition;if(ye){const ce=new ye;ce.lang="it-IT",ce.continuous=!1,ce.interimResults=!0;const Le=p?`${p} `:"";ce.onresult=qe=>{const ie=Array.from(qe.results).map(_e=>_e[0].transcript).join("");m(Le+ie)},ce.onend=()=>U(!1),ce.onerror=qe=>{K(`voice: ${qe.error||"errore"}`),U(!1)},Q.current=ce,ce.start(),U(!0);return}try{const ce=await navigator.mediaDevices.getUserMedia({audio:!0}),Le=new MediaRecorder(ce),qe=[];Le.ondataavailable=ie=>qe.push(ie.data),Le.onstop=async()=>{ce.getTracks().forEach(ie=>ie.stop()),U(!1),K("trascrivo…");try{const ie=new Blob(qe,{type:Le.mimeType||"audio/webm"}),Ce=await(await en(`${u}/voice/transcribe`,t,{method:"POST",headers:{"content-type":"application/octet-stream"},body:ie})).json();Ce.error?K(Ce.error):(K(""),m(Ue=>Ue+(Ue?" ":"")+(Ce.text||"")))}catch(ie){K(String(ie))}},q.current={stop:()=>Le.state!=="inactive"&&Le.stop()},Le.start(),U(!0)}catch{K("microfono non disponibile"),U(!1)}}function Ct(){a&&Fh(),D?Dt():Lt()}return l.jsxs("div",{className:"nc-composer",children:[W&&l.jsx("div",{className:"nc-composer-err",children:W}),l.jsxs("div",{className:"nc-composer-row",children:[n&&l.jsx("button",{ref:M,className:A?"attach busy":"attach",disabled:A,onClick:()=>R?gt(!1):Rt(),title:f(A?"attach-uploading":"attach"),"aria-label":f("attach"),"aria-haspopup":"menu","aria-expanded":R,"aria-controls":Ee.current,children:l.jsx(at,{name:"attach",size:22})}),R&&l.jsxs("div",{ref:O,id:Ee.current,role:"menu",className:"nc-attach-menu",style:{left:$.left,bottom:$.bottom},children:[l.jsxs("button",{role:"menuitem",onClick:()=>Bt(ee),children:[l.jsx(at,{name:"file",size:18})," ",f("attach-file")]}),l.jsxs("button",{role:"menuitem",onClick:()=>Bt(le),children:[l.jsx(at,{name:"camera",size:18})," ",f("attach-camera")]}),l.jsxs("button",{role:"menuitem",onClick:()=>Bt(ve),children:[l.jsx(at,{name:"image",size:18})," ",f("attach-gallery")]})]}),l.jsx("button",{ref:H,type:"button",className:"history",onPointerDown:ye=>ye.preventDefault(),onClick:()=>fe?ht(!1):Mt(),title:f("composer-history-tools"),"aria-label":f("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":fe,children:l.jsx(at,{name:"history",size:21})}),fe&&l.jsxs("div",{ref:se,role:"menu",className:"nc-composer-history-menu",style:{left:st.left,bottom:st.bottom,width:st.width},children:[l.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ye=>ye.preventDefault(),onClick:()=>{w(),ht(!1)},children:[l.jsx(at,{name:v?"chevronDown":"chevronUp",size:18}),f(v?"composer-collapse":"composer-expand")]}),l.jsx("div",{className:"nc-composer-history-title",children:f("composer-history")}),y.length===0&&l.jsx("div",{className:"nc-composer-history-empty",children:f("composer-history-empty")}),y.map((ye,ce)=>l.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:Le=>Le.preventDefault(),onClick:()=>{b(ye.text),ht(!1)},children:[l.jsx("span",{children:ye.text.replace(/\s+/g," ").slice(0,180)}),ye.at>0&&l.jsx("small",{children:new Date(ye.at).toLocaleString()})]},`${ye.at}:${ce}`)),y.length>0&&l.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ye=>ye.preventDefault(),onClick:()=>{N(),ht(!1)},children:f("composer-history-clear")})]}),l.jsx("input",{ref:ee,type:"file",multiple:!0,hidden:!0,onChange:ye=>{kt(Array.from(ye.target.files||[])),ye.target.value=""}}),l.jsx("input",{ref:le,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ye=>{kt(Array.from(ye.target.files||[])),ye.target.value=""}}),l.jsx("input",{ref:ve,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ye=>{kt(Array.from(ye.target.files||[])),ye.target.value=""}}),l.jsx("textarea",{ref:F,className:v?"expanded":"",rows:v?8:2,value:p,placeholder:f("composer-placeholder"),onChange:ye=>m(ye.target.value),onKeyDown:bt,onCompositionStart:()=>{de.current=!0},onCompositionEnd:()=>{de.current=!1},onBlur:z}),qt&&l.jsx("button",{type:"button",className:D?"mic on":"mic",title:f("voice"),"aria-label":f("voice"),onPointerDown:ye=>{ye.preventDefault(),Ct()},onClick:ye=>{ye.detail===0&&Ct()},children:l.jsx(at,{name:"mic",size:22})}),l.jsx("button",{type:"button",className:"go",disabled:I,onPointerDown:ye=>ye.preventDefault(),onClick:ze,title:f("send"),children:l.jsx(at,{name:"enter",size:22})})]})]})}function qw({title:e,subtitle:t,onClose:n,children:s}){const o=C.useRef(null),a=C.useRef(null),u=C.useCallback(()=>{n&&n()},[n]);return C.useEffect(()=>{const h=p=>{p.key==="Escape"&&(p.stopPropagation(),u())};return document.addEventListener("keydown",h,!0),()=>document.removeEventListener("keydown",h,!0)},[u]),C.useEffect(()=>{const h=a.current;h&&typeof h.focus=="function"&&h.focus()},[]),l.jsx("div",{className:"nc-popup-velo",onMouseDown:h=>{h.target===h.currentTarget&&u()},role:"presentation",children:l.jsxs("div",{className:"nc-popup",ref:o,role:"dialog","aria-modal":"true","aria-label":e||f("panel"),children:[l.jsxs("header",{className:"nc-popup-testa",children:[l.jsxs("span",{className:"nc-popup-titolo",children:[e,t?l.jsx("small",{className:"nc-popup-sub",children:t}):null]}),l.jsx("button",{type:"button",ref:a,className:"nc-popup-chiudi",onClick:u,title:f("close"),"aria-label":f("close"),children:"✕"})]}),l.jsx("div",{className:"nc-popup-corpo",children:s})]})})}function Tf({cellId:e,panelUrl:t,route:n=[],panelPort:s=0,token:o,title:a,requestTimeoutMs:u=4e3}){const[h,p]=C.useState(e&&o?"requesting":"none"),[m,v]=C.useState(""),w=Array.isArray(n)?n.join("\0"):"",y=C.useMemo(()=>Array.isArray(n)?n:[],[w]),S=C.useRef(0),k=C.useCallback(async()=>{if(!e||!o||!t){p("none");return}const b=S.current+=1;p("requesting");const j=new AbortController,N=setTimeout(()=>j.abort(),u);try{const z=await B0(o,y,e,{signal:j.signal});if(clearTimeout(N),b!==S.current)return;if(z.ok){let D="/";try{D=new URL(t).pathname||"/"}catch{}const U=s?`http://127.0.0.1:${s}`:Qt(y);v(`${U}/panel/${encodeURIComponent(e)}${D}?ticket=${encodeURIComponent(z.ticket)}`),p("ready")}else p(z.cause)}catch(z){if(clearTimeout(N),b!==S.current)return;p(z&&z.name==="AbortError"?"timeout":"unreachable")}},[e,t,y,s,o,u]);C.useEffect(()=>{k()},[k]);const E=(b,j=!0)=>l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsx("span",{children:f(b)}),j&&l.jsx("span",{className:"nc-cellpanel-actions",children:l.jsx("button",{type:"button",title:f("panel-retry"),onClick:()=>k(),children:f("panel-retry")})})]});return h==="none"||h==="no-panel"?E("panel-none",!1):h==="requesting"?l.jsx("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:l.jsx("span",{children:f("panel-checking")})}):h==="not-granted"?E("panel-not-granted",!1):h==="node-refused"?E("panel-node-refused",!1):h==="unauthorized"?E("panel-unauthorized",!1):h==="denied"?E("panel-denied"):h==="timeout"?E("panel-timeout"):h==="unreachable"?E("panel-unreachable"):l.jsx("iframe",{className:"nc-cellpanel nc-cellpanel-frame",src:m,title:a||f("panel"),allowFullScreen:!0})}const RN=1800*1e3;function Wh(e,t,n=Date.now()){const s=Number(t);if(!Number.isFinite(s)||s<=0)return"";const o=n-s;if(o<0||o>RN)return"";if(o<60*1e3)return`${e("cell-activity")} ${e("cell-activity-now")}`;const a=Math.floor(o/6e4);return a<60?`${e("cell-activity")} ${a}m`:`${e("cell-activity")} ${Math.floor(a/60)}h`}function Kh(e,t){if(!t||typeof t!="object")return"";const n=[];return Number.isInteger(t.contextFreePct)&&n.push(`${e("cell-tele-ctx")} ${t.contextFreePct}% ${e("cell-tele-free")}`),Number.isInteger(t.tier5hUsedPct)&&n.push(`${e("cell-tele-5h")} ${t.tier5hUsedPct}%`),Number.isInteger(t.tier7dUsedPct)&&n.push(`${e("cell-tele-7d")} ${t.tier7dUsedPct}%`),n.join(" · ")}function Vw({row:e,token:t,initialSource:n="preview",panelPort:s=0,onClose:o}){const[a,u]=C.useState(n==="panel"&&!e.panelUrl?"preview":n),h=C.useRef(()=>{}),p=C.useRef(()=>!1),m=C.useRef(()=>{}),v=C.useRef(!1),[w,y]=C.useState(!1),S=[["preview",f("cell-peek-preview")],["stream",f("cell-peek-stream")],...e.panelUrl?[["panel",f("cell-peek-panel")]]:[]];return l.jsxs(qw,{title:e.cellName,subtitle:[e.nodeLabel,e.subtitle].filter(Boolean).join(" · "),onClose:o,children:[l.jsx("div",{className:"nc-peek-sorgenti",role:"tablist",children:S.map(([k,E])=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===k,className:`nc-peek-sorgente${a===k?" attiva":""}`,onClick:()=>u(k),children:E},k))}),a==="stream"?l.jsx("div",{className:"nc-peek-stream",children:l.jsx(Af,{session:e.session,node:e.node||void 0,token:t,readonly:!1,takeSize:!1,focused:!0,sendRef:h,composerRef:p,actionRef:m,ctrlRef:v,setCtrlArmed:y},`peek:${e.key}`)}):a==="panel"?l.jsx(Tf,{cellId:e.cellName,panelUrl:e.panelUrl,route:e.route||[],panelPort:s,token:t,title:e.cellName}):l.jsxs(l.Fragment,{children:[l.jsx("pre",{className:"nc-peek-testo",children:e.preview||f("cell-peek-vuoto")}),[Wh(f,e.activity),Kh(f,e.telemetry)].filter(Boolean).join(" · ")&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:[Wh(f,e.activity),Kh(f,e.telemetry)].filter(Boolean).join(" · ")})]})]})}function pd(e){return String(e||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const PN=180,AN=480,Ar=(e,t=[])=>`${t.length?t.join("/"):"local"}:${e}`;function LN({sessions:e=[],cells:t=[],activeSessions:n=[],nodeGroups:s=[],onPick:o,onAddTile:a,onPower:u,onBoot:h,onNodePower:p,onKill:m,onVisibility:v,onNew:w,onNodeRename:y,onSettings:S,onBootError:k,localNodeId:E,fleetCapabilities:b=[],bootSettlement:j=null,hostByRoute:N={},onDesignateCell:z,onClearHostCell:D,onBootSettlementApplied:U,onOpenVlSession:W,token:K="",onPeekOpen:te,overlayOpen:G=!1,width:Q=240,collapsed:q=!1,onResize:F,onToggleCollapse:R}){const[B,$]=$n(),{pins:L,orders:A,togglePin:x,removePin:I,pinError:T,retryPinPersist:M,clearPinError:O,viewFor:H,updateView:se,canMoveRoster:ee,moveRoster:le,stepRoster:ve}=pf(),{groupsFor:de,moveNode:fe,stepNode:He,nodeKey:st}=Ay(),lt=Y=>N[Vo(Y)]||{};function Ee(Y,re,xe,ge){const Ae=Ty(xe);if(Ae==="addPin"){x(Y.key);return}if(Ae==="designate"){z&&z(re.cell,ge);return}if(Ae==="clearAndUnpin"){if(!D)return;Promise.resolve(D(ge)).then(Ge=>{Ge&&I(Y.key)})}}const xt=new Set((t||[]).map(Y=>Y.tmuxSession)),qt=new Map((e||[]).map(Y=>[Y.name,Y])),ze=(Y,re)=>qx(L,Y,re),Rt=Vx,gt=[...t||[]].sort((Y,re)=>Rt(ze(Y.tmuxSession,(qt.get(Y.tmuxSession)||{}).activity),ze(re.tmuxSession,(qt.get(re.tmuxSession)||{}).activity))),Mt=(e||[]).filter(Y=>!xt.has(Y.name)).sort((Y,re)=>Rt(ze(Y.name,Y.activity),ze(re.name,re.activity))||Y.name.localeCompare(re.name)),ht=new Set(n||[]),[bt,Bt]=C.useState(null),[kt,Dt]=C.useState("preview"),Lt=(Y,re,xe=[],ge="",Ae=null)=>{const rt=(xe.length===0?qt.get(re.tmuxSession):(Ae||[]).find(Pe=>Pe&&Pe.name===re.tmuxSession))||{};return{key:Y.key,cellName:re.cell,subtitle:Y.subtitle||"",nodeLabel:ge,node:xe.length?xe.join("/"):"",session:re.tmuxSession,route:xe,panelUrl:re.panelUrl||"",telemetry:rt.telemetry||null,preview:rt.preview||re.preview||"",activity:rt.activity||re.activity||0}},Ct=(Y,re,xe=[],ge="",Ae="preview")=>Ge=>{Ge&&Ge.stopPropagation(),Dt(Ae),Bt(Y.key),typeof te=="function"&&te()};C.useEffect(()=>{G&&(Bt(null),Dt("preview"))},[G]);const ye=vf(gt,Mt,qt),ce=js(ye,L,H("local").filter,Ji(A,"local")),qe=de(s||[]).map(Y=>{const re=(Y.route&&Y.route.length?Y.route:[Y.name]).join("/"),xe=H(re);if(Y.kind==="vl")return{g:Y,nodeRoute:re,groupView:xe,rawItems:[],items:[]};const{rawItems:ge}=Fl(Y),Ae=js(ge,L,xe.filter,Ji(A,re));return{g:Y,nodeRoute:re,groupView:xe,rawItems:ge,items:Ae}}),ie=[...ce,...qe.flatMap(({items:Y,nodeRoute:re,g:xe})=>(Y||[]).map(ge=>({...ge,nodeRoute:re,nodeLabel:xe.label||xe.name})))].filter(Y=>Y.type==="cell"),_e=bt?ie.find(Y=>Y.key===bt):null,Ce=(Y,re,xe)=>o&&o({session:Y,...re?{node:re}:{},...zr.test(String(xe||""))?{ownerId:xe}:{}}),Ue=async Y=>{if(!(Y!=null&&Y.direct)||!y)return;const re=window.prompt(f("rename-node-prompt"),Y.label||Y.name);if(re!==null)try{await y(Y,re)||window.alert(f("rename-node-invalid"))}catch(xe){window.alert(String((xe==null?void 0:xe.message)||xe))}},[Ve,ft]=C.useState({}),[Et,St]=C.useState(new Set);C.useEffect(()=>{const Y=new Map;for(const re of t||[])Y.set(Ar(re.cell),!!re.boot);for(const re of s||[]){const xe=re.route||[re.name];for(const ge of re.cells||[])Y.set(Ar(ge.cell,xe),!!ge.boot)}ft(re=>{let xe=!1;const ge={...re};for(const[Ae,Ge]of Object.entries(re))Y.has(Ae)&&Y.get(Ae)===Ge&&(delete ge[Ae],xe=!0);return xe?ge:re})},[t,s]),C.useEffect(()=>{if(!(j!=null&&j.cell))return;const Y=Array.isArray(j.route)?j.route:[],re=Ar(j.cell,Y);ft(xe=>({...xe,[re]:!!j.enabled})),U&&U(j.id)},[j,U]);const Nt=(Y,re=[])=>{const xe=Ar(Y.cell,re);return Object.prototype.hasOwnProperty.call(Ve,xe)?Ve[xe]:!!Y.boot},Z=async(Y,re,xe=[])=>{if(Y.stopPropagation(),!h)return;const ge=Ar(re.cell,xe),Ae=!Nt(re,xe);ft(Ge=>({...Ge,[ge]:Ae})),St(Ge=>new Set(Ge).add(ge));try{await h(re.cell,Ae,xe)}catch(Ge){ft(rt=>{const Pe={...rt};return delete Pe[ge],Pe}),k&&k(Ge)}finally{St(Ge=>{const rt=new Set(Ge);return rt.delete(ge),rt})}},we=(Y,re=[])=>{const xe=Ar(Y.cell,re),ge=Nt(Y,re),Ae=`${f(ge?"boot-disable":"boot-enable")} ${Y.cell}`;return l.jsx("button",{className:`nc-boot${ge?" on":""}`,disabled:Et.has(xe),onClick:Ge=>Z(Ge,Y,re),title:Ae,"aria-label":Ae,children:l.jsx(at,{name:"boot",size:14})})},[Oe,je]=C.useState(null),tt=(Y,re)=>{const xe=Y.currentTarget.getBoundingClientRect();je({text:re,y:xe.top+xe.height/2})},Ye=()=>je(null),pt=C.useRef(null);C.useEffect(()=>()=>{pt.current&&pt.current()},[]);function yt(Y){Y.preventDefault(),Y.stopPropagation();const re=Y.clientX,xe=Q,ge=Ge=>{const rt=Math.max(PN,Math.min(AN,xe+(Ge.clientX-re)));F&&F(rt)},Ae=()=>{window.removeEventListener("pointermove",ge),window.removeEventListener("pointerup",Ae),window.removeEventListener("pointercancel",Ae),window.removeEventListener("blur",Ae),pt.current=null};window.addEventListener("pointermove",ge),window.addEventListener("pointerup",Ae),window.addEventListener("pointercancel",Ae),window.addEventListener("blur",Ae),pt.current=Ae}const gn=q?{width:48,flex:"0 0 48px"}:{width:Q,flex:`0 0 ${Q}px`};return q?l.jsxs("aside",{className:"nc-sidebar mini",style:gn,children:[l.jsx("div",{className:"nc-side-head mini",children:l.jsx("button",{className:"nc-collapse-btn",onClick:R,title:f("expand"),children:"⟩"})}),l.jsx("button",{className:"nc-side-gear mini",onClick:()=>S&&S("nodes",!1),title:f("settings"),onMouseEnter:Y=>tt(Y,f("settings")),onMouseLeave:Ye,children:l.jsx(at,{name:"gear",size:16})}),l.jsx("div",{className:"nc-side-scroll mini",children:l.jsxs("div",{className:"nc-side-group mini",children:[H("local").open&&ce.map(Y=>Y.type==="cell"?(()=>{const re=Y.value,xe=re.degraded?"warn":re.tmux?"on":"",ge=!!re.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${ht.has(re.tmuxSession)?" active":""}`,onMouseEnter:Ae=>tt(Ae,`${re.cell}: ${Y.subtitle}`),onMouseLeave:Ye,draggable:ge,onDragStart:ge?Ae=>Ae.dataTransfer.setData("text/nc-session",re.tmuxSession):void 0,onClick:ge?()=>a&&a(re.tmuxSession):()=>u&&u(re),onDoubleClick:ge?()=>Ce(re.tmuxSession,"",E):void 0,children:l.jsx("span",{className:`nc-dot ${xe}${Y.working?" working":""}`})},Y.key)})():(()=>{const re=Y.value;return l.jsx("button",{type:"button",className:`nc-mini-init${ht.has(re.name)?" active":""}`,onMouseEnter:xe=>tt(xe,re.name),onMouseLeave:Ye,draggable:!0,onDragStart:xe=>xe.dataTransfer.setData("text/nc-session",re.name),onClick:()=>a&&a(re.name),onDoubleClick:()=>Ce(re.name,"",E),children:pd(re.name)},Y.key)})()),qe.flatMap(({g:Y,nodeRoute:re,groupView:xe,items:ge})=>Y.kind==="vl"?Y.status==="up"&&Y.sessions.length?Y.sessions.map(Ae=>l.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:Ge=>tt(Ge,`${Y.label||re}: ${Ae.name}`),onMouseLeave:Ye,onClick:()=>W&&W(Y.peer),children:pd(Ae.name)},Ae.key)):[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Ae=>tt(Ae,`${Y.label||Y.name}: ${Y.status==="up"?f("no-sessions-short"):Xi(Y)}`),onMouseLeave:Ye,children:l.jsx("span",{className:`nc-dot${Y.status==="up"?" on":" warn"}`})},`nodo-vl-${re}-${Y.name}`)]:Y.status==="up"?xe.open?ge.map(Ae=>Ae.type==="cell"?(()=>{const Ge=Ae.value,rt=!!Ge.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${ht.has(Ae.key)?" active":""}`,onMouseEnter:Pe=>tt(Pe,`${Y.label||re}: ${Ge.cell} · ${Ae.subtitle}`),onMouseLeave:Ye,draggable:rt,onDragStart:rt?Pe=>Pe.dataTransfer.setData("text/nc-session",Ae.key):void 0,onClick:rt?()=>a&&a(Ae.key):()=>u&&u({...Ge,route:Y.route,availableEngines:Y.engines||[]}),onDoubleClick:rt?()=>Ce(Ge.tmuxSession,re,Y.instanceId):void 0,children:l.jsx("span",{className:`nc-dot ${Ge.degraded?"warn":rt?`on${Ae.working?" working":""}`:""}`})},Ae.key)})():(()=>{const Ge=Ae.value;return l.jsx("button",{type:"button",className:`nc-mini-init${ht.has(Ae.key)?" active":""}`,onMouseEnter:rt=>tt(rt,`${Y.label||re}: ${Ge.name}`),onMouseLeave:Ye,draggable:!0,onDragStart:rt=>rt.dataTransfer.setData("text/nc-session",Ae.key),onClick:()=>a&&a(Ae.key),onDoubleClick:()=>Ce(Ge.name,re,Y.instanceId),children:pd(Ge.name)},Ae.key)})()):[]:[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Ae=>tt(Ae,`${Y.label||(Y.route||[Y.name]).join(" › ")}: ${Xi(Y)}`),onMouseLeave:Ye,children:l.jsx("span",{className:`nc-dot${Y.status==="passive"?"":" warn"}`})},`nodo-${(Y.route||[Y.name]).join("/")}`)])]})}),Oe&&l.jsx("div",{className:"nc-mini-tip",style:{top:Oe.y},children:Oe.text})]}):l.jsxs("aside",{className:"nc-sidebar",style:gn,children:[l.jsxs("div",{className:"nc-side-head",children:[l.jsx("button",{className:"nc-collapse-btn",onClick:R,title:f("collapse"),children:"⟨"}),l.jsx("span",{className:"nc-side-title",children:f("fleet")}),l.jsxs("button",{className:"nc-new-btn",onClick:w,title:f("fleet-new-cell"),children:["+ ",f("new")]})]}),l.jsxs("button",{className:"nc-side-gear",onClick:()=>S&&S("nodes",!1),title:f("settings"),children:[l.jsx(at,{name:"gear",size:15})," ",f("settings")]}),l.jsx(My,{pinError:T,onRetry:M,onDismiss:O}),l.jsxs("div",{className:"nc-side-scroll",children:[l.jsx(TN,{label:f("position-local"),count:ce.length,state:H("local"),onToggle:()=>se("local",{open:!H("local").open}),onFilter:Y=>se("local",{filter:Y})}),H("local").open&&l.jsxs("div",{className:"nc-side-group",children:[ce.map(Y=>Y.type==="cell"?(()=>{const re=Y.value,xe=lt([]),ge=Qd({hostCell:xe.hostCell??null,pins:L,item:Y}),Ae=re.degraded?"warn":re.tmux?"on":"",Ge=Jd(ge,xe.hostLease??null),rt=re.degraded?f("cell-degraded"):Y.working?Y.subtitle:re.tmux?f("cell-idle"):f("cell-off"),Pe=Ge?`${rt} · ${f(Ge)}`:rt,J=!!re.tmux;return l.jsxs("div",{"data-roster-key":Y.key,"data-position":"local",className:`nc-cell${J?" live":""}${ht.has(re.tmuxSession)?" active":""}`,title:`${re.cell} · ${Y.subtitle}${Pe===Y.subtitle?"":` · ${Pe}`}`,"aria-label":`${re.cell}, ${Y.subtitle}${Pe===Y.subtitle?"":`, ${Pe}`}`,draggable:J,onDragStart:J?pe=>pe.dataTransfer.setData("text/nc-session",re.tmuxSession):void 0,onClick:J?()=>a&&a(re.tmuxSession):void 0,onDoubleClick:J?()=>Ce(re.tmuxSession,"",E):void 0,children:[l.jsx(Li,{position:"local",itemKey:Y.key,label:re.cell,canMove:ee,onMove:(pe,Me)=>le("local",pe,Me,ye),onStep:pe=>ve("local",Y.key,pe,ye)}),J?l.jsx("button",{type:"button",className:"nc-side-peek",title:f("cell-peek"),"aria-label":`${f("cell-peek")}: ${re.cell}`,onClick:Ct(Y,re,[],""),children:l.jsx("span",{className:`nc-dot ${Ae}${Y.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${Ae}${Y.working?" working":""}`}),l.jsxs("span",{className:"nc-cell-main",children:[l.jsx("b",{title:re.cell,children:re.cell}),l.jsx("small",{title:Y.subtitle,children:Y.subtitle})]}),l.jsx("button",{className:`nc-pin${ge==="live"?" live":ge==="favorite"?" on":""}`,title:ge==="live"?"live host":f("pin"),onClick:pe=>{pe.stopPropagation(),Ee(Y,re,ge,[])},children:ge==="none"?"☆":"★"}),h&&b.includes("boot")&&we(re),l.jsx("button",{className:`nc-power${re.tmux?" on":""}${re.degraded?" warn":""}`,onClick:pe=>{pe.stopPropagation(),u&&u({...re,boot:Nt(re)})},title:re.active?f("power-off"):f("power-on"),children:l.jsx(at,{name:"power",size:14})})]},Y.key)})():(()=>{var xe;const re=Y.value;return l.jsxs("div",{"data-roster-key":Y.key,"data-position":"local",className:`nc-side-card${ht.has(re.name)?" active":""}`,draggable:!0,onDragStart:ge=>ge.dataTransfer.setData("text/nc-session",re.name),onClick:()=>a&&a(re.name),onDoubleClick:()=>Ce(re.name,"",E),children:[l.jsx(Li,{position:"local",itemKey:Y.key,label:re.name,canMove:ee,onMove:(ge,Ae)=>le("local",ge,Ae,ye),onStep:ge=>ve("local",Y.key,ge,ye)}),l.jsx("span",{className:re.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:re.name}),l.jsxs("small",{children:[re.preview||re.cmd||f("windows").replace("{n}",String(re.windows||0)),((xe=re.outbox)==null?void 0:xe.count)>0?` · 📦${re.outbox.count}`:""]})]}),re.activity?l.jsx("span",{className:"nc-rel",children:Br(re.activity)}):null,l.jsx("button",{className:`nc-pin${L.includes(Y.key)?" on":""}`,title:f("pin"),onClick:ge=>{ge.stopPropagation(),x(Y.key)},children:L.includes(Y.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${re.technical?" on":""}`,title:re.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${re.technical?f("mark-normal"):f("mark-technical")} ${re.name}`,onClick:ge=>{ge.stopPropagation(),v&&v(re.name,!re.technical,[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),onClick:ge=>{ge.stopPropagation(),window.confirm(f("terminate-confirm").replace("{name}",re.name))&&m&&m(re.name)},children:"⋯"})]},Y.key)})()),ce.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]}),qe.map(({g:Y,nodeRoute:re,groupView:xe,rawItems:ge,items:Ae})=>{const rt=Dy(Y.health)||(Y.status==="up"?"on":Y.status==="passive"?"":"warn");return Y.kind==="vl"?l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":st(Y),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>se(re,{open:!xe.open}),onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key===" ")&&(Pe.preventDefault(),se(re,{open:!xe.open}))},children:[l.jsx(Li,{scope:"node",position:"nodes",itemKey:st(Y),label:Y.label||Y.name,onMove:(Pe,J)=>fe(Pe,J,s||[]),onStep:Pe=>He(st(Y),Pe,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:xe.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${rt}`,title:Y.health?Yo(Y.health):""}),l.jsx("b",{children:Y.label||Y.name}),l.jsxs("small",{children:[" · ",Y.status==="up"?f("node-sessions").replace("{n}",String(Y.sessions.length)):Xi(Y)]})]}),Y.status==="up"&&xe.open&&l.jsxs("div",{className:"nc-side-group",children:[Y.sessions.map(Pe=>l.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>W&&W(Y.peer),onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),W&&W(Y.peer))},children:[l.jsx("span",{className:"nc-dot on"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:Pe.name}),l.jsx("small",{children:f("vl-events-title")})]})]},Pe.key)),Y.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]})]},`nodo-vl-${re}-${Y.name}`):l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":st(Y),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:Y.direct&&y?Pe=>{Pe.preventDefault(),Ue(Y)}:void 0,onClick:()=>se(re,{open:!xe.open}),onKeyDown:Pe=>{(Pe.key==="Enter"||Pe.key===" ")&&(Pe.preventDefault(),se(re,{open:!xe.open}))},children:[l.jsx(Li,{scope:"node",position:"nodes",itemKey:st(Y),label:Y.label||Y.name,onMove:(Pe,J)=>fe(Pe,J,s||[]),onStep:Pe=>He(st(Y),Pe,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:xe.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${rt}`,title:Y.health?Yo(Y.health):""}),l.jsx("b",{children:Y.label||Y.name}),l.jsxs("small",{children:[" · ",Y.status==="up"?f("node-sessions").replace("{n}",String(Ae.length)):Y.health&&Yo(Y.health)||Xi(Y)]}),l.jsxs("select",{className:"nc-node-filter",value:xe.filter,title:f(`view-${xe.filter}`),onClick:Pe=>Pe.stopPropagation(),onChange:Pe=>se(re,{filter:Pe.target.value}),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]}),Y.direct&&y&&l.jsx("button",{type:"button",className:"nc-node-rename",title:f("rename-node"),"aria-label":`${f("rename-node")} ${Y.label||Y.name}`,onClick:Pe=>{Pe.stopPropagation(),Ue(Y)},children:"✎"}),Y.direct&&Y.health&&Y.health.managed!==!1&&l.jsx("button",{type:"button",className:`nc-power${Y.tunnelStatus==="up"?" on":""}`,title:Y.tunnelStatus==="up"?f("power-off"):f("power-on"),onClick:Pe=>{Pe.stopPropagation(),p&&p(Y)},children:l.jsx(at,{name:"power",size:14})})]}),Y.status==="up"&&xe.open&&l.jsxs("div",{className:"nc-side-group",children:[Ae.map(Pe=>Pe.type==="cell"?(()=>{const J=Pe.value,pe=Y.route||[Y.name],Me=lt(pe),ot=Qd({hostCell:Me.hostCell??null,pins:L,item:Pe}),Xe=Jd(ot,Me.hostLease??null),vt=!!J.tmux,Pt=J.degraded?"warn":J.tmux?"on":"",nn=Pe.working?Pe.subtitle:J.tmux?f("cell-idle"):f("cell-off"),Dn=Xe?`${nn} · ${f(Xe)}`:nn;return l.jsxs("div",{"data-roster-key":Pe.key,"data-position":re,className:`nc-side-card nc-cell${vt?" live":""}${ht.has(J.key)?" active":""}`,title:Dn,draggable:vt,onDragStart:vt?In=>In.dataTransfer.setData("text/nc-session",J.key):void 0,onClick:vt?()=>a&&a(J.key):void 0,onDoubleClick:vt?()=>Ce(J.tmuxSession,re,Y.instanceId):void 0,children:[l.jsx(Li,{position:re,itemKey:Pe.key,label:J.cell,canMove:ee,onMove:(In,zi)=>le(re,In,zi,ge),onStep:In=>ve(re,Pe.key,In,ge)}),vt?l.jsx("button",{type:"button",className:"nc-side-peek",title:f("cell-peek"),"aria-label":`${f("cell-peek")}: ${J.cell}`,onClick:Ct(Pe,J,Y.route||[Y.name],Y.label||Y.name),children:l.jsx("span",{className:`nc-dot ${Pt}${Pe.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${Pt}${Pe.working?" working":""}`}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:J.cell}),l.jsx("small",{title:Pe.subtitle,children:Pe.subtitle})]}),l.jsx("button",{className:`nc-pin${ot==="live"?" live":ot==="favorite"?" on":""}`,title:ot==="live"?"live host":f("pin"),onClick:In=>{In.stopPropagation(),Ee(Pe,J,ot,pe)},children:ot==="none"?"☆":"★"}),h&&(Y.capabilities||[]).includes("boot")&&we(J,Y.route||[]),(Y.capabilities||[]).includes(J.active?"down":"up")&&l.jsx("button",{className:`nc-power${J.active?" on":""}${J.degraded?" warn":""}`,onClick:In=>{In.stopPropagation(),u&&u({...J,boot:Nt(J,Y.route||[]),route:Y.route,availableEngines:Y.engines||[]})},title:J.active?f("power-off"):f("power-on"),children:l.jsx(at,{name:"power",size:14})})]},Pe.key)})():(()=>{const J=Pe.value;return l.jsxs("div",{"data-roster-key":Pe.key,"data-position":re,className:`nc-side-card${ht.has(J.key)?" active":""}`,draggable:!0,onDragStart:pe=>pe.dataTransfer.setData("text/nc-session",J.key),onClick:()=>a&&a(J.key),onDoubleClick:()=>Ce(J.name,J.node||re,Y.instanceId),children:[l.jsx(Li,{position:re,itemKey:Pe.key,label:J.name,canMove:ee,onMove:(pe,Me)=>le(re,pe,Me,ge),onStep:pe=>ve(re,Pe.key,pe,ge)}),l.jsx("span",{className:J.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:J.name}),l.jsx("small",{children:J.preview?J.preview:J.cmd?J.cmd:f("windows").replace("{n}",String(J.windows||0))})]}),J.activity?l.jsx("span",{className:"nc-rel",children:Br(J.activity)}):null,l.jsx("button",{className:`nc-pin${L.includes(Pe.key)?" on":""}`,title:f("pin"),onClick:pe=>{pe.stopPropagation(),x(Pe.key)},children:L.includes(Pe.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${J.technical?" on":""}`,title:J.technical?f("mark-normal"):f("mark-technical"),"aria-label":`${J.technical?f("mark-normal"):f("mark-technical")} ${J.name}`,onClick:pe=>{pe.stopPropagation(),v&&v(J.name,!J.technical,Y.route||[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:f("terminate"),onClick:pe=>{pe.stopPropagation(),window.confirm(f("terminate-confirm").replace("{name}",J.name))&&m&&m(J.name,Y.route)},children:"⋯"})]},Pe.key)})()),Ae.length===0&&l.jsx("div",{className:"nc-empty",children:f("no-sessions-short")})]})]},`nodo-${(Y.route||[Y.name]).join("/")}`)})]}),l.jsx("div",{className:"nc-side-lang",children:Ey.map((Y,re)=>l.jsxs("span",{children:[re>0&&" · ",l.jsx("button",{className:`nc-lang-btn${B===Y?" on":""}`,onClick:()=>$(Y),title:Y,children:Y.toUpperCase()})]},Y))}),l.jsx("div",{className:"nc-side-resize",onPointerDown:yt,title:""}),_e&&(()=>{const Y=_e.value,re=_e.nodeRoute?s.find(ge=>(ge.route||[ge.name]).join("/")===_e.nodeRoute)||{}:null,xe=_e.nodeRoute?re.route||[_e.nodeRoute]:[];return l.jsx(Vw,{row:Lt(_e,Y,xe,_e.nodeLabel||"",re&&re.sessions),token:K,initialSource:kt,onClose:()=>{Bt(null),Dt("preview")}})})()]})}function TN({label:e,count:t,state:n,onToggle:s,onFilter:o}){return l.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:[l.jsx("span",{className:"nc-node-chevron",children:n.open?"⌄":"›"}),l.jsx("span",{className:"nc-dot on"}),l.jsx("b",{children:e}),l.jsxs("small",{children:[" · ",f("node-sessions").replace("{n}",String(t))]}),l.jsxs("select",{className:"nc-node-filter",value:n.filter,title:f(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>o(a.target.value),children:[l.jsx("option",{value:"all",children:f("view-all")}),l.jsx("option",{value:"pinned",children:f("view-pinned")}),l.jsx("option",{value:"active",children:f("view-active")}),l.jsx("option",{value:"off",children:f("view-off")}),l.jsx("option",{value:"technical",children:f("view-technical")})]})]})}function MN(e,t,n){return!e&&t?n+1:n}const Mf="nc_input_preferences_v1",md="nc-input-preferences",Yw=Object.freeze(["double-tap","single-tap","never"]),Gw=Object.freeze(["full","compact"]),Es=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full"});function Df(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{terminalKeyboardGesture:Yw.includes(t.terminalKeyboardGesture)?t.terminalKeyboardGesture:Es.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof t.keybarKeepsKeyboardClosed=="boolean"?t.keybarKeepsKeyboardClosed:Es.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof t.voiceKeepsKeyboardClosed=="boolean"?t.voiceKeepsKeyboardClosed:Es.voiceKeepsKeyboardClosed,showKeybarEnter:typeof t.showKeybarEnter=="boolean"?t.showKeybarEnter:Es.showKeybarEnter,keybarLayout:Gw.includes(t.keybarLayout)?t.keybarLayout:Es.keybarLayout}}function Xw(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function n_(e=Xw()){if(!e)return{...Es};try{return Df(JSON.parse(e.getItem(Mf)||"null"))}catch{return{...Es}}}function DN(e,t=Xw()){const n=Df(e);if(t)try{t.setItem(Mf,JSON.stringify(n))}catch{}return n}function If(){const[e,t]=C.useState(n_);C.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Mf&&o.key!==null)return;const a=o!=null&&o.detail?Df(o.detail):n_();t(a)};return window.addEventListener(md,s),window.addEventListener("storage",s),()=>{window.removeEventListener(md,s),window.removeEventListener("storage",s)}},[]);const n=C.useCallback(s=>{t(o=>{const a=DN({...o,...s||{}});return window.dispatchEvent(new CustomEvent(md,{detail:a})),a})},[]);return[e,n]}function IN({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,focused:u,onFocus:h,onClose:p,onOpenSingle:m,alive:v=!0,available:w=!0,fontSize:y=ia,onZoom:S,decks:k=[],currentDeck:E,onSendToDeck:b,panelUrl:j="",panelCellId:N="",panelPort:z=0}){const[D]=If(),U=s||e,W=C.useRef(()=>{}),K=C.useRef(()=>!1),te=C.useRef(()=>{}),G=C.useRef(!1),[Q,q]=C.useState(!1),[F,R]=C.useState(!1),[B,$]=C.useState(!1),[L,A]=C.useState(!1),[x,I]=C.useState(null),[T,M]=C.useState(0),O=C.useRef(v),H=t?`${t}:${e}`:e,se=k.filter(ee=>ee.id!==E&&ee.available!==!1);return C.useEffect(()=>{const ee=O.current;!ee&&v&&M(le=>MN(ee,v,le)),O.current=v},[v]),l.jsxs("div",{className:`nc-tile${u?" focused":""}`,onMouseDown:()=>h&&h(H),children:[l.jsxs("div",{className:"nc-tile-head",draggable:!0,onDragStart:ee=>{ee.dataTransfer.setData("text/nc-session",H),ee.dataTransfer.effectAllowed="move"},children:[l.jsxs("button",{className:"nc-tile-name",onClick:()=>h&&h(H),title:t?`${U} · ${t}`:U,children:[l.jsx("span",{className:v?"nc-dot on":"nc-dot"}),l.jsx("b",{children:U})]}),l.jsxs("span",{className:"nc-tile-actions",children:[S&&l.jsx("button",{onClick:()=>S(-1),title:f("zoom-out"),children:l.jsx(at,{name:"zoomOut",size:14})}),S&&l.jsx("button",{onClick:()=>S(1),title:f("zoom-in"),children:l.jsx(at,{name:"zoomIn",size:14})}),b&&se.length>0&&l.jsxs("select",{className:"nc-tile-deck",title:f("send-to-deck"),value:"",onMouseDown:ee=>ee.stopPropagation(),onChange:ee=>{const le=ee.target.value;le&&b(H,le),ee.target.value=""},children:[l.jsx("option",{value:"",children:f("send-to-deck")}),se.map(ee=>l.jsxs("option",{value:ee.id,children:[ee.ownerLabel," · ",ee.name]},ee.id))]}),l.jsx("button",{onClick:()=>R(ee=>!ee),title:f("composer"),children:"⌨"}),l.jsx("button",{onClick:()=>$(ee=>!ee),title:f("files"),children:"📁"}),j&&l.jsx("button",{onClick:()=>A(ee=>!ee),title:f("panel"),"aria-pressed":L,children:l.jsx(at,{name:"monitor",size:14})}),m&&l.jsx("button",{onClick:()=>m({session:e,node:t,ownerId:n}),title:f("single-view"),children:"↗"}),p&&l.jsx("button",{className:"nc-tile-close",onClick:()=>p(H),title:f("close"),children:"✕"})]})]}),l.jsxs("div",{className:"nc-tile-body",children:[w?l.jsx(Af,{session:e,node:t,token:o,readonly:a,takeSize:!1,focused:u,sendRef:W,composerRef:K,actionRef:te,ctrlRef:G,setCtrlArmed:q,onFiles:I,fontSize:y,keyboardGesture:D.terminalKeyboardGesture},`${H}:${T}`):l.jsx("div",{className:"nc-tile-unavailable",children:f("deck-owner-unavailable")}),w&&B&&l.jsx("div",{className:"nc-tile-files",onMouseDown:ee=>ee.stopPropagation(),children:l.jsx(Iw,{session:e,node:t,token:o,filesEvent:x,onClose:()=>$(!1)})})]}),w&&F&&l.jsx("div",{className:"nc-tile-composer",onMouseDown:ee=>ee.stopPropagation(),children:l.jsx(Kw,{submitText:ee=>K.current(ee),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:D.voiceKeepsKeyboardClosed})}),w&&L&&j&&N&&l.jsx(qw,{title:U,onClose:()=>A(!1),children:l.jsx(Tf,{cellId:N,panelUrl:j,route:t?t.split("/"):[],panelPort:z,token:o,title:U})})]})}function Qw({session:e,node:t,ownerId:n,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||n&&p.instanceId&&String(n)!==String(p.instanceId))continue;const v=(Array.isArray(p.cells)?p.cells:[]).find(w=>w&&w.tmuxSession===a);if(v)return v}return null}return(Array.isArray(s)?s:[]).find(h=>h&&h.tmuxSession===a)||null}function Of({session:e,cell:t,node:n,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=Qw({session:u,node:n,ownerId:s,cells:o,nodeGroups:a});return h&&h.cell?h.cell:u}function Jl(e,t,n){const s=u=>Number.isInteger(u)&&u>0&&u<65536?u:0;if(e==null)return s(n);if(!Array.isArray(e))return 0;if(e.length===0)return s(n);const o=typeof e[0]=="string"?e[0]:null;return o?s((t&&typeof t=="object"?t:{})[o]):0}const i_=.2,s_=.28,Jw=(e,t)=>Array.from((e==null?void 0:e.types)||[]).includes(t),gd=e=>Jw(e,"text/nc-session"),r_=e=>{var t;return Jw(e,"Files")||(((t=e==null?void 0:e.files)==null?void 0:t.length)||0)>0};function ON(e,t,n){const s=(e-n.left)/(n.width||1),o=(t-n.top)/(n.height||1);return s<s_?"left":s>1-s_?"right":o<.5?"top":"bottom"}function BN({layout:e,onLayoutChange:t,token:n,readonly:s=!1,sessionsAlive:o,focusSession:a,onFocus:u,onOpenSingle:h,decks:p=[],currentDeck:m,onSendToDeck:v,cells:w=[],nodeGroups:y=[],panelPort:S=0,nodePanelPorts:k={}}){$n();const[E,b]=C.useState(null),j=C.useRef(null),N=C.useRef([]),z=C.useRef(null);function D(R,B){const $=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",$),window.removeEventListener("pointercancel",$),window.removeEventListener("blur",$),z.current=null};window.addEventListener("pointermove",R),window.addEventListener("pointerup",$),window.addEventListener("pointercancel",$),window.addEventListener("blur",$),z.current=$}C.useEffect(()=>()=>{z.current&&z.current()},[]),C.useEffect(()=>{const R=()=>b(null);return window.addEventListener("dragend",R),window.addEventListener("drop",R),()=>{window.removeEventListener("dragend",R),window.removeEventListener("drop",R)}},[]);const U=e.columns.length,W=R=>E&&E.col===R&&E.row===void 0,K=!!E&&E.col===U,te=(R,B)=>E&&E.col===R&&E.row===B&&E.quadrant?` drop-${E.quadrant}`:"";function G(R){if(R.preventDefault(),r_(R.dataTransfer)){b(null);return}const B=R.dataTransfer.getData("text/nc-session"),$=E;if(b(null),!B||!$)return;let L;if($.quadrant){if(L=dk(e,$.col,$.row,$.quadrant),!L)return}else L={col:$.col};t(Di(e).includes(B)?ok(e,B,L):yf(e,B,L))}function Q(R,B){R.preventDefault(),R.stopPropagation();const $=R.clientX,L=e.columns[B].width,A=j.current&&j.current.clientWidth||1,x=e.columns[B+1];D(T=>{let M=Math.max(i_,L+(T.clientX-$)/A);if(x){const O=Qg(M/(M+x.width));M=O/(1-O)*x.width}t(lk(e,B,M))})}function q(R,B,$){R.preventDefault(),R.stopPropagation();const L=R.clientY,A=e.columns[B].tiles[$].height,x=N.current[B],I=x&&x.clientHeight||1,T=e.columns[B].tiles[$+1];D(O=>{let H=Math.max(i_,A+(O.clientY-L)/I);if(T){const se=Qg(H/(H+T.height));H=se/(1-se)*T.height}t(ck(e,B,$,H))})}function F(R){t(Ul(e,R))}return l.jsxs("div",{className:"nc-grid",ref:j,onDragOver:R=>{if(r_(R.dataTransfer)){R.preventDefault(),b(null);return}gd(R.dataTransfer)&&(R.preventDefault(),E&&E.col===U||b({col:U}))},onDrop:G,onDragLeave:R=>{const B=R.relatedTarget;(!B||!(j.current&&j.current.contains(B)))&&b(null)},children:[e.columns.flatMap((R,B)=>{const $=[];return $.push(l.jsx("div",{className:`nc-col${W(B)?" drop-newcol":""}`,ref:L=>{N.current[B]=L},style:{flexGrow:R.width,flexBasis:0},onDragOver:L=>{gd(L.dataTransfer)&&(L.preventDefault(),L.stopPropagation(),E&&E.col===B&&E.row===void 0||b({col:B}))},children:R.tiles.flatMap((L,A)=>{const x=[],I=ii(L),T=Qw({session:L.session,node:L.node,ownerId:L.ownerId,cells:w,nodeGroups:y}),M=Of({session:L.session,cell:T,node:L.node,ownerId:L.ownerId,cells:w,nodeGroups:y}),O=typeof(T==null?void 0:T.panelUrl)=="string"?T.panelUrl.trim():"",H=typeof(T==null?void 0:T.cell)=="string"?T.cell:"";return x.push(l.jsx("div",{className:`nc-tile-slot${te(B,A)}`,style:{flexGrow:L.height,flexBasis:0},onDragOver:se=>{if(!gd(se.dataTransfer))return;se.preventDefault(),se.stopPropagation();const ee=ON(se.clientX,se.clientY,se.currentTarget.getBoundingClientRect());E&&E.col===B&&E.row===A&&E.quadrant===ee||b({col:B,row:A,quadrant:ee})},children:l.jsx(IN,{session:L.session,node:L.node,ownerId:L.ownerId,cellName:M,token:n,readonly:s,focused:a===I,onFocus:u,onClose:F,onOpenSingle:h,available:L.unavailable!==!0,alive:L.unavailable!==!0&&(!o||o.has(I)),fontSize:L.fontSize,onZoom:se=>t(uk(e,B,A,se)),decks:p,currentDeck:m,onSendToDeck:v,panelUrl:O,panelCellId:H,panelPort:Jl(L.node?L.node.split("/"):[],k,S)})},I)),A<R.tiles.length-1&&x.push(l.jsx("div",{className:"nc-divider-h",onPointerDown:se=>q(se,B,A)},`h${A}`)),x})},`c${B}`)),B<U-1&&$.push(l.jsx("div",{className:"nc-divider-v",onPointerDown:L=>Q(L,B)},`v${B}`)),$}),K&&l.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),U===0&&l.jsx("div",{className:"nc-grid-empty",children:f("grid-empty")})]})}const Ti="local",si=/^[a-f0-9]{16,64}$/;function Ir(e,t){return`${e&&si.test(e)?e:Ti}:${t}`}function ac(e){const t=String(e||""),n=t.indexOf(":");if(n<1)return null;const s=t.slice(0,n),o=t.slice(n+1);return s!==Ti&&!si.test(s)||!/^[a-z0-9-]{1,32}$/.test(o)?null:{ownerId:s===Ti?null:s,name:o}}function lc(e){return Array.isArray(e)&&e.length?e.join("/"):""}function Bf(e){return{columns:Js(e).columns.map(t=>({width:t.width,tiles:t.tiles.map(n=>({...n}))}))}}function zN(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&si.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(lc(n.route),n.instanceId);return t}function $N(e){const t=new Map;for(const n of Array.isArray(e)?e:[])n&&si.test(String(n.instanceId||""))&&Array.isArray(n.route)&&t.set(n.instanceId,[...n.route]);return t}function qh(e,t,n=[]){const s=Bf(e),o=zN(n);for(const a of s.columns)for(const u of a.tiles)u.ownerId||(!u.node&&si.test(String(t||""))?u.ownerId=t:u.node&&o.has(u.node)&&(u.ownerId=o.get(u.node)));return s}function Vh(e,t,n=[]){const s=Bf(e),o=new Map;for(const a of n)a&&si.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=lc(o.get(u.ownerId)),delete u.unavailable):u.unavailable=!0);return s}function o_(e,t,n=[]){const s=Bf(e),o=$N(n);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=lc(o.get(u.ownerId))));return s}function Zw(e,t,n=[]){const s=As(e);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...si.test(String(t||""))?{ownerId:t}:{}};const o=n.find(a=>lc(a&&a.route)===s.node);return{...s,...o&&si.test(String(o.instanceId||""))?{ownerId:o.instanceId}:{}}}const FN=/^[a-z0-9-]{1,32}$/,ri="main",eb="nc_decks",tb="nc_deck_order_v1",nb=24;function a_(e){return typeof e!="string"?"":e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Hr(e){return typeof e=="string"&&FN.test(e)}function HN(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/?$/);if(t){let n;try{n=decodeURIComponent(t[1])}catch{n=t[1]}return Hr(n)?n:ri}return ri}function UN(e){const t=String(e||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(t){let s,o;try{s=decodeURIComponent(t[1]),o=decodeURIComponent(t[2])}catch{return{id:Ir(null,ri),ownerId:null,name:ri}}if(si.test(s)&&Hr(o))return{id:Ir(s,o),ownerId:s,name:o}}const n=HN(e);return{id:Ir(null,n),ownerId:null,name:n}}function vd(e,t){const n=typeof e=="object"&&e?{ownerId:e.ownerId||null,name:e.name}:ac(e)||{ownerId:null,name:e},s=Hr(n.name)?n.name:ri,o=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===ri?"/":`/deck/${encodeURIComponent(s)}`;return t?`${o}#token=${encodeURIComponent(t)}`:o}function ib(e){return e===ri?"nc_grid_v1":`nc_grid_v1__${e}`}function sb(e){const t=[ri];if(Array.isArray(e)){for(const n of e)if(Hr(n)&&n!==ri&&!t.includes(n)&&t.push(n),t.length>=nb)break}return t}function Vr(){return typeof localStorage<"u"?localStorage:null}function WN(){const e=Vr();if(!e)return[ri];try{return sb(JSON.parse(e.getItem(eb)||"null"))}catch{return[ri]}}function KN(e){const t=Vr();if(t)try{t.setItem(eb,JSON.stringify(sb(e)))}catch{}}function ca(e){return e==="local"||si.test(String(e||""))}function cc(e,t){const n=ac(e);return!!n&&(n.ownerId||"local")===t}function Oi(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,s]of Object.entries(e).slice(0,64)){if(!ca(n)||!Array.isArray(s))continue;const o=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&cc(a,n)))].slice(0,nb);o.length&&(t[n]=o)}return t}function kl(e=Vr()){if(!e)return{};try{return Oi(JSON.parse(e.getItem(tb)||"null"))}catch{return{}}}function _d(e,t=Vr()){const n=Oi(e);if(t)try{t.setItem(tb,JSON.stringify(n))}catch{}return n}function uc(e,t){return Array.isArray(e==null?void 0:e[t])?e[t]:[]}function qN(e,t,n,s,o=[]){if(!ca(t)||n===s)return Oi(e);const a=[...new Set(o.filter(w=>cc(w,t)))];if(!a.includes(n)||!a.includes(s))return Oi(e);const u=uc(e,t).filter(w=>a.includes(w)),h=[...u,...a.filter(w=>!u.includes(w))],p=h.indexOf(n),m=h.indexOf(s);h.splice(p,1);const v=h.indexOf(s);return h.splice(p<m?v+1:v,0,n),Oi({...e,[t]:h})}function VN(e,t,n,s){if(!ca(t)||!cc(s,t))return Oi(e);const o=uc(e,t);return o.includes(n)?Oi({...e,[t]:o.map(a=>a===n?s:a)}):Oi(e)}function YN(e,t,n){return ca(t)?Oi({...e,[t]:uc(e,t).filter(s=>s!==n)}):Oi(e)}function l_(e,t={}){const n=new Map;for(const o of Array.isArray(e)?e:[]){const a=o!=null&&o.local?"local":String((o==null?void 0:o.ownerId)||"");!ca(a)||!cc(o==null?void 0:o.id,a)||(n.has(a)||n.set(a,[]),n.get(a).push(o))}const s=[];for(const[,o]of n){const a=o[0].local?"local":o[0].ownerId,u=uc(t,a),h=new Map(u.map((p,m)=>[p,m]));o.sort((p,m)=>{const v=h.has(p.id)?h.get(p.id):Number.MAX_SAFE_INTEGER,w=h.has(m.id)?h.get(m.id):Number.MAX_SAFE_INTEGER;return v-w}),s.push(...o)}return s}function Yh(e){const t=Vr();if(!t)return null;try{return JSON.parse(t.getItem(ib(e))||"null")}catch{return null}}function GN(e,t){const n=Vr();if(n)try{n.setItem(ib(e),JSON.stringify(t))}catch{}}const zf="nc_deckbar_collapsed_v1",rb=64;function $f(e){return e===Ti||si.test(String(e||""))}function Ff(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=rb)break;if($f(s)){if(o===!0)t[s]=!0;else if(o===!1)t[s]=!1;else continue;n+=1}}return t}function ob(e,t){return $f(t)&&Object.prototype.hasOwnProperty.call(e||{},t)?e[t]===!0:!0}function XN(e,t){const n=Ff(e);return $f(t)&&(!Object.prototype.hasOwnProperty.call(n,t)&&Object.keys(n).length>=rb&&delete n[Object.keys(n)[0]],n[t]=!ob(n,t)),n}function ab(){return typeof localStorage<"u"?localStorage:null}function c_(e=ab()){if(!e)return{};try{return Ff(JSON.parse(e.getItem(zf)||"null"))}catch{return{}}}function QN(e,t=ab()){const n=Ff(e);if(t)try{t.setItem(zf,JSON.stringify(n))}catch{}return n}function JN(){const[e,t]=C.useState(c_);C.useEffect(()=>{const o=a=>{(a.key===zf||a.key===null)&&t(c_())};return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]);const n=C.useCallback(o=>ob(e,o),[e]),s=C.useCallback(o=>{t(a=>QN(XN(a,o)))},[]);return{collapsed:e,isCollapsed:n,toggle:s}}const Hf="nc_deck_presence_v1",u_=3e4,ZN=18e4,lb=1e4,cb=32,e2=/^[A-Za-z0-9_-]{1,64}$/,t2=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),d_="working",n2="on",i2="neutral",s2="warn";function Uf(e){return typeof e=="string"&&e2.test(e)&&!t2.has(e)}function ub(e){return typeof e=="string"&&ac(e)!==null}function Wf(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function Ur(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t={};let n=0;for(const[s,o]of Object.entries(e)){if(n>=cb)break;Uf(s)&&(!o||typeof o!="object"||ub(o.deckId)&&Wf(o.ts)&&(t[s]={deckId:o.deckId,ts:o.ts,focus:o.focus===!0,visible:o.visible===!0},n+=1))}return t}function db(e,t){const n=Ur(e);if(!Wf(t))return n;const s={};for(const[o,a]of Object.entries(n)){const u=a.visible?u_:ZN,h=t-u;a.ts>=h&&a.ts<=t+u_&&(s[o]=a)}return s}function h_(e,t,n,s){if(!Uf(t)||!Wf(s))return Ur(e);const o=db(e,s);if(!ub(n==null?void 0:n.deckId))return o;if(!Object.prototype.hasOwnProperty.call(o,t)&&Object.keys(o).length>=cb){let a="",u=1/0;for(const[h,p]of Object.entries(o))p.ts<u&&(a=h,u=p.ts);a&&delete o[a]}return o[t]={deckId:n.deckId,ts:s,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},Ur(o)}function r2(e,t){const n=Ur(e);if(!Uf(t))return n;const s={...n};return delete s[t],s}function o2(e,t){const n=db(e,t),s={};for(const o of Object.values(n)){const a=o.focus&&o.visible?d_:n2;s[o.deckId]!==d_&&(s[o.deckId]=a)}return s}function hb(){return typeof localStorage<"u"?localStorage:null}function Cl(e=hb()){if(!e)return{};try{return Ur(JSON.parse(e.getItem(Hf)||"null"))}catch{return{}}}function yd(e,t=hb()){const n=Ur(e);if(t)try{t.setItem(Hf,JSON.stringify(n))}catch{}return n}const a2=Math.min(lb,5e3);function l2(){var e,t;try{const n=(t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e);if(n)return`w${n.replaceAll("-","")}`}catch{}return`w${Date.now().toString(36)}${Math.random().toString(36).slice(2,14)}`}const c2=l2();function f_(){const e=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!0,t=typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState!=="hidden":!0;return{focus:e,visible:t}}function u2(e,t=!0){const s=C.useRef(c2).current,o=C.useRef(e);o.current=e;const[a,u]=C.useState(()=>({map:{},now:Date.now()})),h=C.useCallback(()=>{u({map:Cl(),now:Date.now()})},[]);C.useEffect(()=>{if(!t)return;const v=()=>{const b=Date.now(),j=h_(Cl(),s,{deckId:o.current,...f_()},b);return yd(j),{map:j,now:b}},w=()=>u(v());w();const y=setInterval(v,lb),S=setInterval(h,a2),k=w,E=b=>{(b.key===Hf||b.key===null)&&h()};return window.addEventListener("focus",k),window.addEventListener("blur",k),typeof document<"u"&&document.addEventListener("visibilitychange",k),window.addEventListener("storage",E),()=>{clearInterval(y),clearInterval(S),window.removeEventListener("focus",k),window.removeEventListener("blur",k),typeof document<"u"&&document.removeEventListener("visibilitychange",k),window.removeEventListener("storage",E);try{yd(r2(Cl(),s))}catch{}}},[t,s,h]),C.useEffect(()=>{if(!t)return;const v=Date.now(),w=h_(Cl(),s,{deckId:e,...f_()},v);yd(w),u({map:w,now:v})},[e,t,s]);const p=C.useMemo(()=>t?o2(a.map,a.now):{},[t,a]);return{dotFor:C.useCallback((v,w=!1)=>t?w?s2:p[v]||i2:null,[p,t]),windowId:s}}const p_=52,m_=18;function d2({ownerKey:e,deckId:t,label:n,onMove:s,onStep:o}){const a=C.useRef(null),u=C.useRef(0),[h,p]=C.useState(!1),m=()=>{var E,b,j,N;const k=a.current;(b=(E=k==null?void 0:k.over)==null?void 0:E.classList)==null||b.remove("nc-deck-over"),(N=(j=k==null?void 0:k.source)==null?void 0:j.classList)==null||N.remove("nc-deck-dragging"),u.current&&cancelAnimationFrame(u.current),u.current=0},v=(k=!1)=>{const E=a.current;if(!E)return;const b=E.target;m(),a.current=null,p(!1);try{E.handle.releasePointerCapture(E.pointerId)}catch{}k&&b&&b!==t&&s(t,b)},w=(k,E)=>{var D,U,W,K,te,G,Q,q;const b=a.current;if(!b)return;b.x=k,b.y=E;const j=(U=(D=document.elementFromPoint(k,E))==null?void 0:D.closest)==null?void 0:U.call(D,"[data-deck-id][data-owner-key]"),N=(W=j==null?void 0:j.dataset)==null?void 0:W.deckId,z=((K=j==null?void 0:j.dataset)==null?void 0:K.ownerKey)===e&&N&&N!==t;b.over!==(z?j:null)&&((G=(te=b.over)==null?void 0:te.classList)==null||G.remove("nc-deck-over"),b.over=z?j:null,(q=(Q=b.over)==null?void 0:Q.classList)==null||q.add("nc-deck-over")),b.target=z?N:null},y=()=>{var b,j;const k=a.current;if(!k){u.current=0;return}const E=(j=(b=k.container)==null?void 0:b.getBoundingClientRect)==null?void 0:j.call(b);if(E){const N=k.x<E.left+p_?-m_:k.x>E.right-p_?m_:0;N&&(k.container.scrollLeft+=N,w(k.x,k.y))}u.current=requestAnimationFrame(y)};C.useEffect(()=>{const k=b=>{b.key==="Escape"&&a.current&&(b.preventDefault(),v(!1))},E=()=>v(!1);return window.addEventListener("keydown",k),window.addEventListener("blur",E),()=>{window.removeEventListener("keydown",k),window.removeEventListener("blur",E),m(),a.current=null}},[t,e]);const S=k=>{var j;if(k.pointerType==="mouse"&&k.button!==0)return;k.preventDefault(),k.stopPropagation(),k.currentTarget.focus({preventScroll:!0});const E=k.currentTarget.closest("[data-deck-id][data-owner-key]"),b=k.currentTarget.closest(".nc-deckbar");a.current={pointerId:k.pointerId,handle:k.currentTarget,source:E,container:b,target:null,over:null,x:k.clientX,y:k.clientY},(j=E==null?void 0:E.classList)==null||j.add("nc-deck-dragging");try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}p(!0),u.current=requestAnimationFrame(y)};return l.jsx("button",{type:"button",className:`nc-deck-handle${h?" active":""}`,"aria-label":`${f("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:f("reorder-deck-help"),onClick:k=>{k.preventDefault(),k.stopPropagation()},onDragStart:k=>k.preventDefault(),onKeyDown:k=>{k.key!=="ArrowLeft"&&k.key!=="ArrowRight"||(k.preventDefault(),k.stopPropagation(),o(k.key==="ArrowLeft"?-1:1))},onPointerDown:S,onPointerMove:k=>{!a.current||k.pointerId!==a.current.pointerId||(k.preventDefault(),k.stopPropagation(),w(k.clientX,k.clientY))},onPointerUp:k=>{!a.current||k.pointerId!==a.current.pointerId||(k.preventDefault(),k.stopPropagation(),v(!0))},onPointerCancel:()=>v(!1),onLostPointerCapture:()=>{a.current&&v(!1)},children:"↔"})}function h2({decks:e=[],currentDeck:t="local:main",onCreate:n,onRename:s,onDelete:o,onReorder:a,onOpenWindow:u,onNavigate:h,saveState:p="idle",error:m="",sidebarVisible:v,onToggleSidebar:w}){$n();const{isCollapsed:y,toggle:S}=JN(),{dotFor:k}=u2(t),[E,b]=C.useState(null),[j,N]=C.useState(""),[z,D]=C.useState(!1),[U,W]=C.useState(""),[K,te]=C.useState(""),G=a_(j),Q=Hr(G),q=[];for(const L of e){const A=L.local?"local":L.ownerId;let x=q.find(I=>I.key===A);x||(x={key:A,label:L.ownerLabel||(L.local?"Local":A),local:!!L.local,decks:[]},q.push(x)),x.decks.push(L)}const F=async()=>{if(Q){D(!0),W("");try{n&&await n(G,E),N(""),b(null)}catch(L){W(String(L.message||L))}D(!1)}},R=L=>{te(""),u&&u(L.id)||te(L.id)},B=async L=>{if(!(L.id===t||!h||z||L.available===!1)){D(!0),W("");try{await h(L.id)}catch(A){W(String((A==null?void 0:A.message)||A))}D(!1)}},$=(L,A,x)=>{const I=L.decks.findIndex(M=>M.id===A.id),T=L.decks[I+x];I>=0&&T&&a&&!z&&a(A.id,T.id)};return l.jsxs("div",{className:"nc-deckbar",children:[w&&l.jsx("button",{className:"nc-deck-sidebar-toggle",title:f("toggle-sidebar"),onClick:w,children:v?"◀":"☰"}),l.jsx("span",{className:"nc-deckbar-label",children:f("decks")}),l.jsx("div",{className:"nc-deck-chips",children:q.map(L=>{const A=y(L.key),x=`nc-deck-content-${L.key}`,I=L.local?"Local":L.label,T=L.decks.some(H=>H.id===t),M=(L.decks.find(H=>H.id===t)||{}).name,O=f(L.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",L.decks.length);return l.jsxs("span",{className:`nc-deck-owner-group${A?" collapsed":""}`,"data-owner-key":L.key,"data-collapsed":A?"1":"0",children:[l.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!A,"aria-controls":x,title:f(A?"expand-owner":"collapse-owner").replace("{owner}",I),onClick:()=>{!A&&E===L.key&&(N(""),b(null)),S(L.key)},children:[l.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:A?"▸":"▾"}),l.jsx("span",{className:"nc-deck-owner",children:I})]}),A&&l.jsxs("span",{className:"nc-deck-summary",title:O,children:[l.jsx("span",{className:"nc-deck-summary-count",children:L.decks.length}),T&&l.jsxs("span",{className:"nc-deck-summary-current",children:["• ",M]})]}),l.jsxs("span",{id:x,className:"nc-deck-owner-content",hidden:A,children:[L.decks.map(H=>{const se=k(H.id,H.available===!1);return l.jsxs("span",{"data-deck-id":H.id,"data-owner-key":L.key,className:`nc-deck-chip${H.id===t?" current":""}${H.available===!1?" offline":""}`,children:[se&&l.jsx(f2,{state:se}),l.jsx(d2,{ownerKey:L.key,deckId:H.id,label:`${L.label} · ${H.name}`,onMove:(ee,le)=>{a&&!z&&a(ee,le)},onStep:ee=>$(L,H,ee)}),l.jsxs("button",{className:"nc-deck-open",title:H.available===!1?`${H.ownerLabel} offline`:H.id===t?f("deck-current"):`${H.ownerLabel} · ${H.name}`,disabled:z||H.available===!1,onClick:()=>B(H),children:[H.name,H.id===t?" •":""]}),l.jsx("button",{className:"nc-deck-mini",disabled:H.available===!1,title:f("detach-deck"),onClick:()=>R(H),children:"↗"}),H.name!==ri&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"nc-deck-mini",disabled:H.available===!1,title:f("rename-deck"),onClick:()=>{const ee=(typeof window<"u"?window.prompt(f("rename-deck"),H.name):"")||"",le=a_(ee);Hr(le)&&le!==H.name&&s&&s(H.id,le).catch(ve=>W(String(ve.message||ve)))},children:"✎"}),l.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:H.available===!1,title:f("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(f("delete-deck-confirm").replace("{name}",`${H.ownerLabel} · ${H.name}`)))&&o&&o(H.id).catch(ee=>W(String(ee.message||ee)))},children:"✕"})]})]},H.id)}),E===L.key?l.jsxs("span",{className:"nc-deck-add",children:[l.jsx("input",{autoFocus:!0,className:Q||!j?"":"invalid",placeholder:f("deck-name"),value:j,onChange:H=>N(H.target.value),onKeyDown:H=>{H.key==="Enter"&&F(),H.key==="Escape"&&(N(""),b(null))}}),j&&Q&&G!==j&&l.jsxs("span",{className:"nc-deck-slug",children:["→ ",G]}),l.jsx("button",{className:"nc-deck-ok",disabled:!Q||z,onClick:F,children:f("create")}),l.jsx("button",{className:"nc-deck-cancel",onClick:()=>{N(""),b(null)},children:f("cancel")})]}):l.jsxs("button",{className:"nc-deck-newbtn",disabled:z||L.decks.every(H=>H.available===!1),title:`${f("new-deck")} · ${L.label}`,onClick:()=>{N(""),b(L.key)},children:["+ ",f("new")]})]})]},L.key)})}),l.jsx("span",{className:`nc-deck-state ${p}`,title:f("deck-autosave"),children:f(p==="saving"?"saving":p==="saved"?"saved":"deck-autosave")}),(U||m)&&l.jsx("span",{className:"nc-deck-error",children:U||m}),K&&l.jsx("button",{className:"nc-deck-fallback",onClick:()=>u&&u(K),children:f("popup-blocked")})]})}function f2({state:e}){if(!e)return null;const t=f(`dot-${e}`);return l.jsx("span",{className:`nc-deck-dot ${e}`,role:"img","aria-label":t,title:t})}var Lr={},wd,g_;function p2(){return g_||(g_=1,wd=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),wd}var bd={},xs={},v_;function ir(){if(v_)return xs;v_=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 xs.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},xs.getSymbolTotalCodewords=function(s){return t[s]},xs.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},xs.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');e=s},xs.isKanjiModeEnabled=function(){return typeof e<"u"},xs.toSJIS=function(s){return e(s)},xs}var Sd={},__;function Kf(){return __||(__=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},e.from=function(s,o){if(e.isValid(s))return s;try{return t(s)}catch{return o}}})(Sd)),Sd}var xd,y_;function m2(){if(y_)return xd;y_=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let s=0;s<n;s++)this.putBit((t>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},xd=e,xd}var kd,w_;function g2(){if(w_)return kd;w_=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,s,o){const a=t*this.size+n;this.data[a]=s,o&&(this.reservedBit[a]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,s){this.data[t*this.size+n]^=s},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},kd=e,kd}var Cd={},b_;function v2(){return b_||(b_=1,(function(e){const t=ir().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}})(Cd)),Cd}var Ed={},S_;function _2(){if(S_)return Ed;S_=1;const e=ir().getSymbolSize,t=7;return Ed.getPositions=function(s){const o=e(s);return[[0,0],[o-t,0],[0,o-t]]},Ed}var Nd={},x_;function y2(){return x_||(x_=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,m=null,v=null;for(let w=0;w<a;w++){h=p=0,m=v=null;for(let y=0;y<a;y++){let S=o.get(w,y);S===m?h++:(h>=5&&(u+=t.N1+(h-5)),m=S,h=1),S=o.get(y,w),S===v?p++:(p>=5&&(u+=t.N1+(p-5)),v=S,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 m=o.get(h,p)+o.get(h,p+1)+o.get(h+1,p)+o.get(h+1,p+1);(m===4||m===0)&&u++}return u*t.N2},e.getPenaltyN3=function(o){const a=o.size;let u=0,h=0,p=0;for(let m=0;m<a;m++){h=p=0;for(let v=0;v<a;v++)h=h<<1&2047|o.get(m,v),v>=10&&(h===1488||h===93)&&u++,p=p<<1&2047|o.get(v,m),v>=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 n(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,n(o,p,h))},e.getBestMask=function(o,a){const u=Object.keys(e.Patterns).length;let h=0,p=1/0;for(let m=0;m<u;m++){a(m),e.applyMask(m,o);const v=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(m,o),v<p&&(p=v,h=m)}return h}})(Nd)),Nd}var El={},k_;function fb(){if(k_)return El;k_=1;const e=Kf(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return El.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}},El.getTotalCodewordsCount=function(o,a){switch(a){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},El}var jd={},zo={},C_;function w2(){if(C_)return zo;C_=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]})(),zo.log=function(s){if(s<1)throw new Error("log("+s+")");return t[s]},zo.exp=function(s){return e[s]},zo.mul=function(s,o){return s===0||o===0?0:e[t[s]+t[o]]},zo}var E_;function b2(){return E_||(E_=1,(function(e){const t=w2();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}})(jd)),jd}var Rd,N_;function S2(){if(N_)return Rd;N_=1;const e=b2();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(s){this.degree=s,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(s.length+this.degree);o.set(s);const 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},Rd=t,Rd}var Pd={},Ad={},Ld={},j_;function pb(){return j_||(j_=1,Ld.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Ld}var Ri={},R_;function mb(){if(R_)return Ri;R_=1;const e="[0-9]+",t="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
|
|
82
|
+
]))+`;Ri.KANJI=new RegExp(n,"g"),Ri.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Ri.BYTE=new RegExp(s,"g"),Ri.NUMERIC=new RegExp(e,"g"),Ri.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),a=new RegExp("^"+e+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Ri.testKanji=function(p){return o.test(p)},Ri.testNumeric=function(p){return a.test(p)},Ri.testAlphanumeric=function(p){return u.test(p)},Ri}var P_;function sr(){return P_||(P_=1,(function(e){const t=pb(),n=mb();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 n.testNumeric(a)?e.NUMERIC:n.testAlphanumeric(a)?e.ALPHANUMERIC:n.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}}})(Ad)),Ad}var A_;function x2(){return A_||(A_=1,(function(e){const t=ir(),n=fb(),s=Kf(),o=sr(),a=pb(),u=7973,h=t.getBCHDigit(u);function p(y,S,k){for(let E=1;E<=40;E++)if(S<=e.getCapacity(E,k,y))return E}function m(y,S){return o.getCharCountIndicator(y,S)+4}function v(y,S){let k=0;return y.forEach(function(E){const b=m(E.mode,S);k+=b+E.getBitsLength()}),k}function w(y,S){for(let k=1;k<=40;k++)if(v(y,k)<=e.getCapacity(k,S,o.MIXED))return k}e.from=function(S,k){return a.isValid(S)?parseInt(S,10):k},e.getCapacity=function(S,k,E){if(!a.isValid(S))throw new Error("Invalid QR Code version");typeof E>"u"&&(E=o.BYTE);const b=t.getSymbolTotalCodewords(S),j=n.getTotalCodewordsCount(S,k),N=(b-j)*8;if(E===o.MIXED)return N;const z=N-m(E,S);switch(E){case o.NUMERIC:return Math.floor(z/10*3);case o.ALPHANUMERIC:return Math.floor(z/11*2);case o.KANJI:return Math.floor(z/13);case o.BYTE:default:return Math.floor(z/8)}},e.getBestVersionForData=function(S,k){let E;const b=s.from(k,s.M);if(Array.isArray(S)){if(S.length>1)return w(S,b);if(S.length===0)return 1;E=S[0]}else E=S;return p(E.mode,E.getLength(),b)},e.getEncodedBits=function(S){if(!a.isValid(S)||S<7)throw new Error("Invalid QR Code version");let k=S<<12;for(;t.getBCHDigit(k)-h>=0;)k^=u<<t.getBCHDigit(k)-h;return S<<12|k}})(Pd)),Pd}var Td={},L_;function k2(){if(L_)return Td;L_=1;const e=ir(),t=1335,n=21522,s=e.getBCHDigit(t);return Td.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)^n},Td}var Md={},Dd,T_;function C2(){if(T_)return Dd;T_=1;const e=sr();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let o,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))},Dd=t,Dd}var Id,M_;function E2(){if(M_)return Id;M_=1;const e=sr(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(s){this.mode=e.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let 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)},Id=n,Id}var Od,D_;function N2(){if(D_)return Od;D_=1;const e=sr();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(s){return s*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let s=0,o=this.data.length;s<o;s++)n.put(this.data[s],8)},Od=t,Od}var Bd,I_;function j2(){if(I_)return Bd;I_=1;const e=sr(),t=ir();function n(s){this.mode=e.KANJI,this.data=s}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(s){let o;for(o=0;o<this.data.length;o++){let 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)}},Bd=n,Bd}var zd={exports:{}},O_;function R2(){return O_||(O_=1,(function(e){var t={single_source_shortest_paths:function(n,s,o){var a={},u={};u[s]=0;var h=t.PriorityQueue.make();h.push(s,0);for(var p,m,v,w,y,S,k,E,b;!h.empty();){p=h.pop(),m=p.value,w=p.cost,y=n[m]||{};for(v in y)y.hasOwnProperty(v)&&(S=y[v],k=w+S,E=u[v],b=typeof u[v]>"u",(b||E>k)&&(u[v]=k,h.push(v,k),a[v]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var j=["Could not find a path from ",s," to ",o,"."].join("");throw new Error(j)}return a},extract_shortest_path_from_predecessor_list:function(n,s){for(var o=[],a=s;a;)o.push(a),n[a],a=n[a];return o.reverse(),o},find_path:function(n,s,o){var a=t.single_source_shortest_paths(n,s,o);return t.extract_shortest_path_from_predecessor_list(a,o)},PriorityQueue:{make:function(n){var s=t.PriorityQueue,o={},a;n=n||{};for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);return o.queue=[],o.sorter=n.sorter||s.default_sorter,o},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var o={value:n,cost:s};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(zd)),zd.exports}var B_;function P2(){return B_||(B_=1,(function(e){const t=sr(),n=C2(),s=E2(),o=N2(),a=j2(),u=mb(),h=ir(),p=R2();function m(j){return unescape(encodeURIComponent(j)).length}function v(j,N,z){const D=[];let U;for(;(U=j.exec(z))!==null;)D.push({data:U[0],index:U.index,mode:N,length:U[0].length});return D}function w(j){const N=v(u.NUMERIC,t.NUMERIC,j),z=v(u.ALPHANUMERIC,t.ALPHANUMERIC,j);let D,U;return h.isKanjiModeEnabled()?(D=v(u.BYTE,t.BYTE,j),U=v(u.KANJI,t.KANJI,j)):(D=v(u.BYTE_KANJI,t.BYTE,j),U=[]),N.concat(z,D,U).sort(function(K,te){return K.index-te.index}).map(function(K){return{data:K.data,mode:K.mode,length:K.length}})}function y(j,N){switch(N){case t.NUMERIC:return n.getBitsLength(j);case t.ALPHANUMERIC:return s.getBitsLength(j);case t.KANJI:return a.getBitsLength(j);case t.BYTE:return o.getBitsLength(j)}}function S(j){return j.reduce(function(N,z){const D=N.length-1>=0?N[N.length-1]:null;return D&&D.mode===z.mode?(N[N.length-1].data+=z.data,N):(N.push(z),N)},[])}function k(j){const N=[];for(let z=0;z<j.length;z++){const D=j[z];switch(D.mode){case t.NUMERIC:N.push([D,{data:D.data,mode:t.ALPHANUMERIC,length:D.length},{data:D.data,mode:t.BYTE,length:D.length}]);break;case t.ALPHANUMERIC:N.push([D,{data:D.data,mode:t.BYTE,length:D.length}]);break;case t.KANJI:N.push([D,{data:D.data,mode:t.BYTE,length:m(D.data)}]);break;case t.BYTE:N.push([{data:D.data,mode:t.BYTE,length:m(D.data)}])}}return N}function E(j,N){const z={},D={start:{}};let U=["start"];for(let W=0;W<j.length;W++){const K=j[W],te=[];for(let G=0;G<K.length;G++){const Q=K[G],q=""+W+G;te.push(q),z[q]={node:Q,lastCount:0},D[q]={};for(let F=0;F<U.length;F++){const R=U[F];z[R]&&z[R].node.mode===Q.mode?(D[R][q]=y(z[R].lastCount+Q.length,Q.mode)-y(z[R].lastCount,Q.mode),z[R].lastCount+=Q.length):(z[R]&&(z[R].lastCount=Q.length),D[R][q]=y(Q.length,Q.mode)+4+t.getCharCountIndicator(Q.mode,N))}}U=te}for(let W=0;W<U.length;W++)D[U[W]].end=0;return{map:D,table:z}}function b(j,N){let z;const D=t.getBestModeForData(j);if(z=t.from(N,D),z!==t.BYTE&&z.bit<D.bit)throw new Error('"'+j+'" cannot be encoded with mode '+t.toString(z)+`.
|
|
84
|
+
Suggested mode is: `+t.toString(D));switch(z===t.KANJI&&!h.isKanjiModeEnabled()&&(z=t.BYTE),z){case t.NUMERIC:return new n(j);case t.ALPHANUMERIC:return new s(j);case t.KANJI:return new a(j);case t.BYTE:return new o(j)}}e.fromArray=function(N){return N.reduce(function(z,D){return typeof D=="string"?z.push(b(D,null)):D.data&&z.push(b(D.data,D.mode)),z},[])},e.fromString=function(N,z){const D=w(N,h.isKanjiModeEnabled()),U=k(D),W=E(U,z),K=p.find_path(W.map,"start","end"),te=[];for(let G=1;G<K.length-1;G++)te.push(W.table[K[G]].node);return e.fromArray(S(te))},e.rawSplit=function(N){return e.fromArray(w(N,h.isKanjiModeEnabled()))}})(Md)),Md}var z_;function A2(){if(z_)return bd;z_=1;const e=ir(),t=Kf(),n=m2(),s=g2(),o=v2(),a=_2(),u=y2(),h=fb(),p=S2(),m=x2(),v=k2(),w=sr(),y=P2();function S(W,K){const te=W.size,G=a.getPositions(K);for(let Q=0;Q<G.length;Q++){const q=G[Q][0],F=G[Q][1];for(let R=-1;R<=7;R++)if(!(q+R<=-1||te<=q+R))for(let B=-1;B<=7;B++)F+B<=-1||te<=F+B||(R>=0&&R<=6&&(B===0||B===6)||B>=0&&B<=6&&(R===0||R===6)||R>=2&&R<=4&&B>=2&&B<=4?W.set(q+R,F+B,!0,!0):W.set(q+R,F+B,!1,!0))}}function k(W){const K=W.size;for(let te=8;te<K-8;te++){const G=te%2===0;W.set(te,6,G,!0),W.set(6,te,G,!0)}}function E(W,K){const te=o.getPositions(K);for(let G=0;G<te.length;G++){const Q=te[G][0],q=te[G][1];for(let F=-2;F<=2;F++)for(let R=-2;R<=2;R++)F===-2||F===2||R===-2||R===2||F===0&&R===0?W.set(Q+F,q+R,!0,!0):W.set(Q+F,q+R,!1,!0)}}function b(W,K){const te=W.size,G=m.getEncodedBits(K);let Q,q,F;for(let R=0;R<18;R++)Q=Math.floor(R/3),q=R%3+te-8-3,F=(G>>R&1)===1,W.set(Q,q,F,!0),W.set(q,Q,F,!0)}function j(W,K,te){const G=W.size,Q=v.getEncodedBits(K,te);let q,F;for(q=0;q<15;q++)F=(Q>>q&1)===1,q<6?W.set(q,8,F,!0):q<8?W.set(q+1,8,F,!0):W.set(G-15+q,8,F,!0),q<8?W.set(8,G-q-1,F,!0):q<9?W.set(8,15-q-1+1,F,!0):W.set(8,15-q-1,F,!0);W.set(G-8,8,1,!0)}function N(W,K){const te=W.size;let G=-1,Q=te-1,q=7,F=0;for(let R=te-1;R>0;R-=2)for(R===6&&R--;;){for(let B=0;B<2;B++)if(!W.isReserved(Q,R-B)){let $=!1;F<K.length&&($=(K[F]>>>q&1)===1),W.set(Q,R-B,$),q--,q===-1&&(F++,q=7)}if(Q+=G,Q<0||te<=Q){Q-=G,G=-G;break}}}function z(W,K,te){const G=new n;te.forEach(function(B){G.put(B.mode.bit,4),G.put(B.getLength(),w.getCharCountIndicator(B.mode,W)),B.write(G)});const Q=e.getSymbolTotalCodewords(W),q=h.getTotalCodewordsCount(W,K),F=(Q-q)*8;for(G.getLengthInBits()+4<=F&&G.put(0,4);G.getLengthInBits()%8!==0;)G.putBit(0);const R=(F-G.getLengthInBits())/8;for(let B=0;B<R;B++)G.put(B%2?17:236,8);return D(G,W,K)}function D(W,K,te){const G=e.getSymbolTotalCodewords(K),Q=h.getTotalCodewordsCount(K,te),q=G-Q,F=h.getBlocksCount(K,te),R=G%F,B=F-R,$=Math.floor(G/F),L=Math.floor(q/F),A=L+1,x=$-L,I=new p(x);let T=0;const M=new Array(F),O=new Array(F);let H=0;const se=new Uint8Array(W.buffer);for(let fe=0;fe<F;fe++){const He=fe<B?L:A;M[fe]=se.slice(T,T+He),O[fe]=I.encode(M[fe]),T+=He,H=Math.max(H,He)}const ee=new Uint8Array(G);let le=0,ve,de;for(ve=0;ve<H;ve++)for(de=0;de<F;de++)ve<M[de].length&&(ee[le++]=M[de][ve]);for(ve=0;ve<x;ve++)for(de=0;de<F;de++)ee[le++]=O[de][ve];return ee}function U(W,K,te,G){let Q;if(Array.isArray(W))Q=y.fromArray(W);else if(typeof W=="string"){let $=K;if(!$){const L=y.rawSplit(W);$=m.getBestVersionForData(L,te)}Q=y.fromString(W,$||40)}else throw new Error("Invalid data");const q=m.getBestVersionForData(Q,te);if(!q)throw new Error("The amount of data is too big to be stored in a QR Code");if(!K)K=q;else if(K<q)throw new Error(`
|
|
85
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
86
|
+
Minimum version required to store current data is: `+q+`.
|
|
87
|
+
`);const F=z(K,te,Q),R=e.getSymbolSize(K),B=new s(R);return S(B,K),k(B),E(B,K),j(B,te,0),K>=7&&b(B,K),N(B,F),isNaN(G)&&(G=u.getBestMask(B,j.bind(null,B,te))),u.applyMask(G,B),j(B,te,G),{modules:B,version:K,errorCorrectionLevel:te,maskPattern:G,segments:Q}}return bd.create=function(K,te){if(typeof K>"u"||K==="")throw new Error("No input text");let G=t.M,Q,q;return typeof te<"u"&&(G=t.from(te.errorCorrectionLevel,t.M),Q=m.from(te.version),q=u.from(te.maskPattern),te.toSJISFunc&&e.setToSJISFunction(te.toSJISFunc)),U(K,Q,G,q)},bd}var $d={},Fd={},$_;function gb(){return $_||($_=1,(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let s=n.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+n);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(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),m=Math.floor((u+a.margin*2)*p),v=a.margin*p,w=[a.color.light,a.color.dark];for(let y=0;y<m;y++)for(let S=0;S<m;S++){let k=(y*m+S)*4,E=a.color.light;if(y>=v&&S>=v&&y<m-v&&S<m-v){const b=Math.floor((y-v)/p),j=Math.floor((S-v)/p);E=w[h[b*u+j]?1:0]}s[k++]=E.r,s[k++]=E.g,s[k++]=E.b,s[k]=E.a}}})(Fd)),Fd}var F_;function L2(){return F_||(F_=1,(function(e){const t=gb();function n(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,m=u;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),u||(m=s()),p=t.getOptions(p);const v=t.getImageWidth(a.modules.size,p),w=m.getContext("2d"),y=w.createImageData(v,v);return t.qrToImageData(y.data,a,p),n(w,m,v),w.putImageData(y,0,0),m},e.renderToDataURL=function(a,u,h){let p=h;typeof p>"u"&&(!u||!u.getContext)&&(p=u,u=void 0),p||(p={});const m=e.render(a,u,p),v=p.type||"image/png",w=p.rendererOpts||{};return m.toDataURL(v,w.quality)}})($d)),$d}var Hd={},H_;function T2(){if(H_)return Hd;H_=1;const e=gb();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 n(o,a,u){let h=o+a;return typeof u<"u"&&(h+=" "+u),h}function s(o,a,u){let h="",p=0,m=!1,v=0;for(let w=0;w<o.length;w++){const y=Math.floor(w%a),S=Math.floor(w/a);!y&&!m&&(m=!0),o[w]?(v++,w>0&&y>0&&o[w-1]||(h+=m?n("M",y+u,.5+S+u):n("m",p,0),p=0,m=!1),y+1<a&&o[w+1]||(h+=n("h",v),v=0)):p++}return h}return Hd.render=function(a,u,h){const p=e.getOptions(u),m=a.modules.size,v=a.modules.data,w=m+p.margin*2,y=p.color.light.a?"<path "+t(p.color.light,"fill")+' d="M0 0h'+w+"v"+w+'H0z"/>':"",S="<path "+t(p.color.dark,"stroke")+' d="'+s(v,m,p.margin)+'"/>',k='viewBox="0 0 '+w+" "+w+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(p.width?'width="'+p.width+'" height="'+p.width+'" ':"")+k+' shape-rendering="crispEdges">'+y+S+`</svg>
|
|
88
|
+
`;return typeof h=="function"&&h(null,b),b},Hd}var U_;function M2(){if(U_)return Lr;U_=1;const e=p2(),t=A2(),n=L2(),s=T2();function o(a,u,h,p,m){const v=[].slice.call(arguments,1),w=v.length,y=typeof v[w-1]=="function";if(!y&&!e())throw new Error("Callback required as last argument");if(y){if(w<2)throw new Error("Too few arguments provided");w===2?(m=h,h=u,u=p=void 0):w===3&&(u.getContext&&typeof m>"u"?(m=p,p=void 0):(m=p,p=h,h=u,u=void 0))}else{if(w<1)throw new Error("Too few arguments provided");return w===1?(h=u,u=p=void 0):w===2&&!u.getContext&&(p=h,h=u,u=void 0),new Promise(function(S,k){try{const E=t.create(h,p);S(a(E,u,p))}catch(E){k(E)}})}try{const S=t.create(h,p);m(null,a(S,u,p))}catch(S){m(S)}}return Lr.create=t.create,Lr.toCanvas=o.bind(null,n.render),Lr.toDataURL=o.bind(null,n.renderToDataURL),Lr.toString=o.bind(null,function(a,u,h){return s.render(a,h)}),Lr}var D2=M2();const I2=nf(D2);function W_(e){return typeof e=="string"?e.trim():e&&typeof e=="object"&&typeof e.data=="string"?e.data.trim():""}function O2(e){const t=String(e||"").trim();if(!t)return{kind:"empty"};const n=bk(t);if(!n||!n.ok)return{kind:"invalid"};const s=[];return n.ssh||s.push("ssh"),n.name||s.push("name"),s.length?{kind:"partial",decoded:n,missing:s}:{kind:"complete",decoded:n}}function B2(e,t,n=new Set,s=!1){if(!t||!t.ok)return e;const o=Sk(e,t,n);return t.version===2&&t.name&&!n.has("name")&&!s&&(o.name=t.name),!n.has("label")&&!o.label&&t.label&&(o.label=t.label),o}function K_(e,t,n=new Set,s=!1){const o=String(t||"").trim(),a=O2(o);let u={...e,pairingUrl:o};return(a.kind==="complete"||a.kind==="partial")&&(u={...B2(u,a.decoded,n,s),pairingUrl:o}),{classification:a,form:u}}function Il(e,t){const n=String(t||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const s=String(e||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let o=Rs(s);(o==="localhost"||o==="node")&&(o="nexuscrew");const a=n.slice(0,4),u=Math.max(1,32-a.length-1);return`${o.slice(0,u).replace(/-+$/g,"")||"n"}-${a}`}function z2(e,{deviceDefault:t="",localNodeId:n="",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||Il(a,n)||s||"").trim();return u&&(o.localName=u),o}function $2(){const e=new Set;let t=!1;return{canAuto(n){return!t&&!e.has(String(n||""))},start(n){return t?!1:(t=!0,e.add(String(n||"")),!0)},finish(){t=!1},reset(n){e.delete(String(n||""))},isBusy(){return t}}}const F2=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function H2(e){const t=e&&e.data||{},n=typeof t.stage=="string"&&t.stage?t.stage:"",s=typeof t.detail=="string"&&t.detail?t.detail:"";return{stage:n,code:typeof t.code=="string"?t.code:"",detail:s,hint:typeof t.hint=="string"?t.hint:"",suggestedName:typeof t.suggestedName=="string"?t.suggestedName:"",retryable:typeof t.retryable=="boolean"?t.retryable:!n,message:s||String(e&&e.message||e)}}const U2="modulepreload",W2=function(e){return"/"+e},q_={},K2=function(t,n,s){let o=Promise.resolve();if(n&&n.length>0){let u=function(m){return Promise.all(m.map(v=>Promise.resolve(v).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};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(n.map(m=>{if(m=W2(m),m in q_)return;q_[m]=!0;const v=m.endsWith(".css"),w=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${w}`))return;const y=document.createElement("link");if(y.rel=v?"stylesheet":U2,v||(y.as="script"),y.crossOrigin="",y.href=m,p&&y.setAttribute("nonce",p),document.head.appendChild(y),v)return new Promise((S,k)=>{y.addEventListener("load",S),y.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${m}`)))})}))}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 ct{constructor(t,n,s,o,a){this._legacyCanvasSize=ct.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=t,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||o||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=n),n=typeof s=="object"?s:{},this._onDecodeError=n.onDecodeError||(typeof s=="function"?s:this._onDecodeError),this._calculateScanRegion=n.calculateScanRegion||(typeof o=="function"?o:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof o=="number"?o:this._legacyCanvasSize,this._maxScansPerSecond=n.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),t.disablePictureInPicture=!0,t.playsInline=!0,t.muted=!0;let u=!1;if(t.hidden&&(t.hidden=!1,u=!0),document.body.contains(t)||(document.body.appendChild(t),u=!0),s=t.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(o=!!n.overlay,this.$overlay=n.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&&n.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}s.insertBefore(this.$overlay,this.$video.nextSibling)}n.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(t),requestAnimationFrame(()=>{let 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=ct.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 ct.listCameras(!1)).length}catch{return!1}}static async listCameras(t=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(o=>o.kind==="videoinput"),s;try{t&&(await n()).every(o=>!o.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((o,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"),ct._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"),ct._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(),ct._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:t,facingMode:n}=await this._getCameraStream();!this._active||this._paused?ct._stopVideoStream(t):(this._setVideoMirror(n),this.$video.srcObject=t,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(t){if(!this._paused)throw this._active=!1,t}}stop(){this.pause(),this._active=!1}async pause(t=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let n=()=>{this.$video.srcObject instanceof MediaStream&&(ct._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return t?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(t){t!==this._preferredCamera&&(this._preferredCamera=t,await this._restartVideoStream())}static async scanImage(t,n,s,o,a=!1,u=!1){let h,p=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(h=n.scanRegion,s=n.qrEngine,o=n.canvas,a=n.disallowCanvasResizing||!1,u=n.alsoTryWithoutScanRegion||!1,p=!0):console.warn(n||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."),n=!!s;try{let m,v;[s,m]=await Promise.all([s||ct.createQrEngine(),ct._loadImage(t)]),[o,v]=ct._drawToCanvas(m,h,o,a);let w;if(s instanceof Worker){let y=s;n||ct._postWorkerMessageSync(y,"inversionMode","both"),w=await new Promise((S,k)=>{let E,b,j,N=-1;b=D=>{D.data.id===N&&(y.removeEventListener("message",b),y.removeEventListener("error",j),clearTimeout(E),D.data.data!==null?S({data:D.data.data,cornerPoints:ct._convertPoints(D.data.cornerPoints,h)}):k(ct.NO_QR_CODE_FOUND))},j=D=>{y.removeEventListener("message",b),y.removeEventListener("error",j),clearTimeout(E),k("Scanner error: "+(D?D.message||D:"Unknown Error"))},y.addEventListener("message",b),y.addEventListener("error",j),E=setTimeout(()=>j("timeout"),1e4);let z=v.getImageData(0,0,o.width,o.height);N=ct._postWorkerMessageSync(y,"decode",z,[z.data.buffer])})}else w=await Promise.race([new Promise((y,S)=>window.setTimeout(()=>S("Scanner error: timeout"),1e4)),(async()=>{try{var[y]=await s.detect(o);if(!y)throw ct.NO_QR_CODE_FOUND;return{data:y.rawValue,cornerPoints:ct._convertPoints(y.cornerPoints,h)}}catch(S){if(y=S.message||S,/not implemented|service unavailable/.test(y))return ct._disableBarcodeDetector=!0,ct.scanImage(t,{scanRegion:h,canvas:o,disallowCanvasResizing:a,alsoTryWithoutScanRegion:u});throw`Scanner error: ${y}`}})()]);return p?w:w.data}catch(m){if(!h||!u)throw m;let v=await ct.scanImage(t,{qrEngine:s,canvas:o,disallowCanvasResizing:a});return p?v:v.data}finally{n||ct._postWorkerMessage(s,"close")}}setGrayscaleWeights(t,n,s,o=!0){ct._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:t,green:n,blue:s,useIntegerApproximation:o})}setInversionMode(t){ct._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=()=>K2(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!ct._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return t();let n=navigator.userAgentData;return n&&n.brands.some(({brand:s})=>/Chromium/i.test(s))&&/mac ?OS/i.test(n.platform)&&await n.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:s,platformVersion:o})=>/arm/i.test(s||"arm")&&13<=parseInt(o||"13")).catch(()=>!0)?t():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(t){let n=Math.round(.6666666666666666*Math.min(t.videoWidth,t.videoHeight));return{x:Math.round((t.videoWidth-n)/2),y:Math.round((t.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var t=this.$video,n=t.videoWidth,s=t.videoHeight,o=t.offsetWidth,a=t.offsetHeight,u=t.offsetLeft,h=t.offsetTop,p=window.getComputedStyle(t),m=p.objectFit,v=n/s,w=o/a;switch(m){case"none":var y=n,S=s;break;case"fill":y=o,S=a;break;default:(m==="cover"?v>w:v<w)?(S=a,y=S*v):(y=o,S=y/v),m==="scale-down"&&(y=Math.min(y,n),S=Math.min(S,s))}var[k,E]=p.objectPosition.split(" ").map((j,N)=>{const z=parseFloat(j);return j.endsWith("%")?(N?a-S:o-y)*z/100:z});p=this._scanRegion.width||n,w=this._scanRegion.height||s,m=this._scanRegion.x||0;var b=this._scanRegion.y||0;v=this.$overlay.style,v.width=`${p/n*y}px`,v.height=`${w/s*S}px`,v.top=`${h+E+b/s*S}px`,s=/scaleX\(-1\)/.test(t.style.transform),v.left=`${u+(s?o-k-y:k)+(s?n-m-p:m)/n*y}px`,v.transform=t.style.transform}})}static _convertPoints(t,n){if(!n)return t;let s=n.x||0,o=n.y||0,a=n.width&&n.downScaledWidth?n.width/n.downScaledWidth:1;n=n.height&&n.downScaledHeight?n.height/n.downScaledHeight:1;for(let u of t)u.x=u.x*a+s,u.y=u.y*n+o;return t}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var t=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;t<n&&await new Promise(o=>setTimeout(o,n-t)),this._lastScanTimestamp=Date.now();try{var s=await ct.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(o){if(!this._active)return;this._onDecodeError(o)}!ct._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=ct.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!==ct.NO_QR_CODE_FOUND&&console.log(t)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let t=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(o=>Object.assign({},o,{[t]:{exact:this._preferredCamera}}));for(let o of[...s,...n])try{let 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 n of t.getTracks())n.stop(),t.removeTrack(n)}_setVideoMirror(t){this.$video.style.transform="scaleX("+(t==="user"?-1:1)+")"}_getFacingMode(t){return(t=t.getVideoTracks()[0])?/rear|back|environment/i.test(t.label)?"environment":/front|user|face/i.test(t.label)?"user":null:null}static _drawToCanvas(t,n,s,o=!1){s=s||document.createElement("canvas");let a=n&&n.x?n.x:0,u=n&&n.y?n.y:0,h=n&&n.width?n.width:t.videoWidth||t.width,p=n&&n.height?n.height:t.videoHeight||t.height;return o||(o=n&&n.downScaledWidth?n.downScaledWidth:h,n=n&&n.downScaledHeight?n.downScaledHeight:p,s.width!==o&&(s.width=o),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(t,a,u,h,p,0,0,s.width,s.height),[s,n]}static async _loadImage(t){if(t instanceof Image)return await ct._awaitImageLoad(t),t;if(t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof SVGImageElement||"OffscreenCanvas"in window&&t instanceof OffscreenCanvas||"ImageBitmap"in window&&t instanceof ImageBitmap)return t;if(t instanceof File||t instanceof Blob||t instanceof URL||typeof t=="string"){let n=new Image;n.src=t instanceof File||t instanceof Blob?URL.createObjectURL(t):t.toString();try{return await ct._awaitImageLoad(n),n}finally{(t instanceof File||t instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(t){t.complete&&t.naturalWidth!==0||await new Promise((n,s)=>{let o=a=>{t.removeEventListener("load",o),t.removeEventListener("error",o),a instanceof ErrorEvent?s("Image load error"):n()};t.addEventListener("load",o),t.addEventListener("error",o)})}static async _postWorkerMessage(t,n,s,o){return ct._postWorkerMessageSync(await t,n,s,o)}static _postWorkerMessageSync(t,n,s,o){if(!(t instanceof Worker))return-1;let a=ct._workerMessageId++;return t.postMessage({id:a,type:n,data:s},o),a}}ct.DEFAULT_CANVAS_SIZE=400;ct.NO_QR_CODE_FOUND="No QR code found";ct._disableBarcodeDetector=!1;ct._workerMessageId=0;function q2({onResult:e,onClose:t}){const n=C.useRef(null),s=C.useRef(null),o=C.useRef(!1),[a,u]=C.useState("");C.useEffect(()=>{let p=!1;const m=n.current,v=w=>{p||o.current||(o.current=!0,e(w))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){u(f("qr-unsupported"));return}let w=!1;try{w=await ct.hasCamera()}catch{w=!1}if(!w){u(f("qr-no-camera"));return}if(p||!m)return;const y=new ct(m,S=>{const k=W_(S);k&&v(k)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:S=>{const k=S.videoWidth||640,E=S.videoHeight||480,b=Math.max(1,Math.round(Math.min(k,E)*.92));return{x:Math.round((k-b)/2),y:Math.round((E-b)/2),width:b,height:b,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=y;try{await y.start()}catch(S){if(p)return;const k=S&&S.name||"";u(f(k==="NotAllowedError"||k==="SecurityError"?"qr-permission":k==="NotFoundError"||k==="OverconstrainedError"||k==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{p=!0;const w=s.current;if(w){try{w.stop()}catch{}try{w.destroy()}catch{}s.current=null}const y=m,S=y&&y.srcObject;if(S&&typeof S.getTracks=="function"){for(const k of S.getTracks())try{k.stop()}catch{}try{y.srcObject=null}catch{}}}},[]);const h=async p=>{const m=p.target.files&&p.target.files[0];if(p.target.value="",!!m)try{const v=await ct.scanImage(m,{returnDetailedScanResult:!0}),w=W_(v);if(!w)throw new Error("empty");o.current||(o.current=!0,e(w))}catch{u(f("pairing-qr-invalid"))}};return l.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:t,children:l.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:p=>p.stopPropagation(),children:[l.jsx("div",{className:"nc-sheet-head",children:l.jsx("b",{children:f("scan-qr")})}),l.jsx("video",{ref:n,className:"nc-qr-video",playsInline:!0,muted:!0}),a&&l.jsx("div",{className:"nc-err",role:"alert",children:a}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsxs("label",{className:"nc-btn ghost nc-qr-upload",children:[f("qr-upload"),l.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:h})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:t,children:f("cancel")})]})]})})}function qf({line:e,note:t}){const[n,s]=C.useState(!1);return e?l.jsxs("div",{className:"nc-authkeys",role:"group",children:[l.jsx("div",{className:"nc-sheet-label",children:f("pair-authkeys-title")}),l.jsx("small",{className:"nc-set-hint",children:t||f("pair-authkeys-hint")}),l.jsx("textarea",{className:"nc-authkeys-line",readOnly:!0,rows:3,value:e,"aria-label":f("pair-authkeys-title"),onFocus:o=>o.target.select()}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:async()=>{s(await $h(e))},children:f(n?"pair-authkeys-copied":"pair-authkeys-copy")})]}):null}const V_=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function vb({token:e,initial:t="",autoStart:n=!1,deviceDefault:s="",localNodeId:o="",localNameDefault:a="",readonly:u=!1,onSuccess:h,onBusyChange:p}){const[m,v]=C.useState(V_),[w,y]=C.useState(!1),[S,k]=C.useState(!1),[E,b]=C.useState("idle"),[j,N]=C.useState(null),[z,D]=C.useState(""),[U,W]=C.useState(null),[K,te]=C.useState(!1),[G,Q]=C.useState(!1),q=C.useRef($2()),F=C.useRef(new Set),R=E==="busy",B=Il(m.localLabel||s,o)||a,$=G?m.localName:B;C.useEffect(()=>(p&&p(R),()=>{p&&p(!1)}),[R,p]);const L=async O=>{const H=String(O.pairingUrl||"").trim();if(q.current.start(H)){b("busy"),N(null),D("");try{const se=await tx(e,z2({...O,localName:G?O.localName:Il(O.localLabel||s,o)||a},{deviceDefault:s,localNodeId:o,localNameDefault:a}));b("ok"),y(!1),v(V_()),W(se&&se.authorizedKeys?{line:se.authorizedKeys,note:se.authorizedKeysNote||""}:null),F.current=new Set,te(!1),Q(!1),q.current.finish(),h&&await h(se)}catch(se){const ee=H2(se);N(ee),b("idle"),q.current.finish(),ee.code==="peer-name-conflict"&&eh(ee.suggestedName)&&(Q(!0),F.current.add("localName"),v(le=>({...le,localName:ee.suggestedName}))),(ee.stage==="validation"||ee.stage==="conflict"||ee.stage==="ssh-start"||ee.stage==="ssh-ready"||String(ee.code||"").startsWith("ssh-"))&&y(!0)}}},A=(O,H=!0)=>{const{classification:se,form:ee}=K_(m,O,F.current,K),le=ee.pairingUrl;if(N(null),D(""),E==="ok"&&b("idle"),v(ee),se.kind==="invalid"){N({stage:"validation",code:"bad-link",message:f("pair-invalid-link"),hint:f("pair-invalid-hint"),retryable:!0});return}if(se.kind==="partial"){y(!0),D(se.missing.includes("ssh")?f("pair-missing-ssh"):f("pair-missing-name"));return}se.kind==="complete"&&H&&!u&&q.current.canAuto(le)&&L(ee)};C.useEffect(()=>{t&&A(t,n)},[]);const x=()=>{const O=String(m.pairingUrl||"").trim(),{classification:H,form:se}=K_(m,O,F.current,K);if(v(se),D(""),N(null),H.kind==="empty"){N({stage:"validation",message:f("pairing-required"),retryable:!0});return}if(H.kind==="invalid"){N({stage:"validation",code:"bad-link",message:f("pair-invalid-link"),hint:f("pair-invalid-hint"),retryable:!0});return}if(!se.ssh||!se.name){y(!0),D(se.ssh?f("pair-missing-name"):f("pair-missing-ssh"));return}if(se.label&&!$r(se.label)){N({stage:"validation",message:f("err-label"),retryable:!0});return}if(se.localLabel&&!$r(se.localLabel)){N({stage:"validation",message:f("err-label"),retryable:!0});return}const ee=G?se.localName:Il(se.localLabel||s,o)||a;if(!eh(ee)||ee==="localhost"){y(!0),N({stage:"validation",code:"bad-local-name",message:f("err-local-name"),retryable:!0});return}q.current.reset(O),L(se)},I=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const O=await navigator.clipboard.readText();O&&O.trim()?A(O):D(f("pair-clipboard-empty"))}catch{D(f("pair-clipboard-denied"))}},T=(O,H)=>{F.current.add(O),v(se=>({...se,[O]:H}))},M=j&&j.stage&&(F2.includes(j.stage)||j.stage==="internal")?f(`pair-stage-${j.stage}`):f("pair-stage-generic");return l.jsxs("div",{className:"nc-set-form nc-pair-card",children:[l.jsx("div",{className:"nc-sheet-label",children:f("pair-card-title")}),l.jsx("div",{className:"nc-set-info",children:f("pair-card-help")}),l.jsx("input",{className:"nc-pair-input",placeholder:f("pair-paste-ph"),value:m.pairingUrl,disabled:u||R,onChange:O=>{v({...m,pairingUrl:O.target.value}),N(null),D("")},onPaste:O=>{const H=O.clipboardData&&O.clipboardData.getData("text")||"";H.trim()&&(O.preventDefault(),A(H))},onKeyDown:O=>{O.key==="Enter"&&(O.preventDefault(),x())}}),l.jsxs("div",{className:"nc-pair-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||R,onClick:I,children:f("pair-paste-btn")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||R,onClick:()=>k(!0),children:f("scan-qr")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||R,title:u?f("settings-readonly"):"",onClick:x,children:f("test-and-connect")})]}),l.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[R&&l.jsx("div",{className:"nc-pair-progress",children:f("pair-progress")}),E==="ok"&&l.jsx("div",{className:"nc-set-test ok",children:f("node-connected")}),E==="ok"&&U&&l.jsx(qf,{line:U.line,note:U.note}),z&&l.jsx("div",{className:"nc-set-hint nc-pair-notice",children:z}),j&&l.jsxs("div",{className:"nc-err",role:"alert",children:[l.jsx("b",{children:M})," — ",j.message,j.hint&&l.jsx("div",{className:"nc-pair-hint",children:j.hint}),j.retryable&&l.jsx("div",{children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u||R,onClick:x,children:f("pair-retry")})})]})]}),l.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:R,onClick:()=>y(O=>!O),children:[w?"▾":"▸"," ",f("pair-advanced")]}),w&&l.jsxs("div",{className:"nc-pair-advanced",children:[l.jsxs("label",{className:"nc-field",children:[f("node-display-label"),l.jsx("input",{placeholder:"Home Relay",value:m.label,disabled:u||R,onChange:O=>{F.current.add("label"),v(H=>({...H,label:O.target.value,name:K?H.name:Rs(O.target.value)}))}})]}),l.jsxs("label",{className:"nc-field",children:[f("node-name-label"),l.jsx("input",{placeholder:f("node-name-ph"),value:m.name,disabled:u||R,onChange:O=>{te(!0),F.current.add("name"),v(H=>({...H,name:O.target.value?Rs(O.target.value):""}))}})]}),l.jsx("small",{className:"nc-set-hint",children:f("node-slug-hint").replace("{slug}",m.name||"home-relay")}),l.jsxs("label",{className:"nc-field",children:[f("pair-ssh-local-label"),l.jsx("input",{placeholder:"my-relay",value:m.ssh,disabled:u||R,onChange:O=>{F.current.add("ssh"),T("ssh",O.target.value)}}),l.jsx("small",{className:"nc-set-hint",children:f("node-ssh-local-help")})]}),l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:f("node-ssh-port-help"),value:m.sshPort,disabled:u||R,onChange:O=>T("sshPort",O.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),l.jsxs("label",{className:"nc-field",children:[f("device-name-label"),l.jsx("input",{placeholder:s||"NexusCrew",value:m.localLabel,disabled:u||R,onChange:O=>T("localLabel",O.target.value)}),l.jsx("small",{className:"nc-set-hint",children:f("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[f("local-route-name-label"),l.jsx("input",{placeholder:B||"nexuscrew-5bd6",value:$,disabled:u||R,onChange:O=>{Q(!0),F.current.add("localName"),v(H=>({...H,localName:O.target.value?Rs(O.target.value):""}))}}),l.jsx("small",{className:"nc-set-hint",children:f("local-route-name-hint")})]})]}),S&&l.jsx(q2,{onResult:O=>{k(!1),A(O)},onClose:()=>k(!1)})]})}const Ai={routed:"peer-routed",routedStale:"peer-routed-stale",up:"tunnel-up",down:"tunnel-down",passive:"node-connected-client",vlOnline:"vl-poll-online",vlOffline:"vl-poll-offline"};function Vf(e){if(!e||typeof e!="object")return{key:Ai.down,up:!1};if(e.kind==="vl")return e.online?{key:Ai.vlOnline,up:!0}:{key:Ai.vlOffline,up:!1};if(e.kind==="transitive"){const n=e.stale===!0;return{key:n?Ai.routedStale:Ai.routed,up:!n,routed:!0}}const t=e.tunnel&&e.tunnel.status;return t==="up"?{key:Ai.up,up:!0}:t==="passive"?{key:Ai.passive,up:!1,passive:!0}:{key:Ai.down,up:!1}}function _b(e){if(!e||typeof e!="object")return{key:"peer-private",shortKey:"row-private",shared:!1};if(e.kind==="vl")return{key:"peer-vl-federated",shortKey:"row-vl-federated",shared:!0};if(e.shared!==!0)return{key:"peer-private",shortKey:"row-private",shared:!1};const t=e.visibility||"network";if(t==="relay-only")return{key:"visibility-relay",shortKey:"visibility-relay",shared:!0,visibility:t};if(t==="selected"){const n=Array.isArray(e.selected)?e.selected.length:0;return{key:"visibility-selected",shortKey:"visibility-selected",shared:!0,visibility:t,count:n}}return{key:"visibility-network",shortKey:"visibility-network",shared:!0,visibility:t}}function V2(e){const n=e.health&&typeof e.health.detail=="string"&&e.health.detail.trim()||f(e.online?Ai.vlOnline:Ai.vlOffline);return e.ownerLabel?`${e.ownerLabel} · ${n}`:n}function Y2(e){if(!e||typeof e!="object")return null;const t=typeof e.name=="string"?e.name:"";if(!t)return null;const n=e.kind==="transitive";return{name:t,title:typeof e.label=="string"&&e.label.trim()||t,subtitle:e.kind==="vl"?V2(e):t,reach:Vf(e),exposure:_b(e),routed:n,routeLabel:n&&Array.isArray(e.route)?e.route.join(" › "):null}}function G2(e){if(!e||typeof e!="object"||typeof e.name!="string"||!e.name)return null;const t=e.kind==="transitive";return{name:e.name,title:typeof e.label=="string"&&e.label.trim()||e.name,routed:t,route:t&&Array.isArray(e.route)?[...e.route]:null,ssh:!t&&e.direction==="outbound"&&e.ssh?String(e.ssh):null,inbound:!t&&e.direction==="inbound",transport:e.tunnel&&typeof e.tunnel.transport=="string"&&e.tunnel.transport||null}}function X2(e){return!e||typeof e!="object"?null:e.kind==="transitive"?{key:"authority-routed",ownerEquivalent:!1,grants:[],model:"none"}:{key:"authority-owner-equivalent",ownerEquivalent:!0,grants:[],model:"none"}}function Q2(e,t){if(!e||e.visibility!=="selected")return[];const n=[...new Set(Array.isArray(e.selected)?e.selected:[])],s=new Map;for(const o of Array.isArray(t)?t:[])o&&o.nodeId&&!s.has(o.nodeId)&&s.set(o.nodeId,o);return n.map(o=>{const a=s.get(o);return{id:o,label:a?typeof a.label=="string"&&a.label.trim()||a.name:o,known:!!a}})}function J2(e,t,n=""){if(!e)return[];const s=new Set(Array.isArray(e.selected)?e.selected:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[],h=p=>e.nodeId?p.nodeId===e.nodeId:p.name===e.name;for(const p of Array.isArray(t)?t:[]){if(!p||!p.nodeId||h(p)||s.has(p.nodeId)||a.has(p.nodeId))continue;const m=typeof p.label=="string"&&p.label.trim()||p.name;o&&!`${m} ${p.name}`.toLowerCase().includes(o)||(a.add(p.nodeId),u.push({id:p.nodeId,label:m,name:p.name}))}return u.sort((p,m)=>p.label.localeCompare(m.label))}function Z2(e,{readonly:t=!1,busy:n=!1}={}){if(!e||typeof e!="object")return[];const s=e.actions&&typeof e.actions=="object"?e.actions:{},o=Vf(e).up,a=[],u=(h,p,{mutating:m=!0,danger:v=!1}={})=>{a.push({key:h,action:p,danger:v,disabled:n||m&&t})};return s.edit&&u("edit","edit"),s.test&&u("node-test","test",{mutating:!1}),s.disconnect&&o&&u("tunnel-stop","down"),s.connect&&!o&&u("tunnel-start","up"),s.restart&&u("tunnel-restart","restart"),s.remove&&u("delete","remove",{danger:!0}),a}function yb(e){const t=e&&typeof e.cellVisibility=="string"?e.cellVisibility:"all";return["all","none","selected"].includes(t)?t:"all"}function ej(e,t){if(yb(e)!=="selected")return[];const n=[...new Set(Array.isArray(e.cells)?e.cells:[])];if(!Array.isArray(t))return n.map(o=>({id:o,label:o,known:!0}));const s=new Set(t.map(o=>typeof o=="string"?o:o&&(o.cell||o.id)).filter(Boolean));return n.map(o=>({id:o,label:o,known:s.has(o)}))}function tj(e,t,n=""){const s=new Set(Array.isArray(e&&e.cells)?e.cells:[]),o=String(n||"").trim().toLowerCase(),a=new Set,u=[];for(const h of Array.isArray(t)?t:[]){const p=typeof h=="string"?h:h&&(h.cell||h.id);!p||s.has(p)||a.has(p)||o&&!p.toLowerCase().includes(o)||(a.add(p),u.push({id:p,label:p}))}return u.sort((h,p)=>h.label.localeCompare(p.label))}function nj(e,t,{readonly:n=!1,busy:s=!1}={}){const o=G2(e);return o?{identity:o,reach:Vf(e),authority:X2(e),exposure:_b(e),grants:Q2(e,t),cellScope:yb(e),actions:Z2(e,{readonly:n,busy:s}),canEditVisibility:!!(e.actions&&e.actions.visibility)&&e.shared===!0&&e.kind!=="transitive",canEditCellScope:!!(e.actions&&e.actions.edit)&&e.kind!=="transitive"}:null}const ij=new Set(["update_candidate"]),Y_=4096,sj=new Set(["prompt"]),G_={logs:{limit:50}};function rj(e){if(!e||e.kind!=="vl")return[];const t=Array.isArray(e.capabilities)?e.capabilities:[],n=new Set,s=[];for(const o of t)typeof o!="string"||!o||ij.has(o)||sj.has(o)||n.has(o)||(n.add(o),s.push(o));return s}function X_(e){return!!(e&&e.kind==="vl"&&Array.isArray(e.capabilities)&&e.capabilities.includes("prompt"))}function oj(e){return G_[e]?{...G_[e]}:{}}function aj(e,t){return e?e.inflight&&typeof e.inflight=="object"?{phase:"inflight",kind:e.inflight.kind}:t?e.lastAck&&e.lastAck.id===t.id?{phase:"done",kind:t.kind,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:{phase:"submitted",kind:t.kind}:e.lastAck&&typeof e.lastAck=="object"?{phase:"done",kind:null,status:e.lastAck.status,result:e.lastAck.result,at:e.lastAck.at}:null:null}function lj({title:e,subtitle:t,status:n,footer:s,onClose:o,plain:a=!1,children:u}){const h=C.useRef(null),p=C.useRef(null);return C.useEffect(()=>(p.current=document.activeElement,h.current&&h.current.focus(),()=>{const m=p.current;m&&typeof m.focus=="function"&&document.contains(m)&&m.focus()}),[]),C.useEffect(()=>{const m=v=>{v.key==="Escape"&&(v.stopPropagation(),o&&o())};return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[o]),l.jsx("div",{className:"nc-detail-overlay",onMouseDown:m=>{m.target===m.currentTarget&&o&&o()},children:l.jsxs("div",{className:"nc-detail-sheet",ref:h,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof e=="string"?e:void 0,children:[l.jsxs("div",{className:"nc-detail-head",children:[l.jsxs("div",{className:"nc-detail-title",children:[l.jsx("b",{children:e}),t&&l.jsx("small",{children:t})]}),n,l.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:o,"aria-label":f("close"),children:l.jsx(at,{name:"x",size:14})})]}),l.jsx("div",{className:`nc-detail-body${a?" plain":""}`,children:u}),s&&l.jsx("div",{className:"nc-detail-foot",children:s})]})})}function Tr({title:e,hint:t,children:n}){return n==null||n===!1?null:l.jsxs("section",{className:"nc-detail-section",children:[e&&l.jsx("div",{className:"nc-sheet-label",children:e}),t&&l.jsx("small",{className:"nc-set-hint",children:t}),n]})}function cj({node:e,nodes:t,token:n,readonly:s,refresh:o,onClose:a}){var Ct,ye;$n();const[u,h]=C.useState(null),[p,m]=C.useState(null),[v,w]=C.useState(null),[y,S]=C.useState(null),[k,E]=C.useState(!1),[b,j]=C.useState(""),[N,z]=C.useState(!1),[D,U]=C.useState(null),[W,K]=C.useState(!1),[te,G]=C.useState(""),[Q,q]=C.useState(!1),[F,R]=C.useState(null),[B,$]=C.useState(!1),[L,A]=C.useState(""),x=C.useMemo(()=>nj(e,t,{readonly:s,busy:!!u}),[e,t,s,u]);if(!x)return null;const{identity:I,reach:T,authority:M,exposure:O,grants:H,actions:se,canEditVisibility:ee,canEditCellScope:le,cellScope:ve}=x,de=I.routed?{up:T.up,since:null}:th(e.tunnel,Date.now()),fe=async(ce,Le)=>{m(null),h(ce);try{await Le()}catch(qe){m(String(qe&&qe.message||qe))}h(null)},He=ce=>{if(ce==="edit"){S({label:e.label||e.name,ssh:e.ssh||"",sshPort:e.sshPort?String(e.sshPort):"",autostart:e.autostart===!0,visibility:e.visibility||"network"});return}if(ce==="remove"){E(!0);return}fe(`${e.name}:${ce}`,async()=>{const Le=await uf(n,e.name,ce);ce==="test"&&w(Le),await o()})},st=(ce,Le=oj(ce))=>fe(`${e.nodeId}:${ce}`,async()=>{const qe=await Mg(n,e.nodeId,ce,Le,e.route||[]);R({id:qe.id,kind:ce,submittedAt:Date.now()}),await o()}),lt=()=>{const ce=L.trim().slice(0,Y_);ce&&fe(`${e.nodeId}:prompt`,async()=>{const Le=await Mg(n,e.nodeId,"prompt",{text:ce},e.route||[]);R({id:Le.id,kind:"prompt",submittedAt:Date.now()}),A(""),$(!1),await o()})},Ee=()=>{if(!$r(y.label)){m(f("err-label"));return}const ce=I.inbound?{label:y.label,visibility:y.visibility,selected:y.visibility==="selected"?[...e.selected||[]]:[]}:{label:y.label,ssh:y.ssh,autostart:y.autostart,...y.sshPort?{sshPort:Number(y.sshPort)}:{}};return fe(`${e.name}:edit`,async()=>{await Og(n,e.name,ce),S(null),await o()})},xt=(ce,Le)=>fe(`${e.name}:visibility`,async()=>{await ax(n,e.name,ce,Le),await o()}),qt=ee&&e.visibility==="selected"?J2(e,t,b):[],ze=(ce,Le)=>fe(`${e.name}:cell-scope`,async()=>{await Og(n,e.name,ce==="selected"?{cellVisibility:ce,cells:Array.isArray(Le)?Le:e.cells||[]}:{cellVisibility:ce}),await o()}),Rt=async({retry:ce=!1}={})=>{if(ce&&W)K(!1);else if(D!==null||W)return;try{const Le=await ec(n);U(Array.isArray(Le&&Le.cells)?Le.cells:[])}catch{K(!0)}};C.useEffect(()=>{le&&ve==="selected"&&D===null&&Rt()},[le,ve,D]);const gt=ej(e,D),Mt=ve==="selected"?tj(e,D,te):[],ht=l.jsxs("span",{className:`nc-set-tunnel${T.up?" up":""}`,children:[f(T.key),de.since?` · ${de.since}`:""]}),bt=e.kind==="vl",Bt=bt?rj(e):[],kt=bt?aj(e,F):null,Dt=ce=>{const Le=`vl-cmd-${ce}`,qe=f(Le);return qe===Le?ce:qe},Lt=bt?[...Bt.map(ce=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u||s,title:s?f("settings-readonly"):void 0,onClick:()=>st(ce),children:Dt(ce)},ce)),...X_(e)?[l.jsx("button",{type:"button",className:`nc-btn ghost${B?" on":""}`,disabled:!!u||s,title:s?f("settings-readonly"):void 0,onClick:()=>$(ce=>!ce),children:Dt("prompt")},"prompt")]:[]]:se.map(ce=>l.jsx("button",{type:"button",className:`nc-btn ${ce.danger?"danger":"ghost"}`,disabled:ce.disabled,title:ce.disabled&&s?f("settings-readonly"):void 0,onClick:()=>He(ce.action),children:ce.action==="remove"?l.jsxs(l.Fragment,{children:[l.jsx(at,{name:"trash",size:14})," ",f(ce.key)]}):f(ce.key)},ce.action));return l.jsxs(lj,{title:I.title,subtitle:I.name,status:ht,footer:Lt,onClose:a,children:[l.jsxs(Tr,{title:f("node-detail-reach"),children:[l.jsxs("dl",{className:"nc-detail-facts",children:[I.route&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-route")}),l.jsx("dd",{children:I.route.join(" › ")})]}),I.ssh&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-ssh")}),l.jsxs("dd",{children:[I.ssh,e.sshPort?`:${e.sshPort}`:""]})]}),I.transport&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-transport")}),l.jsx("dd",{children:I.transport})]}),bt&&e.ownerLabel&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:f("node-detail-owner")}),l.jsx("dd",{children:e.ownerLabel})]})]}),((Ct=e.health)==null?void 0:Ct.detail)&&l.jsx("div",{className:`nc-set-test${bt?e.health.state==="running"?" ok":e.health.state==="starting"?"":" ko":e.health.status==="healthy"?" ok":e.health.status==="passive"?"":" ko"}`,children:e.health.detail}),(()=>{const ce=nk(e.health);return ce?ce.line?l.jsx(qf,{line:ce.line,note:ce.note}):l.jsx("small",{className:"nc-set-hint",children:ce.note}):null})(),v&&l.jsxs("div",{className:`nc-set-test${v.ok?" ok":" ko"}`,children:[v.result,v.detail?` — ${v.detail}`:""]})]}),bt&&l.jsxs(Tr,{title:f("node-detail-command"),children:[Bt.length===0&&!X_(e)&&l.jsx("small",{className:"nc-set-hint",children:f("vl-no-commands")}),B&&l.jsxs("div",{className:"nc-vl-prompt",children:[l.jsx("textarea",{value:L,maxLength:Y_,placeholder:f("vl-prompt-placeholder"),"aria-label":f("vl-prompt-placeholder"),disabled:!!u||s,onChange:ce=>A(ce.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u||s||!L.trim(),onClick:lt,children:f("vl-prompt-send")})]}),kt&&l.jsxs("div",{className:`nc-set-test${kt.phase==="done"?kt.status==="ok"?" ok":" ko":""}`,children:[kt.kind&&`${Dt(kt.kind)}: `,kt.phase==="submitted"&&f("vl-cmd-phase-submitted"),kt.phase==="inflight"&&f("vl-cmd-phase-inflight"),kt.phase==="done"&&f(kt.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),kt.phase==="done"&&((ye=kt.result)!=null&&ye.detail)?` — ${kt.result.detail}`:""]})]}),l.jsxs(Tr,{title:f("node-detail-authority"),children:[l.jsx("div",{className:"nc-set-info",children:f(M.key)}),M.grants.length===0&&l.jsx("small",{className:"nc-set-hint",children:f(le?"authority-no-grants":"authority-no-grants-elsewhere")})]}),l.jsxs(Tr,{title:f("node-detail-network-view"),children:[l.jsx("div",{className:"nc-set-info",children:f(bt?O.key:O.shared?"peer-shared":"peer-private")}),ee&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[f("peer-visibility"),l.jsxs("select",{value:e.visibility||"network",disabled:s||!!u,onChange:ce=>xt(ce.target.value),children:[l.jsx("option",{value:"network",children:f("visibility-network")}),l.jsx("option",{value:"relay-only",children:f("visibility-relay")}),l.jsx("option",{value:"selected",children:f("visibility-selected")})]})]}),e.visibility==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[H.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("node-grant-none")}),H.map(ce=>l.jsxs("div",{className:`nc-detail-grant${ce.known?"":" unknown"}`,children:[l.jsxs("span",{children:[ce.label,ce.known?"":` — ${f("node-grant-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>xt("selected",(e.selected||[]).filter(Le=>Le!==ce.id)),children:f("node-grant-remove")})]},ce.id)),!N&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>{z(!0),j("")},children:f("node-grant-add")}),N&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:b,placeholder:f("node-grant-search"),disabled:s||!!u,onChange:ce=>j(ce.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[qt.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("node-grant-no-candidates")}),qt.map(ce=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await xt("selected",[...e.selected||[],ce.id]),z(!1),j("")},children:ce.label},ce.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{z(!1),j("")},children:f("cancel")})]})]})]})]}),le&&l.jsxs(Tr,{title:f("cell-scope"),children:[l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-help")}),l.jsx("label",{className:"nc-field",children:l.jsxs("select",{value:ve,"aria-label":f("cell-scope"),disabled:s||!!u,onChange:ce=>{ce.target.value==="selected"&&Rt(),ze(ce.target.value)},children:[l.jsx("option",{value:"all",children:f("cell-scope-all")}),l.jsx("option",{value:"none",children:f("cell-scope-none")}),l.jsx("option",{value:"selected",children:f("cell-scope-selected")})]})}),ve==="selected"&>.length>0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-reset-warning")}),W&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-list-unavailable")}),ve==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[gt.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-none-granted")}),gt.map(ce=>l.jsxs("div",{className:`nc-detail-grant${ce.known?"":" unknown"}`,children:[l.jsxs("span",{children:[ce.label,ce.known?"":` — ${f("cell-scope-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>ze("selected",(e.cells||[]).filter(Le=>Le!==ce.id)),children:f("node-grant-remove")})]},ce.id)),!Q&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Rt({retry:!0}),q(!0),G("")},children:f("cell-scope-add")}),Q&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:te,placeholder:f("cell-scope-search"),disabled:s||!!u,onChange:ce=>G(ce.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[Mt.length===0&&l.jsx("small",{className:"nc-set-hint",children:f("cell-scope-no-candidates")}),Mt.map(ce=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await ze("selected",[...e.cells||[],ce.id]),q(!1),G("")},children:ce.label},ce.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{q(!1),G("")},children:f("cancel")})]})]})]}),y&&l.jsxs(Tr,{title:f("edit"),children:[l.jsxs("label",{className:"nc-field",children:[f("node-display-label"),l.jsx("input",{value:y.label,disabled:!!u,onChange:ce=>S({...y,label:ce.target.value})})]}),I.inbound?l.jsxs("label",{className:"nc-field",children:[f("peer-visibility"),l.jsxs("select",{value:y.visibility,disabled:!!u,onChange:ce=>S({...y,visibility:ce.target.value}),children:[l.jsx("option",{value:"network",children:f("visibility-network")}),l.jsx("option",{value:"relay-only",children:f("visibility-relay")}),l.jsx("option",{value:"selected",children:f("visibility-selected")})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[f("node-ssh-label"),l.jsx("input",{value:y.ssh,disabled:!!u,onChange:ce=>S({...y,ssh:ce.target.value})})]}),l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",value:y.sshPort,disabled:!!u,onChange:ce=>S({...y,sshPort:ce.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:y.autostart,disabled:!!u,onChange:ce=>S({...y,autostart:ce.target.checked})})," ",f("boot-persist")]})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u,onClick:Ee,children:f("save")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>S(null),children:f("cancel")})]})]}),k&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("b",{children:f("node-remove-confirm").replace("{name}",I.title)}),l.jsx("small",{children:f("node-remove-warning")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!u,onClick:()=>fe(`${e.name}:remove`,async()=>{await rx(n,e.name),E(!1),await o(),a&&a()}),children:f("delete")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>E(!1),children:f("cancel")})]})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function Yf(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function uj(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),o=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)o[a]=s.charCodeAt(a);return o}async function dj(){if(!Yf())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function hj(e){if(!Yf())throw new Error("push-unsupported");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await en("/api/push/vapid",e),{publicKey:s}=await n.json();if(!s)throw new Error("vapid non disponibile");const a=await(await navigator.serviceWorker.ready).pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:uj(s)}),u=await en("/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 fj(e){if(!Yf())return!1;const n=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!n)return!1;const s=n.endpoint;try{await n.unsubscribe()}catch{}try{await en("/api/push/subscribe",e,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const Gh="nexuscrew.fleet",wb=3,pj="nexuscrew.cells",bb=/^[A-Za-z0-9._-]{1,32}$/,dc=/^[a-z0-9._-]{1,32}$/,Sb=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,xb=new Set(["standard","unsafe"]),mj=4096,gj=4096,Zl=256,kb=8192,vj=4096,_j=32,yj=64,wj=24,bj=new Set(["format","version","exportedAt","cells","engines","models"]),Sj=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label","mcp"]),xj=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function Gs(e){if(typeof e!="string"||e.length>gj)return null;for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);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 n of e.split("/"))if(!(n===""||n===".")){if(n==="..")return null;t.push(n)}return t.join("/")}const kj=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag","panelUrl"]),Cj=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]),Ej=new Set(["127.0.0.1","localhost","[::1]"]);function Gf(e){if(typeof e!="string"||!e||e.length>512||/[\x00-\x1f\x7f]|\s/.test(e))return!1;let t;try{t=new URL(e)}catch{return!1}return!(t.protocol!=="http:"&&t.protocol!=="https:"||!Ej.has(t.hostname))}function Gi(e,t){return typeof e=="string"&&e.length<=t&&!/[\x00-\x1f\x7f]/.test(e)}function Xf(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 Xo(e,t){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))return null;const n=Object.entries(e);if(n.length>128)return null;const s={};for(const[o,a]of n){if(!dc.test(o)||!t(a))return null;s[o]=a}return s}function Cb(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(h=>!Sj.has(h))||!bb.test(String(e.id||""))||typeof e.cwdRel!="string")return null;const t=Gs(e.cwdRel);if(t===null||!dc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Zl)||e.systemPrompt!==void 0&&e.prompt!==void 0&&e.systemPrompt!==e.prompt)return null;const n=e.systemPrompt===void 0?e.prompt===void 0?"":e.prompt:e.systemPrompt;if(typeof n!="string"||n.length>kb)return null;const s=Xo(e.models,h=>typeof h=="string"&&!!h&&h.length<=Zl),o=Xo(e.permissionPolicies,h=>xb.has(h)),a=Xo(e.commands,h=>Gi(h,vj)&&!Xf(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:n};if(e.model&&(u.model=e.model),e.label!==void 0){if(!Gi(e.label,yj)||!String(e.label).trim())return null;u.label=String(e.label).trim()}return Object.keys(s).length&&(u.models=s),Object.keys(o).length&&(u.permissionPolicies=o),Object.keys(a).length&&(u.commands=a),u}function Nj(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(a=>!xj.has(a))||!bb.test(String(e.id||""))||typeof e.cwd!="string"||!e.cwd||e.cwd.length>mj||!dc.test(String(e.engine||""))||e.boot!==void 0&&typeof e.boot!="boolean"||e.model!==void 0&&(typeof e.model!="string"||e.model.length>Zl)||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>kb)return null;const n=Xo(e.models,a=>typeof a=="string"&&!!a&&a.length<=Zl),s=Xo(e.permissionPolicies,a=>xb.has(a));if(n===null||s===null)return null;const o={id:e.id,cwd:e.cwd,engine:e.engine,boot:e.boot===!0,systemPrompt:t};return e.model&&(o.model=e.model),Object.keys(n).length&&(o.models=n),Object.keys(s).length&&(o.permissionPolicies=s),o}function jj(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(n=>!Cj.has(n)))return null;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"||!Gi(s,n==="baseUrl"?512:128)||Xf(s))return null;t[n]=s}return!t.client||!t.provider||t.envKey&&!Sb.test(t.envKey)?null:t}function Eb(e){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(s=>!kj.has(s))||!dc.test(String(e.id||""))||!Gi(e.label||e.id,64)||e.rc!==void 0&&typeof e.rc!="boolean"||e.panelUrl!==void 0&&!Gf(e.panelUrl))return null;const t={id:e.id,label:e.label||e.id,rc:e.rc===!0};if(e.panelUrl!==void 0&&(t.panelUrl=e.panelUrl),e.managed!==void 0){const s=jj(e.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(o=>e[o]!==void 0)?null:(t.managed=s,t)}if(!Gi(e.command,512)||!e.command.startsWith("/")||!Array.isArray(e.args)||e.args.length>32||e.args.some(s=>!Gi(s,1024)||Xf(s))||e.promptMode!=="flag"&&e.promptMode!=="send-keys"||e.promptMode==="flag"&&(!Gi(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")||!Gi(e.model.flag,32)||/\s/.test(e.model.flag)||!Gi(e.model.value||"",128))return null;t.model={flag:e.model.flag,value:e.model.value||""}}const n=e.envKeys===void 0?[]:e.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!Sb.test(s))?null:(Object.assign(t,{command:e.command,args:[...e.args],envKeys:[...new Set(n)].sort(),promptMode:e.promptMode}),e.promptMode==="flag"&&(t.promptFlag=e.promptFlag),t)}function Nb(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,...e.panelUrl!==void 0?{panelUrl:e.panelUrl}:{}}:{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,...e.panelUrl!==void 0?{panelUrl:e.panelUrl}:{}},n=Eb(t);return n||null}function Rj(e,t,n){const s=new Set;for(const o of Array.isArray(t)?t:[]){if(!n.has(o.id)||!o.managed)continue;const{client:a,provider:u,credentialProfile:h}=o.managed;s.add(h?`${a}.${u}-${h}`:`${a}.${u}`),s.add(`${a}.${u}`)}return(Array.isArray(e)?e:[]).filter(o=>o&&s.has(o.engine))}function Pj(e,t,n=[],s=[],o=new Date,a=[]){n instanceof Date&&(o=n,n=[],s=[]);const u=t instanceof Set?t:new Set(t||[]),h=s instanceof Set?s:new Set(s||[]),p=[];for(const w of Array.isArray(e)?e:[]){if(!u.has(w.id))continue;const y=Cb({id:w.id,cwdRel:w.cwdRel,engine:w.engine,boot:w.boot===!0,...w.label?{label:w.label}:{},...w.model?{model:w.model}:{},...w.models?{models:w.models}:{},...w.permissionPolicies?{permissionPolicies:w.permissionPolicies}:{},systemPrompt:w.prompt||"",...w.commands?{commands:w.commands}:{}});if(!y)return{ok:!1,error:"invalid-cell",invalidCellIds:[w.id]};p.push(y)}const m=[];for(const w of Array.isArray(n)?n:[]){if(!h.has(w.id))continue;const y=Nb(w);y&&m.push(y)}const v=Rj(a,n,h);return{format:Gh,version:wb,exportedAt:o.toISOString(),cells:p,engines:m,...v.length?{models:v}:{}}}function Aj(e){let t;try{t=JSON.parse(String(e||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(t==null?void 0:t.format)===pj&&(t==null?void 0:t.version)===1,s=(t==null?void 0:t.format)===Gh&&(t==null?void 0:t.version)===2,o=(t==null?void 0:t.format)===Gh&&(t==null?void 0:t.version)===wb,a=n||s,u=s||o;if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(y=>!bj.has(y))||!n&&!s&&!o||!Array.isArray(t.cells)||t.cells.length>_j||u&&(!Array.isArray(t.engines)||t.engines.length>wj))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const h=[],p=new Set;for(const y of t.cells){const S=a?Nj(y):Cb(y);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 m=[],v=new Set;for(const y of u?t.engines:[]){const S=Eb(y);if(!S)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(v.has(S.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};v.add(S.id),m.push(S)}const w=[];if(t.models!==void 0){if(!Array.isArray(t.models)||t.models.length>64)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const y=new Set;for(const S of t.models){if(!S||typeof S!="object"||Array.isArray(S))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const k=new Set(["id","engine","label","contextWindow","maxTokens","reasoning"]);if(Object.keys(S).some(N=>!k.has(N)))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const E=typeof S.id=="string"?S.id.trim():"",b=typeof S.engine=="string"?S.engine.trim():"";if(!E||!b)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const j=`${b}::${E}`;if(y.has(j))return{ok:!1,error:"duplicate-model",cells:[],engines:[]};y.add(j),w.push({...S,id:E,engine:b})}}return{ok:!0,cells:h,engines:m,models:w,legacy:a,exportedAt:typeof t.exportedAt=="string"?t.exportedAt:""}}function Lj(e,t,n){const s=new Set(n||[]);if(!s.has(t))return null;const o=m=>Object.fromEntries(Object.entries(m||{}).filter(([v])=>s.has(v))),a={id:e.id,engine:t,boot:e.boot===!0,prompt:e.systemPrompt||""};typeof e.label=="string"&&e.label&&(a.label=e.label),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 Tj=()=>({kind:"managed",id:"claude.native",label:"",client:"claude",provider:"native",credentialProfile:"",managedModel:"",permissionPolicy:"unsafe",credentialSourcePolicy:"auto",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,panelUrl:""}),Q_=(e="")=>({id:"",cwd:"",engine:e,boot:!1,label:"",model:"",prompt:"",commands:{},command:"",panelUrl:""}),jb=e=>e==="claude"?"unsafe":"standard",ta=(e,t)=>e.find(n=>n.client===t.client&&n.provider===t.provider&&(n.credentialProfile||"")===(t.credentialProfile||"")),Mj=(e,t)=>{var n;return((n=ta(e,t))==null?void 0:n.label)||`${t.client} · ${t.provider}`};function Dj(e){var t,n,s,o,a,u,h,p,m,v,w,y,S,k,E;return{kind:e.managed?"managed":"custom",id:e.id,label:e.label||"",command:e.command||"",argsText:(e.args||[]).join(`
|
|
89
|
+
`),rc:!!e.rc,client:((t=e.managed)==null?void 0:t.client)||"claude",provider:((n=e.managed)==null?void 0:n.provider)||"native",credentialProfile:((s=e.managed)==null?void 0:s.credentialProfile)||"",managedModel:((o=e.managed)==null?void 0:o.model)||"",permissionPolicy:((a=e.managed)==null?void 0:a.permissionPolicy)||jb((u=e.managed)==null?void 0:u.client),credentialSourcePolicy:((h=e.managed)==null?void 0:h.credentialSourcePolicy)||"auto",displayName:((p=e.managed)==null?void 0:p.displayName)||"",protocol:((m=e.managed)==null?void 0:m.protocol)||"",baseUrl:((v=e.managed)==null?void 0:v.baseUrl)||"",envKey:((w=e.managed)==null?void 0:w.envKey)||"",providerId:((y=e.managed)==null?void 0:y.providerId)||"nexuscrew-custom",modelOptions:e.availableModels||((S=e.managedInfo)==null?void 0:S.models)||[],promptMode:e.promptMode||"send-keys",promptFlag:e.promptFlag||"",modelFlag:((k=e.model)==null?void 0:k.flag)||"",modelValue:((E=e.model)==null?void 0:E.value)||"",envRows:(e.envKeys||[]).map(b=>({key:b,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,panelUrl:e.panelUrl||""}}function J_(e,t,n){const s=(t.panelUrl||"").trim();return n?s&&(e.panelUrl=s):e.panelUrl=s||null,e}function Ij(e,t,n=[]){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||jb(e.client)};e.credentialProfile&&(o.credentialProfile=e.credentialProfile),e.credentialSourcePolicy&&e.credentialSourcePolicy!=="auto"&&(o.credentialSourcePolicy=e.credentialSourcePolicy);const a=ta(n,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}),J_({...t?{id:e.id}:{},label:e.label||Mj(n,e),rc:!!e.rc,managed:o},e,t)}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]))),J_(s,e,t)}function ks({children:e,onClose:t,label:n,error:s=""}){const o=C.useRef(null),a=C.useRef(null),u=C.useRef(t);return u.current=t,C.useEffect(()=>{const h=document.activeElement,p=o.current,m=()=>Array.from((p==null?void 0:p.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(y=>y.offsetParent!==null),v=requestAnimationFrame(()=>{var y;return(y=m()[0]||p)==null?void 0:y.focus({preventScroll:!0})}),w=y=>{var b;if(y.key==="Escape"){y.preventDefault(),(b=u.current)==null||b.call(u);return}if(y.key!=="Tab")return;const S=m();if(!S.length){y.preventDefault(),p==null||p.focus();return}const k=S[0],E=S[S.length-1];y.shiftKey&&document.activeElement===k?(y.preventDefault(),E.focus()):!y.shiftKey&&document.activeElement===E&&(y.preventDefault(),k.focus())};return document.addEventListener("keydown",w),()=>{cancelAnimationFrame(v),document.removeEventListener("keydown",w),h&&h.isConnected&&typeof h.focus=="function"&&h.focus({preventScroll:!0})}},[]),C.useEffect(()=>{s&&requestAnimationFrame(()=>{var h;return(h=a.current)==null?void 0:h.scrollIntoView({block:"nearest"})})},[s]),l.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:h=>{h.target===h.currentTarget&&t()},children:l.jsxs("div",{ref:o,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||f("settings"),tabIndex:-1,children:[e,s&&l.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function Ud({token:e,targets:t=[],readonly:n=!1,onPower:s,onImport:o}){const[a,u]=C.useState([]),[h,p]=C.useState(0);C.useEffect(()=>{let b=!0;async function j(){const z=[{route:[],label:f("local")}].concat((t||[]).map(U=>({route:Array.isArray(U.route)?U.route:[],label:U.label||(U.route||[]).join(" › ")}))),D=await Promise.all(z.map(async U=>{const W={...U,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const K=await Ls(e,U.route);W.available=!!K.available,W.capabilities=K.capabilities||[],W.provider=K.provider||null,W.cells=(K.cells||[]).map(te=>({...te,route:U.route}));try{W.readonly=!!(await cf(e,U.route)).readonlyDefault}catch{}try{const te=await lf(e,U.route),G=new Set(W.cells.map(Q=>Q.tmuxSession).filter(Boolean));W.unmanaged=(te.sessions||[]).filter(Q=>Q&&!G.has(Q.name))}catch{}}catch(K){W.err=String(K&&K.message||K)}return W}));b&&u(D)}j();const N=setInterval(j,6e3);return()=>{b=!1,clearInterval(N)}},[e,t,h]);const m=(b,j)=>Array.isArray(b.capabilities)&&b.capabilities.includes(j)&&!n&&!b.readonly,v=()=>p(b=>b+1),w=(b,j)=>{s&&s({...b,route:j})},y=(b,j)=>{s&&s({...b,route:j})},S=async(b,j)=>{try{await Fo(e,b.cell,j)}catch{}v()},k=async(b,j)=>{if(window.confirm(f("fleet-remove-cell").replace("{id}",b.cell))){try{await my(e,b.cell,!0,j)}catch{}v()}},E=async(b,j)=>{if(window.confirm(f("terminate-confirm").replace("{name}",b.name))){try{await of(e,b.name,j)}catch{}v()}};return l.jsxs("div",{className:"nc-fleet-inventory",children:[l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-inventory")}),l.jsx("small",{children:f("fleet-inventory-help")})]}),a.map(b=>{const j=b.route.length?b.route.join("/"):"local";return l.jsxs("div",{className:"nc-fleet-pos",children:[l.jsxs("div",{className:"nc-fleet-pos-title",children:[l.jsx("span",{className:`dot ${b.available?"on":"warn"}`}),l.jsx("b",{children:b.label}),l.jsx("small",{children:b.available?`${b.cells.length} ${f("fleet-cells")} · ${b.unmanaged.length} ${f("fleet-tmux")}`:b.err||f("fleet-not-available")})]}),b.cells.map(N=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[l.jsxs("span",{children:[l.jsx("b",{children:N.cell}),l.jsx("small",{children:`${N.engine||""}${N.key?`·${N.key}`:""}${N.active?"":` · ${f("cell-off")}`}`})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[N.active&&m(b,"down")&&l.jsx("button",{className:"nc-btn ghost",title:f("power-off"),onClick:()=>y(N,b.route),children:f("stop")}),!N.active&&m(b,"up")&&l.jsx("button",{className:"nc-btn ghost",title:f("power-on"),onClick:()=>w(N,b.route),children:f("start")}),m(b,"restart")&&N.active&&l.jsx("button",{className:"nc-btn ghost",title:f("restart"),onClick:()=>S(N,b.route),children:f("restart")}),m(b,"remove")&&l.jsx("button",{className:"nc-btn danger",title:f("delete"),onClick:()=>k(N,b.route),children:"×"})]})]},`${j}:${N.cell}`)),b.unmanaged.map(N=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[l.jsxs("span",{children:[l.jsx("b",{children:N.name}),l.jsx("small",{children:f("fleet-tmux")})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[m(b,"import")&&o&&l.jsx("button",{className:"nc-btn ghost",title:f("import-as-cell"),onClick:()=>o(N,b.route),children:f("import-as-cell")}),l.jsx("button",{className:"nc-btn danger",title:f("terminate"),onClick:()=>E(N,b.route),children:"×"})]})]},`${j}:u:${N.name}`)),b.available&&b.cells.length===0&&b.unmanaged.length===0&&l.jsx("div",{className:"nc-empty",children:f("fleet-inventory-empty")})]},j)})]})}function Oj({cells:e=[],engines:t=[],models:n=[],busy:s,canRestore:o=!1,onRestore:a,onClose:u}){const[h,p]=C.useState("export"),[m,v]=C.useState([]),[w,y]=C.useState(()=>new Set(e.map(L=>L.id))),[S,k]=C.useState(()=>new Set(t.map(L=>L.id))),[E,b]=C.useState([]),[j,N]=C.useState([]),[z,D]=C.useState(""),U=new Set(t.map(L=>L.id)),W=new Set(e.map(L=>L.id)),K=(L,A)=>L(x=>{const I=new Set(x);return I.has(A)?I.delete(A):I.add(A),I}),te=()=>{const L=Pj(e,w,t,S,new Date,n);if(L.ok===!1){D(f(`fleet-backup-${L.error}`));return}const A=e.filter(O=>w.has(O.id)).length,x=t.filter(O=>S.has(O.id)).length;if(L.cells.length!==A){D(f("fleet-backup-invalid-cell"));return}if(L.engines.length!==x){D(f("fleet-backup-invalid-engine"));return}if(!L.cells.length&&!L.engines.length){D(f("fleet-backup-select-one"));return}const I=new Blob([`${JSON.stringify(L,null,2)}
|
|
91
|
+
`],{type:"application/json"}),T=URL.createObjectURL(I),M=document.createElement("a");M.href=T,M.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(M),M.click(),M.remove(),setTimeout(()=>URL.revokeObjectURL(T),0),D("")},G=async L=>{if(D(""),b([]),N([]),!!L){if(L.size>1024*1024){D(f("fleet-backup-too-large"));return}try{const A=Aj(await L.text());if(!A.ok){D(f(`fleet-backup-${A.error}`));return}v(Array.isArray(A.models)?A.models:[]);const x=new Set(A.engines.map(I=>I.id));N(A.engines.map(I=>({engine:I,exists:U.has(I.id),selected:!U.has(I.id)}))),b(A.cells.map(I=>{const T=U.has(I.engine)||x.has(I.engine),M=W.has(I.id);return{cell:I,engine:T?I.engine:"",selected:T&&!M,exists:M}}))}catch(A){D(String(A.message||A))}}},Q=(L,A)=>b(x=>x.map((I,T)=>T===L?{...I,...A}:I)),q=(L,A)=>N(x=>x.map((I,T)=>T===L?{...I,...A}:I)),F=new Set([...U,...j.filter(L=>L.selected).map(L=>L.engine.id)]),R=E.filter(L=>L.selected&&L.engine&&F.has(L.engine)),B=j.filter(L=>L.selected),$=[...new Map([...t.map(L=>[L.id,L.label||L.id]),...j.filter(L=>L.selected).map(L=>[L.engine.id,L.engine.label||L.engine.id])]).entries()];return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[l.jsx("b",{children:f("fleet-backup")}),l.jsx("small",{children:f("fleet-backup-help")}),l.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[l.jsx("button",{type:"button",className:`nc-set-tabbtn${h==="export"?" on":""}`,onClick:()=>{p("export"),D("")},children:f("fleet-backup-export")}),l.jsx("button",{type:"button",className:`nc-set-tabbtn${h==="import"?" on":""}`,disabled:!o,title:o?"":f("fleet-backup-restore-unavailable"),onClick:()=>{p("import"),D("")},children:f("fleet-backup-import")})]}),h==="export"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{y(new Set(e.map(L=>L.id))),k(new Set(t.map(L=>L.id)))},children:f("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{y(new Set),k(new Set)},children:f("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[l.jsx("b",{children:f("fleet-engines")}),t.map(L=>{var A;return l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:S.has(L.id),onChange:()=>K(k,L.id)}),l.jsxs("span",{children:[l.jsx("b",{children:L.label||L.id}),l.jsxs("small",{children:[L.id,(A=L.envKeys)!=null&&A.length?` · ${L.envKeys.length} ${f("fleet-backup-env-names")}`:""]})]})]},L.id)}),l.jsx("b",{children:f("fleet-cells")}),e.map(L=>l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:w.has(L.id),onChange:()=>K(y,L.id)}),l.jsxs("span",{children:[l.jsx("b",{children:L.id}),l.jsxs("small",{children:[L.engine," · ",f("fleet-system-prompt")," ",(L.prompt||"").length," ",f("characters")]})]})]},L.id)),!e.length&&!t.length&&l.jsx("div",{className:"nc-empty",children:f("fleet-backup-empty")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:u,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!w.size&&!S.size,onClick:te,children:f("fleet-backup-download")})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",accept:"application/json,.json",disabled:s,onChange:L=>G(L.target.files&&L.target.files[0])}),l.jsx("small",{children:f("fleet-backup-import-help")}),!!(E.length||j.length)&&l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{N(L=>L.map(A=>({...A,selected:!0}))),b(L=>L.map(A=>({...A,selected:!!A.engine})))},children:f("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{N(L=>L.map(A=>({...A,selected:!1}))),b(L=>L.map(A=>({...A,selected:!1})))},children:f("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[!!j.length&&l.jsx("b",{children:f("fleet-engines")}),j.map((L,A)=>{var x;return l.jsx("div",{className:"nc-backup-import-row",children:l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:L.selected,onChange:I=>q(A,{selected:I.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:L.engine.label||L.engine.id}),l.jsxs("small",{children:[L.engine.id," · ",L.exists?f("fleet-backup-overwrite"):f("fleet-backup-new"),(x=L.engine.envKeys)!=null&&x.length?` · ${f("fleet-backup-env-values-required")}`:""]})]})]})},L.engine.id)}),!!E.length&&l.jsx("b",{children:f("fleet-cells")}),E.map((L,A)=>l.jsxs("div",{className:"nc-backup-import-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:L.selected,disabled:!L.engine||!F.has(L.engine),onChange:x=>Q(A,{selected:x.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:L.cell.id}),l.jsxs("small",{children:[L.exists?f("fleet-backup-overwrite"):f("fleet-backup-new")," · ",f("fleet-system-prompt")," ",L.cell.systemPrompt.length," ",f("characters")]})]})]}),l.jsxs("select",{value:L.engine,onChange:x=>Q(A,{engine:x.target.value,selected:!!x.target.value}),children:[l.jsx("option",{value:"",children:f("fleet-backup-engine-missing")}),$.map(([x,I])=>l.jsx("option",{value:x,children:I},x))]})]},L.cell.id))]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:u,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!R.length&&!B.length,onClick:()=>a({engineRows:j,cellRows:E,models:m}),children:f("fleet-backup-restore")})]})]}),z&&l.jsx("div",{className:"nc-err",children:z})]})}function Bj({state:e,setState:t,busy:n,onSave:s,catalog:o}){var j;const a=e.form,u=N=>t({...e,form:{...a,...N}}),h=a.envRows||[],p=[...new Map(o.map(N=>[N.client,N.clientLabel||N.client])).entries()],m=o.filter(N=>N.client===a.client),v=ta(o,a),w=typeof(v==null?void 0:v.credentialEnv)=="string"?v.credentialEnv:"",y=Array.isArray(v==null?void 0:v.credentialUsedBy)?v.credentialUsedBy:[],S=(v==null?void 0:v.credentialSource)||"missing",k=!!(v!=null&&v.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",E=!!w&&e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,b=N=>{N&&u({client:N.client,provider:N.provider,credentialProfile:N.credentialProfile||"",managedModel:N.model||"",protocol:N.protocol||"",permissionPolicy:N.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!N.rc,displayName:N.custom?f("fleet-custom-provider-default"):"",baseUrl:N.custom?"":N.endpoint||"",envKey:N.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...e.mode==="new"?{id:N.id,label:""}:{}})};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:e.mode==="new"?f("fleet-new-engine"):`${f("edit")} ${a.id}`}),l.jsx("input",{value:a.id,disabled:e.mode!=="new",placeholder:"id",onChange:N=>u({id:N.target.value})}),l.jsx("input",{value:a.label,placeholder:f("label"),onChange:N=>u({label:N.target.value})}),l.jsxs("select",{value:a.kind,disabled:e.mode!=="new",onChange:N=>u({kind:N.target.value}),children:[l.jsx("option",{value:"managed",children:f("fleet-managed")}),l.jsx("option",{value:"custom",children:f("fleet-custom")})]}),a.kind==="managed"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("select",{value:a.client,disabled:e.mode!=="new",onChange:N=>b(o.find(z=>z.client===N.target.value&&z.default)||o.find(z=>z.client===N.target.value)),children:p.map(([N,z])=>l.jsx("option",{value:N,children:z},N))}),l.jsx("select",{value:((j=ta(o,a))==null?void 0:j.id)||"",disabled:e.mode!=="new",onChange:N=>b(o.find(z=>z.id===N.target.value)),children:m.map(N=>l.jsx("option",{value:N.id,children:N.label},N.id))})]}),a.client!=="shell"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:f(v!=null&&v.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:N=>u({managedModel:N.target.value})}),l.jsx("datalist",{id:"nc-managed-models",children:[...(v==null?void 0:v.models)||[],...a.modelOptions||[]].filter((N,z,D)=>N&&D.indexOf(N)===z).map(N=>l.jsx("option",{value:N},N))})]}),v!=null&&v.supportsUnsafe?l.jsxs("select",{value:a.permissionPolicy,onChange:N=>u({permissionPolicy:N.target.value}),children:[l.jsx("option",{value:"standard",children:f("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:f("fleet-unsafe-permissions")})]}):l.jsx("small",{children:f("fleet-standard-permissions")}),(v==null?void 0:v.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&l.jsx("small",{className:"nc-err",children:f("fleet-unsafe-warning")}),k&&l.jsxs("select",{"aria-label":f("fleet-credential-source-policy"),value:a.credentialSourcePolicy||"auto",onChange:N=>u({credentialSourcePolicy:N.target.value}),children:[l.jsx("option",{value:"auto",children:f("fleet-credential-source-policy-auto")}),l.jsx("option",{value:"nexuscrew-store",children:f("fleet-credential-source-policy-nexuscrew-store")}),l.jsx("option",{value:"environment",children:f("fleet-credential-source-policy-environment")})]}),(v==null?void 0:v.credentialEnv)===!0&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.envKey,placeholder:f("fleet-api-key-env"),onChange:N=>u({envKey:N.target.value})}),l.jsx("small",{children:f("fleet-custom-secret-help")})]}),w&&l.jsxs("section",{className:"nc-fleet-key","aria-label":f("fleet-key-section"),children:[l.jsxs("div",{className:"nc-fleet-key-head",children:[l.jsx("b",{children:f("fleet-key-section")}),l.jsx("span",{children:f(`fleet-credential-source-${S}`)})]}),l.jsxs("label",{className:"nc-field",children:[f("fleet-key-variable"),l.jsx("input",{value:w,readOnly:!0,"aria-label":f("fleet-key-variable")})]}),l.jsx("small",{children:y.length?f("fleet-key-used-by").replace("{engines}",y.join(", ")):f("fleet-key-used-by-none")}),y.length>0&&l.jsx("small",{children:f("fleet-key-shared-impact").replace("{key}",w).replace("{engines}",y.join(", "))}),l.jsxs("div",{className:"nc-fleet-key-input",children:[l.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":f("fleet-key-value").replace("{key}",w),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:v!=null&&v.authConfigured||e.mode==="edit"?f("fleet-key-blank-keeps"):f("fleet-key-enter"),onChange:N=>u({credentialValue:N.target.value,allowMissingCredential:N.target.value?!1:a.allowMissingCredential})}),l.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":f(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>u({credentialReveal:!a.credentialReveal}),children:f(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),l.jsx("small",{children:f("fleet-key-local-help")}),e.mode==="new"&&(v==null?void 0:v.authConfigured)!==!0&&!a.credentialValue&&l.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[l.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:N=>u({allowMissingCredential:N.target.checked})}),f("fleet-key-create-missing")]}),(v==null?void 0:v.notice)&&l.jsx("small",{className:"nc-fleet-provider-notice",children:f(`fleet-provider-notice-${v.notice}`)})]}),(v==null?void 0:v.notice)&&!w&&l.jsx("small",{className:"nc-fleet-provider-notice",children:f(`fleet-provider-notice-${v.notice}`)}),a.provider==="custom"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.displayName,placeholder:f("fleet-provider-display"),onChange:N=>u({displayName:N.target.value})}),l.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:N=>u({baseUrl:N.target.value})}),((v==null?void 0:v.protocols)||[]).length>1&&l.jsx("select",{value:a.protocol,onChange:N=>u({protocol:N.target.value}),children:v.protocols.map(N=>l.jsx("option",{value:N,children:N},N))}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.envKey,placeholder:f("fleet-api-key-env"),onChange:N=>u({envKey:N.target.value})}),l.jsx("input",{value:a.providerId,placeholder:f("fleet-provider-id"),onChange:N=>u({providerId:N.target.value})})]}),l.jsxs("small",{children:[a.protocol," · ",f("fleet-custom-secret-help")]})]}),l.jsx("small",{children:f(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.command,placeholder:f("command-path"),onChange:N=>u({command:N.target.value})}),l.jsx("textarea",{value:a.argsText,placeholder:f("args-lines"),onChange:N=>u({argsText:N.target.value})}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:a.rc,onChange:N=>u({rc:N.target.checked})})," ",f("fleet-remote-control")]}),l.jsxs("select",{value:a.promptMode,onChange:N=>u({promptMode:N.target.value}),children:[l.jsx("option",{value:"send-keys",children:"send-keys"}),l.jsx("option",{value:"flag",children:"flag"})]}),a.promptMode==="flag"&&l.jsx("input",{value:a.promptFlag,placeholder:"prompt flag",onChange:N=>u({promptFlag:N.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:N=>u({modelFlag:N.target.value})}),l.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:N=>u({modelValue:N.target.value})})]}),l.jsx("small",{children:f("env-write-only")}),h.map((N,z)=>l.jsxs("div",{className:"nc-fleet-env",children:[l.jsx("input",{value:N.key,disabled:N.configured,placeholder:"ENV_KEY",onChange:D=>{const U=h.slice();U[z]={...N,key:D.target.value},u({envRows:U})}}),l.jsx("input",{type:"password",value:N.value,placeholder:N.configured?"•••••• (unchanged)":"value",onChange:D=>{const U=h.slice();U[z]={...N,value:D.target.value},u({envRows:U})}}),l.jsx("button",{className:"nc-btn danger",onClick:()=>u({envRows:h.filter((D,U)=>U!==z)}),children:"×"})]},`${N.key}-${z}`)),l.jsx("button",{className:"nc-btn ghost",onClick:()=>u({envRows:[...h,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),l.jsx("input",{value:a.panelUrl||"",maxLength:512,placeholder:f("fleet-panel-url"),onChange:N=>u({panelUrl:N.target.value})}),l.jsx("small",{children:f("fleet-panel-url-help")}),a.panelUrl&&!Gf(a.panelUrl)&&l.jsx("small",{className:"nc-err",children:f("fleet-panel-url-invalid")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>t(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||E||a.kind==="custom"&&!a.command||a.kind==="managed"&&(v==null?void 0:v.requiresModel)&&!a.managedModel||a.kind==="managed"&&(v==null?void 0:v.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:f("save")})]})]})}function zj({state:e,setState:t,busy:n,onSave:s,onTest:o,profiles:a=[],canTest:u=!0}){const[h,p]=C.useState(null),[m,v]=C.useState(!1),w=e.form,y=b=>t({...e,form:{...w,...b}}),S=/^[^\x00-\x1f\x7f]{1,128}$/.test(w.id||""),k=!!(w.id||"").trim()&&!!(w.engine||"").trim()&&S,E=async()=>{p(null),v(!0);try{p(await o(w.engine,w.id))}catch(b){p({outcome:"unverified",detail:String(b&&b.message||b)})}v(!1)};return l.jsxs("div",{className:"nc-fleet-form",children:[l.jsxs("label",{className:"nc-field",children:[f("model-editor-engine"),l.jsxs("select",{value:w.engine||"",disabled:n||e.mode==="edit",onChange:b=>{p(null),y({engine:b.target.value})},children:[l.jsx("option",{value:"",children:"—"}),a.map(b=>l.jsx("option",{value:b.id,children:b.label?`${b.id} · ${b.label}`:b.id},b.id))]})]}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-id"),l.jsx("input",{value:w.id||"",disabled:n||e.mode==="edit",placeholder:"qwen3.9-max",onChange:b=>{p(null),y({id:b.target.value})}})]}),l.jsx("small",{className:"nc-set-hint",children:f("model-editor-id-help")}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-context"),l.jsx("input",{inputMode:"numeric",value:w.contextWindow||"",disabled:n,onChange:b=>y({contextWindow:b.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-field",children:[f("model-editor-max-tokens"),l.jsx("input",{inputMode:"numeric",value:w.maxTokens||"",disabled:n,onChange:b=>y({maxTokens:b.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:w.reasoning===!0,disabled:n,onChange:b=>y({reasoning:b.target.checked})})," ",f("model-editor-reasoning")]}),l.jsxs("div",{className:"nc-set-row",children:[u&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||m||!k,onClick:E,children:f(m?"model-test-running":"model-test")}),h&&l.jsxs("span",{className:`nc-model-test ${h.outcome}`,children:[f(`model-test-${h.outcome}`),h.outcome==="ok"&&Number.isInteger(h.latencyMs)?` · ${h.latencyMs}ms`:""]})]}),h&&h.detail&&l.jsx("small",{className:"nc-set-hint",children:h.detail}),h&&h.outcome==="unverified"&&l.jsx("small",{className:"nc-set-hint",children:f("model-test-unverified-help")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(null),children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!k,onClick:()=>s(w),children:f("save")})]})]})}function $j({token:e,route:t,targets:n=[],location:s,setLocation:o,state:a,setState:u,engines:h,mcpServers:p=[],managedCatalog:m=[],busy:v,onSave:w}){var B,$,L;const[y,S]=C.useState(null),[k,E]=C.useState(""),b=a.form,j=A=>u({...a,form:{...b,...A}}),N=h.find(A=>A.id===b.engine),z=((B=N==null?void 0:N.managed)==null?void 0:B.client)==="shell",D=(($=N==null?void 0:N.managed)==null?void 0:$.client)||"",U=((L=m.find(A=>A.client===D))==null?void 0:L.mcpManaged)!==!1,W=A=>{var T,M,O,H;const x=h.find(se=>se.id===A),I={...b.commands||{}};((T=N==null?void 0:N.managed)==null?void 0:T.client)==="shell"&&(b.command?I[b.engine]=b.command:delete I[b.engine]),j({engine:A,model:((M=b.models)==null?void 0:M[A])||((O=x==null?void 0:x.managed)==null?void 0:O.model)||((H=x==null?void 0:x.model)==null?void 0:H.value)||"",commands:I,command:I[A]||""})},K=A=>{const x={...b.commands||{}};A?x[b.engine]=A:delete x[b.engine],j({command:A,commands:x})},te=z&&/[|&;<>()`$*?{}\[\]~]/.test(b.command||""),G=[...new Set([...p||[],...Array.isArray(b.mcp)?b.mcp:[]])].sort(),Q=Array.isArray(b.mcp)?b.mcp.length?"some":"none":"all",q=A=>{var x;return j({mcp:A==="all"?void 0:A==="none"?[]:(x=b.mcp)!=null&&x.length?b.mcp:[...G]})},F=A=>{const x=Array.isArray(b.mcp)?b.mcp:[];j({mcp:x.includes(A)?x.filter(I=>I!==A):[...x,A].sort()})},R=async A=>{try{const x=await af(e,A,t);S(x),j({cwd:x.path}),E("")}catch(x){E(String(x.message||x))}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:a.mode==="new"?f("fleet-new-cell"):`${f("edit")} ${b.id}`}),a.mode==="new"&&l.jsxs("label",{className:"nc-field",children:[f("location"),l.jsx("span",{className:"nc-req",children:" *"}),l.jsxs("select",{value:s,onChange:A=>{o(A.target.value),j({engine:""})},children:[l.jsx("option",{value:"",children:f("local")}),n.map(A=>l.jsxs("option",{value:A.route.join("/"),disabled:A.status&&A.status!=="up",children:[A.label,A.status&&A.status!=="up"?` · ${f("node-offline")}`:""]},A.route.join("/")))]})]}),l.jsx("input",{value:b.id,disabled:a.mode!=="new",placeholder:"id",onChange:A=>j({id:A.target.value})}),l.jsx("input",{value:b.label||"",maxLength:64,placeholder:f("fleet-cell-label"),onChange:A=>j({label:A.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:b.cwd,placeholder:f("cwd"),onChange:A=>j({cwd:A.target.value})}),l.jsx("button",{className:"nc-btn ghost",onClick:()=>y?S(null):R(b.cwd),children:f("browse")})]}),y&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:y.path}),l.jsxs("div",{className:"nc-fs-list",children:[y.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>R(y.parent),children:["↑ ",f("fs-parent")]}),(y.dirs||[]).map(A=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>R(`${y.path.replace(/\/$/,"")}/${A}`),children:["📁 ",A]},A))]})]}),k&&l.jsx("div",{className:"nc-err",children:k}),l.jsx("select",{value:b.engine,onChange:A=>W(A.target.value),children:h.map(A=>l.jsx("option",{value:A.id,children:A.label},A.id))}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:A=>j({boot:A.target.checked})})," ",f("fleet-boot")]}),l.jsx("input",{value:b.panelUrl||"",maxLength:512,placeholder:f("fleet-panel-url"),onChange:A=>j({panelUrl:A.target.value})}),l.jsx("small",{children:f("fleet-panel-url-help")}),b.panelUrl&&!Gf(b.panelUrl)&&l.jsx("small",{className:"nc-err",children:f("fleet-panel-url-invalid")}),z?l.jsxs(l.Fragment,{children:[l.jsx("input",{value:b.command||"",maxLength:4096,placeholder:f("fleet-shell-command-placeholder"),onChange:A=>K(A.target.value)}),l.jsx("small",{children:b.command?f("fleet-shell-command-help"):f("fleet-shell-interactive")}),te&&l.jsx("small",{className:"nc-note",children:f("fleet-shell-command-metachar")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:b.model||"",list:"nc-cell-models",placeholder:f("fleet-model-override"),onChange:A=>j({model:A.target.value})}),l.jsx("datalist",{id:"nc-cell-models",children:((N==null?void 0:N.availableModels)||[]).map(A=>l.jsx("option",{value:A},A))}),l.jsx("textarea",{value:b.prompt||"",placeholder:f("cell-prompt"),onChange:A=>j({prompt:A.target.value})}),l.jsx("small",{children:f("cell-prompt-help")}),l.jsxs("label",{className:"nc-field",children:[f("cell-mcp"),l.jsxs("select",{value:Q,onChange:A=>q(A.target.value),children:[l.jsx("option",{value:"all",children:f("cell-mcp-all")}),l.jsx("option",{value:"none",children:f("cell-mcp-none")}),l.jsx("option",{value:"some",children:f("cell-mcp-some")})]})]}),!U&&l.jsx("small",{className:"nc-note",children:f("cell-mcp-inert")}),Q==="some"&&l.jsx("div",{className:"nc-fleet-mcp-list",children:G.map(A=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:(b.mcp||[]).includes(A),onChange:()=>F(A)})," ",A]},A))}),l.jsx("small",{children:f("cell-mcp-help")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>u(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:v||!b.id||!b.cwd||!b.engine,onClick:w,children:f("save")})]})]})}function Z_({token:e,route:t=[],state:n,setState:s,busy:o,onSave:a}){const[u,h]=C.useState(null),[p,m]=C.useState([]),[v,w]=C.useState(""),y=Array.isArray(t)?t.join("/"):"";C.useEffect(()=>{let j=!0;return ec(e,y?y.split("/"):[]).then(N=>{j&&(m(N.engines||[]),w(""))}).catch(N=>{j&&(m([]),w(String(N.message||N)))}),()=>{j=!1}},[e,y]);const S=n.form,k=j=>s({...n,form:{...S,...j}}),E=async j=>{try{const N=await af(e,j,t);h(N),k({cwd:N.path})}catch{}},b=!S.id&&S.tmuxSession?S.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):S.id;return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsxs("b",{children:[f("import-as-cell")," · ",S.tmuxSession]}),l.jsx("small",{children:f("import-help")}),l.jsx("input",{value:S.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),l.jsx("input",{value:S.id,placeholder:f("name"),onChange:j=>k({id:j.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:S.cwd,placeholder:f("cwd"),onChange:j=>k({cwd:j.target.value})}),l.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>u?h(null):E(S.cwd),children:f("browse")})]}),u&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:u.path}),l.jsxs("div",{className:"nc-fs-list",children:[u.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>E(u.parent),children:["↑ ",f("fs-parent")]}),(u.dirs||[]).map(j=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>E(`${u.path.replace(/\/$/,"")}/${j}`),children:["📁 ",j]},j))]})]}),l.jsxs("select",{value:S.engine,onChange:j=>k({engine:j.target.value}),children:[l.jsx("option",{value:"",children:f("import-engine-required")}),p.map(j=>l.jsx("option",{value:j.id,children:j.label},j.id))]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!S.boot,onChange:j=>k({boot:j.target.checked})})," ",f("fleet-boot")]}),(n.err||v)&&l.jsx("div",{className:"nc-err",children:n.err||v}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:o||!S.tmuxSession||!S.engine||!p.length,onClick:a,children:f(b?"import-as-cell":"save")})]})]})}function Nl(e){const t=Gs(e);return t===null?`~/${e}`:t?`~/${t}`:"~"}function Fj(e){if(!e||typeof e.path!="string"||typeof e.home!="string")return"";const{path:t,home:n}=e;return!n||t===n||!t.startsWith(n+"/")?"":t.slice(n.length+1).replace(/\/+$/,"")}function Hj({token:e,route:t,cell:n,busy:s=!1,onSaved:o,onClose:a}){const[u,h]=C.useState(""),[p,m]=C.useState(null),[v,w]=C.useState(!1),[y,S]=C.useState(""),k=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&Gs(n.cwdSuggestion)!==null?Gs(n.cwdSuggestion):null,[E,b]=C.useState(k),j=n==null?void 0:n.id,N=s||v,z=async G=>{const Q=Gs(G);if(Q===null){m({rel:"",dirs:[],loading:!1,err:f("fleet-cwd-repair-invalid")});return}m({rel:Q,dirs:[],loading:!0,err:""});try{const q=await af(e,Q,t),F=Fj(q);m({rel:F,dirs:Array.isArray(q.dirs)?q.dirs:[],loading:!1,err:""})}catch(q){m({rel:Q,dirs:[],loading:!1,err:String(q&&q.message||q)})}},D=G=>{if(!p)return;const Q=p.rel?`${p.rel}/${G}`:G;z(Q)},U=()=>{p!=null&&p.rel&&z(p.rel.split("/").slice(0,-1).join("/"))},W=()=>{p&&(h(p.rel||""),m(null),S(""),b(null))},K=()=>{E!==null&&(h(E),b(null),S(""))},te=async()=>{if(N)return;const G=Gs(u);if(G===null){S(f("fleet-cwd-repair-invalid"));return}const Q=Nl(G);let q=!0;try{q=window.confirm(f("fleet-cwd-repair-confirm").replace("{id}",String(j||"")).replace("{path}",Q))}catch{q=!1}if(q){w(!0),S(""),b(null);try{const F=await py(e,j,{cwdRel:G},t);o==null||o(F)}catch(F){const R=F&&F.data||{};if(R.code==="unportable-cwd"){S(f("fleet-cwd-repair-unportable"));const B=Array.isArray(R.cells)?R.cells.find(L=>L&&L.id===j):null,$=B&&typeof B.suggestion=="string"?B.suggestion:null;$!==null&&Gs($)!==null&&b($)}else S(String(F&&F.message||F))}finally{w(!1)}}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[l.jsx("b",{children:f("fleet-cwd-repair-title").replace("{id}",String(j||""))}),l.jsx("small",{className:"nc-set-info",children:f("fleet-cwd-repair-help")}),l.jsx("small",{className:"nc-cwd-no-source",children:f("fleet-cwd-repair-no-source-path")}),l.jsxs("label",{className:"nc-field",children:[f("cwd"),l.jsxs("div",{className:"nc-cwd-rel-row",children:[l.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),l.jsx("input",{value:u,placeholder:f("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:G=>h(G.target.value)}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:N,onClick:()=>p?m(null):z(""),children:f(p?"close":"fleet-cwd-repair-browse")})]})]}),l.jsx("div",{className:"nc-cwd-preview",children:f("fleet-cwd-repair-preview").replace("{path}",Nl(u))}),p&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:Nl(p.rel)}),l.jsxs("div",{className:"nc-fs-list",children:[p.rel&&l.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:U,children:["↑ ",f("fs-parent")]}),p.loading&&l.jsx("div",{className:"nc-fs-empty",children:"…"}),!p.loading&&p.dirs.length===0&&l.jsx("div",{className:"nc-fs-empty",children:f("fleet-cwd-repair-fs-empty")}),!p.loading&&p.dirs.map(G=>l.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>D(G),children:["📁 ",G]},G))]}),p.err&&l.jsx("div",{className:"nc-err",children:p.err}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{type:"button",className:"nc-btn primary",disabled:N||p.loading||!!p.err,onClick:W,children:f("fleet-cwd-repair-use-current")})})]}),y&&l.jsx("div",{className:"nc-err",role:"alert",children:y}),E!==null&&l.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[l.jsx("span",{children:f("fleet-cwd-repair-suggestion")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:K,children:f("fleet-cwd-repair-use-suggestion").replace("{path}",Nl(E))})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:v,onClick:a,children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:N,onClick:te,children:v?"…":f("save")})]})]})}function Uj({token:e,readonly:t,targets:n=[],startNewCell:s=!1,initialLocation:o=""}){const[a,u]=C.useState({engines:[],cells:[],managedCatalog:[]}),[h,p]=C.useState({available:!1,capabilities:[]}),[m,v]=C.useState(!1),[w,y]=C.useState(null),[S,k]=C.useState(null),[E,b]=C.useState({}),[j,N]=C.useState(null),[z,D]=C.useState(!1),[U,W]=C.useState(""),[K,te]=C.useState(""),[G,Q]=C.useState(o),[q,F]=C.useState(!1),[R,B]=C.useState(null),[$,L]=C.useState(null),[A,x]=C.useState(null),[I,T]=C.useState(!1),[M,O]=C.useState([]),[H,se]=C.useState(null),[ee,le]=C.useState("manage"),ve=C.useRef(!1),de=G?G.split("/"):[],fe=C.useCallback(async()=>{try{const ie=await Ls(e,de);p(ie);try{const _e=await cf(e,de);F(!!_e.readonlyDefault)}catch{F(!1)}if(ie.provider==="builtin"&&(ie.capabilities||[]).includes("definitions")){const _e=await ec(e,de),Ce=new Map((ie.engines||[]).map(Ue=>[Ue.id,Ue]));if(_e.engines=(_e.engines||[]).map(Ue=>{var Ve;return{...Ue,availableModels:((Ve=Ce.get(Ue.id))==null?void 0:Ve.models)||[]}}),u(_e),(ie.capabilities||[]).includes("credentials"))try{O((await z0(e,de)).credentials||[])}catch{O([])}else O([])}W("")}catch(ie){W(String(ie.message||ie))}finally{v(!0)}},[e,G]);C.useEffect(()=>{fe();const ie=setInterval(fe,5e3);return()=>clearInterval(ie)},[fe]);const He=new Set((h.cells||[]).filter(ie=>ie.active).map(ie=>ie.cell)),st=h.provider==="builtin"&&(h.capabilities||[]).includes("edit"),lt=(h.capabilities||[]).includes("restore");C.useEffect(()=>{!s||ve.current||!st||!a.engines.length||(ve.current=!0,N({mode:"new",form:Q_(a.engines[0].id)}))},[s,st,a.engines]);const Ee=async ie=>{D(!0),W(""),te("");try{await ie(),await fe()}catch(_e){W(String(_e.message||_e))}D(!1)},xt=async(ie,_e)=>{const Ce=await q0(e,ie,_e,de);return b(Ue=>({...Ue,[`${ie}::${_e}`]:Ce})),Ce},qt=ie=>Ee(async()=>{const _e={id:String(ie.id||"").trim(),engine:String(ie.engine||"").trim()};for(const Ce of["contextWindow","maxTokens"]){const Ue=String(ie[Ce]||"").trim();Ue&&(_e[Ce]=Number(Ue))}ie.reasoning===!0&&(_e.reasoning=!0),await W0(e,_e,de),k(null),await fe()}),ze=()=>Ee(async()=>{var Oe;const ie=w.mode==="new",_e=w.form,Ce=a.managedCatalog||[],Ue=_e.kind==="managed"?ta(Ce,_e):null,Ve=typeof(Ue==null?void 0:Ue.credentialEnv)=="string"?Ue.credentialEnv:"",ft=Ve&&_e.credentialValue||"",Et=Ij(_e,ie,Ce);!ie&&w.form.kind==="custom"&&!w.form.modelFlag&&(Et.model=null),!ie&&w.form.kind==="custom"&&w.form.promptMode!=="flag"&&(Et.promptFlag=null);let St;if(ie)St=await F0(e,Et,de);else{const je=w.original,tt=new Set(w.form.envRows.filter(yt=>!yt.remove).map(yt=>yt.key)),Ye=(je.envKeys||[]).filter(yt=>!tt.has(yt)),pt=Object.fromEntries(w.form.envRows.filter(yt=>!yt.remove&&yt.key&&(!yt.configured||yt.value!=="")).map(yt=>[yt.key,yt.value]));St=await H0(e,je.id,Et,w.form.kind==="custom"?{set:pt,remove:Ye}:void 0,de)}let Nt=null;if(Ve&&ft)try{Nt=await Tg(e,Ve,ft,de),O(Nt.credentials||[])}catch{throw await fe(),ie&&y({mode:"edit",original:{...Et,id:_e.id},form:{..._e,credentialReveal:!1}}),new Error(f(ie?"fleet-key-partial-create":"fleet-key-partial-edit"))}await fe(),y(null),te(f("fleet-saved"));const Z=((Oe=((Nt==null?void 0:Nt.credentials)||[]).find(je=>je.envKey===Ve))==null?void 0:Oe.activeCells)||[],we=[...new Set([...(St==null?void 0:St.activeCells)||[],...Z])];if(we.length&&window.confirm(f("fleet-restart-confirm").replace("{cells}",we.join(", "))))for(const je of we)await Fo(e,je,de)}),Rt=()=>Ee(async()=>{var Z,we,Oe,je,tt,Ye;const ie=j.mode==="new",_e=j.form,Ce={...ie?{id:_e.id}:{},cwd:_e.cwd,engine:_e.engine,boot:!!_e.boot},Ue={..._e.commands||{}},Ve=a.engines.find(pt=>pt.id===_e.engine);((Z=Ve==null?void 0:Ve.managed)==null?void 0:Z.client)==="shell"&&typeof _e.command=="string"&&_e.command.length?Ue[_e.engine]=_e.command:((we=Ve==null?void 0:Ve.managed)==null?void 0:we.client)==="shell"&&delete Ue[_e.engine],(Object.keys(Ue).length||!ie)&&(Ce.commands=Ue);const ft=(_e.label||"").trim();ie?ft&&(Ce.label=ft):Ce.label=ft||null;const Et=(_e.panelUrl||"").trim();ie?Et&&(Ce.panelUrl=Et):Ce.panelUrl=Et||null,ie?Array.isArray(_e.mcp)&&(Ce.mcp=_e.mcp):Ce.mcp=Array.isArray(_e.mcp)?_e.mcp:null,ie?(((Oe=Ve==null?void 0:Ve.managed)==null?void 0:Oe.client)!=="shell"&&_e.model&&(Ce.model=_e.model),((je=Ve==null?void 0:Ve.managed)==null?void 0:je.client)!=="shell"&&_e.prompt&&(Ce.prompt=_e.prompt)):(Ce.model=((tt=Ve==null?void 0:Ve.managed)==null?void 0:tt.client)==="shell"?null:_e.model||null,((Ye=Ve==null?void 0:Ve.managed)==null?void 0:Ye.client)!=="shell"&&(Ce.prompt=_e.prompt||null));const St=ie?await V0(e,Ce,de):await py(e,j.original.id,Ce,de),Nt=ie?_e.id:j.original.id;N(null),te(f("fleet-saved")),!ie&&(St!=null&&St.active)&&window.confirm(f("fleet-restart-confirm").replace("{cells}",Nt))&&await Fo(e,Nt,de)}),gt=t||q,Mt=h.capabilities||[],ht=de.length>0&>,bt=ie=>M.find(_e=>{var Ce;return(Ce=_e.engines)==null?void 0:Ce.includes(ie.id)})||null,Bt=()=>Ee(async()=>{var Ce;const ie=await Tg(e,H.envKey,H.value,de);O(ie.credentials||[]),se(null),te(f("fleet-credential-saved"));const _e=((Ce=(ie.credentials||[]).find(Ue=>Ue.envKey===H.envKey))==null?void 0:Ce.activeCells)||[];if(_e.length&&window.confirm(f("fleet-restart-confirm").replace("{cells}",_e.join(", "))))for(const Ue of _e)await Fo(e,Ue,de)}),kt=ie=>Ee(async()=>{if(!window.confirm(f("fleet-credential-remove-confirm").replace("{key}",ie.envKey)))return;const _e=await $0(e,ie.envKey,de);O(_e.credentials||[]),te(f("fleet-credential-removed"))}),Dt=ie=>B({...ie,route:Array.isArray(ie==null?void 0:ie.route)?ie.route:de}),Lt=async ie=>{if(!R)return;const _e=R.cell||R.id,Ce=Array.isArray(R.route)?R.route:de;if(ie.action==="up"){const Ue=await rf(e,{cell:_e,boot:!!ie.boot,...ie.engine?{engine:ie.engine}:{},...ie.model!==void 0?{model:ie.model}:{},...ie.permissionPolicy?{permissionPolicy:ie.permissionPolicy}:{}},Ce),Ve=wf(Ue);Ve&&te(Ve.text)}else await Ol(e,{cell:_e,boot:!!ie.boot},Ce)},Ct=(ie,_e)=>{W(""),L({mode:"new",route:Array.isArray(_e)?_e:de,form:{tmuxSession:ie.name,id:"",engine:"",cwd:"",boot:!1},err:""})},ye=()=>Ee(async()=>{const ie=$.form;if(!ie.engine){L({...$,err:f("import-engine-required")});return}await Y0(e,{tmuxSession:ie.tmuxSession,id:ie.id||void 0,engine:ie.engine,cwd:ie.cwd||void 0,boot:!!ie.boot},ie.route||de),L(null),te(f("fleet-saved"))}),ce=({engineRows:ie=[],cellRows:_e=[],models:Ce=[]})=>Ee(async()=>{const Ue=ie.filter(je=>je.selected),Ve=Ue.map(je=>Nb(je.engine));if(Ve.some(je=>!je))throw new Error(f("fleet-backup-invalid-engine"));const ft=Ue.filter(je=>je.exists).map(je=>je.engine.id);if(ft.length&&!window.confirm(f("fleet-backup-confirm-engine-overwrite").replace("{engines}",ft.join(", "))))return;const Et=[...new Set([...a.engines.map(je=>je.id),...Ve.map(je=>je.id)])],St=[];for(const je of _e.filter(tt=>tt.selected)){const tt=Lj(je.cell,je.engine,Et);if(!tt)throw new Error(`${je.cell.id}: ${f("fleet-backup-engine-missing")}`);St.push(tt)}const Nt=_e.filter(je=>je.selected&&je.exists).map(je=>je.cell.id);if(Nt.length&&!window.confirm(f("fleet-backup-confirm-overwrite").replace("{cells}",Nt.join(", "))))return;const Z=Ve.length?await X0(e,Ve,ft.length>0,de,Ce):{needsRestart:[]},we=St.length?await G0(e,St,de):{needsRestart:[]},Oe=[...new Set([...Z.needsRestart||[],...we.needsRestart||[]])];T(!1),te(`${f("fleet-backup-restored").replace("{n}",String(St.length))}${Ve.length?` · ${Ve.length} ${f("fleet-engines").toLowerCase()}`:""}${Oe.length?` · ${f("fleet-backup-needs-restart").replace("{cells}",Oe.join(", "))}`:""}`)}),Le=l.jsxs("label",{className:"nc-field",children:[f("location"),l.jsxs("select",{value:G,onChange:ie=>{Q(ie.target.value),y(null),N(null),W(""),te(""),F(!1),v(!1),p({available:!1,capabilities:[]}),u({engines:[],cells:[],managedCatalog:[]}),O([]),se(null)},children:[l.jsx("option",{value:"",children:f("local")}),n.map(ie=>l.jsxs("option",{value:ie.route.join("/"),disabled:ie.status&&ie.status!=="up",children:[ie.label,ie.status&&ie.status!=="up"?` · ${f("node-offline")}`:""]},ie.route.join("/")))]})]}),qe=l.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":f("tab-fleet"),children:[l.jsx("button",{type:"button",role:"tab","aria-selected":ee==="manage",className:`nc-set-tabbtn${ee==="manage"?" on":""}`,onClick:()=>le("manage"),children:f("fleet-manage-location")}),l.jsx("button",{type:"button",role:"tab","aria-selected":ee==="overview",className:`nc-set-tabbtn${ee==="overview"?" on":""}`,onClick:()=>le("overview"),children:f("fleet-network-overview")})]});return m?st?l.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[qe,ee==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(Ud,{token:e,targets:n,readonly:t,onPower:Dt,onImport:Ct})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-manage-help")}),Le,l.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:gt||z,onClick:()=>{W(""),T(!0)},children:f("fleet-backup")}),l.jsx("small",{children:f("fleet-backup-help")})]}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-cells")}),l.jsx("span",{className:"nc-fleet-head-actions",children:l.jsxs("button",{className:"nc-btn primary",disabled:gt||z||!a.engines.length,onClick:()=>{var ie;W(""),N({mode:"new",form:Q_((ie=a.engines[0])==null?void 0:ie.id)})},children:["+ ",f("add")]})})]}),a.cells.map(ie=>{const _e=He.has(ie.id),Ce=ie.needsRepair===!0;return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:ie.id}),ie.label?l.jsxs("small",{className:"nc-fleet-label",children:[" ",ie.label]}):null,l.jsxs("small",{children:[ie.engine," · ",Ce?l.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:f("fleet-cwd-needs-repair")}):ie.cwd,_e?` · ${f("service-active")}`:` · ${f("cell-off")}`]})]}),l.jsxs("span",{children:[_e&&Mt.includes("down")&&l.jsx("button",{className:"nc-btn ghost",disabled:gt||z,onClick:()=>Ee(()=>Ol(e,{cell:ie.id},de)),children:f("stop")}),!_e&&Mt.includes("up")&&l.jsx("button",{className:"nc-btn primary",disabled:gt||z,onClick:()=>Dt({cell:ie.id,id:ie.id,engine:ie.engine,model:ie.model,models:ie.models,permissionPolicies:ie.permissionPolicies,active:!1,boot:ie.boot}),children:f("start")}),_e&&Mt.includes("restart")&&l.jsx("button",{className:"nc-btn ghost",disabled:gt||z,onClick:()=>Ee(()=>Fo(e,ie.id,de)),children:f("restart")}),Ce?l.jsx("button",{className:"nc-btn ghost",disabled:gt||z,onClick:()=>{W(""),x(ie)},children:f("fleet-cwd-repair")}):l.jsx("button",{className:"nc-btn ghost",disabled:gt||z,onClick:()=>{var Ue;W(""),N({mode:"edit",original:ie,form:{...ie,commands:{...ie.commands||{}},command:((Ue=ie.commands)==null?void 0:Ue[ie.engine])||""}})},children:f("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:gt||z,onClick:()=>Ee(async()=>{window.confirm(f("fleet-remove-cell").replace("{id}",ie.id))&&await my(e,ie.id,!0,de)}),children:"×"})]})]},ie.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-engines")}),l.jsxs("button",{className:"nc-btn primary",disabled:gt||z,onClick:()=>{W(""),y({mode:"new",form:Tj()})},children:["+ ",f("add")]})]}),a.engines.map(ie=>{var Ce,Ue;const _e=bt(ie);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:ie.label}),l.jsx("small",{children:ie.managed?`${ie.id} · ${ie.managed.client} / ${ie.managed.provider} · ${(Ce=ie.managedInfo)!=null&&Ce.configured?f("fleet-ready"):((Ue=ie.managedInfo)==null?void 0:Ue.reason)||f("fleet-not-ready")}`:`${ie.id} · ${ie.command}`}),_e&&l.jsxs("small",{children:[_e.envKey," · ",f(`fleet-credential-source-${_e.source||"missing"}`)]})]}),l.jsxs("span",{children:[_e&&l.jsx("button",{className:"nc-btn ghost",disabled:gt||z,onClick:()=>{W(""),se({envKey:_e.envKey,value:""})},children:_e.configured?f("fleet-credential-change"):f("fleet-credential-set")}),(_e==null?void 0:_e.source)==="local"&&l.jsx("button",{className:"nc-btn danger",disabled:gt||z,onClick:()=>kt(_e),children:f("fleet-credential-forget")}),l.jsx("button",{className:"nc-btn ghost",disabled:gt||z,onClick:()=>{W(""),y({mode:"edit",original:ie,form:Dj(ie)})},children:f("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:gt||z,onClick:()=>Ee(async()=>{window.confirm(f("fleet-remove-engine").replace("{id}",ie.id))&&await U0(e,ie.id,de)}),children:"×"})]})]},ie.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:f("fleet-models")}),l.jsxs("button",{className:"nc-btn primary",disabled:gt||z,onClick:()=>{W(""),k({mode:"new",form:{id:"",engine:""}})},children:["+ ",f("add")]})]}),!(a.models||[]).length&&l.jsx("small",{className:"nc-set-hint",children:f("fleet-no-models")}),(a.models||[]).map(ie=>{const _e=`${ie.engine}::${ie.id}`,Ce=E[_e],Ue=(a.engines||[]).some(Ve=>Ve.managed&&Ve.managed.model===ie.id);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:ie.id}),l.jsxs("small",{children:[ie.engine,ie.contextWindow?` · ${ie.contextWindow}`:"",Ue?` · ${f("model-in-use")}`:""]}),Ce&&l.jsxs("small",{className:`nc-model-test ${Ce.outcome}`,children:[f(`model-test-${Ce.outcome}`),Ce.outcome==="ok"&&Number.isInteger(Ce.latencyMs)?` · ${Ce.latencyMs}ms`:""]})]}),l.jsxs("span",{children:[Mt.includes("model-test")&&l.jsx("button",{className:"nc-btn ghost",disabled:z||ht,onClick:()=>Ee(()=>xt(ie.engine,ie.id)),children:f("model-test")}),l.jsx("button",{className:"nc-btn danger",disabled:gt||z,onClick:()=>Ee(()=>K0(e,ie.id,ie.engine,de)),children:"×"})]})]},_e)})]}),S&&l.jsx(ks,{onClose:()=>k(null),label:f("fleet-models"),error:U,children:l.jsx(zj,{state:S,setState:k,busy:z,onSave:qt,onTest:xt,profiles:a.managedCatalog||[],canTest:Mt.includes("model-test")&&!ht})}),w&&l.jsx(ks,{onClose:()=>y(null),label:f("fleet-new-engine"),error:U,children:l.jsx(Bj,{state:w,setState:y,busy:z,onSave:ze,catalog:a.managedCatalog||[]})}),j&&l.jsx(ks,{onClose:()=>N(null),label:f("fleet-new-cell"),error:U,children:l.jsx($j,{token:e,route:de,targets:n,location:G,setLocation:Q,state:j,setState:N,engines:a.engines,mcpServers:a.mcpServers||[],managedCatalog:a.managedCatalog||[],busy:z,onSave:Rt})}),A&&l.jsx(ks,{onClose:()=>x(null),label:f("fleet-cwd-repair-title").replace("{id}",A.id),error:"",children:l.jsx(Hj,{token:e,route:de,cell:A,busy:z,onSaved:async()=>{x(null),te(f("fleet-cwd-repaired")),await fe()},onClose:()=>x(null)})}),K&&l.jsx("div",{className:"nc-set-note",children:K}),U&&l.jsx("div",{className:"nc-err",children:U}),I&&l.jsx(ks,{onClose:()=>T(!1),label:f("fleet-backup"),error:U,children:l.jsx(Oj,{cells:a.cells,engines:a.engines,models:a.models||[],busy:z,canRestore:lt,onRestore:ce,onClose:()=>T(!1)})}),H&&l.jsx(ks,{onClose:()=>se(null),label:f("fleet-credential-title"),error:U,children:l.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[l.jsx("b",{children:f("fleet-credential-title")}),l.jsx("small",{children:f("fleet-credential-help")}),l.jsxs("label",{className:"nc-field",children:[H.envKey,l.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:H.value,onChange:ie=>se({...H,value:ie.target.value})})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>se(null),children:f("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:z||!H.value,onClick:Bt,children:f("save")})]})]})}),$&&l.jsx(ks,{onClose:()=>L(null),label:f("import-as-cell"),error:U,children:l.jsx(Z_,{token:e,route:$.route||de,state:$,setState:L,busy:z,onSave:ye})}),R&&l.jsx(zl,{cell:R,token:e,route:Array.isArray(R.route)?R.route:de,onConfirm:async ie=>{try{await Lt(ie)}finally{await fe()}},onClose:()=>B(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[qe,ee==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(Ud,{token:e,targets:n,readonly:t,onPower:Dt,onImport:Ct})]}):l.jsxs(l.Fragment,{children:[Le,l.jsxs("div",{className:"nc-set-info",children:[f(U?"fleet-editor-load-error":"fleet-editor-unavailable"),!U&&h.reason?` ${h.reason}`:""]})]}),U&&l.jsx("div",{className:"nc-err",children:U}),$&&l.jsx(ks,{onClose:()=>L(null),label:f("import-as-cell"),error:U,children:l.jsx(Z_,{token:e,route:$.route||de,state:$,setState:L,busy:z,onSave:ye})}),R&&l.jsx(zl,{cell:R,token:e,route:Array.isArray(R.route)?R.route:de,onConfirm:async ie=>{try{await Lt(ie)}finally{await fe()}},onClose:()=>B(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[qe,ee==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:f("fleet-overview-help")}),l.jsx(Ud,{token:e,targets:n,readonly:t,onPower:Dt,onImport:Ct})]}):l.jsxs(l.Fragment,{children:[Le,l.jsx("div",{className:"nc-set-info",children:f("fleet-editor-loading")})]})]})}const Qf="nc_notification_speech_v1",jl="nc-notification-speech",Xh="nc-notification-speech-preview",Wj=320,Kj=2,qj=3e4,Vj=1e4,Yj=6e4,Gj=64,ey=Object.freeze({enabled:!1}),Xj=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),Qj=Object.freeze({it:new Set(["che","con","correzione","della","delle","difetto","il","lavoro","nessun","non","per","pronto","pubblicata","pubblicato","rilascio","sono","stato","tutti","verificata","verificato","versione","completata","completato","riepilogo"]),en:new Set(["all","and","completed","fix","for","issue","no","published","ready","release","summary","the","verified","version","with","work"]),es:new Set(["con","correccion","defecto","el","esta","para","publicada","publicado","resumen","sin","todos","trabajo","verificada","verificado","version","y"])}),Jf=new WeakSet;function Zf(e){return{enabled:(e&&typeof e=="object"&&!Array.isArray(e)?e:{}).enabled===!0}}function Rb(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function ty(e=Rb()){if(!e)return{...ey};try{return Zf(JSON.parse(e.getItem(Qf)||"null"))}catch{return{...ey}}}function Jj(e,t=Rb()){const n=Zf(e);if(t)try{t.setItem(Qf,JSON.stringify(n))}catch{}return n}function Yr(){try{return typeof window<"u"?window:null}catch{return null}}function na(e=Yr()){try{return!!(e&&e.speechSynthesis&&typeof e.speechSynthesis.speak=="function"&&typeof e.SpeechSynthesisUtterance=="function")}catch{return!1}}function Pb(e=Yr()){return!!(e&&(typeof e=="object"||typeof e=="function")&&Jf.has(e))}function Qh(e=Yr()){e&&(typeof e=="object"||typeof e=="function")&&Jf.delete(e)}function Or(e){const t=String(e||"").trim().toLowerCase().split("-")[0];return Xj[t]||""}function hc(e){return String(e||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function Zj(e){const t=hc(e).normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase(),n=new Set(t.match(new RegExp("\\p{L}+","gu"))||[]);if(n.size<4)return"";const s=Object.entries(Qj).map(([o,a])=>({lang:o,score:[...n].reduce((u,h)=>u+(a.has(h)?1:0),0)})).sort((o,a)=>a.score-o.score);return s[0].score>=3&&s[0].score-s[1].score>=2?s[0].lang:""}function eR(e,t){const n=Or(e&&e.lang);return n||Or(Zj(e&&e.body))||Or(t)}function Ab(e){try{const t=e&&e.speechSynthesis&&e.speechSynthesis.getVoices;return typeof t=="function"?Array.from(t.call(e.speechSynthesis)||[]).filter(Boolean):[]}catch{return[]}}function Lb(e,t){const n=Or(t);if(!n)return null;const s=Array.from(e||[]).filter(h=>h&&typeof h.lang=="string"&&h.lang.trim()),o=s.filter(h=>h.lang.trim().toLowerCase()===n.toLowerCase()),a=n.slice(0,2).toLowerCase(),u=s.filter(h=>h.lang.trim().toLowerCase().split("-")[0]===a);return o.find(h=>h.default===!0)||o[0]||u.find(h=>h.default===!0)||u[0]||null}function ny(e){return hc(e).replace(/\bBearer\s+\S+/gi,"Bearer [redacted]").replace(/\b(?:sk|hf|zai|xox[baprs]|gh[pousr]|npm)[_-][A-Za-z0-9._-]{8,}\b/gi,"[redacted]").replace(/\b(?:token|password|secret|credential|api[_-]?key)\s*[=:]\s*(?:"[^"]*"|'[^']*'|\S+)/gi,"[redacted]").replace(/\b[A-Z][A-Z0-9_]{2,}\s*=\s*(?:"[^"]*"|'[^']*'|\S+)/g,"[redacted]").replace(/(?:\/home\/[^/\s]+|\/Users\/[^/\s]+|\/data\/(?:data|user\/\d+)\/[^/\s]+)(?:\/[^\s]*)?/g,"[private path]").replace(/\b[A-Za-z]:\\Users\\[^\\\s]+(?:\\[^\s]*)?/g,"[private path]")}function tR(e,t=Wj){const n=ny(e&&e.title),s=ny(e&&e.body),o=[n,s&&s!==n?s:""].filter(Boolean).join(". "),a=Array.from(o);return a.length<=t?o:`${a.slice(0,Math.max(0,t-1)).join("").trimEnd()}…`}function nR(e){try{return!!(e&&e.visibilityState==="visible"&&typeof e.hasFocus=="function"&&e.hasFocus())}catch{return!1}}function Tb(e=Yr()){if(!na(e))return!1;try{return e.speechSynthesis.cancel(),!0}catch{return!1}}function iR(e){try{e&&typeof e.dispatchEvent=="function"&&typeof e.Event=="function"&&e.dispatchEvent(new e.Event(Xh))}catch{}}function sR(e,t,n=Yr(),s={}){var m;if(Qh(n),!na(n))return Promise.resolve(!1);const o=hc(e);if(!o||(m=s.signal)!=null&&m.aborted)return Promise.resolve(!1);const a=Number.isFinite(s.timeoutMs)&&s.timeoutMs>0?s.timeoutMs:Vj,u=s.setTimer||((v,w)=>setTimeout(v,w)),h=s.clearTimer||(v=>clearTimeout(v)),p=s.signal;return iR(n),new Promise(v=>{let w=!1,y=!1,S=null,k=null;const E=b=>{if(!w){if(w=!0,p&&k&&p.removeEventListener("abort",k),S!==null&&h(S),b)Jf.add(n);else try{n.speechSynthesis.cancel()}catch{}v(b)}};k=()=>E(!1),p&&p.addEventListener("abort",k,{once:!0});try{n.speechSynthesis.cancel();const b=new n.SpeechSynthesisUtterance(o);b.lang=Or(t);const j=Lb(Ab(n),b.lang);j&&(b.voice=j),b.onstart=()=>{y=!0},b.onend=()=>E(y),b.onerror=()=>E(!1),S=u(()=>E(!1),a),n.speechSynthesis.speak(b)}catch{E(!1)}})}function rR(e={}){const t=e.scope||Yr(),n=e.document||t&&t.document,s=Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:Kj,o=Number.isFinite(e.watchdogMs)&&e.watchdogMs>0?e.watchdogMs:qj,a=Number.isFinite(e.dedupWindowMs)&&e.dedupWindowMs>0?e.dedupWindowMs:Yj,u=Number.isInteger(e.maxDedup)&&e.maxDedup>0?e.maxDedup:Gj,h=e.now||Date.now,p=e.setTimer||((q,F)=>setTimeout(q,F)),m=e.clearTimer||(q=>clearTimeout(q)),v=e.isPrimed||(()=>Pb(t)),w=t&&t.speechSynthesis;let y=null,S=null,k=[],E=[],b=()=>{};const j=new Map,N=()=>{E=Ab(t)};if(N(),w&&typeof w.addEventListener=="function")w.addEventListener("voiceschanged",N),b=()=>w.removeEventListener("voiceschanged",N);else if(w&&"onvoiceschanged"in w){const q=w.onvoiceschanged,F=(...R)=>{N(),typeof q=="function"&&q.apply(w,R)};w.onvoiceschanged=F,b=()=>{w.onvoiceschanged===F&&(w.onvoiceschanged=q)}}const z=q=>{if(q&&typeof q.id=="string"&&q.id)return`id:${q.id}`;const F=Number(q&&q.ts),R=hc(q&&q.title);return Number.isFinite(F)&&R?`frame:${F}:${R}`:""},D=q=>{if(!q)return!0;const F=h();for(const[R,B]of j)F-B>=a&&j.delete(R);if(j.has(q))return!1;for(j.set(q,F);j.size>u;)j.delete(j.keys().next().value);return!0},U=()=>{S!==null&&m(S),S=null},W=()=>{U(),y&&(y.onend=null,y.onerror=null,y=null),Tb(t)},K=q=>{if(!na(t))return k=[],"unsupported";let F;try{F=new t.SpeechSynthesisUtterance(q.text),F.lang=Or(q.lang);const B=Lb(E,F.lang);B&&(F.voice=B)}catch{return k=[],"error"}y=F;const R=()=>{if(y!==F)return;U(),y=null,F.onend=null,F.onerror=null;const B=k.shift();B&&K(B)};F.onend=R,F.onerror=R;try{return S=p(()=>{if(y!==F)return;y=null,F.onend=null,F.onerror=null;try{t.speechSynthesis.cancel()}catch{}U();const B=k.shift();B&&K(B)},o),t.speechSynthesis.speak(F),"speaking"}catch{return R(),"error"}},te=(q,F)=>{if(!na(t))return"unsupported";const R=tR(q);if(!R)return"empty";if(!D(z(q)))return"duplicate";if(!nR(n))return"inactive";if(!v())return"unprimed";const B={text:R,lang:F};return q&&q.urgency==="high"?(k=[],W(),K(B)):y?s===0?"dropped":(k.length>=s&&k.shift(),k.push(B),"queued"):K(B)},G=()=>{k=[],W()};return{enqueue:te,stop:G,dispose:()=>{G(),b(),b=()=>{}}}}function Mb(){const[e,t]=C.useState(ty);C.useEffect(()=>{const s=o=>{if((o==null?void 0:o.type)==="storage"&&o.key!==Qf&&o.key!==null)return;const a=(o==null?void 0:o.type)===jl?Zf(o.detail):ty();t(a)};return window.addEventListener(jl,s),window.addEventListener("storage",s),()=>{window.removeEventListener(jl,s),window.removeEventListener("storage",s)}},[]);const n=C.useCallback(s=>{const o=Jj({enabled:s===!0});return t(o),window.dispatchEvent(new CustomEvent(jl,{detail:o})),o.enabled},[]);return[e.enabled,n]}function oR({text:e}){const[t,n]=C.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return l.jsxs("div",{className:"nc-set-copyline",children:[l.jsx("code",{children:e}),l.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[l.jsx(at,{name:"copy",size:14})," ",f(t?"copied":"copy")]})]})}function aR({value:e}){const[t,n]=C.useState("");return C.useEffect(()=>{let s=!0;return I2.toDataURL(e,{margin:1,width:220}).then(o=>{s&&n(o)}).catch(()=>{}),()=>{s=!1}},[e]),t?l.jsx("img",{src:t,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function lR({token:e,nodes:t,roster:n,settings:s,readonly:o,refresh:a,refreshAliases:u,vlUnavailable:h=[]}){const[p,m]=C.useState(null),[v,w]=C.useState(null),[y,S]=C.useState(null),[k,E]=C.useState({ssh:"",sshPort:"",name:""}),[b,j]=C.useState(""),[N,z]=C.useState(""),[D,U]=C.useState(!1),[W,K]=C.useState(null),te=Date.now(),G=s&&s.deviceName||"",Q=(t||[]).filter(x=>x&&x.direction==="outbound"&&x.name&&x.ssh),q=Q.find(x=>x.name===b)||Q[0]||null,F=q?th(q.tunnel,te):null,R=q!=null&&q.shared?F!=null&&F.up?"share-local-active":"share-local-pending":F!=null&&F.up?"share-local-private":"share-local-private-down",B=[{key:"peer-group-hubs",rows:(t||[]).filter(x=>x.kind!=="transitive"&&x.kind!=="vl"&&x.relation!=="client")},{key:"peer-group-clients",rows:(t||[]).filter(x=>x.kind!=="transitive"&&x.kind!=="vl"&&x.relation==="client")},{key:"peer-group-routed",rows:(t||[]).filter(x=>x.kind==="transitive")},{key:"peer-group-vl",rows:(t||[]).filter(x=>x.kind==="vl")}],$=W&&(t||[]).find(x=>`${x.kind||"direct"}:${x.nodeId||x.name}`===W)||null,L=async x=>{if(q){m(null),w(`${q.name}:share`);try{const I=await ox(e,q.name,x);await a(),I&&I.reversePoolPending===!0&&m(`${q.name}: ${f("share-reverse-pool-pending")}`)}catch(I){const T=I!=null&&I.data&&I.data.shared===!1?I.data:null;if(T)try{await a()}catch{}const M=I!=null&&I.data&&typeof I.data.hint=="string"?I.data.hint:"",O=(T==null?void 0:T.revoked)===!0&&(T==null?void 0:T.localReconcilePending)===!0?f("share-off-local-reconcile-pending"):(T==null?void 0:T.revoked)===!1&&(T==null?void 0:T.reconcilePending)===!0?f("share-off-hub-reconcile-pending"):"",H=I!=null&&I.data&&I.data.reversePoolPending===!0?f("share-reverse-pool-pending"):"",se=I!=null&&I.data&&typeof I.data.code=="string"?I.data.code:"",ee=I!=null&&I.data&&typeof I.data.detail=="string"?I.data.detail.trim():"",le=ee&&ee!==String(I.message||"")?ee:"";m(`${q.name}: ${String(I.message||I)}${se?` [${se}]`:""}${le?` — ${le}`:""}${M?` — ${M}`:""}${O?` — ${O}`:""}${H?` — ${H}`:""}`)}w(null)}},A=async()=>{m(null);const x=Rs(k.name||N||G||"NexusCrew"),I=gk({name:x,ssh:k.ssh,sshPort:k.sshPort});if(!I.ok){m(f(I.error));return}w("invite");try{S(await nx(e,{...N||G?{label:N||G}:{},name:x,ssh:I.value.ssh,...I.value.sshPort?{sshPort:I.value.sshPort}:{}}))}catch(T){m(String(T.message||T))}w(null)};return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-sheet-label",children:f("peer-inventory-title")}),(t||[]).length===0&&l.jsx("div",{className:"nc-empty",children:f("no-nodes")}),B.map(x=>x.rows.length>0&&l.jsxs("div",{className:"nc-peer-group",children:[l.jsxs("div",{className:"nc-peer-group-title",children:[f(x.key)," ",l.jsx("span",{children:x.rows.length})]}),x.rows.map(I=>{const T=Y2(I);if(!T)return null;const M=`${I.kind||"direct"}:${I.nodeId||I.name}`,O=T.routed?{up:T.reach.up,since:null}:th(I.tunnel,te);return l.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${T.routed?" routed":""}`,"aria-label":`${T.title} — ${f("node-detail-open")}`,onClick:()=>K(M),children:[l.jsx("span",{className:`nc-dot ${T.reach.up?"on":""}`}),l.jsxs("span",{className:"nc-node-row-text",children:[l.jsx("b",{children:T.title}),l.jsxs("small",{children:[T.routed?T.routeLabel:`${T.subtitle} · ${f(T.exposure.shortKey)}`,!T.routed&&T.exposure.shortKey==="visibility-selected"?` (${T.exposure.count})`:""]})]}),l.jsxs("span",{className:`nc-set-tunnel${T.reach.up?" up":""}`,children:[f(T.reach.key),O.since?` · ${O.since}`:""]}),l.jsx("span",{className:"nc-node-row-more",children:l.jsx(at,{name:"chevronDown",size:14})})]},M)})]},x.key)),h.length>0&&l.jsxs("div",{className:"nc-err",children:[f("vl-owners-unavailable"),": ",h.map(x=>x.label||x.route.join("/")).join(", ")]}),$&&l.jsx(cj,{node:$,nodes:t||[],token:e,readonly:o,refresh:a,onClose:()=>K(null)}),(n||[]).some(x=>!x.direct&&x.instanceId)&&l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("routed-node-aliases")}),l.jsx("small",{className:"nc-set-hint",children:f("routed-node-aliases-help")}),(n||[]).filter(x=>!x.direct&&x.instanceId).map(x=>l.jsxs("div",{className:"nc-set-node",children:[l.jsxs("div",{className:"nc-set-node-head",children:[l.jsx("span",{className:`nc-dot ${x.status==="up"?"on":""}`}),l.jsx("b",{children:x.label||x.name}),l.jsx("small",{children:(x.route||[]).join(" › ")})]}),l.jsxs("div",{className:"nc-set-node-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{const I=window.prompt(f("node-local-alias"),x.alias||"");if(I!=null){if(I.trim()&&!$r(I.normalize("NFC"))){m(f("err-label"));return}w(`${x.instanceId}:alias`),m(null);try{I.trim()?await sx(e,x.instanceId,I):await Ig(e,x.instanceId),u()}catch(T){m(String(T.message||T))}w(null)}},children:f("alias-on-device")}),x.alias&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:async()=>{w(`${x.instanceId}:alias-reset`),m(null);try{await Ig(e,x.instanceId),u()}catch(I){m(String(I.message||I))}w(null)},children:f("reset-alias")})]})]},x.instanceId))]}),q&&l.jsxs("div",{className:"nc-set-form nc-local-share",children:[l.jsx("div",{className:"nc-sheet-label",children:f("share-local-heading")}),Q.length>1&&l.jsxs("label",{className:"nc-field",children:[f("share-local-hub"),l.jsx("select",{value:q.name,disabled:o||!!v,onChange:x=>j(x.target.value),children:Q.map(x=>l.jsx("option",{value:x.name,children:x.label||x.name},x.name))})]}),l.jsxs("label",{className:"nc-check nc-node-share",children:[l.jsx("input",{type:"checkbox",checked:q.shared===!0,disabled:o||!!v,onChange:x=>L(x.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("share-local-through").replace("{device}",G||f("local")).replace("{hub}",q.label||q.name)}),l.jsx("small",{children:f(q.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),l.jsx("div",{className:`nc-set-test${q.shared&&(F!=null&&F.up)?" ok":F!=null&&F.up?"":" ko"}`,children:f(R)}),!(F!=null&&F.up)&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:o||!!v,onClick:()=>L(q.shared===!0),children:f("share-local-reconnect")})]}),l.jsx(vb,{token:e,deviceDefault:G,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:o,onSuccess:a}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("invite-node")}),l.jsx("small",{className:"nc-set-hint",children:f("invite-v2-hint")}),l.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[f("invite-target-local"),": ",l.jsx("b",{children:G||f("invite-target-this")})]}),l.jsxs("label",{className:"nc-field",children:[f("invite-endpoint-label"),l.jsx("input",{placeholder:"user@host",value:k.ssh,disabled:o,onChange:x=>E({...k,ssh:x.target.value})}),l.jsx("small",{className:"nc-set-hint",children:f("invite-endpoint-needed")})]}),Q.length>0&&l.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:f("invite-hub-only")}),D&&l.jsxs("div",{className:"nc-invite-advanced",children:[l.jsxs("label",{className:"nc-field",children:[f("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:"22",value:k.sshPort,disabled:o,onChange:x=>E({...k,sshPort:x.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-field",children:[f("device-name-label"),l.jsx("input",{placeholder:G||"NexusCrew",value:N,disabled:o,onChange:x=>z(x.target.value)}),l.jsx("small",{className:"nc-set-hint",children:f("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[f("node-name-label"),l.jsx("input",{placeholder:Rs(N||G||f("node-name-ph")),value:k.name,disabled:o,onChange:x=>E({...k,name:x.target.value?Rs(x.target.value):""})})]})]}),l.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:o||!!v||!k.ssh.trim(),onClick:A,children:f("create-pairing-link")}),l.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!v,onClick:()=>U(x=>!x),children:[D?"▾":"▸"," ",f("pair-advanced")]})]}),y&&l.jsxs(l.Fragment,{children:[l.jsx(aR,{value:y.pairingUrl}),l.jsx(oR,{text:y.pairingUrl}),l.jsx("div",{className:"nc-set-info",children:f("invite-next-steps")})]})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function cR({token:e,readonly:t}){const[n,s]=C.useState("idle"),[o,a]=C.useState(!1),[u,h]=C.useState(null);C.useEffect(()=>{let m=!1;return dj().then(v=>{m||s(v)}),()=>{m=!0}},[]);const p=async()=>{h(null),a(!0);try{n==="subscribed"?(await fj(e),s("idle")):(await hj(e),s("subscribed"))}catch(m){const v=String(m.message||m);v==="push-denied"?(s("denied"),h(f("push-denied"))):v==="push-unsupported"?(s("unsupported"),h(f("push-unsupported"))):h(v)}a(!1)};return n==="unsupported"?l.jsx("div",{className:"nc-set-info",children:f("push-unsupported")}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||o||n==="denied",title:t?f("settings-readonly"):"",onClick:p,children:f(n==="subscribed"?"push-disable":"push-enable")}),l.jsx("span",{className:"nc-set-info",children:f(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),u&&l.jsx("div",{className:"nc-err",children:u})]})}function uR(){const[e,t]=Mb(),[n,s]=C.useState(""),[o,a]=C.useState(""),[u,h]=C.useState(!1),[p,m]=C.useState(Pb),v=C.useRef(0),w=C.useRef(!1),y=C.useRef(null),S=na();C.useEffect(()=>()=>{var b;v.current+=1,w.current&&((b=y.current)==null||b.abort(),y.current=null,w.current=!1,Qh())},[]);const k=async()=>{const b=v.current+=1,j=typeof AbortController=="function"?new AbortController:null;s(""),a(""),h(!0),m(!1),w.current=!0,y.current=j;const N=await sR(f("notification-speech-preview"),Bl(),void 0,j?{signal:j.signal}:{});return b!==v.current||(y.current=null,w.current=!1,h(!1),m(N),N?a(f("notification-speech-preview-ok")):s(f("notification-speech-preview-failed"))),N},E=b=>{var j;if(t(b),s(""),a(""),b)k();else{v.current+=1;const N=w.current;(j=y.current)==null||j.abort(),y.current=null,w.current=!1,h(!1),m(!1),Qh(),N||Tb()}};return l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("notification-speech-enable"),checked:e,disabled:!S,onChange:b=>E(b.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("notification-speech-enable")}),l.jsx("small",{children:f("notification-speech-help")})]})]}),S?l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!e||u,onClick:()=>{k()},children:f(u?"notification-speech-testing":"notification-speech-test")})}):l.jsx("div",{className:"nc-set-info",children:f("notification-speech-unsupported")}),e&&!p&&!u&&!n&&l.jsx("div",{className:"nc-set-info",children:f("notification-speech-needs-test")}),o&&l.jsx("div",{className:"nc-set-info",role:"status",children:o}),n&&l.jsx("div",{className:"nc-err",children:n})]})}function dR({token:e,readonly:t,nodes:n=[],settings:s=null}){const[o,a]=C.useState(null),[u,h]=C.useState([]),[p,m]=C.useState({name:"",mode:"primary-failover",targets:[]}),[v,w]=C.useState(null),[y,S]=C.useState(!1),[k,E]=C.useState(null),[b,j]=C.useState(""),N=C.useCallback(async()=>{try{const[A,x]=await Promise.all([lx(e),hx(e)]);a(A),h(Array.isArray(x==null?void 0:x.groups)?x.groups:[]),j("")}catch(A){j(String(A.message||A))}},[e]);C.useEffect(()=>{N()},[N]);const z=async A=>{S(!0),E(null),j("");try{a(await cx(e,A))}catch(x){j(String(x.message||x))}S(!1)},D=async()=>{S(!0),E(null),j("");try{E({kind:"test",...await ux(e)})}catch(A){j(String(A.message||A))}S(!1)},U=async()=>{S(!0),E(null),j("");try{E({kind:"stop",...await dx(e)})}catch(A){j(String(A.message||A))}S(!1)},W=[],K=new Set,te=(A,x)=>{const I=typeof A=="string"?A.toLowerCase():"";!/^[a-f0-9]{32}$/.test(I)||K.has(I)||(K.add(I),W.push({id:I,label:x||I}))};te(s==null?void 0:s.nodeId,f("audio-group-local"));for(const A of n||[])te((A==null?void 0:A.nodeId)||(A==null?void 0:A.instanceId),(A==null?void 0:A.label)||(A==null?void 0:A.name)||(A==null?void 0:A.nodeId));for(const A of p.targets)te(A,`${A} (${f("audio-group-unavailable-target")})`);const G=(A=null)=>{j(""),A?(w(A.name),m({name:A.name,mode:A.mode,targets:[...A.targets||[]]})):(w(null),m({name:"",mode:"primary-failover",targets:[]}))},Q=(A,x)=>m(I=>({...I,targets:x?[...new Set([...I.targets,A])]:I.targets.filter(T=>T!==A)})),q=async()=>{const A=p.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(A)||p.targets.length<1){j(f("audio-group-invalid"));return}S(!0),j("");try{const x=await fx(e,A,{targets:p.targets,mode:p.mode}),I=x==null?void 0:x.group;if(!I||!I.name)throw new Error(f("audio-group-save-failed"));h(T=>[...T.filter(M=>M.name!==I.name),I].sort((M,O)=>M.name.localeCompare(O.name))),G(null)}catch(x){j(String(x.message||x))}S(!1)},F=async A=>{S(!0),j("");try{await px(e,A),h(x=>x.filter(I=>I.name!==A)),v===A&&G(null)}catch(x){j(String(x.message||x))}S(!1)},R=(o==null?void 0:o.installed)===!0,B=(o==null?void 0:o.liveness)==="ready",$=(o==null?void 0:o.consent)===!0&&R&&B,L=k?k.kind==="stop"?f(k.stopped?"audio-stop-stopped":"audio-stop-idle"):k.status==="accepted"||k.status==="spoken"?f("audio-test-accepted"):k.status==="unknown"?f("audio-test-unknown"):`${f("audio-test-refused")}${k.reason?` (${k.reason})`:""}`:"";return l.jsxs("div",{className:"nc-set-tab nc-audio-settings",children:[l.jsxs("div",{className:"nc-set-info",children:[l.jsx("b",{children:f("audio-title")}),l.jsx("br",{}),f("audio-help")]}),o?l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("audio-consent"),checked:o.consent===!0,disabled:t||y,onChange:A=>{z(A.target.checked)}}),l.jsxs("span",{children:[l.jsx("b",{children:f("audio-consent")}),l.jsx("small",{children:f("audio-consent-help")})]})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("audio-capability")}),l.jsxs("div",{className:"nc-set-info",children:[f("audio-adapter"),": ",o.adapter||f("audio-adapter-none"),l.jsx("br",{}),f("audio-installed"),": ",f(R?"audio-installed-yes":"audio-installed-no"),l.jsx("br",{}),f("audio-liveness"),": ",f(B?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(o.languages)&&o.languages.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),f("audio-languages"),": ",o.languages.join(", ")]})]}),o.limits&&l.jsxs("small",{className:"nc-set-hint",children:[f("audio-limits"),": ",o.limits]})]}),!o.consent&&l.jsx("div",{className:"nc-set-info",children:f("audio-test-needs-consent")}),!R&&l.jsx("div",{className:"nc-set-info",children:f("audio-unavailable")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||y||!$,title:t?f("settings-readonly"):"",onClick:()=>{D()},children:f(y?"audio-testing":"audio-test")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>{U()},children:f(y?"audio-stopping":"audio-stop")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>{N()},children:f("refresh")})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("audio-groups-title")}),l.jsx("small",{className:"nc-set-hint",children:f("audio-groups-help")}),u.length===0&&l.jsx("div",{className:"nc-set-info",children:f("audio-groups-empty")}),u.map(A=>{var x;return l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("span",{children:[l.jsx("b",{children:A.name})," ",l.jsxs("small",{children:["· ",A.mode==="fanout"?f("audio-group-fanout"):f("audio-group-primary")," · ",((x=A.targets)==null?void 0:x.length)||0]})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>G(A),children:f("audio-group-edit")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>{F(A.name)},children:f("audio-group-delete")})]},A.name)}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:t||y,onClick:()=>G(null),children:f("audio-group-new")})}),l.jsxs("label",{className:"nc-field",children:[f("audio-group-name"),l.jsx("input",{"aria-label":f("audio-group-name"),value:p.name,maxLength:"32",disabled:t||y,onChange:A=>m(x=>({...x,name:A.target.value}))})]}),l.jsxs("label",{className:"nc-field",children:[f("audio-group-mode"),l.jsxs("select",{"aria-label":f("audio-group-mode"),value:p.mode,disabled:t||y,onChange:A=>m(x=>({...x,mode:A.target.value})),children:[l.jsx("option",{value:"primary-failover",children:f("audio-group-primary")}),l.jsx("option",{value:"fanout",children:f("audio-group-fanout")})]})]}),l.jsx("div",{className:"nc-set-info",children:f("audio-group-targets")}),W.length===0?l.jsx("small",{className:"nc-set-hint",children:f("audio-group-no-targets")}):W.map(A=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:p.targets.includes(A.id),disabled:t||y,onChange:x=>Q(A.id,x.target.checked)}),l.jsxs("span",{children:[A.label,l.jsx("small",{children:A.id})]})]},A.id)),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:t||y,onClick:()=>{q()},children:f("audio-group-save")}),v&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:y,onClick:()=>G(null),children:f("audio-group-cancel")})]})]})]}):l.jsx("div",{className:"nc-set-info",children:f("audio-loading")}),L&&l.jsx("div",{className:"nc-set-note",role:"status",children:L}),b&&l.jsx("div",{className:"nc-err",children:b})]})}function hR(){const[e,t]=If();return l.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[l.jsx("div",{className:"nc-set-info",children:f("input-settings-local")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-field",children:[f("terminal-keyboard-gesture"),l.jsx("select",{"aria-label":f("terminal-keyboard-gesture"),value:e.terminalKeyboardGesture,onChange:n=>t({terminalKeyboardGesture:n.target.value}),children:Yw.map(n=>l.jsx("option",{value:n,children:f(`terminal-keyboard-${n}`)},n))}),l.jsx("small",{children:f("terminal-keyboard-gesture-help")})]}),l.jsxs("label",{className:"nc-field",children:[f("keybar-layout"),l.jsx("select",{"aria-label":f("keybar-layout"),value:e.keybarLayout,onChange:n=>t({keybarLayout:n.target.value}),children:Gw.map(n=>l.jsx("option",{value:n,children:f(`keybar-layout-${n}`)},n))}),l.jsx("small",{children:f("keybar-layout-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.keybarKeepsKeyboardClosed,onChange:n=>t({keybarKeepsKeyboardClosed:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("keybar-ime-lock")}),l.jsx("small",{children:f("keybar-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.voiceKeepsKeyboardClosed,onChange:n=>t({voiceKeepsKeyboardClosed:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("voice-ime-lock")}),l.jsx("small",{children:f("voice-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:e.showKeybarEnter,onChange:n=>t({showKeybarEnter:n.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:f("keybar-enter-show")}),l.jsx("small",{children:f("keybar-enter-show-help")})]})]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>t(Es),children:f("input-settings-reset")})})]})}function fR({token:e,roster:t=[],readonly:n}){const s=[{key:"local",route:[],label:f("diagnostics-local"),status:"up"},...t.filter($=>Array.isArray($.route)&&$.route.length).map($=>({key:$.route.join("/"),route:$.route,label:$.label||$.name,status:$.status}))],[o,a]=C.useState("local"),u=s.find($=>$.key===o)||s[0],[h,p]=C.useState(null),[m,v]=C.useState([]),[w,y]=C.useState(""),[S,k]=C.useState(!1),[E,b]=C.useState(!0),[j,N]=C.useState(900),[z,D]=C.useState("all"),[U,W]=C.useState(""),K=C.useRef(0),te=C.useRef(null),G=C.useCallback(async()=>{try{const $=await _x(e,u.route);if(p($),y(""),!S){const L=await yx(e,{after:K.current,limit:200},u.route);Array.isArray(L.records)&&L.records.length&&(K.current=L.cursor,v(A=>[...A,...L.records].slice(-500)))}}catch($){y($&&$.status===404?f("diagnostics-unsupported"):String($.message||$))}},[e,u.key,S]);C.useEffect(()=>{K.current=0,v([]),p(null),y("")},[u.key]),C.useEffect(()=>{let $=null,L=!0;const A=()=>{!L||document.visibilityState==="hidden"||G()},x=()=>{$&&clearInterval($),$=document.visibilityState==="hidden"?null:setInterval(A,2e3),document.visibilityState!=="hidden"&&A()};return document.addEventListener("visibilitychange",x),x(),()=>{L=!1,$&&clearInterval($),document.removeEventListener("visibilitychange",x)}},[G]),C.useEffect(()=>{E&&te.current&&(te.current.scrollTop=te.current.scrollHeight)},[m,E]);const Q=m.filter($=>(z==="all"||$.level===z)&&(!U||String($.component||"").toLowerCase().includes(U.toLowerCase()))),q=Q.map($=>`${$.ts} ${$.level.toUpperCase()} ${$.component} ${$.code} ${$.message}${Object.keys($.meta||{}).length?` ${JSON.stringify($.meta)}`:""}`).join(`
|
|
92
|
+
`),F=async $=>{y("");try{const L=await $();p(L),await G()}catch(L){y(String(L.message||L))}},R=async()=>{try{await navigator.clipboard.writeText(q)}catch{y(f("copy-manual"))}},B=()=>{try{const $=new Blob([`${JSON.stringify(Q,null,2)}
|
|
93
|
+
`],{type:"application/json"}),L=URL.createObjectURL($),A=document.createElement("a");A.href=L,A.download="nexuscrew-diagnostics.json",A.click(),URL.revokeObjectURL(L)}catch{y(f("diagnostics-export-failed"))}};return l.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[l.jsxs("label",{className:"nc-field",children:[f("diagnostics-target"),l.jsx("select",{value:u.key,onChange:$=>a($.target.value),children:s.map($=>l.jsxs("option",{value:$.key,children:[$.label,$.status!=="up"?` · ${$.status}`:""]},$.key))})]}),l.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[l.jsx("div",{className:"nc-sheet-label",children:f("diagnostics-verbose")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("select",{"aria-label":f("diagnostics-duration"),value:j,onChange:$=>N(Number($.target.value)),disabled:n,children:[300,900,1800,3600].map($=>l.jsxs("option",{value:$,children:[$/60," min"]},$))}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(h==null?void 0:h.verbose)===!0,onClick:()=>F(()=>Bg(e,!0,j,u.route)),children:f("enable")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(h==null?void 0:h.verbose)!==!0,onClick:()=>F(()=>Bg(e,!1,j,u.route)),children:f("stop")})]}),l.jsx("small",{className:"nc-set-hint",children:h!=null&&h.verbose?f("diagnostics-expires").replace("{time}",new Date(h.expiresAt).toLocaleTimeString()):f("diagnostics-off")})]}),l.jsxs("div",{className:"nc-diag-filters",children:[l.jsxs("select",{"aria-label":f("diagnostics-level"),value:z,onChange:$=>D($.target.value),children:[l.jsx("option",{value:"all",children:f("diagnostics-all-levels")}),["debug","info","warn","error"].map($=>l.jsx("option",{value:$,children:$},$))]}),l.jsx("input",{"aria-label":f("diagnostics-component"),placeholder:f("diagnostics-component"),value:U,onChange:$=>W($.target.value)})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:S,onChange:$=>k($.target.checked)})," ",f("diagnostics-pause")]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:E,onChange:$=>b($.target.checked)})," ",f("diagnostics-autoscroll")]})]}),l.jsx("pre",{ref:te,className:"nc-diag-log","aria-label":f("diagnostics-log"),children:q||f("diagnostics-empty")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:R,children:f("copy")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:B,children:f("diagnostics-export")}),l.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(f("diagnostics-clear-confirm"))&&F(async()=>{const $=await wx(e,u.route);return K.current=0,v([]),$})},children:f("diagnostics-clear")})]}),w&&l.jsx("div",{className:"nc-err",children:w})]})}function pR({token:e,settings:t,readonly:n,refresh:s,roster:o,section:a,setSection:u}){const[h,p]=C.useState(null),[m,v]=C.useState(null),[w,y]=C.useState(!1),[S,k]=C.useState(!1),[E,b]=C.useState(null),[j,N]=C.useState(!0),[z,D]=C.useState(!1);C.useEffect(()=>{b(t&&t.update||null),N(!t||t.autoUpdate!==!1),D(!!(t&&t.alternateScreen))},[t]);const U=async()=>{p(null),v(null),k(!0);try{const R=await ex(e);v(R.note||"ok"),y(!1)}catch(R){p(String(R.message||R))}k(!1)},W=async()=>{p(null),v(null),k(!0);try{const R=await mx(e);v(`${R.note||"ok"}${R.target?` (${R.target})`:""}`)}catch(R){p(String(R.message||R))}k(!1)},K=async R=>{p(null),v(null),k(!0);try{await Yd(e,{autoUpdate:R}),N(R),s&&await s()}catch(B){p(String(B.message||B))}k(!1)},te=async R=>{p(null),v(null),k(!0);try{await Yd(e,{alternateScreen:R}),D(R),s&&await s()}catch(B){p(String(B.message||B))}k(!1)},G=async()=>{p(null),v(null),k(!0);try{b(await gx(e))}catch(R){p(String(R.message||R))}k(!1)},Q=async()=>{p(null),v(null),k(!0);try{const R=await vx(e);b(R),v(f("npm-update-restarting"))}catch(R){p(String(R.message||R))}k(!1)},q=()=>{window.confirm(f("composer-clear-confirm"))&&(p(null),CN()?(window.dispatchEvent(new Event(Hh)),v(f("composer-clear-done"))):p(f("composer-clear-failed")))},F=t&&t.service;return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":f("tab-system"),children:["general","diagnostics"].map(R=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===R,className:`nc-set-tabbtn${a===R?" on":""}`,onClick:()=>u(R),children:f(`system-${R}`)},R))}),a==="general"&&l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-this-node")}),t&&l.jsxs("div",{className:"nc-set-info",children:["v",t.version," · ",t.platform," · :",t.port,l.jsx("br",{}),F&&F.installed?f("service-installed"):f("service-missing"),F&&F.installed?` · ${F.active?f("service-active"):f("service-inactive")}`:"",F?` · boot ${F.boot?"on":"off"}`:""]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?f("settings-readonly"):"",onClick:W,children:f("service-regenerate")})}),l.jsx(cR,{token:e,readonly:n}),l.jsx(uR,{})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-updates")}),l.jsxs("div",{className:"nc-set-form nc-update-settings",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:j,disabled:n||S||E&&!E.supported,onChange:R=>K(R.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("npm-auto-update")}),l.jsx("small",{children:f("npm-auto-update-help")})]})]}),E&&l.jsxs("div",{className:"nc-set-info",children:[f("npm-update-current")," v",E.current,E.latest?` · ${f("npm-update-latest")} v${E.latest}`:""," · ",f(`npm-update-${E.supported?E.phase:"unsupported"}`)]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S||!E||!E.supported,onClick:G,children:f("npm-update-check")}),E&&E.available&&l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||S||E.phase==="installing",onClick:Q,children:f("npm-update-install")})]}),E&&E.lastError&&l.jsx("div",{className:"nc-err",children:E.lastError})]})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-security")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||S,title:n?f("settings-readonly"):"",onClick:()=>{p(null),v(null),y(!0)},children:f("token-rotate")})})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:f("system-local-data")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:f("composer-clear-data")}),l.jsx("small",{className:"nc-set-hint",children:f("composer-clear-data-help")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:q,children:f("composer-clear-data")})})]})]})]}),a==="diagnostics"&&l.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[l.jsx("h3",{children:f("system-diagnostics")}),l.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[l.jsx("div",{className:"nc-sheet-label",children:f("system-terminal")}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":f("alternate-screen"),checked:z,disabled:n||S,onChange:R=>te(R.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:f("alternate-screen")}),l.jsx("small",{children:f("alternate-screen-help")})]})]})]}),l.jsx(fR,{token:e,roster:o,readonly:n})]}),w&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("div",{children:f("token-rotate-explain")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>y(!1),children:f("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:S,onClick:U,children:f("confirm")})]})]}),m&&l.jsx("div",{className:"nc-set-note",children:m}),h&&l.jsx("div",{className:"nc-err",children:h})]})}function mR({token:e,onClose:t,initialTab:n="nodes",initialLocation:s="",startNewCell:o=!1}){$n();const a=n==="diagnostics"?"diagnostics":"general",[u,h]=C.useState(n==="diagnostics"?"system":n),p=C.useRef(null),m=C.useRef(null),[v,w]=C.useState({start:!1,end:!1}),[y,S]=C.useState(a),[k,E]=C.useState(null),[b,j]=C.useState([]),[N,z]=C.useState([]),[D,U]=C.useState(!1),[W,K]=C.useState(null),[te,G]=C.useState(0),Q=hf(e,!0,te),q=C.useCallback(()=>{const R=p.current;if(!R)return;const B=R.scrollWidth>R.clientWidth+1,$={start:B&&R.scrollLeft>1,end:B&&R.scrollLeft+R.clientWidth<R.scrollWidth-1};w(L=>L.start===$.start&&L.end===$.end?L:$)},[]);C.useEffect(()=>{const R=p.current;if(!R)return;const B=typeof ResizeObserver=="function"?new ResizeObserver(q):null;return B==null||B.observe(R),window.addEventListener("resize",q),q(),()=>{B==null||B.disconnect(),window.removeEventListener("resize",q)}},[q]),C.useEffect(()=>{var B,$;($=(B=m.current)==null?void 0:B.scrollIntoView)==null||$.call(B,{behavior:"smooth",block:"nearest",inline:"nearest"});const R=window.requestAnimationFrame?window.requestAnimationFrame(q):setTimeout(q,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(R):clearTimeout(R)}},[u,q]);const F=C.useCallback(async()=>{var R;try{const B=await vy(e);E(B),K(null)}catch(B){K(String(B.message||B))}try{const $=(await J0(e)).peers||[];let L=[],A=[];try{const[x,I]=await Promise.all([en("/api/config",e).then(H=>H.json()).catch(()=>null),yy(e).catch(()=>null)]),T=x&&typeof x.instanceId=="string"?x.instanceId:"",M=[{instanceId:T||null,route:[],label:null},...jy(I,T)],O=await Promise.all(M.map(async H=>{try{return{ok:!0,peers:((await _y(e,H.route)).nodes||[]).map(le=>Ny(le,H)).filter(Boolean)}}catch(se){return{ok:!1,owner:H,error:se}}}));for(const H of O){if(H.ok){L.push(...H.peers);continue}H.owner.route.length!==0&&A.push({instanceId:H.owner.instanceId,label:H.owner.label,route:H.owner.route,failure:/timeout/i.test(String(((R=H.error)==null?void 0:R.message)||H.error))?"timeout":"unreachable"})}}catch{}z(A),j([...$,...L])}catch(B){K(String(B.message||B))}},[e]);return C.useEffect(()=>{F();const R=setInterval(F,5e3);return()=>clearInterval(R)},[F]),C.useEffect(()=>{let R=!1;return en("/api/config",e).then(B=>B.json()).then(B=>{R||U(!!B.readonlyDefault)}).catch(()=>{}),()=>{R=!0}},[e]),l.jsx("div",{className:"nc-set-overlay",onClick:t,children:l.jsxs("div",{className:"nc-set-panel",onClick:R=>R.stopPropagation(),children:[l.jsxs("div",{className:"nc-set-head",children:[l.jsx(at,{name:"gear",size:18}),l.jsx("b",{children:f("settings")}),l.jsx("button",{type:"button",className:"nc-set-close",onClick:t,title:f("close"),children:l.jsx(at,{name:"x",size:18})})]}),D&&l.jsx("div",{className:"nc-set-readonly",children:f("settings-readonly")}),W&&l.jsx("div",{className:"nc-err",children:W}),l.jsx("div",{className:`nc-set-tabs-wrap${v.start?" has-start-overflow":""}${v.end?" has-end-overflow":""}`,children:l.jsx("div",{className:"nc-set-tabs",ref:p,onScroll:q,children:["nodes","fleet","audio","input","system"].map(R=>l.jsx("button",{ref:u===R?m:null,type:"button",className:`nc-set-tabbtn${u===R?" on":""}`,onClick:()=>h(R),children:f(`tab-${R}`)},R))})}),l.jsxs("div",{className:"nc-set-body",children:[u==="nodes"&&l.jsx(lR,{token:e,nodes:b,roster:Q,settings:k,readonly:D,vlUnavailable:N,refresh:F,refreshAliases:()=>G(R=>R+1)}),u==="fleet"&&l.jsx(Uj,{token:e,readonly:D,startNewCell:o,initialLocation:s,targets:Q.map(R=>({route:R.route,label:R.label||R.name,status:R.status}))}),u==="audio"&&l.jsx(dR,{token:e,readonly:D,nodes:b,settings:k}),u==="input"&&l.jsx(hR,{}),u==="system"&&l.jsx(pR,{token:e,settings:k,readonly:D,refresh:F,roster:Q,section:y,setSection:S})]})]})})}function gR({token:e,initialPair:t,deviceDefault:n="",localNodeId:s="",localNameDefault:o="",onPairDone:a,onDone:u}){$n();const[h,p]=C.useState(t?"pair":"welcome"),[m,v]=C.useState(!1),[w,y]=C.useState(null),[S,k]=C.useState(null),E=async()=>{v(!0),y(null);try{await Yd(e,{wizardDone:!0}),a&&a(),u()}catch(b){y(String(b.message||b)),v(!1)}};return l.jsx("div",{className:"nc-wiz-overlay",children:l.jsxs("div",{className:"nc-wiz",children:[l.jsxs("div",{className:"nc-wiz-head",children:[l.jsx("b",{children:f("wizard-title")}),l.jsx("small",{children:f("hydra-simple")})]}),h==="welcome"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:f("local-ready")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:E,children:f("local-only")}),l.jsx("button",{className:"nc-btn primary",disabled:m,onClick:()=>p("pair"),children:f("add-node")})]})]}),h==="pair"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx(vb,{token:e,initial:t||"",autoStart:!!t,deviceDefault:n,localNodeId:s,localNameDefault:o,onBusyChange:v,onSuccess:async b=>{k(b&&b.authorizedKeys?{line:b.authorizedKeys,note:b.authorizedKeysNote||""}:null),a&&a(),p("done")}}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn ghost",disabled:m,onClick:()=>{a&&a(),p("welcome")},children:f("back")})})]}),h==="done"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:f("node-connected")}),S&&l.jsx(qf,{line:S.line,note:S.note}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn primary",disabled:m,onClick:E,children:f("finish")})})]}),w&&l.jsx("div",{className:"nc-err",children:w})]})})}function vR(e,t){if(typeof EventSource>"u"||!e)return()=>{};const n=new EventSource(`/api/events?token=${encodeURIComponent(e)}`);return n.onmessage=s=>{try{const o=JSON.parse(s.data);o&&typeof o=="object"&&typeof o.type=="string"&&t(o)}catch{}},()=>{try{n.close()}catch{}}}const _R=6e3,yR=12e3;function wR({n:e,onClose:t}){return l.jsxs("div",{className:`nc-ntf-toast${e.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[l.jsxs("div",{className:"nc-ntf-toast-txt",children:[l.jsx("b",{children:e.title}),e.body&&l.jsx("small",{children:e.body}),e.session&&l.jsx("span",{className:"nc-ntf-from",children:e.session})]}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:t,title:f("close"),children:l.jsx(at,{name:"x",size:14})})]})}function bR({ask:e,token:t,onAnswered:n,onDismiss:s}){const[o,a]=C.useState(""),[u,h]=C.useState(!1),[p,m]=C.useState(null),[v,w]=C.useState(!1),y=async k=>{const E=String(k||"").trim();if(!(!E||u)){m(null),h(!0);try{await Sx(t,e.id,E),n(e.id)}catch(b){m(String(b.message||b))}h(!1)}},S=async()=>{if(!v){w(!0);try{await xx(t,e.id),s(e.id)}catch{w(!1)}}};return l.jsxs("div",{className:"nc-ask-card",children:[l.jsxs("div",{className:"nc-ask-head",children:[l.jsx("span",{className:"nc-ntf-from",children:e.session}),l.jsxs("code",{className:"nc-ask-id",children:["#",e.id]}),l.jsx("button",{type:"button",className:"nc-ask-dismiss",title:f("ask-dismiss"),"aria-label":f("ask-dismiss"),disabled:v,onClick:S,children:l.jsx(at,{name:"x",size:14})})]}),l.jsx("div",{className:"nc-ask-q",children:e.question}),Array.isArray(e.options)&&e.options.length>0&&l.jsx("div",{className:"nc-ask-opts",children:e.options.map(k=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:u,onClick:()=>y(k),children:k},k))}),l.jsxs("div",{className:"nc-ask-reply",children:[l.jsx("textarea",{rows:2,placeholder:f("ask-reply-ph"),value:o,disabled:u,onChange:k=>a(k.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:u||!o.trim(),onClick:()=>y(o),children:f("send")})]}),p&&l.jsx("div",{className:"nc-err",children:p})]})}function SR({token:e}){const[t]=$n(),[n]=Mb(),[s,o]=C.useState([]),[a,u]=C.useState([]),[h,p]=C.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),m=C.useRef(0),v=C.useRef(null);v.current||(v.current=rR());const w=C.useRef({enabled:n,lang:t});w.current={enabled:n,lang:t};const y=C.useCallback(b=>{o(j=>j.filter(N=>N.key!==b))},[]),S=C.useCallback(b=>{const j=`t${m.current+=1}`;o(z=>[...z.slice(-3),{...b,key:j}]),setTimeout(()=>y(j),b.urgency==="high"?yR:_R);const N=w.current;if(N.enabled)try{v.current.enqueue(b,eR(b,N.lang))}catch{}},[y]);C.useEffect(()=>{n||v.current.stop()},[n]),C.useEffect(()=>{const b=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&v.current.stop()},j=()=>v.current.stop();return document.addEventListener("visibilitychange",b),window.addEventListener("blur",b),window.addEventListener(Xh,j),()=>{document.removeEventListener("visibilitychange",b),window.removeEventListener("blur",b),window.removeEventListener(Xh,j),typeof v.current.dispose=="function"?v.current.dispose():v.current.stop()}},[]),C.useEffect(()=>{if(!e)return;let b=!1;bx(e).then(N=>{b||u(N.asks||[])}).catch(()=>{});const j=vR(e,N=>{N.type==="notify"?S(N):N.type==="ask"&&N.ask&&N.ask.id?u(z=>z.some(D=>D.id===N.ask.id)?z:[...z,N.ask]):N.type==="ask-answered"&&N.id?u(z=>z.filter(D=>D.id!==N.id)):N.type==="ask-dismissed"&&N.id&&u(z=>z.filter(D=>D.id!==N.id))});return()=>{b=!0,j()}},[e,S]);const k=b=>u(j=>j.filter(N=>N.id!==b)),E=b=>u(j=>j.filter(N=>N.id!==b));return l.jsxs(l.Fragment,{children:[s.length>0&&l.jsx("div",{className:"nc-ntf-toasts",children:s.map(b=>l.jsx(wR,{n:b,onClose:()=>y(b.key)},b.key))}),a.length>0&&!h&&l.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>p(!0),title:f("asks-title"),children:["? ",l.jsx("span",{className:"nc-ask-count",children:a.length})]}),a.length>0&&h&&l.jsxs("div",{className:"nc-ask-panel",children:[l.jsxs("div",{className:"nc-ask-panel-head",children:[l.jsx("b",{children:f("asks-title")}),l.jsx("span",{className:"nc-ask-count",children:a.length}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>p(!1),title:f("close"),children:l.jsx(at,{name:"x",size:16})})]}),l.jsx("div",{className:"nc-ask-panel-body",children:a.map(b=>l.jsx(bR,{ask:b,token:e,onAnswered:k,onDismiss:E},b.id))})]})]})}const xR=4e3;async function kR(e){const t=await en("/api/sessions",e);if((t==null?void 0:t.ok)===!1)throw new Error(`HTTP ${t.status}`);const n=await t.json();if(!Array.isArray(n==null?void 0:n.sessions))throw new Error("invalid sessions payload");return n.sessions}async function Wd(e,t=[]){var h;const[n,s]=await Promise.allSettled([t.length?lf(e,t):kR(e),Ls(e,t)]),o=n.status==="fulfilled"&&Array.isArray((h=n.value)==null?void 0:h.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,a=s.status==="fulfilled"?s.value:null,u=(a==null?void 0:a.available)===!0&&Array.isArray(a.cells)?a.cells:null;return{sessions:o,cells:u,fresh:Array.isArray(o)&&Array.isArray(u)}}function Db(e,t,n){return n===!0&&(e==null?void 0:e.degraded)!==!0&&(e==null?void 0:e.active)===!0&&e.tmux!==!1&&!!e.tmuxSession&&(t||[]).some(s=>(s==null?void 0:s.name)===e.tmuxSession)}function CR(e){const t=new Map((e.sessions||[]).map(o=>[o.name,o])),n=[],s=(o,a,u,h=[],p="")=>{const m=new Map((a||[]).map(v=>[v.name,v]));for(const v of o||[]){const w=m.get(v.tmuxSession)||{},y=gf(v,w),S=Db(v,a,u);n.push({key:Qo(h,v.tmuxSession||v.cell),session:v.tmuxSession,route:h,cellName:v.cell,label:v.cell,node:h.length?h.join("/"):"",nodeLabel:p,live:S,selectable:S,verified:u===!0,working:y.working,degraded:!!v.degraded,active:v.active===!0,activity:w.activity||v.activity||0,subtitle:y.subtitle,preview:w.preview||v.preview||"",telemetry:w.telemetry||null,panelUrl:v.panelUrl||""})}};s(e.cells,[...t.values()],e.localFresh===!0);for(const o of e.nodeGroups||[]){const a=Array.isArray(o.route)?o.route:[];o.kind==="vl"||!a.length||s(o.cells,o.sessions,o.switcherFresh===!0,a,o.label||o.name||"")}return n}function ER(e){const t=new Map,n=Array.isArray(e.sessions)?e.sessions:[],s=Array.isArray(e.cells)?e.cells:[],o=new Map(n.map(u=>[u.name,u])),a=new Set(s.map(u=>u.tmuxSession).filter(Boolean));t.set("local",vf(s,n.filter(u=>!a.has(u.name)),o));for(const u of e.nodeGroups||[]){const h=Array.isArray(u.route)?u.route:[];if(u.kind==="vl"||!h.length)continue;const p=Array.isArray(u.cells)?u.cells:[],m=Array.isArray(u.sessions)?u.sessions:[],v=new Set(p.map(w=>w.tmuxSession).filter(Boolean));t.set(h.join("/"),Fl({...u,route:h,cells:p,sessions:m,unmanaged:m.filter(w=>!v.has(w.name))}).rawItems)}return t}function NR(e,t,n,s){return[...new Set(e.map(a=>a.node||"local"))].flatMap(a=>{const u=e.filter(v=>(v.node||"local")===a),h=new Map((t.get(a)||[]).map(v=>[v.key,v])),p=new Map(u.map(v=>[v.key,v])),m=u.map(v=>{const w=h.get(v.key);return{...v,label:(w==null?void 0:w.label)||v.label,live:(w==null?void 0:w.live)??v.live,fresh:(w==null?void 0:w.fresh)===!0,activity:(w==null?void 0:w.activity)??v.activity}});return js(m,n,"all",Ji(s,a)).map(v=>p.get(v.key))})}function jR({token:e,current:t,onPick:n,onClose:s,panelPort:o=0,nodePanelPorts:a={}}){const[u,h]=C.useState(Zg),[p,m]=C.useState(!1),[v,w]=C.useState(!1),[y,S]=C.useState(""),[k,E]=C.useState(null),[b,j]=C.useState(""),[N,z]=C.useState(""),D=C.useRef(null),U=C.useRef(null),W=C.useMemo(()=>CR(u),[u]),K=C.useMemo(()=>ER(u),[u]),{pins:te,orders:G,canMoveRoster:Q,moveRoster:q,stepRoster:F}=pf(),R=C.useMemo(()=>NR(W,K,te,G),[W,K,te,G]),B=C.useMemo(()=>p?R:R.filter(T=>T.selectable||T.degraded&&T.active),[R,p]),$=C.useMemo(()=>W.find(T=>T.key===b&&T.selectable),[W,b]),L=C.useMemo(()=>k?W.find(T=>T.key===k.key):null,[W,k]);C.useEffect(()=>{var O;const T=document.activeElement;(O=U.current)==null||O.focus();const M=H=>{H.key==="Escape"&&s()};return document.addEventListener("keydown",M),()=>{var H;document.removeEventListener("keydown",M),(H=T==null?void 0:T.focus)==null||H.call(T)}},[s]),C.useEffect(()=>{let T=!0,M=!1;const O=async()=>{if(M)return;M=!0;const se=Zg(),ee=Array.isArray(se.nodeGroups)?se.nodeGroups:[],le=Wd(e),ve=Ee=>Ee.kind!=="vl"&&Array.isArray(Ee.route)&&Ee.route.length>0,de=await Promise.all(ee.filter(ve).map(async Ee=>({group:Ee,result:await Wd(e,Ee.route)}))),fe=await le;if(!T)return;const He=new Map(de.map(({group:Ee,result:xt})=>[JSON.stringify(Ee.route||[]),xt])),st=ee.map(Ee=>{if(!ve(Ee))return{...Ee,switcherFresh:!1};const xt=He.get(JSON.stringify(Ee.route||[]));return xt?{...Ee,sessions:xt.sessions||Ee.sessions||[],cells:xt.cells||Ee.cells||[],switcherFresh:xt.fresh}:{...Ee,switcherFresh:!1}}),lt=Hy({...se,sessions:fe.sessions||se.sessions||[],cells:fe.cells||se.cells||[],localFresh:fe.fresh,nodeGroups:st,refreshedAt:Date.now()});h(lt),w(!0),M=!1};O();const H=setInterval(O,xR);return()=>{T=!1,clearInterval(H)}},[e]);const A=T=>T.degraded?f("cell-degraded"):T.verified?T.selectable?T.working?f("cell-working"):f("cell-idle"):f("cell-off"):f("cell-switcher-not-confirmed"),x=T=>{if(S(""),!T.selectable){S(f("cell-switcher-not-active"));return}j(T.key)},I=async()=>{const T=$;if(!T){S(f("cell-switcher-select"));return}S(""),z(T.key);try{const M=await Wd(e,T.route),O=(M.cells||[]).find(H=>(H==null?void 0:H.cell)===T.cellName&&(H==null?void 0:H.tmuxSession)===T.session);if(!Db(O,M.sessions,M.fresh)){S(f("cell-switcher-not-active"));return}n({session:T.session,...T.node?{node:T.node}:{},cellName:T.cellName}),s()}catch{S(f("cell-switcher-not-active"))}finally{z("")}};return l.jsx("div",{className:"nc-cell-switcher-backdrop",onClick:s,children:l.jsxs("aside",{ref:D,className:"nc-cell-switcher",role:"dialog","aria-label":f("fleet-cells"),tabIndex:-1,onClick:T=>T.stopPropagation(),children:[l.jsxs("div",{className:"nc-cell-switcher-list",children:[!v&&l.jsx("div",{className:"nc-empty",role:"status",children:f("cell-switcher-refreshing")}),v&&B.length===0&&l.jsx("div",{className:"nc-empty",role:"status",children:f("cell-switcher-empty-active")}),B.map(T=>{const M=(t==null?void 0:t.session)===T.session&&((t==null?void 0:t.node)||"")===T.node,O=b===T.key,H=A(T),se=Wh(f,T.activity),ee=Kh(f,T.telemetry),le=[se,ee].filter(Boolean).join(" · "),ve=T.node||"local",de=K.get(ve)||W.filter(fe=>(fe.node||"local")===ve);return l.jsxs("div",{className:`nc-cell-switcher-row${M?" current":""}${O?" selected":""}${T.selectable?"":" off"}`,"data-roster-key":T.key,"data-position":ve,children:[l.jsx(Li,{position:ve,itemKey:T.key,label:T.cellName,canMove:Q,onMove:(fe,He)=>q(ve,fe,He,de),onStep:fe=>F(ve,T.key,fe,de)}),l.jsx("button",{type:"button",className:"nc-cell-switcher-peek",title:f("cell-peek"),"aria-label":`${f("cell-peek")}: ${T.cellName}`,onClick:fe=>{fe.stopPropagation(),E({key:T.key,source:"preview"})},children:l.jsx("span",{className:`nc-cell-switcher-dot${T.degraded?" warn":T.live?` on${T.working?" working":""}`:""}`})}),l.jsxs("span",{className:"nc-cell-switcher-acts",children:[l.jsx("button",{type:"button",className:"nc-cell-switcher-act",title:f("cell-peek-stream"),"aria-label":`${f("cell-peek-stream")}: ${T.cellName}`,onClick:fe=>{fe.stopPropagation(),E({key:T.key,source:"stream"})},children:"▶"}),T.panelUrl&&l.jsx("button",{type:"button",className:"nc-cell-switcher-act",title:f("cell-peek-panel"),"aria-label":`${f("cell-peek-panel")}: ${T.cellName}`,onClick:fe=>{fe.stopPropagation(),E({key:T.key,source:"panel"})},children:"▣"})]}),l.jsx("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":M?"true":void 0,"aria-pressed":O,"aria-disabled":!T.selectable,disabled:N===T.key,onClick:()=>x(T),children:l.jsxs("span",{className:"nc-cell-switcher-copy",children:[l.jsx("b",{children:T.cellName}),l.jsx("small",{className:"nc-cell-switcher-state",children:H}),l.jsx("small",{children:[T.nodeLabel,T.subtitle].filter(Boolean).join(" · ")}),le&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:le})]})})]},T.key)})]}),y&&l.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:y}),k&&L&&l.jsx(Vw,{row:L,token:e,initialSource:k.source,panelPort:Jl(L.route||[],a,o),onClose:()=>E(null)}),l.jsx("div",{className:"nc-cell-switcher-actions",children:l.jsx("button",{type:"button",className:"nc-cell-switcher-open",disabled:!$||!!N,onClick:I,children:$?`${f("cell-switcher-open")}: ${$.cellName}`:f("cell-switcher-select")})}),l.jsxs("div",{className:"nc-cell-switcher-controls",children:[l.jsx("b",{children:f("fleet-cells")}),l.jsx("button",{type:"button",className:"nc-cell-switcher-filter","aria-pressed":p,onClick:()=>{S(""),m(T=>!T)},children:f(p?"cell-switcher-show-active":"cell-switcher-show-all")}),l.jsx("button",{ref:U,type:"button",className:"nc-cell-switcher-close","aria-label":f("cell-switcher-close"),title:f("cell-switcher-close"),onClick:s,children:"×"})]})]})})}const RR=2e3;function PR(e){if(e.kind==="gap")return`${f("vl-events-gap")} ${e.count||"?"}`;if(e.kind==="truncate")return f("vl-events-truncated");if(e.kind==="turn_end")return f("vl-events-turn-end");if(e.kind==="done")return f("vl-events-done");if(e.kind==="writer_epoch")return f("vl-events-writer-epoch");if(e.kind==="tool_start")return`${f("vl-events-tool")} ${e.name||""}`.trim();if(e.kind==="tool_end"){const t=e.isError?f("vl-events-tool-failed"):f("vl-events-tool-ok");return`${f("vl-events-tool")} ${e.name||""} — ${t}`.trim()}return e.kind==="usage"?e.text||f("vl-events-usage"):e.text||""}function AR({token:e,nodeId:t,route:n=[]}){const[s,o]=C.useState([]),[a,u]=C.useState(!1),h=C.useRef(0),p=C.useRef(!1);return C.useEffect(()=>{let m=!0;h.current=0,p.current=!1,o([]);const v=async()=>{if(!p.current){p.current=!0;try{const S=await Z0(e,t,h.current,n);if(!m)return;u(!1);const E=(Array.isArray(S==null?void 0:S.events)?S.events:[]).filter(b=>Number.isSafeInteger(b==null?void 0:b.seq)&&b.seq>h.current);E.length&&(o(b=>b.concat(E).slice(-500)),h.current=E[E.length-1].seq),Number.isSafeInteger(S==null?void 0:S.cursor)&&S.cursor>h.current&&(h.current=S.cursor)}catch{m&&u(!0)}finally{p.current=!1}}},w=()=>{v().catch(()=>{})};w();const y=setInterval(w,RR);return()=>{m=!1,clearInterval(y)}},[e,t,JSON.stringify(n)]),l.jsxs("div",{className:"nc-vl-events",children:[a&&l.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:f("vl-events-stale")}),s.length===0&&!a&&l.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:f("vl-events-empty")}),s.length>0&&l.jsx("ol",{className:"nc-vl-events-list",children:s.map(m=>l.jsx("li",{"data-testid":`vl-ev-${m.seq}`,className:`nc-vl-ev nc-vl-ev-${m.kind}${m.isError?" error":""}${m.kind==="gap"?" gap":""}`,children:PR(m)},`${m.seq}-${m.kind}`))})]})}function iy({peer:e,token:t,onBack:n}){var s;return $n(),e?l.jsxs("section",{className:"nc-vl-session-view",children:[l.jsxs("header",{className:"nc-bar nc-bar-single",children:[l.jsxs("button",{onClick:n,title:f("back"),children:[l.jsx(at,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:f("back")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:e.label,children:e.label}),((s=e.session)==null?void 0:s.profile)&&l.jsxs("small",{className:"nc-bar-sub",children:[e.session.profile," · ",f("vl-events-title")]})]}),l.jsx("span",{className:"nc-bar-right"})]}),l.jsx("div",{className:"nc-vl-session-body",children:l.jsx(AR,{token:t,nodeId:e.nodeId,route:e.route||[]})})]}):null}const Kd=e=>Di(Js(e)).length===0,qd=e=>Array.isArray(e)?e.join("/"):"";function LR(e){const t=new Set,n=[];for(const s of Array.isArray(e)?e:[])!s||!si.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||t.has(s.instanceId)||(t.add(s.instanceId),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline"}));return n.sort((s,o)=>s.label.localeCompare(o.label))}function $o(e){return{instanceId:e.ownerId,route:e.ownerRoute||[],label:e.ownerLabel,status:e.available===!1?"offline":"up"}}function qs(e,t,n,s=!1,o=!0){const a=t.instanceId;return{...e,id:Ir(s?null:a,e.name),ownerId:a,ownerRoute:s?[]:[...t.route],ownerLabel:s?"Local":t.label,local:s,available:o,ownerTopology:Array.isArray(n)?n:[],layout:qh(e.layout,a,n)}}function TR(e,t,n,s,o=[]){const[a,u]=C.useState([]),[h,p]=C.useState(!1),[m,v]=C.useState("idle"),[w,y]=C.useState(""),[S,k]=C.useState(""),E=C.useRef([]),b=C.useRef([]),j=C.useRef(""),N=C.useRef(t),z=C.useRef(n),D=C.useRef(!1),U=C.useRef(!0),W=C.useRef(""),K=C.useMemo(()=>LR(o),[o]),te=K.map(T=>`${T.instanceId}:${qd(T.route)}:${T.status}:${T.label}`).join("|");b.current=K,z.current=n,N.current=t,E.current=a;const G=C.useCallback(T=>Vh(T.layout,j.current,b.current),[]),Q=C.useCallback((T,M=!0,O=N.current)=>{const H=l_(T,kl()),se=E.current.some(le=>le.id===O);E.current=H,u(H);const ee=H.find(le=>le.id===O);if(M&&ee){U.current=!0;const le=G(ee);s(le),ee.local&&GN(ee.name,le)}else se&&!ee&&(U.current=!0,s(Dr()),y("deck non più condiviso dal nodo owner"));KN(H.filter(le=>le.local).map(le=>le.name))},[s,G]),q=C.useCallback(async T=>{let M=await ml(e);const O=M.decks.find(H=>H.name==="main");if(M.decks.length===1&&O&&O.revision===0&&Kd(O.layout)){const H=WN(),se=Js(Yh("main")||Dr());if(!Kd(se)){const ee=qh(se,T,[]);M.decks[0]=await gl(e,"main",ee,0,[])}for(const ee of H.filter(le=>le!=="main"))try{let le=await zg(e,ee,[]);const ve=Js(Yh(ee)||Dr());Kd(ve)||(le=await gl(e,ee,qh(ve,T,[]),le.revision,[]))}catch{}M=await ml(e)}return M},[e]),F=C.useCallback(async({migrate:T=!1}={})=>{const M=await cf(e,[]),O=si.test(String(M.instanceId||""))?M.instanceId:"";if(!O)throw new Error("instanceId locale non disponibile");j.current=O,k(O);const[H,se]=await Promise.all([T?q(O):ml(e),Dg(e,[]).catch(()=>({nodes:[]}))]),ee={instanceId:O,route:[],label:"Local"},le=H.decks.map(de=>qs(de,ee,se.nodes,!0,!0)),ve=E.current;return await Promise.all(b.current.map(async de=>{if(de.status!=="up"){le.push(...ve.filter(fe=>!fe.local&&fe.ownerId===de.instanceId).map(fe=>({...fe,ownerRoute:[...de.route],ownerLabel:de.label,available:!1})));return}try{const[fe,He]=await Promise.all([ml(e,de.route),Dg(e,de.route).catch(()=>({nodes:[]}))]);le.push(...fe.decks.map(st=>qs(st,de,He.nodes,!1,!0)))}catch{le.push(...ve.filter(He=>!He.local&&He.ownerId===de.instanceId).map(He=>({...He,ownerRoute:[...de.route],ownerLabel:de.label,available:!1})))}})),le.sort((de,fe)=>de.local===fe.local?de.ownerLabel.localeCompare(fe.ownerLabel)||(de.name==="main"?-1:fe.name==="main"?1:de.name.localeCompare(fe.name)):de.local?-1:1),le},[e,q,te]);C.useEffect(()=>{if(!e)return;let T=!1;const M=W.current!==e;return W.current=e,F({migrate:M}).then(O=>{if(T)return;const H=E.current.find(le=>le.id===N.current),se=O.find(le=>le.id===N.current),ee=se&&(!H||se.revision>H.revision||H.available!==se.available||qd(H.ownerRoute)!==qd(se.ownerRoute));Q(O,M||!!ee&&!D.current),p(!0),se&&y("")}).catch(O=>{T||(p(!0),y(String(O.message||O)))}),()=>{T=!0}},[Q,F,te,e]);const R=C.useCallback(async(T=N.current)=>{if(!h||!D.current)return!0;const M=E.current.find(O=>O.id===T);if(!M)return y(`deck inesistente: ${T}`),!1;if(M.available===!1)return y(`nodo owner offline: ${M.ownerLabel}`),!1;v("saving");try{const O=o_(Js(z.current),M.ownerId,M.ownerTopology),H=await gl(e,M.name,O,M.revision,M.ownerRoute),se=qs(H,$o(M),M.ownerTopology,M.local,!0);return Q(E.current.map(ee=>ee.id===T?se:ee),!1),D.current=!1,v("saved"),y(""),setTimeout(()=>v("idle"),1500),!0}catch(O){if(v("error"),y(String(O.message||O)),O.status===409&&O.data&&O.data.current){const H=E.current.find(ee=>ee.id===T),se=qs(O.data.current,$o(H),H.ownerTopology,H.local,!0);Q(E.current.map(ee=>ee.id===T?se:ee),!1)}return!1}},[h,e,Q]);return C.useEffect(()=>{if(!h)return;if(U.current){U.current=!1;return}D.current=!0,v("saving");const T=setTimeout(R,650);return()=>clearTimeout(T)},[n,h,R]),C.useEffect(()=>{if(!h)return;const T=setInterval(async()=>{try{const M=await F(),O=E.current.find(ee=>ee.id===N.current),H=M.find(ee=>ee.id===N.current),se=H&&(!O||H.revision>O.revision||O.available!==H.available);Q(M,se&&!D.current)}catch{}},5e3);return()=>clearInterval(T)},[h,F,Q]),{decks:a,records:a,localNodeId:S,ready:h,saveState:m,error:w,setError:y,saveNow:R,select:async T=>{if(D.current&&!await R(N.current))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const M=E.current.find(O=>O.id===T);if(!M)throw new Error(`deck inesistente: ${T}`);return D.current=!1,U.current=!0,G(M)},add:async(T,M=null)=>{const O=M===Ti?E.current.find(ee=>ee.local):M?E.current.find(ee=>ee.ownerId===M):null;if(!O||O.available===!1)throw new Error("nodo owner non disponibile");const H=await zg(e,T,O.ownerRoute),se=qs(H,$o(O),O.ownerTopology,O.local,!0);return Q([...E.current,se],!1),se},rename:async(T,M)=>{const O=E.current.find(ve=>ve.id===T);if(!O)throw new Error("deck inesistente");if(T===N.current&&D.current&&!await R(T))throw new Error(`salvataggio di "${O.name}" fallito: rinomina annullata`);const H=E.current.find(ve=>ve.id===T);if(!H)throw new Error("deck inesistente");const se=await kx(e,H.name,M,H.revision,H.ownerRoute),ee=qs(se,$o(H),H.ownerTopology,H.local,!0),le=H.local?Ti:H.ownerId;return _d(VN(kl(),le,T,ee.id)),Q(E.current.map(ve=>ve.id===T?ee:ve),!1),ee},remove:async T=>{const M=E.current.find(H=>H.id===T);if(!M)throw new Error("deck inesistente");T===N.current&&(D.current=!1),await Cx(e,M.name,M.revision,M.ownerRoute);const O=M.local?Ti:M.ownerId;_d(YN(kl(),O,T)),Q(E.current.filter(H=>H.id!==T),!1)},reorder:(T,M)=>{const O=E.current.find(de=>de.id===T),H=E.current.find(de=>de.id===M);if(!O||!H)return!1;const se=O.local?Ti:O.ownerId,ee=H.local?Ti:H.ownerId;if(se!==ee)return!1;const le=E.current.filter(de=>(de.local?Ti:de.ownerId)===se).map(de=>de.id),ve=_d(qN(kl(),se,T,M,le));return Q(l_(E.current,ve),!1),!0},addTileTo:async(T,M)=>{const O=E.current.find(de=>de.id===T);if(!O)throw new Error("deck inesistente");if(O.available===!1)throw new Error(`nodo owner offline: ${O.ownerLabel}`);const H=Zw(M,j.current,b.current);if(!H)throw new Error("riferimento sessione non valido");const se=G(O),ee=o_(zy(se,H),O.ownerId,O.ownerTopology),le=await gl(e,O.name,ee,O.revision,O.ownerRoute),ve=qs(le,$o(O),O.ownerTopology,O.local,!0);return Q(E.current.map(de=>de.id===T?ve:de),!1),ve},localMainId:Ir(null,"main"),parseDeckId:ac}}const MR="/sw.js",Jh="nc-sw-update";let Zh=null,ef=!1,tf=null,Ib=Object.freeze({needed:!1,kind:null,version:""}),Ob=!1;function Bb(){typeof window<"u"&&window.dispatchEvent(new Event(Jh))}function zb(){const e=tf||(ef?{kind:"reload",version:""}:null);Ib=Object.freeze({needed:!!e,kind:(e==null?void 0:e.kind)||null,version:(e==null?void 0:e.version)||""})}function sy(){return Ib}function DR(e){return typeof window>"u"?()=>{}:(window.addEventListener(Jh,e),()=>window.removeEventListener(Jh,e))}function ep(e){ef!==e&&(ef=e,zb(),Bb())}const Vd="nc-auto-reload";function IR(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function OR(e,t,n,s={}){let o=null;e&&t&&e!==t?o={kind:"install",version:e}:t&&n&&t!==n&&(o={kind:"reload",version:t});const a=JSON.stringify(o)===JSON.stringify(tf);tf=o,zb(),a||Bb();const u=s.storage===void 0?IR():s.storage;if(!o){try{u&&u.removeItem(Vd)}catch{}return}if(o.kind!=="reload"||!u)return;const h=`${t}|${n}`;try{if(u.getItem(Vd)===h)return;u.setItem(Vd,h)}catch{return}(s.applyImpl||$b)()}function BR(e){e.addEventListener("statechange",()=>{e.state==="installed"&&navigator.serviceWorker.controller&&ep(!0)})}function zR(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{Ob&&location.reload()}),navigator.serviceWorker.register(MR).then(e=>{Zh=e,e.waiting&&ep(!0),e.addEventListener("updatefound",()=>{const t=e.installing;t&&BR(t)}),setInterval(()=>{e.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function $b(){Ob=!0,ep(!1);const e=Zh&&Zh.waiting;e?(e.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function $R({hash:e="",origin:t="",pathname:n="",search:s=""}={}){const o=String(e||"").replace(/^#/,""),a=`${n||""}${s||""}`;if(!o)return{token:"",pair:"",nextUrl:a};const u=new URLSearchParams(o),h=u.get("token")||"",p=u.get("pair")||"",m=p?`${t||""}${n||""}#pair=${p}`:"";return{token:h,pair:m,nextUrl:a}}const Fb=9,Hb=24,Ub="nc_side_w",ry="nc_side_min",FR=240,oy="(min-width:1024px) and (pointer:fine)";function HR(){const e=Number(localStorage.getItem(Ub));return e>=180&&e<=480?e:FR}function UR(){const e=Number(localStorage.getItem("nc_fontsize"));return e>=Fb&&e<=Hb?e:13}function WR(){const e={token:"",pair:""};try{const{token:t,pair:n,nextUrl:s}=$R({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(t){e.token=t;try{localStorage.setItem("nc_token",t)}catch{}}if(n){e.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",s)}catch{}}catch{}if(e.token||(e.token=sessionStorage.getItem("nc_token")||localStorage.getItem("nc_token")||""),!e.pair){const t=sessionStorage.getItem("nc_pair");t&&(e.pair=t)}return e}function KR(e){try{return Js(Yh(e))}catch{return Dr()}}function ay(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 qR(){const[e,t]=C.useState(()=>window.matchMedia(oy).matches);return C.useEffect(()=>{const n=window.matchMedia(oy),s=o=>t(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function ly({session:e,node:t,ownerId:n,cellName:s,token:o,readonly:a=!1,panelPort:u=0,onBack:h,onCellSwitcher:p,cellSwitcherOpen:m=!1}){$n();const[v]=If(),[w,y]=C.useState(!1),[S,k]=C.useState(()=>window.matchMedia("(pointer: coarse)").matches),[E,b]=C.useState(null),[j,N]=C.useState(UR),[z,D]=C.useState(s||e),[U,W]=C.useState(""),[K,te]=C.useState(""),[G,Q]=C.useState(""),[q,F]=C.useState(!1),R=H=>N(se=>{const ee=Math.max(Fb,Math.min(Hb,se+H));return localStorage.setItem("nc_fontsize",String(ee)),ee}),B=C.useRef(()=>{}),$=C.useRef(()=>!1),L=C.useRef(()=>{}),A=C.useRef(!1),[x,I]=C.useState(!1),[T,M]=C.useState(!1),O=()=>{A.current=!A.current,I(A.current)};return C.useEffect(()=>{D(s||e),F(!1)},[s,e]),C.useEffect(()=>{let H=!0;const se=t?t.split("/"):[],ee=t?`/api/route/${t.split("/").map(encodeURIComponent).join("/")}/_`:"/api";async function le(){let de=null,fe=null;try{const lt=await(await en(`${ee}/sessions`,o)).json();Array.isArray(lt.sessions)&&(de=lt.sessions.find(Ee=>Ee.name===e))}catch{}try{const st=await Ls(o,se);st.available&&Array.isArray(st.cells)&&(fe=st.cells.find(lt=>lt.tmuxSession===e))}catch{}if(!H)return;D(Of({session:e,cell:fe||(s?{cell:s}:null)})),te(typeof(fe==null?void 0:fe.panelUrl)=="string"?fe.panelUrl.trim():""),Q(typeof(fe==null?void 0:fe.cell)=="string"?fe.cell:"");let He="";fe?He=`${fe.engine}${fe.key?`·${fe.key}`:""}`:de&&(He=de.attached?`attached · ${ay(de.activity)}`:de.activity?ay(de.activity):""),W(He)}le();const ve=setInterval(le,4e3);return()=>{H=!1,clearInterval(ve)}},[e,t,o]),l.jsxs("div",{className:"nc-app",children:[l.jsxs("header",{className:"nc-bar nc-bar-single",children:[l.jsxs("button",{onClick:h,title:f("sessions"),children:[l.jsx(at,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:f("sessions")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:t?`${z} · ${t}`:z,children:z}),U&&l.jsx("small",{className:"nc-bar-sub",children:U})]}),l.jsxs("span",{className:"nc-bar-right",children:[l.jsx("button",{onClick:()=>R(-1),title:f("zoom-out"),children:l.jsx(at,{name:"zoomOut",size:18})}),l.jsx("button",{onClick:()=>R(1),title:f("zoom-in"),children:l.jsx(at,{name:"zoomIn",size:18})}),l.jsx("button",{onClick:()=>k(H=>!H),title:f("composer"),children:l.jsx(at,{name:"keyboard",size:20})}),l.jsx("button",{onClick:()=>y(H=>!H),title:f("files"),children:l.jsx(at,{name:"folder",size:20})}),K&&l.jsx("button",{onClick:()=>F(H=>!H),title:f("panel"),"aria-pressed":q,children:l.jsx(at,{name:"monitor",size:20})})]})]}),l.jsxs("div",{className:"nc-termwrap",children:[l.jsx(Af,{session:e,node:t,token:o,readonly:a,takeSize:!0,sendRef:B,composerRef:$,actionRef:L,ctrlRef:A,setCtrlArmed:I,onFiles:b,fontSize:j,selectionMode:T,onSelectionModeChange:M,keyboardGesture:v.terminalKeyboardGesture}),q&&K&&G&&l.jsx(Tf,{cellId:G,panelUrl:K,route:t?t.split("/"):[],panelPort:u,token:o,title:z})]}),l.jsx(pN,{onKeyboard:()=>k(H=>!H),onCellSwitcher:p,cellSwitcherOpen:m,send:H=>B.current(H),action:H=>L.current(H),ctrlArmed:x,onCtrl:O,selectionMode:T,onSelectionMode:M,keepKeyboardClosed:v.keybarKeepsKeyboardClosed,showEnter:v.showKeybarEnter,keybarLayout:v.keybarLayout}),S&&l.jsx(Kw,{submitText:H=>$.current(H),token:o,session:e,node:t,ownerId:n,keepKeyboardClosedOnVoice:v.voiceKeepsKeyboardClosed}),w&&l.jsx(Iw,{session:e,node:t,token:o,filesEvent:E,onClose:()=>y(!1)})]})}function VR(){$n();const[e]=C.useState(WR),[t,n]=C.useState(e.token),[s,o]=C.useState(e.pair||""),a=C.useCallback(()=>{o("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),[u,h]=C.useState(!1),p=qR(),[m]=C.useState(()=>UN(typeof location<"u"?location.pathname:"/")),[v,w]=C.useState(m.id),y=v===Ir(null,ri),[S,k]=C.useState(null),E=J=>{const pe=As(J);k(pe?{...pe,...typeof(J==null?void 0:J.cellName)=="string"&&J.cellName?{cellName:J.cellName}:{}}:null)},[b,j]=C.useState([]),[N,z]=C.useState([]),[D,U]=C.useState([]),[W,K]=C.useState(()=>m.ownerId?Dr():KR(m.name)),[te,G]=C.useState(null),[Q,q]=C.useState(null),F=J=>q(As(J)),[R,B]=C.useState(null),$=hf(t,p),L=C.useMemo(()=>($||[]).filter(J=>J.instanceId).map(J=>({instanceId:J.instanceId,route:J.route,label:J.label,status:J.status})),[$]),A=TR(t,v,W,K,L),x=A.decks;C.useEffect(()=>{const J=new Map;for(const pe of $||[]){const Me=(pe.route||[pe.name]).join("/"),ot=new Set((pe.sessions||[]).map(Xe=>Xe.name));for(const Xe of pe.cells||[])!Xe.cell||!Xe.tmuxSession||Xe.cell===Xe.tmuxSession||ot.has(Xe.cell)||J.set(`${Me}:${Xe.cell}`,`${Me}:${Xe.tmuxSession}`)}K(pe=>ak(pe,J))},[$]),C.useEffect(()=>{A.localNodeId&&K(J=>{const pe=Vh(J,A.localNodeId,L);return JSON.stringify(pe)===JSON.stringify(J)?J:pe})},[L,A.localNodeId]);const[I,T]=C.useState(null),[M,O]=C.useState(null),H=C.useRef(0),[se,ee]=C.useState(!1),[le,ve]=C.useState(HR),[de,fe]=C.useState(!y),[He,st]=C.useState(()=>y?localStorage.getItem(ry)==="1":!0),[lt,Ee]=C.useState(!1),[xt,qt]=C.useState("nodes"),[ze,Rt]=C.useState(!1),[gt,Mt]=C.useState(""),[ht,bt]=C.useState(!1),Bt=(J="nodes",pe=!1,Me="")=>{qt(J),Rt(pe),Mt(Me),Ee(!0)},[kt,Dt]=C.useState(!1),[Lt,Ct]=C.useState({deviceDefault:"",localNodeId:"",localNameDefault:""}),[ye,ce]=C.useState(!1),[Le,qe]=C.useState(0),[ie,_e]=C.useState({});C.useEffect(()=>{try{localStorage.setItem(Ub,String(le))}catch{}},[le]),C.useEffect(()=>{try{localStorage.setItem(ry,He?"1":"")}catch{}},[He]),C.useEffect(()=>{if(!t)return;let J=!1;return Promise.all([vy(t),en("/api/config",t).then(pe=>pe.json())]).then(([pe,Me])=>{J||(Ct({deviceDefault:pe.deviceName||"",localNodeId:pe.nodeId||"",localNameDefault:pe.localName||""}),ce(!!Me.readonlyDefault),qe(Number.isInteger(Me.panelPort)?Me.panelPort:0),_e(Me.nodePanelPorts&&typeof Me.nodePanelPorts=="object"&&!Array.isArray(Me.nodePanelPorts)?Me.nodePanelPorts:{}),(pe.firstRun===!0&&!Me.readonlyDefault||s)&&Dt(!0))}).catch(()=>{}),()=>{J=!0}},[t,s]);const[Ce,Ue]=C.useState({}),Ve=C.useRef($);C.useEffect(()=>{Ve.current=$},[$]);const ft=C.useCallback(async()=>{try{const pe=await(await en("/api/sessions",t)).json();pe.error||j(pe.sessions||[])}catch{}try{const J=await Ls(t);z(J.available?J.cells||[]:[]),U(J.available?J.capabilities||[]:[])}catch{z([]),U([])}},[t]);C.useEffect(()=>{let J=!1;const pe=async()=>{const ot=[[],...(Ve.current||[]).filter(vt=>vt.kind!=="vl"&&vt.status==="up").map(vt=>Array.isArray(vt.route)&&vt.route.length?vt.route:[vt.name])],Xe=await Promise.all(ot.map(async vt=>{try{const Pt=await Ex(t,vt);return[Vo(vt),{hostCell:Pt&&typeof Pt.hostCell=="string"?Pt.hostCell:null,hostLease:Pt&&Pt.host&&typeof Pt.host.lease=="string"?Pt.host.lease:null,hostRevision:Number.isInteger(Pt&&Pt.revision)?Pt.revision:0}]}catch{return null}}));J||Ue(vt=>{let Pt=!1;const nn={...vt};for(const Dn of Xe)Dn&&(nn[Dn[0]]=Dn[1],Pt=!0);return Pt?nn:vt})};pe();const Me=setInterval(pe,4e3);return()=>{J=!0,clearInterval(Me)}},[t]),C.useEffect(()=>{if(!p)return;ft();const J=setInterval(ft,4e3);return()=>clearInterval(J)},[p,ft]);const Et=C.useCallback(async(J,pe=[])=>{const Me=Vo(pe),ot=Ce[Me]&&Ce[Me].hostRevision||0;try{const Xe=await Nx(t,J,ot,pe);Ue(vt=>({...vt,[Me]:{hostCell:Xe.hostCell||null,hostLease:Xe.host&&typeof Xe.host.lease=="string"?Xe.host.lease:null,hostRevision:Number.isInteger(Xe.revision)?Xe.revision:ot}}))}catch(Xe){window.alert(f(Xg(Xe)))}},[t,Ce]),St=C.useCallback(async(J=[])=>{const pe=Vo(J),Me=Ce[pe]&&Ce[pe].hostRevision||0;try{const ot=await jx(t,Me,J);return Ue(Xe=>({...Xe,[pe]:{hostCell:ot.hostCell||null,hostLease:null,hostRevision:Number.isInteger(ot.revision)?ot.revision:Me}})),!0}catch(ot){return window.alert(f(Xg(ot))),!1}},[t,Ce]);C.useEffect(()=>{let J=!1;const pe=()=>{en("/api/config",t).then(ot=>ot.json()).then(ot=>{J||OR(ot.version,ot.uiVersion,"0.9.5")}).catch(()=>{})};pe();const Me=setInterval(pe,6e4);return()=>{J=!0,clearInterval(Me)}},[t]);const Nt=new Set([...b.map(J=>J.name),...$.flatMap(J=>J.sessions.map(pe=>pe.key))]),Z=Di(W),we=J=>K(pe=>{const Me=Zw(J,A.localNodeId,L)||J,ot=zy(pe,Me);return ot===pe&&Di(pe).length>=9&&A.setError(f("grid-full")),ot}),Oe=async(J,pe=[])=>{try{await of(t,J,pe)}catch{return}const Me=pe.length?`${pe.join("/")}:${J}`:J;K(ot=>Ul(ot,Me)),ft()},je=async(J,pe,Me=[])=>{try{await gy(t,J,pe,Me)}catch{return}ft()},tt=async(J,pe,Me=[])=>{await fy(t,{cell:J,enabled:!!pe},Me),ft()},Ye=async J=>{if(!I)return;const{cell:pe}=I,Me=Array.isArray(I.route)?I.route:[];if(J.action==="up"){const Xe=await rf(t,{cell:pe,boot:!!J.boot,...J.engine?{engine:J.engine}:{},...J.model!==void 0?{model:J.model}:{},...J.permissionPolicy?{permissionPolicy:J.permissionPolicy}:{}},Me),vt=wf(Xe);vt&&A.setError(vt.text)}else await Ol(t,{cell:pe,boot:!!J.boot},Me);const ot=J.action==="up"?!!J.boot:J.boot?!1:!!I.boot;O({id:++H.current,cell:pe,route:Me,enabled:ot}),ft()},pt=C.useCallback(J=>{O(pe=>(pe==null?void 0:pe.id)===J?null:pe)},[]),yt=async J=>{if(!(!(J!=null&&J.direct)||se)){ee(!0);try{await uf(t,J.name,J.tunnelStatus==="up"?"down":"up")}finally{ee(!1)}}},gn=async(J,pe)=>{const Me=String(pe||"").trim();return!(J!=null&&J.direct)||!$r(Me)?!1:(await wy(t,J.name,Me),!0)},Y=J=>{const pe=x.find(Me=>Me.id===J);if(!pe)return!1;try{const Me=window.open(vd(pe,t),"_blank");return Me&&(Me.opener=null),!!Me}catch{return!1}},re=async J=>{if(!J||J===v)return;const pe=await A.select(J),Me=A.records.find(ot=>ot.id===J);w(J),K(pe),G(null),q(null);try{history.replaceState(null,"",vd(Me||J,null))}catch{}},xe=async(J,pe)=>{const Me=await A.add(J,pe);await re(Me.id)},ge=async(J,pe)=>{const Me=await A.rename(J,pe);if(J===v){w(Me.id),K(Vh(Me.layout,A.localNodeId,L)),G(null),q(null);try{history.replaceState(null,"",vd(Me,null))}catch{}}},Ae=async J=>{await A.remove(J),J===v&&await re(A.localMainId)},Ge=async(J,pe)=>{!pe||pe===v||(await A.addTileTo(pe,J),K(Me=>Ul(Me,J)))};if(!t)return l.jsxs("div",{className:"nc-auth",children:[l.jsx("p",{children:f("auth-prompt")}),l.jsx("input",{onChange:J=>n(J.target.value.trim()),placeholder:"token"}),l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:u,onChange:J=>h(J.target.checked)})," ",f("remember-device")]}),l.jsx("button",{onClick:()=>{(u?localStorage:sessionStorage).setItem("nc_token",t)},children:"ok"})]});const rt=l.jsxs(l.Fragment,{children:[lt&&l.jsx(mR,{token:t,initialTab:xt,initialLocation:gt,startNewCell:ze,onClose:()=>{Ee(!1),Rt(!1),Mt("")}}),kt&&l.jsx(gR,{token:t,initialPair:s,...Lt,onPairDone:a,onDone:()=>Dt(!1)}),l.jsx(SR,{token:t})]});if(!p)return R?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-single-overlay",children:l.jsx(iy,{peer:R,token:t,onBack:()=>B(null)})}),rt]}):S?l.jsxs(l.Fragment,{children:[l.jsx(ly,{session:S.session,node:S.node,ownerId:S.ownerId,cellName:S.cellName,token:t,readonly:ye,panelPort:Jl(S.node?S.node.split("/"):[],ie,Le),onBack:()=>k(null),onCellSwitcher:()=>bt(!0),cellSwitcherOpen:ht}),ht&&l.jsx(jR,{token:t,current:S,panelPort:Le,nodePanelPorts:ie,onPick:J=>{E(J),bt(!1)},onClose:()=>bt(!1)}),rt]}):l.jsxs(l.Fragment,{children:[l.jsx(Ck,{onPick:E,token:t,onSettings:Bt,onOpenVlSession:B,hostByRoute:Ce,onDesignateCell:Et,onClearHostCell:St}),rt]});const Pe=y||!de;return l.jsxs("div",{className:"nc-workspace",children:[Pe&&l.jsx(LN,{sessions:b,cells:N,activeSessions:Z,nodeGroups:$,token:t,onPeekOpen:()=>bt(!1),overlayOpen:ht,fleetCapabilities:D,bootSettlement:M,onBootSettlementApplied:pt,localNodeId:A.localNodeId,hostByRoute:Ce,onDesignateCell:Et,onClearHostCell:St,onPick:F,onAddTile:we,onPower:T,onBoot:tt,onBootError:J=>A.setError(String((J==null?void 0:J.message)||J)),onNodePower:yt,onNodeRename:gn,onKill:Oe,onVisibility:je,onNew:()=>Bt("fleet",!0),onSettings:Bt,onOpenVlSession:B,width:le,collapsed:He,onResize:ve,onToggleCollapse:()=>st(J=>!J)}),l.jsxs("div",{className:"nc-workspace-main",children:[l.jsx(h2,{decks:x,currentDeck:v,onCreate:xe,onRename:ge,onDelete:Ae,onReorder:A.reorder,onOpenWindow:Y,onNavigate:re,saveState:A.saveState,error:A.error,sidebarVisible:Pe,onToggleSidebar:y?null:()=>fe(J=>!J)}),l.jsx(BN,{layout:W,onLayoutChange:K,token:t,readonly:ye,sessionsAlive:Nt,focusSession:te,onFocus:G,onOpenSingle:F,decks:x,currentDeck:v,onSendToDeck:Ge,cells:N,nodeGroups:$,panelPort:Le,nodePanelPorts:ie})]}),R&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(iy,{peer:R,token:t,onBack:()=>B(null)})}),Q&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(ly,{session:Q.session,node:Q.node,ownerId:Q.ownerId,cellName:Of({session:Q.session,node:Q.node,ownerId:Q.ownerId,cells:N,nodeGroups:$}),token:t,readonly:ye,panelPort:Jl(Q.node?Q.node.split("/"):[],ie,Le),onBack:()=>q(null)})}),I&&l.jsx(zl,{cell:I,token:t,route:Array.isArray(I.route)?I.route:[],onConfirm:Ye,onClose:()=>T(null)}),rt]})}function YR(){$n();const e=C.useSyncExternalStore(DR,sy,sy);if(!e.needed)return null;const t=e.kind==="install"?f("install-version-mismatch").replace("{v}",e.version):f("update-available").replace("{v}",e.version).replace(" "," ").trim();return l.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"nc-update-msg",children:t}),e.kind==="reload"&&l.jsx("button",{className:"nc-update-btn",onClick:$b,children:f("reload")})]})}zR();O0.createRoot(document.getElementById("root")).render(l.jsxs(P0.StrictMode,{children:[l.jsx(VR,{}),l.jsx(YR,{})]}));
|