@mmmbuto/nexuscrew 0.9.62 → 0.9.64
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 +14 -0
- package/README.md +9 -21
- package/docs/SECURITY.md +13 -12
- package/frontend/dist/assets/index-BC6vO7Zd.css +32 -0
- package/frontend/dist/assets/index-oUd5O8W8.js +169 -0
- package/frontend/dist/index.html +2 -2
- package/frontend/dist/version.json +1 -1
- package/lib/cells/routes.js +37 -3
- package/lib/cli/commands.js +1 -1
- package/lib/config.js +1 -1
- package/lib/fleet/builtin.js +3 -0
- package/lib/fleet/cell-lease-server.js +1 -1
- package/lib/fleet/cell-lease.js +1 -1
- package/lib/fleet/lease-client.js +1 -1
- package/lib/fleet/lease-verifier.js +1 -1
- package/lib/live-host/attest.js +39 -0
- package/lib/live-host/bridge.js +81 -21
- package/lib/live-host/entry.js +49 -0
- package/lib/live-host/registry.js +111 -0
- package/lib/live-host/reserved.js +12 -0
- package/lib/mcp/cells.js +37 -0
- package/lib/mcp/server.js +7 -1
- package/lib/mcp/tools.js +7 -1
- package/lib/server.js +27 -10
- package/lib/tmux/actions.js +1 -1
- package/lib/tmux/list.js +16 -5
- package/package.json +2 -2
- package/frontend/dist/assets/index-Cq8wINIe.js +0 -169
- package/frontend/dist/assets/index-fCIoVxeq.css +0 -32
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const c of a.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();function Yg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hf={exports:{}},Dl={},Uf={exports:{}},Ht={};/**
|
|
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 xw;function aN(){if(xw)return Ht;xw=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.iterator;function _(P){return P===null||typeof P!="object"?null:(P=v&&P[v]||P["@@iterator"],typeof P=="function"?P:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,L={};function k(P,H,ie){this.props=P,this.context=H,this.refs=L,this.updater=ie||b}k.prototype.isReactComponent={},k.prototype.setState=function(P,H){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,H,"setState")},k.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function R(){}R.prototype=k.prototype;function S(P,H,ie){this.props=P,this.context=H,this.refs=L,this.updater=ie||b}var j=S.prototype=new R;j.constructor=S,x(j,k.prototype),j.isPureReactComponent=!0;var E=Array.isArray,F=Object.prototype.hasOwnProperty,$={current:null},G={key:!0,ref:!0,__self:!0,__source:!0};function K(P,H,ie){var J,Q={},ve=null,de=null;if(H!=null)for(J in H.ref!==void 0&&(de=H.ref),H.key!==void 0&&(ve=""+H.key),H)F.call(H,J)&&!G.hasOwnProperty(J)&&(Q[J]=H[J]);var ne=arguments.length-2;if(ne===1)Q.children=ie;else if(1<ne){for(var xe=Array(ne),$e=0;$e<ne;$e++)xe[$e]=arguments[$e+2];Q.children=xe}if(P&&P.defaultProps)for(J in ne=P.defaultProps,ne)Q[J]===void 0&&(Q[J]=ne[J]);return{$$typeof:t,type:P,key:ve,ref:de,props:Q,_owner:$.current}}function Y(P,H){return{$$typeof:t,type:P.type,key:H,ref:P.ref,props:P.props,_owner:P._owner}}function te(P){return typeof P=="object"&&P!==null&&P.$$typeof===t}function q(P){var H={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(ie){return H[ie]})}var D=/\/+/g;function I(P,H){return typeof P=="object"&&P!==null&&P.key!=null?q(""+P.key):H.toString(36)}function O(P,H,ie,J,Q){var ve=typeof P;(ve==="undefined"||ve==="boolean")&&(P=null);var de=!1;if(P===null)de=!0;else switch(ve){case"string":case"number":de=!0;break;case"object":switch(P.$$typeof){case t:case e:de=!0}}if(de)return de=P,Q=Q(de),P=J===""?"."+I(de,0):J,E(Q)?(ie="",P!=null&&(ie=P.replace(D,"$&/")+"/"),O(Q,H,ie,"",function($e){return $e})):Q!=null&&(te(Q)&&(Q=Y(Q,ie+(!Q.key||de&&de.key===Q.key?"":(""+Q.key).replace(D,"$&/")+"/")+P)),H.push(Q)),1;if(de=0,J=J===""?".":J+":",E(P))for(var ne=0;ne<P.length;ne++){ve=P[ne];var xe=J+I(ve,ne);de+=O(ve,H,ie,xe,Q)}else if(xe=_(P),typeof xe=="function")for(P=xe.call(P),ne=0;!(ve=P.next()).done;)ve=ve.value,xe=J+I(ve,ne++),de+=O(ve,H,ie,xe,Q);else if(ve==="object")throw H=String(P),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.");return de}function M(P,H,ie){if(P==null)return P;var J=[],Q=0;return O(P,J,"","",function(ve){return H.call(ie,ve,Q++)}),J}function z(P){if(P._status===-1){var H=P._result;H=H(),H.then(function(ie){(P._status===0||P._status===-1)&&(P._status=1,P._result=ie)},function(ie){(P._status===0||P._status===-1)&&(P._status=2,P._result=ie)}),P._status===-1&&(P._status=0,P._result=H)}if(P._status===1)return P._result.default;throw P._result}var T={current:null},A={transition:null},N={ReactCurrentDispatcher:T,ReactCurrentBatchConfig:A,ReactCurrentOwner:$};function U(){throw Error("act(...) is not supported in production builds of React.")}return Ht.Children={map:M,forEach:function(P,H,ie){M(P,function(){H.apply(this,arguments)},ie)},count:function(P){var H=0;return M(P,function(){H++}),H},toArray:function(P){return M(P,function(H){return H})||[]},only:function(P){if(!te(P))throw Error("React.Children.only expected to receive a single React element child.");return P}},Ht.Component=k,Ht.Fragment=n,Ht.Profiler=i,Ht.PureComponent=S,Ht.StrictMode=s,Ht.Suspense=h,Ht.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=N,Ht.act=U,Ht.cloneElement=function(P,H,ie){if(P==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+P+".");var J=x({},P.props),Q=P.key,ve=P.ref,de=P._owner;if(H!=null){if(H.ref!==void 0&&(ve=H.ref,de=$.current),H.key!==void 0&&(Q=""+H.key),P.type&&P.type.defaultProps)var ne=P.type.defaultProps;for(xe in H)F.call(H,xe)&&!G.hasOwnProperty(xe)&&(J[xe]=H[xe]===void 0&&ne!==void 0?ne[xe]:H[xe])}var xe=arguments.length-2;if(xe===1)J.children=ie;else if(1<xe){ne=Array(xe);for(var $e=0;$e<xe;$e++)ne[$e]=arguments[$e+2];J.children=ne}return{$$typeof:t,type:P.type,key:Q,ref:ve,props:J,_owner:de}},Ht.createContext=function(P){return P={$$typeof:c,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},P.Provider={$$typeof:a,_context:P},P.Consumer=P},Ht.createElement=K,Ht.createFactory=function(P){var H=K.bind(null,P);return H.type=P,H},Ht.createRef=function(){return{current:null}},Ht.forwardRef=function(P){return{$$typeof:u,render:P}},Ht.isValidElement=te,Ht.lazy=function(P){return{$$typeof:g,_payload:{_status:-1,_result:P},_init:z}},Ht.memo=function(P,H){return{$$typeof:f,type:P,compare:H===void 0?null:H}},Ht.startTransition=function(P){var H=A.transition;A.transition={};try{P()}finally{A.transition=H}},Ht.unstable_act=U,Ht.useCallback=function(P,H){return T.current.useCallback(P,H)},Ht.useContext=function(P){return T.current.useContext(P)},Ht.useDebugValue=function(){},Ht.useDeferredValue=function(P){return T.current.useDeferredValue(P)},Ht.useEffect=function(P,H){return T.current.useEffect(P,H)},Ht.useId=function(){return T.current.useId()},Ht.useImperativeHandle=function(P,H,ie){return T.current.useImperativeHandle(P,H,ie)},Ht.useInsertionEffect=function(P,H){return T.current.useInsertionEffect(P,H)},Ht.useLayoutEffect=function(P,H){return T.current.useLayoutEffect(P,H)},Ht.useMemo=function(P,H){return T.current.useMemo(P,H)},Ht.useReducer=function(P,H,ie){return T.current.useReducer(P,H,ie)},Ht.useRef=function(P){return T.current.useRef(P)},Ht.useState=function(P){return T.current.useState(P)},Ht.useSyncExternalStore=function(P,H,ie){return T.current.useSyncExternalStore(P,H,ie)},Ht.useTransition=function(){return T.current.useTransition()},Ht.version="18.3.1",Ht}var kw;function Gg(){return kw||(kw=1,Uf.exports=aN()),Uf.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 Cw;function lN(){if(Cw)return Dl;Cw=1;var t=Gg(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(u,h,f){var g,v={},_=null,b=null;f!==void 0&&(_=""+f),h.key!==void 0&&(_=""+h.key),h.ref!==void 0&&(b=h.ref);for(g in h)s.call(h,g)&&!a.hasOwnProperty(g)&&(v[g]=h[g]);if(u&&u.defaultProps)for(g in h=u.defaultProps,h)v[g]===void 0&&(v[g]=h[g]);return{$$typeof:e,type:u,key:_,ref:b,props:v,_owner:i.current}}return Dl.Fragment=n,Dl.jsx=c,Dl.jsxs=c,Dl}var Ew;function cN(){return Ew||(Ew=1,Hf.exports=lN()),Hf.exports}var l=cN(),w=Gg();const uN=Yg(w);var zu={},Wf={exports:{}},Fs={},qf={exports:{}},Kf={};/**
|
|
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 Nw;function dN(){return Nw||(Nw=1,(function(t){function e(A,N){var U=A.length;A.push(N);e:for(;0<U;){var P=U-1>>>1,H=A[P];if(0<i(H,N))A[P]=N,A[U]=H,U=P;else break e}}function n(A){return A.length===0?null:A[0]}function s(A){if(A.length===0)return null;var N=A[0],U=A.pop();if(U!==N){A[0]=U;e:for(var P=0,H=A.length,ie=H>>>1;P<ie;){var J=2*(P+1)-1,Q=A[J],ve=J+1,de=A[ve];if(0>i(Q,U))ve<H&&0>i(de,Q)?(A[P]=de,A[ve]=U,P=ve):(A[P]=Q,A[J]=U,P=J);else if(ve<H&&0>i(de,U))A[P]=de,A[ve]=U,P=ve;else break e}}return N}function i(A,N){var U=A.sortIndex-N.sortIndex;return U!==0?U:A.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var h=[],f=[],g=1,v=null,_=3,b=!1,x=!1,L=!1,k=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(A){for(var N=n(f);N!==null;){if(N.callback===null)s(f);else if(N.startTime<=A)s(f),N.sortIndex=N.expirationTime,e(h,N);else break;N=n(f)}}function E(A){if(L=!1,j(A),!x)if(n(h)!==null)x=!0,z(F);else{var N=n(f);N!==null&&T(E,N.startTime-A)}}function F(A,N){x=!1,L&&(L=!1,R(K),K=-1),b=!0;var U=_;try{for(j(N),v=n(h);v!==null&&(!(v.expirationTime>N)||A&&!q());){var P=v.callback;if(typeof P=="function"){v.callback=null,_=v.priorityLevel;var H=P(v.expirationTime<=N);N=t.unstable_now(),typeof H=="function"?v.callback=H:v===n(h)&&s(h),j(N)}else s(h);v=n(h)}if(v!==null)var ie=!0;else{var J=n(f);J!==null&&T(E,J.startTime-N),ie=!1}return ie}finally{v=null,_=U,b=!1}}var $=!1,G=null,K=-1,Y=5,te=-1;function q(){return!(t.unstable_now()-te<Y)}function D(){if(G!==null){var A=t.unstable_now();te=A;var N=!0;try{N=G(!0,A)}finally{N?I():($=!1,G=null)}}else $=!1}var I;if(typeof S=="function")I=function(){S(D)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,M=O.port2;O.port1.onmessage=D,I=function(){M.postMessage(null)}}else I=function(){k(D,0)};function z(A){G=A,$||($=!0,I())}function T(A,N){K=k(function(){A(t.unstable_now())},N)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(A){A.callback=null},t.unstable_continueExecution=function(){x||b||(x=!0,z(F))},t.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Y=0<A?Math.floor(1e3/A):5},t.unstable_getCurrentPriorityLevel=function(){return _},t.unstable_getFirstCallbackNode=function(){return n(h)},t.unstable_next=function(A){switch(_){case 1:case 2:case 3:var N=3;break;default:N=_}var U=_;_=N;try{return A()}finally{_=U}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(A,N){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var U=_;_=A;try{return N()}finally{_=U}},t.unstable_scheduleCallback=function(A,N,U){var P=t.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?P+U:P):U=P,A){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=U+H,A={id:g++,callback:N,priorityLevel:A,startTime:U,expirationTime:H,sortIndex:-1},U>P?(A.sortIndex=U,e(f,A),n(h)===null&&A===n(f)&&(L?(R(K),K=-1):L=!0,T(E,U-P))):(A.sortIndex=H,e(h,A),x||b||(x=!0,z(F))),A},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(A){var N=_;return function(){var U=_;_=N;try{return A.apply(this,arguments)}finally{_=U}}}})(Kf)),Kf}var Rw;function hN(){return Rw||(Rw=1,qf.exports=dN()),qf.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 Lw;function fN(){if(Lw)return Fs;Lw=1;var t=Gg(),e=hN();function n(r){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+r,d=1;d<arguments.length;d++)o+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+r+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,i={};function a(r,o){c(r,o),c(r+"Capture",o)}function c(r,o){for(i[r]=o,r=0;r<o.length;r++)s.add(o[r])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,g={},v={};function _(r){return h.call(v,r)?!0:h.call(g,r)?!1:f.test(r)?v[r]=!0:(g[r]=!0,!1)}function b(r,o,d,m){if(d!==null&&d.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return m?!1:d!==null?!d.acceptsBooleans:(r=r.toLowerCase().slice(0,5),r!=="data-"&&r!=="aria-");default:return!1}}function x(r,o,d,m){if(o===null||typeof o>"u"||b(r,o,d,m))return!0;if(m)return!1;if(d!==null)switch(d.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function L(r,o,d,m,y,C,B){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=m,this.attributeNamespace=y,this.mustUseProperty=d,this.propertyName=r,this.type=o,this.sanitizeURL=C,this.removeEmptyString=B}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){k[r]=new L(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var o=r[0];k[o]=new L(o,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){k[r]=new L(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){k[r]=new L(r,2,!1,r,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(r){k[r]=new L(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){k[r]=new L(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){k[r]=new L(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){k[r]=new L(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){k[r]=new L(r,5,!1,r.toLowerCase(),null,!1,!1)});var R=/[\-:]([a-z])/g;function S(r){return r[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(r){var o=r.replace(R,S);k[o]=new L(o,1,!1,r,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(r){var o=r.replace(R,S);k[o]=new L(o,1,!1,r,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(r){var o=r.replace(R,S);k[o]=new L(o,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){k[r]=new L(r,1,!1,r.toLowerCase(),null,!1,!1)}),k.xlinkHref=new L("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){k[r]=new L(r,1,!1,r.toLowerCase(),null,!0,!0)});function j(r,o,d,m){var y=k.hasOwnProperty(o)?k[o]:null;(y!==null?y.type!==0:m||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(x(o,d,y,m)&&(d=null),m||y===null?_(o)&&(d===null?r.removeAttribute(o):r.setAttribute(o,""+d)):y.mustUseProperty?r[y.propertyName]=d===null?y.type===3?!1:"":d:(o=y.attributeName,m=y.attributeNamespace,d===null?r.removeAttribute(o):(y=y.type,d=y===3||y===4&&d===!0?"":""+d,m?r.setAttributeNS(m,o,d):r.setAttribute(o,d))))}var E=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,F=Symbol.for("react.element"),$=Symbol.for("react.portal"),G=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),te=Symbol.for("react.provider"),q=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),T=Symbol.for("react.offscreen"),A=Symbol.iterator;function N(r){return r===null||typeof r!="object"?null:(r=A&&r[A]||r["@@iterator"],typeof r=="function"?r:null)}var U=Object.assign,P;function H(r){if(P===void 0)try{throw Error()}catch(d){var o=d.stack.trim().match(/\n( *(at )?)/);P=o&&o[1]||""}return`
|
|
34
|
-
`+P+r}var ie=!1;function J(r,o){if(!r||ie)return"";ie=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(Ee){var m=Ee}Reflect.construct(r,[],o)}else{try{o.call()}catch(Ee){m=Ee}r.call(o.prototype)}else{try{throw Error()}catch(Ee){m=Ee}r()}}catch(Ee){if(Ee&&m&&typeof Ee.stack=="string"){for(var y=Ee.stack.split(`
|
|
35
|
-
`),C=m.stack.split(`
|
|
36
|
-
`),B=y.length-1,ee=C.length-1;1<=B&&0<=ee&&y[B]!==C[ee];)ee--;for(;1<=B&&0<=ee;B--,ee--)if(y[B]!==C[ee]){if(B!==1||ee!==1)do if(B--,ee--,0>ee||y[B]!==C[ee]){var ce=`
|
|
37
|
-
`+y[B].replace(" at new "," at ");return r.displayName&&ce.includes("<anonymous>")&&(ce=ce.replace("<anonymous>",r.displayName)),ce}while(1<=B&&0<=ee);break}}}finally{ie=!1,Error.prepareStackTrace=d}return(r=r?r.displayName||r.name:"")?H(r):""}function Q(r){switch(r.tag){case 5:return H(r.type);case 16:return H("Lazy");case 13:return H("Suspense");case 19:return H("SuspenseList");case 0:case 2:case 15:return r=J(r.type,!1),r;case 11:return r=J(r.type.render,!1),r;case 1:return r=J(r.type,!0),r;default:return""}}function ve(r){if(r==null)return null;if(typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case G:return"Fragment";case $:return"Portal";case Y:return"Profiler";case K:return"StrictMode";case I:return"Suspense";case O:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case q:return(r.displayName||"Context")+".Consumer";case te:return(r._context.displayName||"Context")+".Provider";case D:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case M:return o=r.displayName||null,o!==null?o:ve(r.type)||"Memo";case z:o=r._payload,r=r._init;try{return ve(r(o))}catch{}}return null}function de(r){var o=r.type;switch(r.tag){case 24:return"Cache";case 9:return(o.displayName||"Context")+".Consumer";case 10:return(o._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return r=o.render,r=r.displayName||r.name||"",o.displayName||(r!==""?"ForwardRef("+r+")":"ForwardRef");case 7:return"Fragment";case 5:return o;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ve(o);case 8:return o===K?"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 o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o}return null}function ne(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function xe(r){var o=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function $e(r){var o=xe(r)?"checked":"value",d=Object.getOwnPropertyDescriptor(r.constructor.prototype,o),m=""+r[o];if(!r.hasOwnProperty(o)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var y=d.get,C=d.set;return Object.defineProperty(r,o,{configurable:!0,get:function(){return y.call(this)},set:function(B){m=""+B,C.call(this,B)}}),Object.defineProperty(r,o,{enumerable:d.enumerable}),{getValue:function(){return m},setValue:function(B){m=""+B},stopTracking:function(){r._valueTracker=null,delete r[o]}}}}function rt(r){r._valueTracker||(r._valueTracker=$e(r))}function je(r){if(!r)return!1;var o=r._valueTracker;if(!o)return!0;var d=o.getValue(),m="";return r&&(m=xe(r)?r.checked?"true":"false":r.value),r=m,r!==d?(o.setValue(r),!0):!1}function Ie(r){if(r=r||(typeof document<"u"?document:void 0),typeof r>"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function oe(r,o){var d=o.checked;return U({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??r._wrapperState.initialChecked})}function Ne(r,o){var d=o.defaultValue==null?"":o.defaultValue,m=o.checked!=null?o.checked:o.defaultChecked;d=ne(o.value!=null?o.value:d),r._wrapperState={initialChecked:m,initialValue:d,controlled:o.type==="checkbox"||o.type==="radio"?o.checked!=null:o.value!=null}}function me(r,o){o=o.checked,o!=null&&j(r,"checked",o,!1)}function Ce(r,o){me(r,o);var d=ne(o.value),m=o.type;if(d!=null)m==="number"?(d===0&&r.value===""||r.value!=d)&&(r.value=""+d):r.value!==""+d&&(r.value=""+d);else if(m==="submit"||m==="reset"){r.removeAttribute("value");return}o.hasOwnProperty("value")?ge(r,o.type,d):o.hasOwnProperty("defaultValue")&&ge(r,o.type,ne(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(r.defaultChecked=!!o.defaultChecked)}function V(r,o,d){if(o.hasOwnProperty("value")||o.hasOwnProperty("defaultValue")){var m=o.type;if(!(m!=="submit"&&m!=="reset"||o.value!==void 0&&o.value!==null))return;o=""+r._wrapperState.initialValue,d||o===r.value||(r.value=o),r.defaultValue=o}d=r.name,d!==""&&(r.name=""),r.defaultChecked=!!r._wrapperState.initialChecked,d!==""&&(r.name=d)}function ge(r,o,d){(o!=="number"||Ie(r.ownerDocument)!==r)&&(d==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+d&&(r.defaultValue=""+d))}var Le=Array.isArray;function ke(r,o,d,m){if(r=r.options,o){o={};for(var y=0;y<d.length;y++)o["$"+d[y]]=!0;for(d=0;d<r.length;d++)y=o.hasOwnProperty("$"+r[d].value),r[d].selected!==y&&(r[d].selected=y),y&&m&&(r[d].defaultSelected=!0)}else{for(d=""+ne(d),o=null,y=0;y<r.length;y++){if(r[y].value===d){r[y].selected=!0,m&&(r[y].defaultSelected=!0);return}o!==null||r[y].disabled||(o=r[y])}o!==null&&(o.selected=!0)}}function We(r,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return U({},o,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Re(r,o){var d=o.value;if(d==null){if(d=o.children,o=o.defaultValue,d!=null){if(o!=null)throw Error(n(92));if(Le(d)){if(1<d.length)throw Error(n(93));d=d[0]}o=d}o==null&&(o=""),d=o}r._wrapperState={initialValue:ne(d)}}function _e(r,o){var d=ne(o.value),m=ne(o.defaultValue);d!=null&&(d=""+d,d!==r.value&&(r.value=d),o.defaultValue==null&&r.defaultValue!==d&&(r.defaultValue=d)),m!=null&&(r.defaultValue=""+m)}function st(r){var o=r.textContent;o===r._wrapperState.initialValue&&o!==""&&o!==null&&(r.value=o)}function Xe(r){switch(r){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 De(r,o){return r==null||r==="http://www.w3.org/1999/xhtml"?Xe(o):r==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var He,Ke=(function(r){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(o,d,m,y){MSApp.execUnsafeLocalFunction(function(){return r(o,d,m,y)})}:r})(function(r,o){if(r.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in r)r.innerHTML=o;else{for(He=He||document.createElement("div"),He.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=He.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;o.firstChild;)r.appendChild(o.firstChild)}});function wt(r,o){if(o){var d=r.firstChild;if(d&&d===r.lastChild&&d.nodeType===3){d.nodeValue=o;return}}r.textContent=o}var fe={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},he=["Webkit","ms","Moz","O"];Object.keys(fe).forEach(function(r){he.forEach(function(o){o=o+r.charAt(0).toUpperCase()+r.substring(1),fe[o]=fe[r]})});function Z(r,o,d){return o==null||typeof o=="boolean"||o===""?"":d||typeof o!="number"||o===0||fe.hasOwnProperty(r)&&fe[r]?(""+o).trim():o+"px"}function X(r,o){r=r.style;for(var d in o)if(o.hasOwnProperty(d)){var m=d.indexOf("--")===0,y=Z(d,o[d],m);d==="float"&&(d="cssFloat"),m?r.setProperty(d,y):r[d]=y}}var ue=U({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 Ze(r,o){if(o){if(ue[r]&&(o.children!=null||o.dangerouslySetInnerHTML!=null))throw Error(n(137,r));if(o.dangerouslySetInnerHTML!=null){if(o.children!=null)throw Error(n(60));if(typeof o.dangerouslySetInnerHTML!="object"||!("__html"in o.dangerouslySetInnerHTML))throw Error(n(61))}if(o.style!=null&&typeof o.style!="object")throw Error(n(62))}}function se(r,o){if(r.indexOf("-")===-1)return typeof o.is=="string";switch(r){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 Be=null;function ht(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Pt=null,St=null,Nt=null;function ut(r){if(r=bl(r)){if(typeof Pt!="function")throw Error(n(280));var o=r.stateNode;o&&(o=tu(o),Pt(r.stateNode,r.type,o))}}function zt(r){St?Nt?Nt.push(r):Nt=[r]:St=r}function Yt(){if(St){var r=St,o=Nt;if(Nt=St=null,ut(r),o)for(r=0;r<o.length;r++)ut(o[r])}}function Ut(r,o){return r(o)}function dt(){}var qt=!1;function In(r,o,d){if(qt)return r(o,d);qt=!0;try{return Ut(r,o,d)}finally{qt=!1,(St!==null||Nt!==null)&&(dt(),Yt())}}function Kt(r,o){var d=r.stateNode;if(d===null)return null;var m=tu(d);if(m===null)return null;d=m[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(m=!m.disabled)||(r=r.type,m=!(r==="button"||r==="input"||r==="select"||r==="textarea")),r=!m;break e;default:r=!1}if(r)return null;if(d&&typeof d!="function")throw Error(n(231,o,typeof d));return d}var wn=!1;if(u)try{var tn={};Object.defineProperty(tn,"passive",{get:function(){wn=!0}}),window.addEventListener("test",tn,tn),window.removeEventListener("test",tn,tn)}catch{wn=!1}function bn(r,o,d,m,y,C,B,ee,ce){var Ee=Array.prototype.slice.call(arguments,3);try{o.apply(d,Ee)}catch(Ue){this.onError(Ue)}}var Ft=!1,Jt=null,Qt=!1,Zt=null,ls={onError:function(r){Ft=!0,Jt=r}};function cs(r,o,d,m,y,C,B,ee,ce){Ft=!1,Jt=null,bn.apply(ls,arguments)}function mn(r,o,d,m,y,C,B,ee,ce){if(cs.apply(this,arguments),Ft){if(Ft){var Ee=Jt;Ft=!1,Jt=null}else throw Error(n(198));Qt||(Qt=!0,Zt=Ee)}}function gn(r){var o=r,d=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(d=o.return),r=o.return;while(r)}return o.tag===3?d:null}function qs(r){if(r.tag===13){var o=r.memoizedState;if(o===null&&(r=r.alternate,r!==null&&(o=r.memoizedState)),o!==null)return o.dehydrated}return null}function Vn(r){if(gn(r)!==r)throw Error(n(188))}function bt(r){var o=r.alternate;if(!o){if(o=gn(r),o===null)throw Error(n(188));return o!==r?null:r}for(var d=r,m=o;;){var y=d.return;if(y===null)break;var C=y.alternate;if(C===null){if(m=y.return,m!==null){d=m;continue}break}if(y.child===C.child){for(C=y.child;C;){if(C===d)return Vn(y),r;if(C===m)return Vn(y),o;C=C.sibling}throw Error(n(188))}if(d.return!==m.return)d=y,m=C;else{for(var B=!1,ee=y.child;ee;){if(ee===d){B=!0,d=y,m=C;break}if(ee===m){B=!0,m=y,d=C;break}ee=ee.sibling}if(!B){for(ee=C.child;ee;){if(ee===d){B=!0,d=C,m=y;break}if(ee===m){B=!0,m=C,d=y;break}ee=ee.sibling}if(!B)throw Error(n(189))}}if(d.alternate!==m)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?r:o}function us(r){return r=bt(r),r!==null?le(r):null}function le(r){if(r.tag===5||r.tag===6)return r;for(r=r.child;r!==null;){var o=le(r);if(o!==null)return o;r=r.sibling}return null}var re=e.unstable_scheduleCallback,Te=e.unstable_cancelCallback,Ge=e.unstable_shouldYield,gt=e.unstable_requestPaint,W=e.unstable_now,ae=e.unstable_getCurrentPriorityLevel,Ae=e.unstable_ImmediatePriority,Je=e.unstable_UserBlockingPriority,Pe=e.unstable_NormalPriority,xt=e.unstable_LowPriority,vt=e.unstable_IdlePriority,Qe=null,Rt=null;function ot(r){if(Rt&&typeof Rt.onCommitFiberRoot=="function")try{Rt.onCommitFiberRoot(Qe,r,void 0,(r.current.flags&128)===128)}catch{}}var ze=Math.clz32?Math.clz32:Se,Wt=Math.log,Sn=Math.LN2;function Se(r){return r>>>=0,r===0?32:31-(Wt(r)/Sn|0)|0}var Me=64,qe=4194304;function ct(r){switch(r&-r){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 r&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return r&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return r}}function Lt(r,o){var d=r.pendingLanes;if(d===0)return 0;var m=0,y=r.suspendedLanes,C=r.pingedLanes,B=d&268435455;if(B!==0){var ee=B&~y;ee!==0?m=ct(ee):(C&=B,C!==0&&(m=ct(C)))}else B=d&~y,B!==0?m=ct(B):C!==0&&(m=ct(C));if(m===0)return 0;if(o!==0&&o!==m&&(o&y)===0&&(y=m&-m,C=o&-o,y>=C||y===16&&(C&4194240)!==0))return o;if((m&4)!==0&&(m|=d&16),o=r.entangledLanes,o!==0)for(r=r.entanglements,o&=m;0<o;)d=31-ze(o),y=1<<d,m|=r[d],o&=~y;return m}function Ks(r,o){switch(r){case 1:case 2:case 4:return o+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 o+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 Vs(r,o){for(var d=r.suspendedLanes,m=r.pingedLanes,y=r.expirationTimes,C=r.pendingLanes;0<C;){var B=31-ze(C),ee=1<<B,ce=y[B];ce===-1?((ee&d)===0||(ee&m)!==0)&&(y[B]=Ks(ee,o)):ce<=o&&(r.expiredLanes|=ee),C&=~ee}}function en(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function nn(){var r=Me;return Me<<=1,(Me&4194240)===0&&(Me=64),r}function on(r){for(var o=[],d=0;31>d;d++)o.push(r);return o}function Si(r,o,d){r.pendingLanes|=o,o!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,o=31-ze(o),r[o]=d}function go(r,o){var d=r.pendingLanes&~o;r.pendingLanes=o,r.suspendedLanes=0,r.pingedLanes=0,r.expiredLanes&=o,r.mutableReadLanes&=o,r.entangledLanes&=o,o=r.entanglements;var m=r.eventTimes;for(r=r.expirationTimes;0<d;){var y=31-ze(d),C=1<<y;o[y]=0,m[y]=-1,r[y]=-1,d&=~C}}function rr(r,o){var d=r.entangledLanes|=o;for(r=r.entanglements;d;){var m=31-ze(d),y=1<<m;y&o|r[m]&o&&(r[m]|=o),d&=~y}}var Gt=0;function rl(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var ol,Ps,al,ll,cl,Ar=!1,ni=[],Ys=null,xi=null,si=null,jr=new Map,ii=new Map,ki=[],Mr="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 Gs(r,o){switch(r){case"focusin":case"focusout":Ys=null;break;case"dragenter":case"dragleave":xi=null;break;case"mouseover":case"mouseout":si=null;break;case"pointerover":case"pointerout":jr.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":ii.delete(o.pointerId)}}function or(r,o,d,m,y,C){return r===null||r.nativeEvent!==C?(r={blockedOn:o,domEventName:d,eventSystemFlags:m,nativeEvent:C,targetContainers:[y]},o!==null&&(o=bl(o),o!==null&&Ps(o)),r):(r.eventSystemFlags|=m,o=r.targetContainers,y!==null&&o.indexOf(y)===-1&&o.push(y),r)}function qc(r,o,d,m,y){switch(o){case"focusin":return Ys=or(Ys,r,o,d,m,y),!0;case"dragenter":return xi=or(xi,r,o,d,m,y),!0;case"mouseover":return si=or(si,r,o,d,m,y),!0;case"pointerover":var C=y.pointerId;return jr.set(C,or(jr.get(C)||null,r,o,d,m,y)),!0;case"gotpointercapture":return C=y.pointerId,ii.set(C,or(ii.get(C)||null,r,o,d,m,y)),!0}return!1}function ys(r){var o=So(r.target);if(o!==null){var d=gn(o);if(d!==null){if(o=d.tag,o===13){if(o=qs(d),o!==null){r.blockedOn=o,cl(r.priority,function(){al(d)});return}}else if(o===3&&d.stateNode.current.memoizedState.isDehydrated){r.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}r.blockedOn=null}function vo(r){if(r.blockedOn!==null)return!1;for(var o=r.targetContainers;0<o.length;){var d=ia(r.domEventName,r.eventSystemFlags,o[0],r.nativeEvent);if(d===null){d=r.nativeEvent;var m=new d.constructor(d.type,d);Be=m,d.target.dispatchEvent(m),Be=null}else return o=bl(d),o!==null&&Ps(o),r.blockedOn=d,!1;o.shift()}return!0}function _o(r,o,d){vo(r)&&d.delete(o)}function yo(){Ar=!1,Ys!==null&&vo(Ys)&&(Ys=null),xi!==null&&vo(xi)&&(xi=null),si!==null&&vo(si)&&(si=null),jr.forEach(_o),ii.forEach(_o)}function Bi(r,o){r.blockedOn===o&&(r.blockedOn=null,Ar||(Ar=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,yo)))}function Tr(r){function o(y){return Bi(y,r)}if(0<ni.length){Bi(ni[0],r);for(var d=1;d<ni.length;d++){var m=ni[d];m.blockedOn===r&&(m.blockedOn=null)}}for(Ys!==null&&Bi(Ys,r),xi!==null&&Bi(xi,r),si!==null&&Bi(si,r),jr.forEach(o),ii.forEach(o),d=0;d<ki.length;d++)m=ki[d],m.blockedOn===r&&(m.blockedOn=null);for(;0<ki.length&&(d=ki[0],d.blockedOn===null);)ys(d),d.blockedOn===null&&ki.shift()}var Ci=E.ReactCurrentBatchConfig,wo=!0;function na(r,o,d,m){var y=Gt,C=Ci.transition;Ci.transition=null;try{Gt=1,sa(r,o,d,m)}finally{Gt=y,Ci.transition=C}}function Kc(r,o,d,m){var y=Gt,C=Ci.transition;Ci.transition=null;try{Gt=4,sa(r,o,d,m)}finally{Gt=y,Ci.transition=C}}function sa(r,o,d,m){if(wo){var y=ia(r,o,d,m);if(y===null)jh(r,o,m,bo,d),Gs(r,m);else if(qc(y,r,o,d,m))m.stopPropagation();else if(Gs(r,m),o&4&&-1<Mr.indexOf(r)){for(;y!==null;){var C=bl(y);if(C!==null&&ol(C),C=ia(r,o,d,m),C===null&&jh(r,o,m,bo,d),C===y)break;y=C}y!==null&&m.stopPropagation()}else jh(r,o,m,null,d)}}var bo=null;function ia(r,o,d,m){if(bo=null,r=ht(m),r=So(r),r!==null)if(o=gn(r),o===null)r=null;else if(d=o.tag,d===13){if(r=qs(o),r!==null)return r;r=null}else if(d===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;r=null}else o!==r&&(r=null);return bo=r,null}function ul(r){switch(r){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(ae()){case Ae:return 1;case Je:return 4;case Pe:case xt:return 16;case vt:return 536870912;default:return 16}default:return 16}}var Ei=null,ye=null,Ve=null;function tt(){if(Ve)return Ve;var r,o=ye,d=o.length,m,y="value"in Ei?Ei.value:Ei.textContent,C=y.length;for(r=0;r<d&&o[r]===y[r];r++);var B=d-r;for(m=1;m<=B&&o[d-m]===y[C-m];m++);return Ve=y.slice(r,1<m?1-m:void 0)}function ft(r){var o=r.keyCode;return"charCode"in r?(r=r.charCode,r===0&&o===13&&(r=13)):r=o,r===10&&(r=13),32<=r||r===13?r:0}function Et(){return!0}function At(){return!1}function It(r){function o(d,m,y,C,B){this._reactName=d,this._targetInst=y,this.type=m,this.nativeEvent=C,this.target=B,this.currentTarget=null;for(var ee in r)r.hasOwnProperty(ee)&&(d=r[ee],this[ee]=d?d(C):C[ee]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?Et:At,this.isPropagationStopped=At,this}return U(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=Et)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=Et)},persist:function(){},isPersistent:Et}),o}var sn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yn=It(sn),cn=U({},sn,{view:0,detail:0}),Is=It(cn),ri,dl,ra,Vc=U({},cn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wh,button:0,buttons:0,relatedTarget:function(r){return r.relatedTarget===void 0?r.fromElement===r.srcElement?r.toElement:r.fromElement:r.relatedTarget},movementX:function(r){return"movementX"in r?r.movementX:(r!==ra&&(ra&&r.type==="mousemove"?(ri=r.screenX-ra.screenX,dl=r.screenY-ra.screenY):dl=ri=0,ra=r),ri)},movementY:function(r){return"movementY"in r?r.movementY:dl}}),h_=It(Vc),IE=U({},Vc,{dataTransfer:0}),DE=It(IE),OE=U({},cn,{relatedTarget:0}),yh=It(OE),BE=U({},sn,{animationName:0,elapsedTime:0,pseudoElement:0}),$E=It(BE),zE=U({},sn,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),FE=It(zE),HE=U({},sn,{data:0}),f_=It(HE),UE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},WE={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"},qE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function KE(r){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(r):(r=qE[r])?!!o[r]:!1}function wh(){return KE}var VE=U({},cn,{key:function(r){if(r.key){var o=UE[r.key]||r.key;if(o!=="Unidentified")return o}return r.type==="keypress"?(r=ft(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?WE[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wh,charCode:function(r){return r.type==="keypress"?ft(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?ft(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),YE=It(VE),GE=U({},Vc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),p_=It(GE),XE=U({},cn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wh}),JE=It(XE),QE=U({},sn,{propertyName:0,elapsedTime:0,pseudoElement:0}),ZE=It(QE),e2=U({},Vc,{deltaX:function(r){return"deltaX"in r?r.deltaX:"wheelDeltaX"in r?-r.wheelDeltaX:0},deltaY:function(r){return"deltaY"in r?r.deltaY:"wheelDeltaY"in r?-r.wheelDeltaY:"wheelDelta"in r?-r.wheelDelta:0},deltaZ:0,deltaMode:0}),t2=It(e2),n2=[9,13,27,32],bh=u&&"CompositionEvent"in window,hl=null;u&&"documentMode"in document&&(hl=document.documentMode);var s2=u&&"TextEvent"in window&&!hl,m_=u&&(!bh||hl&&8<hl&&11>=hl),g_=" ",v_=!1;function __(r,o){switch(r){case"keyup":return n2.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function y_(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var oa=!1;function i2(r,o){switch(r){case"compositionend":return y_(o);case"keypress":return o.which!==32?null:(v_=!0,g_);case"textInput":return r=o.data,r===g_&&v_?null:r;default:return null}}function r2(r,o){if(oa)return r==="compositionend"||!bh&&__(r,o)?(r=tt(),Ve=ye=Ei=null,oa=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return m_&&o.locale!=="ko"?null:o.data;default:return null}}var o2={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 w_(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o==="input"?!!o2[r.type]:o==="textarea"}function b_(r,o,d,m){zt(m),o=Qc(o,"onChange"),0<o.length&&(d=new Yn("onChange","change",null,d,m),r.push({event:d,listeners:o}))}var fl=null,pl=null;function a2(r){$_(r,0)}function Yc(r){var o=da(r);if(je(o))return r}function l2(r,o){if(r==="change")return o}var S_=!1;if(u){var Sh;if(u){var xh="oninput"in document;if(!xh){var x_=document.createElement("div");x_.setAttribute("oninput","return;"),xh=typeof x_.oninput=="function"}Sh=xh}else Sh=!1;S_=Sh&&(!document.documentMode||9<document.documentMode)}function k_(){fl&&(fl.detachEvent("onpropertychange",C_),pl=fl=null)}function C_(r){if(r.propertyName==="value"&&Yc(pl)){var o=[];b_(o,pl,r,ht(r)),In(a2,o)}}function c2(r,o,d){r==="focusin"?(k_(),fl=o,pl=d,fl.attachEvent("onpropertychange",C_)):r==="focusout"&&k_()}function u2(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Yc(pl)}function d2(r,o){if(r==="click")return Yc(o)}function h2(r,o){if(r==="input"||r==="change")return Yc(o)}function f2(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}var Ni=typeof Object.is=="function"?Object.is:f2;function ml(r,o){if(Ni(r,o))return!0;if(typeof r!="object"||r===null||typeof o!="object"||o===null)return!1;var d=Object.keys(r),m=Object.keys(o);if(d.length!==m.length)return!1;for(m=0;m<d.length;m++){var y=d[m];if(!h.call(o,y)||!Ni(r[y],o[y]))return!1}return!0}function E_(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function N_(r,o){var d=E_(r);r=0;for(var m;d;){if(d.nodeType===3){if(m=r+d.textContent.length,r<=o&&m>=o)return{node:d,offset:o-r};r=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=E_(d)}}function R_(r,o){return r&&o?r===o?!0:r&&r.nodeType===3?!1:o&&o.nodeType===3?R_(r,o.parentNode):"contains"in r?r.contains(o):r.compareDocumentPosition?!!(r.compareDocumentPosition(o)&16):!1:!1}function L_(){for(var r=window,o=Ie();o instanceof r.HTMLIFrameElement;){try{var d=typeof o.contentWindow.location.href=="string"}catch{d=!1}if(d)r=o.contentWindow;else break;o=Ie(r.document)}return o}function kh(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o&&(o==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||o==="textarea"||r.contentEditable==="true")}function p2(r){var o=L_(),d=r.focusedElem,m=r.selectionRange;if(o!==d&&d&&d.ownerDocument&&R_(d.ownerDocument.documentElement,d)){if(m!==null&&kh(d)){if(o=m.start,r=m.end,r===void 0&&(r=o),"selectionStart"in d)d.selectionStart=o,d.selectionEnd=Math.min(r,d.value.length);else if(r=(o=d.ownerDocument||document)&&o.defaultView||window,r.getSelection){r=r.getSelection();var y=d.textContent.length,C=Math.min(m.start,y);m=m.end===void 0?C:Math.min(m.end,y),!r.extend&&C>m&&(y=m,m=C,C=y),y=N_(d,C);var B=N_(d,m);y&&B&&(r.rangeCount!==1||r.anchorNode!==y.node||r.anchorOffset!==y.offset||r.focusNode!==B.node||r.focusOffset!==B.offset)&&(o=o.createRange(),o.setStart(y.node,y.offset),r.removeAllRanges(),C>m?(r.addRange(o),r.extend(B.node,B.offset)):(o.setEnd(B.node,B.offset),r.addRange(o)))}}for(o=[],r=d;r=r.parentNode;)r.nodeType===1&&o.push({element:r,left:r.scrollLeft,top:r.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<o.length;d++)r=o[d],r.element.scrollLeft=r.left,r.element.scrollTop=r.top}}var m2=u&&"documentMode"in document&&11>=document.documentMode,aa=null,Ch=null,gl=null,Eh=!1;function A_(r,o,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Eh||aa==null||aa!==Ie(m)||(m=aa,"selectionStart"in m&&kh(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),gl&&ml(gl,m)||(gl=m,m=Qc(Ch,"onSelect"),0<m.length&&(o=new Yn("onSelect","select",null,o,d),r.push({event:o,listeners:m}),o.target=aa)))}function Gc(r,o){var d={};return d[r.toLowerCase()]=o.toLowerCase(),d["Webkit"+r]="webkit"+o,d["Moz"+r]="moz"+o,d}var la={animationend:Gc("Animation","AnimationEnd"),animationiteration:Gc("Animation","AnimationIteration"),animationstart:Gc("Animation","AnimationStart"),transitionend:Gc("Transition","TransitionEnd")},Nh={},j_={};u&&(j_=document.createElement("div").style,"AnimationEvent"in window||(delete la.animationend.animation,delete la.animationiteration.animation,delete la.animationstart.animation),"TransitionEvent"in window||delete la.transitionend.transition);function Xc(r){if(Nh[r])return Nh[r];if(!la[r])return r;var o=la[r],d;for(d in o)if(o.hasOwnProperty(d)&&d in j_)return Nh[r]=o[d];return r}var M_=Xc("animationend"),T_=Xc("animationiteration"),P_=Xc("animationstart"),I_=Xc("transitionend"),D_=new Map,O_="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 Pr(r,o){D_.set(r,o),a(o,[r])}for(var Rh=0;Rh<O_.length;Rh++){var Lh=O_[Rh],g2=Lh.toLowerCase(),v2=Lh[0].toUpperCase()+Lh.slice(1);Pr(g2,"on"+v2)}Pr(M_,"onAnimationEnd"),Pr(T_,"onAnimationIteration"),Pr(P_,"onAnimationStart"),Pr("dblclick","onDoubleClick"),Pr("focusin","onFocus"),Pr("focusout","onBlur"),Pr(I_,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var vl="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(" "),_2=new Set("cancel close invalid load scroll toggle".split(" ").concat(vl));function B_(r,o,d){var m=r.type||"unknown-event";r.currentTarget=d,mn(m,o,void 0,r),r.currentTarget=null}function $_(r,o){o=(o&4)!==0;for(var d=0;d<r.length;d++){var m=r[d],y=m.event;m=m.listeners;e:{var C=void 0;if(o)for(var B=m.length-1;0<=B;B--){var ee=m[B],ce=ee.instance,Ee=ee.currentTarget;if(ee=ee.listener,ce!==C&&y.isPropagationStopped())break e;B_(y,ee,Ee),C=ce}else for(B=0;B<m.length;B++){if(ee=m[B],ce=ee.instance,Ee=ee.currentTarget,ee=ee.listener,ce!==C&&y.isPropagationStopped())break e;B_(y,ee,Ee),C=ce}}}if(Qt)throw r=Zt,Qt=!1,Zt=null,r}function un(r,o){var d=o[Oh];d===void 0&&(d=o[Oh]=new Set);var m=r+"__bubble";d.has(m)||(z_(o,r,2,!1),d.add(m))}function Ah(r,o,d){var m=0;o&&(m|=4),z_(d,r,m,o)}var Jc="_reactListening"+Math.random().toString(36).slice(2);function _l(r){if(!r[Jc]){r[Jc]=!0,s.forEach(function(d){d!=="selectionchange"&&(_2.has(d)||Ah(d,!1,r),Ah(d,!0,r))});var o=r.nodeType===9?r:r.ownerDocument;o===null||o[Jc]||(o[Jc]=!0,Ah("selectionchange",!1,o))}}function z_(r,o,d,m){switch(ul(o)){case 1:var y=na;break;case 4:y=Kc;break;default:y=sa}d=y.bind(null,o,d,r),y=void 0,!wn||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(y=!0),m?y!==void 0?r.addEventListener(o,d,{capture:!0,passive:y}):r.addEventListener(o,d,!0):y!==void 0?r.addEventListener(o,d,{passive:y}):r.addEventListener(o,d,!1)}function jh(r,o,d,m,y){var C=m;if((o&1)===0&&(o&2)===0&&m!==null)e:for(;;){if(m===null)return;var B=m.tag;if(B===3||B===4){var ee=m.stateNode.containerInfo;if(ee===y||ee.nodeType===8&&ee.parentNode===y)break;if(B===4)for(B=m.return;B!==null;){var ce=B.tag;if((ce===3||ce===4)&&(ce=B.stateNode.containerInfo,ce===y||ce.nodeType===8&&ce.parentNode===y))return;B=B.return}for(;ee!==null;){if(B=So(ee),B===null)return;if(ce=B.tag,ce===5||ce===6){m=C=B;continue e}ee=ee.parentNode}}m=m.return}In(function(){var Ee=C,Ue=ht(d),Ye=[];e:{var Fe=D_.get(r);if(Fe!==void 0){var lt=Yn,mt=r;switch(r){case"keypress":if(ft(d)===0)break e;case"keydown":case"keyup":lt=YE;break;case"focusin":mt="focus",lt=yh;break;case"focusout":mt="blur",lt=yh;break;case"beforeblur":case"afterblur":lt=yh;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":lt=h_;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":lt=DE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":lt=JE;break;case M_:case T_:case P_:lt=$E;break;case I_:lt=ZE;break;case"scroll":lt=Is;break;case"wheel":lt=t2;break;case"copy":case"cut":case"paste":lt=FE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":lt=p_}var _t=(o&4)!==0,Mn=!_t&&r==="scroll",we=_t?Fe!==null?Fe+"Capture":null:Fe;_t=[];for(var pe=Ee,be;pe!==null;){be=pe;var et=be.stateNode;if(be.tag===5&&et!==null&&(be=et,we!==null&&(et=Kt(pe,we),et!=null&&_t.push(yl(pe,et,be)))),Mn)break;pe=pe.return}0<_t.length&&(Fe=new lt(Fe,mt,null,d,Ue),Ye.push({event:Fe,listeners:_t}))}}if((o&7)===0){e:{if(Fe=r==="mouseover"||r==="pointerover",lt=r==="mouseout"||r==="pointerout",Fe&&d!==Be&&(mt=d.relatedTarget||d.fromElement)&&(So(mt)||mt[ar]))break e;if((lt||Fe)&&(Fe=Ue.window===Ue?Ue:(Fe=Ue.ownerDocument)?Fe.defaultView||Fe.parentWindow:window,lt?(mt=d.relatedTarget||d.toElement,lt=Ee,mt=mt?So(mt):null,mt!==null&&(Mn=gn(mt),mt!==Mn||mt.tag!==5&&mt.tag!==6)&&(mt=null)):(lt=null,mt=Ee),lt!==mt)){if(_t=h_,et="onMouseLeave",we="onMouseEnter",pe="mouse",(r==="pointerout"||r==="pointerover")&&(_t=p_,et="onPointerLeave",we="onPointerEnter",pe="pointer"),Mn=lt==null?Fe:da(lt),be=mt==null?Fe:da(mt),Fe=new _t(et,pe+"leave",lt,d,Ue),Fe.target=Mn,Fe.relatedTarget=be,et=null,So(Ue)===Ee&&(_t=new _t(we,pe+"enter",mt,d,Ue),_t.target=be,_t.relatedTarget=Mn,et=_t),Mn=et,lt&&mt)t:{for(_t=lt,we=mt,pe=0,be=_t;be;be=ca(be))pe++;for(be=0,et=we;et;et=ca(et))be++;for(;0<pe-be;)_t=ca(_t),pe--;for(;0<be-pe;)we=ca(we),be--;for(;pe--;){if(_t===we||we!==null&&_t===we.alternate)break t;_t=ca(_t),we=ca(we)}_t=null}else _t=null;lt!==null&&F_(Ye,Fe,lt,_t,!1),mt!==null&&Mn!==null&&F_(Ye,Mn,mt,_t,!0)}}e:{if(Fe=Ee?da(Ee):window,lt=Fe.nodeName&&Fe.nodeName.toLowerCase(),lt==="select"||lt==="input"&&Fe.type==="file")var yt=l2;else if(w_(Fe))if(S_)yt=h2;else{yt=u2;var kt=c2}else(lt=Fe.nodeName)&<.toLowerCase()==="input"&&(Fe.type==="checkbox"||Fe.type==="radio")&&(yt=d2);if(yt&&(yt=yt(r,Ee))){b_(Ye,yt,d,Ue);break e}kt&&kt(r,Fe,Ee),r==="focusout"&&(kt=Fe._wrapperState)&&kt.controlled&&Fe.type==="number"&&ge(Fe,"number",Fe.value)}switch(kt=Ee?da(Ee):window,r){case"focusin":(w_(kt)||kt.contentEditable==="true")&&(aa=kt,Ch=Ee,gl=null);break;case"focusout":gl=Ch=aa=null;break;case"mousedown":Eh=!0;break;case"contextmenu":case"mouseup":case"dragend":Eh=!1,A_(Ye,d,Ue);break;case"selectionchange":if(m2)break;case"keydown":case"keyup":A_(Ye,d,Ue)}var Ct;if(bh)e:{switch(r){case"compositionstart":var jt="onCompositionStart";break e;case"compositionend":jt="onCompositionEnd";break e;case"compositionupdate":jt="onCompositionUpdate";break e}jt=void 0}else oa?__(r,d)&&(jt="onCompositionEnd"):r==="keydown"&&d.keyCode===229&&(jt="onCompositionStart");jt&&(m_&&d.locale!=="ko"&&(oa||jt!=="onCompositionStart"?jt==="onCompositionEnd"&&oa&&(Ct=tt()):(Ei=Ue,ye="value"in Ei?Ei.value:Ei.textContent,oa=!0)),kt=Qc(Ee,jt),0<kt.length&&(jt=new f_(jt,r,null,d,Ue),Ye.push({event:jt,listeners:kt}),Ct?jt.data=Ct:(Ct=y_(d),Ct!==null&&(jt.data=Ct)))),(Ct=s2?i2(r,d):r2(r,d))&&(Ee=Qc(Ee,"onBeforeInput"),0<Ee.length&&(Ue=new f_("onBeforeInput","beforeinput",null,d,Ue),Ye.push({event:Ue,listeners:Ee}),Ue.data=Ct))}$_(Ye,o)})}function yl(r,o,d){return{instance:r,listener:o,currentTarget:d}}function Qc(r,o){for(var d=o+"Capture",m=[];r!==null;){var y=r,C=y.stateNode;y.tag===5&&C!==null&&(y=C,C=Kt(r,d),C!=null&&m.unshift(yl(r,C,y)),C=Kt(r,o),C!=null&&m.push(yl(r,C,y))),r=r.return}return m}function ca(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function F_(r,o,d,m,y){for(var C=o._reactName,B=[];d!==null&&d!==m;){var ee=d,ce=ee.alternate,Ee=ee.stateNode;if(ce!==null&&ce===m)break;ee.tag===5&&Ee!==null&&(ee=Ee,y?(ce=Kt(d,C),ce!=null&&B.unshift(yl(d,ce,ee))):y||(ce=Kt(d,C),ce!=null&&B.push(yl(d,ce,ee)))),d=d.return}B.length!==0&&r.push({event:o,listeners:B})}var y2=/\r\n?/g,w2=/\u0000|\uFFFD/g;function H_(r){return(typeof r=="string"?r:""+r).replace(y2,`
|
|
38
|
-
`).replace(w2,"")}function Zc(r,o,d){if(o=H_(o),H_(r)!==o&&d)throw Error(n(425))}function eu(){}var Mh=null,Th=null;function Ph(r,o){return r==="textarea"||r==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Ih=typeof setTimeout=="function"?setTimeout:void 0,b2=typeof clearTimeout=="function"?clearTimeout:void 0,U_=typeof Promise=="function"?Promise:void 0,S2=typeof queueMicrotask=="function"?queueMicrotask:typeof U_<"u"?function(r){return U_.resolve(null).then(r).catch(x2)}:Ih;function x2(r){setTimeout(function(){throw r})}function Dh(r,o){var d=o,m=0;do{var y=d.nextSibling;if(r.removeChild(d),y&&y.nodeType===8)if(d=y.data,d==="/$"){if(m===0){r.removeChild(y),Tr(o);return}m--}else d!=="$"&&d!=="$?"&&d!=="$!"||m++;d=y}while(d);Tr(o)}function Ir(r){for(;r!=null;r=r.nextSibling){var o=r.nodeType;if(o===1||o===3)break;if(o===8){if(o=r.data,o==="$"||o==="$!"||o==="$?")break;if(o==="/$")return null}}return r}function W_(r){r=r.previousSibling;for(var o=0;r;){if(r.nodeType===8){var d=r.data;if(d==="$"||d==="$!"||d==="$?"){if(o===0)return r;o--}else d==="/$"&&o++}r=r.previousSibling}return null}var ua=Math.random().toString(36).slice(2),$i="__reactFiber$"+ua,wl="__reactProps$"+ua,ar="__reactContainer$"+ua,Oh="__reactEvents$"+ua,k2="__reactListeners$"+ua,C2="__reactHandles$"+ua;function So(r){var o=r[$i];if(o)return o;for(var d=r.parentNode;d;){if(o=d[ar]||d[$i]){if(d=o.alternate,o.child!==null||d!==null&&d.child!==null)for(r=W_(r);r!==null;){if(d=r[$i])return d;r=W_(r)}return o}r=d,d=r.parentNode}return null}function bl(r){return r=r[$i]||r[ar],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function da(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function tu(r){return r[wl]||null}var Bh=[],ha=-1;function Dr(r){return{current:r}}function dn(r){0>ha||(r.current=Bh[ha],Bh[ha]=null,ha--)}function an(r,o){ha++,Bh[ha]=r.current,r.current=o}var Or={},ws=Dr(Or),Ds=Dr(!1),xo=Or;function fa(r,o){var d=r.type.contextTypes;if(!d)return Or;var m=r.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===o)return m.__reactInternalMemoizedMaskedChildContext;var y={},C;for(C in d)y[C]=o[C];return m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=o,r.__reactInternalMemoizedMaskedChildContext=y),y}function Os(r){return r=r.childContextTypes,r!=null}function nu(){dn(Ds),dn(ws)}function q_(r,o,d){if(ws.current!==Or)throw Error(n(168));an(ws,o),an(Ds,d)}function K_(r,o,d){var m=r.stateNode;if(o=o.childContextTypes,typeof m.getChildContext!="function")return d;m=m.getChildContext();for(var y in m)if(!(y in o))throw Error(n(108,de(r)||"Unknown",y));return U({},d,m)}function su(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Or,xo=ws.current,an(ws,r),an(Ds,Ds.current),!0}function V_(r,o,d){var m=r.stateNode;if(!m)throw Error(n(169));d?(r=K_(r,o,xo),m.__reactInternalMemoizedMergedChildContext=r,dn(Ds),dn(ws),an(ws,r)):dn(Ds),an(Ds,d)}var lr=null,iu=!1,$h=!1;function Y_(r){lr===null?lr=[r]:lr.push(r)}function E2(r){iu=!0,Y_(r)}function Br(){if(!$h&&lr!==null){$h=!0;var r=0,o=Gt;try{var d=lr;for(Gt=1;r<d.length;r++){var m=d[r];do m=m(!0);while(m!==null)}lr=null,iu=!1}catch(y){throw lr!==null&&(lr=lr.slice(r+1)),re(Ae,Br),y}finally{Gt=o,$h=!1}}return null}var pa=[],ma=0,ru=null,ou=0,oi=[],ai=0,ko=null,cr=1,ur="";function Co(r,o){pa[ma++]=ou,pa[ma++]=ru,ru=r,ou=o}function G_(r,o,d){oi[ai++]=cr,oi[ai++]=ur,oi[ai++]=ko,ko=r;var m=cr;r=ur;var y=32-ze(m)-1;m&=~(1<<y),d+=1;var C=32-ze(o)+y;if(30<C){var B=y-y%5;C=(m&(1<<B)-1).toString(32),m>>=B,y-=B,cr=1<<32-ze(o)+y|d<<y|m,ur=C+r}else cr=1<<C|d<<y|m,ur=r}function zh(r){r.return!==null&&(Co(r,1),G_(r,1,0))}function Fh(r){for(;r===ru;)ru=pa[--ma],pa[ma]=null,ou=pa[--ma],pa[ma]=null;for(;r===ko;)ko=oi[--ai],oi[ai]=null,ur=oi[--ai],oi[ai]=null,cr=oi[--ai],oi[ai]=null}var Xs=null,Js=null,vn=!1,Ri=null;function X_(r,o){var d=di(5,null,null,0);d.elementType="DELETED",d.stateNode=o,d.return=r,o=r.deletions,o===null?(r.deletions=[d],r.flags|=16):o.push(d)}function J_(r,o){switch(r.tag){case 5:var d=r.type;return o=o.nodeType!==1||d.toLowerCase()!==o.nodeName.toLowerCase()?null:o,o!==null?(r.stateNode=o,Xs=r,Js=Ir(o.firstChild),!0):!1;case 6:return o=r.pendingProps===""||o.nodeType!==3?null:o,o!==null?(r.stateNode=o,Xs=r,Js=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(d=ko!==null?{id:cr,overflow:ur}:null,r.memoizedState={dehydrated:o,treeContext:d,retryLane:1073741824},d=di(18,null,null,0),d.stateNode=o,d.return=r,r.child=d,Xs=r,Js=null,!0):!1;default:return!1}}function Hh(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Uh(r){if(vn){var o=Js;if(o){var d=o;if(!J_(r,o)){if(Hh(r))throw Error(n(418));o=Ir(d.nextSibling);var m=Xs;o&&J_(r,o)?X_(m,d):(r.flags=r.flags&-4097|2,vn=!1,Xs=r)}}else{if(Hh(r))throw Error(n(418));r.flags=r.flags&-4097|2,vn=!1,Xs=r}}}function Q_(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Xs=r}function au(r){if(r!==Xs)return!1;if(!vn)return Q_(r),vn=!0,!1;var o;if((o=r.tag!==3)&&!(o=r.tag!==5)&&(o=r.type,o=o!=="head"&&o!=="body"&&!Ph(r.type,r.memoizedProps)),o&&(o=Js)){if(Hh(r))throw Z_(),Error(n(418));for(;o;)X_(r,o),o=Ir(o.nextSibling)}if(Q_(r),r.tag===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(n(317));e:{for(r=r.nextSibling,o=0;r;){if(r.nodeType===8){var d=r.data;if(d==="/$"){if(o===0){Js=Ir(r.nextSibling);break e}o--}else d!=="$"&&d!=="$!"&&d!=="$?"||o++}r=r.nextSibling}Js=null}}else Js=Xs?Ir(r.stateNode.nextSibling):null;return!0}function Z_(){for(var r=Js;r;)r=Ir(r.nextSibling)}function ga(){Js=Xs=null,vn=!1}function Wh(r){Ri===null?Ri=[r]:Ri.push(r)}var N2=E.ReactCurrentBatchConfig;function Sl(r,o,d){if(r=d.ref,r!==null&&typeof r!="function"&&typeof r!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var m=d.stateNode}if(!m)throw Error(n(147,r));var y=m,C=""+r;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===C?o.ref:(o=function(B){var ee=y.refs;B===null?delete ee[C]:ee[C]=B},o._stringRef=C,o)}if(typeof r!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,r))}return r}function lu(r,o){throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function ey(r){var o=r._init;return o(r._payload)}function ty(r){function o(we,pe){if(r){var be=we.deletions;be===null?(we.deletions=[pe],we.flags|=16):be.push(pe)}}function d(we,pe){if(!r)return null;for(;pe!==null;)o(we,pe),pe=pe.sibling;return null}function m(we,pe){for(we=new Map;pe!==null;)pe.key!==null?we.set(pe.key,pe):we.set(pe.index,pe),pe=pe.sibling;return we}function y(we,pe){return we=Kr(we,pe),we.index=0,we.sibling=null,we}function C(we,pe,be){return we.index=be,r?(be=we.alternate,be!==null?(be=be.index,be<pe?(we.flags|=2,pe):be):(we.flags|=2,pe)):(we.flags|=1048576,pe)}function B(we){return r&&we.alternate===null&&(we.flags|=2),we}function ee(we,pe,be,et){return pe===null||pe.tag!==6?(pe=Df(be,we.mode,et),pe.return=we,pe):(pe=y(pe,be),pe.return=we,pe)}function ce(we,pe,be,et){var yt=be.type;return yt===G?Ue(we,pe,be.props.children,et,be.key):pe!==null&&(pe.elementType===yt||typeof yt=="object"&&yt!==null&&yt.$$typeof===z&&ey(yt)===pe.type)?(et=y(pe,be.props),et.ref=Sl(we,pe,be),et.return=we,et):(et=Mu(be.type,be.key,be.props,null,we.mode,et),et.ref=Sl(we,pe,be),et.return=we,et)}function Ee(we,pe,be,et){return pe===null||pe.tag!==4||pe.stateNode.containerInfo!==be.containerInfo||pe.stateNode.implementation!==be.implementation?(pe=Of(be,we.mode,et),pe.return=we,pe):(pe=y(pe,be.children||[]),pe.return=we,pe)}function Ue(we,pe,be,et,yt){return pe===null||pe.tag!==7?(pe=To(be,we.mode,et,yt),pe.return=we,pe):(pe=y(pe,be),pe.return=we,pe)}function Ye(we,pe,be){if(typeof pe=="string"&&pe!==""||typeof pe=="number")return pe=Df(""+pe,we.mode,be),pe.return=we,pe;if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case F:return be=Mu(pe.type,pe.key,pe.props,null,we.mode,be),be.ref=Sl(we,null,pe),be.return=we,be;case $:return pe=Of(pe,we.mode,be),pe.return=we,pe;case z:var et=pe._init;return Ye(we,et(pe._payload),be)}if(Le(pe)||N(pe))return pe=To(pe,we.mode,be,null),pe.return=we,pe;lu(we,pe)}return null}function Fe(we,pe,be,et){var yt=pe!==null?pe.key:null;if(typeof be=="string"&&be!==""||typeof be=="number")return yt!==null?null:ee(we,pe,""+be,et);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case F:return be.key===yt?ce(we,pe,be,et):null;case $:return be.key===yt?Ee(we,pe,be,et):null;case z:return yt=be._init,Fe(we,pe,yt(be._payload),et)}if(Le(be)||N(be))return yt!==null?null:Ue(we,pe,be,et,null);lu(we,be)}return null}function lt(we,pe,be,et,yt){if(typeof et=="string"&&et!==""||typeof et=="number")return we=we.get(be)||null,ee(pe,we,""+et,yt);if(typeof et=="object"&&et!==null){switch(et.$$typeof){case F:return we=we.get(et.key===null?be:et.key)||null,ce(pe,we,et,yt);case $:return we=we.get(et.key===null?be:et.key)||null,Ee(pe,we,et,yt);case z:var kt=et._init;return lt(we,pe,be,kt(et._payload),yt)}if(Le(et)||N(et))return we=we.get(be)||null,Ue(pe,we,et,yt,null);lu(pe,et)}return null}function mt(we,pe,be,et){for(var yt=null,kt=null,Ct=pe,jt=pe=0,Jn=null;Ct!==null&&jt<be.length;jt++){Ct.index>jt?(Jn=Ct,Ct=null):Jn=Ct.sibling;var Xt=Fe(we,Ct,be[jt],et);if(Xt===null){Ct===null&&(Ct=Jn);break}r&&Ct&&Xt.alternate===null&&o(we,Ct),pe=C(Xt,pe,jt),kt===null?yt=Xt:kt.sibling=Xt,kt=Xt,Ct=Jn}if(jt===be.length)return d(we,Ct),vn&&Co(we,jt),yt;if(Ct===null){for(;jt<be.length;jt++)Ct=Ye(we,be[jt],et),Ct!==null&&(pe=C(Ct,pe,jt),kt===null?yt=Ct:kt.sibling=Ct,kt=Ct);return vn&&Co(we,jt),yt}for(Ct=m(we,Ct);jt<be.length;jt++)Jn=lt(Ct,we,jt,be[jt],et),Jn!==null&&(r&&Jn.alternate!==null&&Ct.delete(Jn.key===null?jt:Jn.key),pe=C(Jn,pe,jt),kt===null?yt=Jn:kt.sibling=Jn,kt=Jn);return r&&Ct.forEach(function(Vr){return o(we,Vr)}),vn&&Co(we,jt),yt}function _t(we,pe,be,et){var yt=N(be);if(typeof yt!="function")throw Error(n(150));if(be=yt.call(be),be==null)throw Error(n(151));for(var kt=yt=null,Ct=pe,jt=pe=0,Jn=null,Xt=be.next();Ct!==null&&!Xt.done;jt++,Xt=be.next()){Ct.index>jt?(Jn=Ct,Ct=null):Jn=Ct.sibling;var Vr=Fe(we,Ct,Xt.value,et);if(Vr===null){Ct===null&&(Ct=Jn);break}r&&Ct&&Vr.alternate===null&&o(we,Ct),pe=C(Vr,pe,jt),kt===null?yt=Vr:kt.sibling=Vr,kt=Vr,Ct=Jn}if(Xt.done)return d(we,Ct),vn&&Co(we,jt),yt;if(Ct===null){for(;!Xt.done;jt++,Xt=be.next())Xt=Ye(we,Xt.value,et),Xt!==null&&(pe=C(Xt,pe,jt),kt===null?yt=Xt:kt.sibling=Xt,kt=Xt);return vn&&Co(we,jt),yt}for(Ct=m(we,Ct);!Xt.done;jt++,Xt=be.next())Xt=lt(Ct,we,jt,Xt.value,et),Xt!==null&&(r&&Xt.alternate!==null&&Ct.delete(Xt.key===null?jt:Xt.key),pe=C(Xt,pe,jt),kt===null?yt=Xt:kt.sibling=Xt,kt=Xt);return r&&Ct.forEach(function(oN){return o(we,oN)}),vn&&Co(we,jt),yt}function Mn(we,pe,be,et){if(typeof be=="object"&&be!==null&&be.type===G&&be.key===null&&(be=be.props.children),typeof be=="object"&&be!==null){switch(be.$$typeof){case F:e:{for(var yt=be.key,kt=pe;kt!==null;){if(kt.key===yt){if(yt=be.type,yt===G){if(kt.tag===7){d(we,kt.sibling),pe=y(kt,be.props.children),pe.return=we,we=pe;break e}}else if(kt.elementType===yt||typeof yt=="object"&&yt!==null&&yt.$$typeof===z&&ey(yt)===kt.type){d(we,kt.sibling),pe=y(kt,be.props),pe.ref=Sl(we,kt,be),pe.return=we,we=pe;break e}d(we,kt);break}else o(we,kt);kt=kt.sibling}be.type===G?(pe=To(be.props.children,we.mode,et,be.key),pe.return=we,we=pe):(et=Mu(be.type,be.key,be.props,null,we.mode,et),et.ref=Sl(we,pe,be),et.return=we,we=et)}return B(we);case $:e:{for(kt=be.key;pe!==null;){if(pe.key===kt)if(pe.tag===4&&pe.stateNode.containerInfo===be.containerInfo&&pe.stateNode.implementation===be.implementation){d(we,pe.sibling),pe=y(pe,be.children||[]),pe.return=we,we=pe;break e}else{d(we,pe);break}else o(we,pe);pe=pe.sibling}pe=Of(be,we.mode,et),pe.return=we,we=pe}return B(we);case z:return kt=be._init,Mn(we,pe,kt(be._payload),et)}if(Le(be))return mt(we,pe,be,et);if(N(be))return _t(we,pe,be,et);lu(we,be)}return typeof be=="string"&&be!==""||typeof be=="number"?(be=""+be,pe!==null&&pe.tag===6?(d(we,pe.sibling),pe=y(pe,be),pe.return=we,we=pe):(d(we,pe),pe=Df(be,we.mode,et),pe.return=we,we=pe),B(we)):d(we,pe)}return Mn}var va=ty(!0),ny=ty(!1),cu=Dr(null),uu=null,_a=null,qh=null;function Kh(){qh=_a=uu=null}function Vh(r){var o=cu.current;dn(cu),r._currentValue=o}function Yh(r,o,d){for(;r!==null;){var m=r.alternate;if((r.childLanes&o)!==o?(r.childLanes|=o,m!==null&&(m.childLanes|=o)):m!==null&&(m.childLanes&o)!==o&&(m.childLanes|=o),r===d)break;r=r.return}}function ya(r,o){uu=r,qh=_a=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&o)!==0&&(Bs=!0),r.firstContext=null)}function li(r){var o=r._currentValue;if(qh!==r)if(r={context:r,memoizedValue:o,next:null},_a===null){if(uu===null)throw Error(n(308));_a=r,uu.dependencies={lanes:0,firstContext:r}}else _a=_a.next=r;return o}var Eo=null;function Gh(r){Eo===null?Eo=[r]:Eo.push(r)}function sy(r,o,d,m){var y=o.interleaved;return y===null?(d.next=d,Gh(o)):(d.next=y.next,y.next=d),o.interleaved=d,dr(r,m)}function dr(r,o){r.lanes|=o;var d=r.alternate;for(d!==null&&(d.lanes|=o),d=r,r=r.return;r!==null;)r.childLanes|=o,d=r.alternate,d!==null&&(d.childLanes|=o),d=r,r=r.return;return d.tag===3?d.stateNode:null}var $r=!1;function Xh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function iy(r,o){r=r.updateQueue,o.updateQueue===r&&(o.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,effects:r.effects})}function hr(r,o){return{eventTime:r,lane:o,tag:0,payload:null,callback:null,next:null}}function zr(r,o,d){var m=r.updateQueue;if(m===null)return null;if(m=m.shared,(Vt&2)!==0){var y=m.pending;return y===null?o.next=o:(o.next=y.next,y.next=o),m.pending=o,dr(r,d)}return y=m.interleaved,y===null?(o.next=o,Gh(m)):(o.next=y.next,y.next=o),m.interleaved=o,dr(r,d)}function du(r,o,d){if(o=o.updateQueue,o!==null&&(o=o.shared,(d&4194240)!==0)){var m=o.lanes;m&=r.pendingLanes,d|=m,o.lanes=d,rr(r,d)}}function ry(r,o){var d=r.updateQueue,m=r.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var y=null,C=null;if(d=d.firstBaseUpdate,d!==null){do{var B={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};C===null?y=C=B:C=C.next=B,d=d.next}while(d!==null);C===null?y=C=o:C=C.next=o}else y=C=o;d={baseState:m.baseState,firstBaseUpdate:y,lastBaseUpdate:C,shared:m.shared,effects:m.effects},r.updateQueue=d;return}r=d.lastBaseUpdate,r===null?d.firstBaseUpdate=o:r.next=o,d.lastBaseUpdate=o}function hu(r,o,d,m){var y=r.updateQueue;$r=!1;var C=y.firstBaseUpdate,B=y.lastBaseUpdate,ee=y.shared.pending;if(ee!==null){y.shared.pending=null;var ce=ee,Ee=ce.next;ce.next=null,B===null?C=Ee:B.next=Ee,B=ce;var Ue=r.alternate;Ue!==null&&(Ue=Ue.updateQueue,ee=Ue.lastBaseUpdate,ee!==B&&(ee===null?Ue.firstBaseUpdate=Ee:ee.next=Ee,Ue.lastBaseUpdate=ce))}if(C!==null){var Ye=y.baseState;B=0,Ue=Ee=ce=null,ee=C;do{var Fe=ee.lane,lt=ee.eventTime;if((m&Fe)===Fe){Ue!==null&&(Ue=Ue.next={eventTime:lt,lane:0,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null});e:{var mt=r,_t=ee;switch(Fe=o,lt=d,_t.tag){case 1:if(mt=_t.payload,typeof mt=="function"){Ye=mt.call(lt,Ye,Fe);break e}Ye=mt;break e;case 3:mt.flags=mt.flags&-65537|128;case 0:if(mt=_t.payload,Fe=typeof mt=="function"?mt.call(lt,Ye,Fe):mt,Fe==null)break e;Ye=U({},Ye,Fe);break e;case 2:$r=!0}}ee.callback!==null&&ee.lane!==0&&(r.flags|=64,Fe=y.effects,Fe===null?y.effects=[ee]:Fe.push(ee))}else lt={eventTime:lt,lane:Fe,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},Ue===null?(Ee=Ue=lt,ce=Ye):Ue=Ue.next=lt,B|=Fe;if(ee=ee.next,ee===null){if(ee=y.shared.pending,ee===null)break;Fe=ee,ee=Fe.next,Fe.next=null,y.lastBaseUpdate=Fe,y.shared.pending=null}}while(!0);if(Ue===null&&(ce=Ye),y.baseState=ce,y.firstBaseUpdate=Ee,y.lastBaseUpdate=Ue,o=y.shared.interleaved,o!==null){y=o;do B|=y.lane,y=y.next;while(y!==o)}else C===null&&(y.shared.lanes=0);Lo|=B,r.lanes=B,r.memoizedState=Ye}}function oy(r,o,d){if(r=o.effects,o.effects=null,r!==null)for(o=0;o<r.length;o++){var m=r[o],y=m.callback;if(y!==null){if(m.callback=null,m=d,typeof y!="function")throw Error(n(191,y));y.call(m)}}}var xl={},zi=Dr(xl),kl=Dr(xl),Cl=Dr(xl);function No(r){if(r===xl)throw Error(n(174));return r}function Jh(r,o){switch(an(Cl,o),an(kl,r),an(zi,xl),r=o.nodeType,r){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:De(null,"");break;default:r=r===8?o.parentNode:o,o=r.namespaceURI||null,r=r.tagName,o=De(o,r)}dn(zi),an(zi,o)}function wa(){dn(zi),dn(kl),dn(Cl)}function ay(r){No(Cl.current);var o=No(zi.current),d=De(o,r.type);o!==d&&(an(kl,r),an(zi,d))}function Qh(r){kl.current===r&&(dn(zi),dn(kl))}var xn=Dr(0);function fu(r){for(var o=r;o!==null;){if(o.tag===13){var d=o.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return o}else if(o.tag===19&&o.memoizedProps.revealOrder!==void 0){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Zh=[];function ef(){for(var r=0;r<Zh.length;r++)Zh[r]._workInProgressVersionPrimary=null;Zh.length=0}var pu=E.ReactCurrentDispatcher,tf=E.ReactCurrentBatchConfig,Ro=0,kn=null,Fn=null,Gn=null,mu=!1,El=!1,Nl=0,R2=0;function bs(){throw Error(n(321))}function nf(r,o){if(o===null)return!1;for(var d=0;d<o.length&&d<r.length;d++)if(!Ni(r[d],o[d]))return!1;return!0}function sf(r,o,d,m,y,C){if(Ro=C,kn=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,pu.current=r===null||r.memoizedState===null?M2:T2,r=d(m,y),El){C=0;do{if(El=!1,Nl=0,25<=C)throw Error(n(301));C+=1,Gn=Fn=null,o.updateQueue=null,pu.current=P2,r=d(m,y)}while(El)}if(pu.current=_u,o=Fn!==null&&Fn.next!==null,Ro=0,Gn=Fn=kn=null,mu=!1,o)throw Error(n(300));return r}function rf(){var r=Nl!==0;return Nl=0,r}function Fi(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Gn===null?kn.memoizedState=Gn=r:Gn=Gn.next=r,Gn}function ci(){if(Fn===null){var r=kn.alternate;r=r!==null?r.memoizedState:null}else r=Fn.next;var o=Gn===null?kn.memoizedState:Gn.next;if(o!==null)Gn=o,Fn=r;else{if(r===null)throw Error(n(310));Fn=r,r={memoizedState:Fn.memoizedState,baseState:Fn.baseState,baseQueue:Fn.baseQueue,queue:Fn.queue,next:null},Gn===null?kn.memoizedState=Gn=r:Gn=Gn.next=r}return Gn}function Rl(r,o){return typeof o=="function"?o(r):o}function of(r){var o=ci(),d=o.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=r;var m=Fn,y=m.baseQueue,C=d.pending;if(C!==null){if(y!==null){var B=y.next;y.next=C.next,C.next=B}m.baseQueue=y=C,d.pending=null}if(y!==null){C=y.next,m=m.baseState;var ee=B=null,ce=null,Ee=C;do{var Ue=Ee.lane;if((Ro&Ue)===Ue)ce!==null&&(ce=ce.next={lane:0,action:Ee.action,hasEagerState:Ee.hasEagerState,eagerState:Ee.eagerState,next:null}),m=Ee.hasEagerState?Ee.eagerState:r(m,Ee.action);else{var Ye={lane:Ue,action:Ee.action,hasEagerState:Ee.hasEagerState,eagerState:Ee.eagerState,next:null};ce===null?(ee=ce=Ye,B=m):ce=ce.next=Ye,kn.lanes|=Ue,Lo|=Ue}Ee=Ee.next}while(Ee!==null&&Ee!==C);ce===null?B=m:ce.next=ee,Ni(m,o.memoizedState)||(Bs=!0),o.memoizedState=m,o.baseState=B,o.baseQueue=ce,d.lastRenderedState=m}if(r=d.interleaved,r!==null){y=r;do C=y.lane,kn.lanes|=C,Lo|=C,y=y.next;while(y!==r)}else y===null&&(d.lanes=0);return[o.memoizedState,d.dispatch]}function af(r){var o=ci(),d=o.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=r;var m=d.dispatch,y=d.pending,C=o.memoizedState;if(y!==null){d.pending=null;var B=y=y.next;do C=r(C,B.action),B=B.next;while(B!==y);Ni(C,o.memoizedState)||(Bs=!0),o.memoizedState=C,o.baseQueue===null&&(o.baseState=C),d.lastRenderedState=C}return[C,m]}function ly(){}function cy(r,o){var d=kn,m=ci(),y=o(),C=!Ni(m.memoizedState,y);if(C&&(m.memoizedState=y,Bs=!0),m=m.queue,lf(hy.bind(null,d,m,r),[r]),m.getSnapshot!==o||C||Gn!==null&&Gn.memoizedState.tag&1){if(d.flags|=2048,Ll(9,dy.bind(null,d,m,y,o),void 0,null),Xn===null)throw Error(n(349));(Ro&30)!==0||uy(d,o,y)}return y}function uy(r,o,d){r.flags|=16384,r={getSnapshot:o,value:d},o=kn.updateQueue,o===null?(o={lastEffect:null,stores:null},kn.updateQueue=o,o.stores=[r]):(d=o.stores,d===null?o.stores=[r]:d.push(r))}function dy(r,o,d,m){o.value=d,o.getSnapshot=m,fy(o)&&py(r)}function hy(r,o,d){return d(function(){fy(o)&&py(r)})}function fy(r){var o=r.getSnapshot;r=r.value;try{var d=o();return!Ni(r,d)}catch{return!0}}function py(r){var o=dr(r,1);o!==null&&Mi(o,r,1,-1)}function my(r){var o=Fi();return typeof r=="function"&&(r=r()),o.memoizedState=o.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Rl,lastRenderedState:r},o.queue=r,r=r.dispatch=j2.bind(null,kn,r),[o.memoizedState,r]}function Ll(r,o,d,m){return r={tag:r,create:o,destroy:d,deps:m,next:null},o=kn.updateQueue,o===null?(o={lastEffect:null,stores:null},kn.updateQueue=o,o.lastEffect=r.next=r):(d=o.lastEffect,d===null?o.lastEffect=r.next=r:(m=d.next,d.next=r,r.next=m,o.lastEffect=r)),r}function gy(){return ci().memoizedState}function gu(r,o,d,m){var y=Fi();kn.flags|=r,y.memoizedState=Ll(1|o,d,void 0,m===void 0?null:m)}function vu(r,o,d,m){var y=ci();m=m===void 0?null:m;var C=void 0;if(Fn!==null){var B=Fn.memoizedState;if(C=B.destroy,m!==null&&nf(m,B.deps)){y.memoizedState=Ll(o,d,C,m);return}}kn.flags|=r,y.memoizedState=Ll(1|o,d,C,m)}function vy(r,o){return gu(8390656,8,r,o)}function lf(r,o){return vu(2048,8,r,o)}function _y(r,o){return vu(4,2,r,o)}function yy(r,o){return vu(4,4,r,o)}function wy(r,o){if(typeof o=="function")return r=r(),o(r),function(){o(null)};if(o!=null)return r=r(),o.current=r,function(){o.current=null}}function by(r,o,d){return d=d!=null?d.concat([r]):null,vu(4,4,wy.bind(null,o,r),d)}function cf(){}function Sy(r,o){var d=ci();o=o===void 0?null:o;var m=d.memoizedState;return m!==null&&o!==null&&nf(o,m[1])?m[0]:(d.memoizedState=[r,o],r)}function xy(r,o){var d=ci();o=o===void 0?null:o;var m=d.memoizedState;return m!==null&&o!==null&&nf(o,m[1])?m[0]:(r=r(),d.memoizedState=[r,o],r)}function ky(r,o,d){return(Ro&21)===0?(r.baseState&&(r.baseState=!1,Bs=!0),r.memoizedState=d):(Ni(d,o)||(d=nn(),kn.lanes|=d,Lo|=d,r.baseState=!0),o)}function L2(r,o){var d=Gt;Gt=d!==0&&4>d?d:4,r(!0);var m=tf.transition;tf.transition={};try{r(!1),o()}finally{Gt=d,tf.transition=m}}function Cy(){return ci().memoizedState}function A2(r,o,d){var m=Wr(r);if(d={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null},Ey(r))Ny(o,d);else if(d=sy(r,o,d,m),d!==null){var y=Rs();Mi(d,r,m,y),Ry(d,o,m)}}function j2(r,o,d){var m=Wr(r),y={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null};if(Ey(r))Ny(o,y);else{var C=r.alternate;if(r.lanes===0&&(C===null||C.lanes===0)&&(C=o.lastRenderedReducer,C!==null))try{var B=o.lastRenderedState,ee=C(B,d);if(y.hasEagerState=!0,y.eagerState=ee,Ni(ee,B)){var ce=o.interleaved;ce===null?(y.next=y,Gh(o)):(y.next=ce.next,ce.next=y),o.interleaved=y;return}}catch{}finally{}d=sy(r,o,y,m),d!==null&&(y=Rs(),Mi(d,r,m,y),Ry(d,o,m))}}function Ey(r){var o=r.alternate;return r===kn||o!==null&&o===kn}function Ny(r,o){El=mu=!0;var d=r.pending;d===null?o.next=o:(o.next=d.next,d.next=o),r.pending=o}function Ry(r,o,d){if((d&4194240)!==0){var m=o.lanes;m&=r.pendingLanes,d|=m,o.lanes=d,rr(r,d)}}var _u={readContext:li,useCallback:bs,useContext:bs,useEffect:bs,useImperativeHandle:bs,useInsertionEffect:bs,useLayoutEffect:bs,useMemo:bs,useReducer:bs,useRef:bs,useState:bs,useDebugValue:bs,useDeferredValue:bs,useTransition:bs,useMutableSource:bs,useSyncExternalStore:bs,useId:bs,unstable_isNewReconciler:!1},M2={readContext:li,useCallback:function(r,o){return Fi().memoizedState=[r,o===void 0?null:o],r},useContext:li,useEffect:vy,useImperativeHandle:function(r,o,d){return d=d!=null?d.concat([r]):null,gu(4194308,4,wy.bind(null,o,r),d)},useLayoutEffect:function(r,o){return gu(4194308,4,r,o)},useInsertionEffect:function(r,o){return gu(4,2,r,o)},useMemo:function(r,o){var d=Fi();return o=o===void 0?null:o,r=r(),d.memoizedState=[r,o],r},useReducer:function(r,o,d){var m=Fi();return o=d!==void 0?d(o):o,m.memoizedState=m.baseState=o,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:o},m.queue=r,r=r.dispatch=A2.bind(null,kn,r),[m.memoizedState,r]},useRef:function(r){var o=Fi();return r={current:r},o.memoizedState=r},useState:my,useDebugValue:cf,useDeferredValue:function(r){return Fi().memoizedState=r},useTransition:function(){var r=my(!1),o=r[0];return r=L2.bind(null,r[1]),Fi().memoizedState=r,[o,r]},useMutableSource:function(){},useSyncExternalStore:function(r,o,d){var m=kn,y=Fi();if(vn){if(d===void 0)throw Error(n(407));d=d()}else{if(d=o(),Xn===null)throw Error(n(349));(Ro&30)!==0||uy(m,o,d)}y.memoizedState=d;var C={value:d,getSnapshot:o};return y.queue=C,vy(hy.bind(null,m,C,r),[r]),m.flags|=2048,Ll(9,dy.bind(null,m,C,d,o),void 0,null),d},useId:function(){var r=Fi(),o=Xn.identifierPrefix;if(vn){var d=ur,m=cr;d=(m&~(1<<32-ze(m)-1)).toString(32)+d,o=":"+o+"R"+d,d=Nl++,0<d&&(o+="H"+d.toString(32)),o+=":"}else d=R2++,o=":"+o+"r"+d.toString(32)+":";return r.memoizedState=o},unstable_isNewReconciler:!1},T2={readContext:li,useCallback:Sy,useContext:li,useEffect:lf,useImperativeHandle:by,useInsertionEffect:_y,useLayoutEffect:yy,useMemo:xy,useReducer:of,useRef:gy,useState:function(){return of(Rl)},useDebugValue:cf,useDeferredValue:function(r){var o=ci();return ky(o,Fn.memoizedState,r)},useTransition:function(){var r=of(Rl)[0],o=ci().memoizedState;return[r,o]},useMutableSource:ly,useSyncExternalStore:cy,useId:Cy,unstable_isNewReconciler:!1},P2={readContext:li,useCallback:Sy,useContext:li,useEffect:lf,useImperativeHandle:by,useInsertionEffect:_y,useLayoutEffect:yy,useMemo:xy,useReducer:af,useRef:gy,useState:function(){return af(Rl)},useDebugValue:cf,useDeferredValue:function(r){var o=ci();return Fn===null?o.memoizedState=r:ky(o,Fn.memoizedState,r)},useTransition:function(){var r=af(Rl)[0],o=ci().memoizedState;return[r,o]},useMutableSource:ly,useSyncExternalStore:cy,useId:Cy,unstable_isNewReconciler:!1};function Li(r,o){if(r&&r.defaultProps){o=U({},o),r=r.defaultProps;for(var d in r)o[d]===void 0&&(o[d]=r[d]);return o}return o}function uf(r,o,d,m){o=r.memoizedState,d=d(m,o),d=d==null?o:U({},o,d),r.memoizedState=d,r.lanes===0&&(r.updateQueue.baseState=d)}var yu={isMounted:function(r){return(r=r._reactInternals)?gn(r)===r:!1},enqueueSetState:function(r,o,d){r=r._reactInternals;var m=Rs(),y=Wr(r),C=hr(m,y);C.payload=o,d!=null&&(C.callback=d),o=zr(r,C,y),o!==null&&(Mi(o,r,y,m),du(o,r,y))},enqueueReplaceState:function(r,o,d){r=r._reactInternals;var m=Rs(),y=Wr(r),C=hr(m,y);C.tag=1,C.payload=o,d!=null&&(C.callback=d),o=zr(r,C,y),o!==null&&(Mi(o,r,y,m),du(o,r,y))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var d=Rs(),m=Wr(r),y=hr(d,m);y.tag=2,o!=null&&(y.callback=o),o=zr(r,y,m),o!==null&&(Mi(o,r,m,d),du(o,r,m))}};function Ly(r,o,d,m,y,C,B){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(m,C,B):o.prototype&&o.prototype.isPureReactComponent?!ml(d,m)||!ml(y,C):!0}function Ay(r,o,d){var m=!1,y=Or,C=o.contextType;return typeof C=="object"&&C!==null?C=li(C):(y=Os(o)?xo:ws.current,m=o.contextTypes,C=(m=m!=null)?fa(r,y):Or),o=new o(d,C),r.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=yu,r.stateNode=o,o._reactInternals=r,m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=y,r.__reactInternalMemoizedMaskedChildContext=C),o}function jy(r,o,d,m){r=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(d,m),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(d,m),o.state!==r&&yu.enqueueReplaceState(o,o.state,null)}function df(r,o,d,m){var y=r.stateNode;y.props=d,y.state=r.memoizedState,y.refs={},Xh(r);var C=o.contextType;typeof C=="object"&&C!==null?y.context=li(C):(C=Os(o)?xo:ws.current,y.context=fa(r,C)),y.state=r.memoizedState,C=o.getDerivedStateFromProps,typeof C=="function"&&(uf(r,o,C,d),y.state=r.memoizedState),typeof o.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(o=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),o!==y.state&&yu.enqueueReplaceState(y,y.state,null),hu(r,d,y,m),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308)}function ba(r,o){try{var d="",m=o;do d+=Q(m),m=m.return;while(m);var y=d}catch(C){y=`
|
|
39
|
-
Error generating stack: `+C.message+`
|
|
40
|
-
`+C.stack}return{value:r,source:o,stack:y,digest:null}}function hf(r,o,d){return{value:r,source:null,stack:d??null,digest:o??null}}function ff(r,o){try{console.error(o.value)}catch(d){setTimeout(function(){throw d})}}var I2=typeof WeakMap=="function"?WeakMap:Map;function My(r,o,d){d=hr(-1,d),d.tag=3,d.payload={element:null};var m=o.value;return d.callback=function(){Eu||(Eu=!0,Rf=m),ff(r,o)},d}function Ty(r,o,d){d=hr(-1,d),d.tag=3;var m=r.type.getDerivedStateFromError;if(typeof m=="function"){var y=o.value;d.payload=function(){return m(y)},d.callback=function(){ff(r,o)}}var C=r.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(d.callback=function(){ff(r,o),typeof m!="function"&&(Hr===null?Hr=new Set([this]):Hr.add(this));var B=o.stack;this.componentDidCatch(o.value,{componentStack:B!==null?B:""})}),d}function Py(r,o,d){var m=r.pingCache;if(m===null){m=r.pingCache=new I2;var y=new Set;m.set(o,y)}else y=m.get(o),y===void 0&&(y=new Set,m.set(o,y));y.has(d)||(y.add(d),r=G2.bind(null,r,o,d),o.then(r,r))}function Iy(r){do{var o;if((o=r.tag===13)&&(o=r.memoizedState,o=o!==null?o.dehydrated!==null:!0),o)return r;r=r.return}while(r!==null);return null}function Dy(r,o,d,m,y){return(r.mode&1)===0?(r===o?r.flags|=65536:(r.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(o=hr(-1,1),o.tag=2,zr(d,o,1))),d.lanes|=1),r):(r.flags|=65536,r.lanes=y,r)}var D2=E.ReactCurrentOwner,Bs=!1;function Ns(r,o,d,m){o.child=r===null?ny(o,null,d,m):va(o,r.child,d,m)}function Oy(r,o,d,m,y){d=d.render;var C=o.ref;return ya(o,y),m=sf(r,o,d,m,C,y),d=rf(),r!==null&&!Bs?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~y,fr(r,o,y)):(vn&&d&&zh(o),o.flags|=1,Ns(r,o,m,y),o.child)}function By(r,o,d,m,y){if(r===null){var C=d.type;return typeof C=="function"&&!If(C)&&C.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(o.tag=15,o.type=C,$y(r,o,C,m,y)):(r=Mu(d.type,null,m,o,o.mode,y),r.ref=o.ref,r.return=o,o.child=r)}if(C=r.child,(r.lanes&y)===0){var B=C.memoizedProps;if(d=d.compare,d=d!==null?d:ml,d(B,m)&&r.ref===o.ref)return fr(r,o,y)}return o.flags|=1,r=Kr(C,m),r.ref=o.ref,r.return=o,o.child=r}function $y(r,o,d,m,y){if(r!==null){var C=r.memoizedProps;if(ml(C,m)&&r.ref===o.ref)if(Bs=!1,o.pendingProps=m=C,(r.lanes&y)!==0)(r.flags&131072)!==0&&(Bs=!0);else return o.lanes=r.lanes,fr(r,o,y)}return pf(r,o,d,m,y)}function zy(r,o,d){var m=o.pendingProps,y=m.children,C=r!==null?r.memoizedState:null;if(m.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},an(xa,Qs),Qs|=d;else{if((d&1073741824)===0)return r=C!==null?C.baseLanes|d:d,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:r,cachePool:null,transitions:null},o.updateQueue=null,an(xa,Qs),Qs|=r,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=C!==null?C.baseLanes:d,an(xa,Qs),Qs|=m}else C!==null?(m=C.baseLanes|d,o.memoizedState=null):m=d,an(xa,Qs),Qs|=m;return Ns(r,o,y,d),o.child}function Fy(r,o){var d=o.ref;(r===null&&d!==null||r!==null&&r.ref!==d)&&(o.flags|=512,o.flags|=2097152)}function pf(r,o,d,m,y){var C=Os(d)?xo:ws.current;return C=fa(o,C),ya(o,y),d=sf(r,o,d,m,C,y),m=rf(),r!==null&&!Bs?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~y,fr(r,o,y)):(vn&&m&&zh(o),o.flags|=1,Ns(r,o,d,y),o.child)}function Hy(r,o,d,m,y){if(Os(d)){var C=!0;su(o)}else C=!1;if(ya(o,y),o.stateNode===null)bu(r,o),Ay(o,d,m),df(o,d,m,y),m=!0;else if(r===null){var B=o.stateNode,ee=o.memoizedProps;B.props=ee;var ce=B.context,Ee=d.contextType;typeof Ee=="object"&&Ee!==null?Ee=li(Ee):(Ee=Os(d)?xo:ws.current,Ee=fa(o,Ee));var Ue=d.getDerivedStateFromProps,Ye=typeof Ue=="function"||typeof B.getSnapshotBeforeUpdate=="function";Ye||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(ee!==m||ce!==Ee)&&jy(o,B,m,Ee),$r=!1;var Fe=o.memoizedState;B.state=Fe,hu(o,m,B,y),ce=o.memoizedState,ee!==m||Fe!==ce||Ds.current||$r?(typeof Ue=="function"&&(uf(o,d,Ue,m),ce=o.memoizedState),(ee=$r||Ly(o,d,ee,m,Fe,ce,Ee))?(Ye||typeof B.UNSAFE_componentWillMount!="function"&&typeof B.componentWillMount!="function"||(typeof B.componentWillMount=="function"&&B.componentWillMount(),typeof B.UNSAFE_componentWillMount=="function"&&B.UNSAFE_componentWillMount()),typeof B.componentDidMount=="function"&&(o.flags|=4194308)):(typeof B.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=m,o.memoizedState=ce),B.props=m,B.state=ce,B.context=Ee,m=ee):(typeof B.componentDidMount=="function"&&(o.flags|=4194308),m=!1)}else{B=o.stateNode,iy(r,o),ee=o.memoizedProps,Ee=o.type===o.elementType?ee:Li(o.type,ee),B.props=Ee,Ye=o.pendingProps,Fe=B.context,ce=d.contextType,typeof ce=="object"&&ce!==null?ce=li(ce):(ce=Os(d)?xo:ws.current,ce=fa(o,ce));var lt=d.getDerivedStateFromProps;(Ue=typeof lt=="function"||typeof B.getSnapshotBeforeUpdate=="function")||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(ee!==Ye||Fe!==ce)&&jy(o,B,m,ce),$r=!1,Fe=o.memoizedState,B.state=Fe,hu(o,m,B,y);var mt=o.memoizedState;ee!==Ye||Fe!==mt||Ds.current||$r?(typeof lt=="function"&&(uf(o,d,lt,m),mt=o.memoizedState),(Ee=$r||Ly(o,d,Ee,m,Fe,mt,ce)||!1)?(Ue||typeof B.UNSAFE_componentWillUpdate!="function"&&typeof B.componentWillUpdate!="function"||(typeof B.componentWillUpdate=="function"&&B.componentWillUpdate(m,mt,ce),typeof B.UNSAFE_componentWillUpdate=="function"&&B.UNSAFE_componentWillUpdate(m,mt,ce)),typeof B.componentDidUpdate=="function"&&(o.flags|=4),typeof B.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof B.componentDidUpdate!="function"||ee===r.memoizedProps&&Fe===r.memoizedState||(o.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||ee===r.memoizedProps&&Fe===r.memoizedState||(o.flags|=1024),o.memoizedProps=m,o.memoizedState=mt),B.props=m,B.state=mt,B.context=ce,m=Ee):(typeof B.componentDidUpdate!="function"||ee===r.memoizedProps&&Fe===r.memoizedState||(o.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||ee===r.memoizedProps&&Fe===r.memoizedState||(o.flags|=1024),m=!1)}return mf(r,o,d,m,C,y)}function mf(r,o,d,m,y,C){Fy(r,o);var B=(o.flags&128)!==0;if(!m&&!B)return y&&V_(o,d,!1),fr(r,o,C);m=o.stateNode,D2.current=o;var ee=B&&typeof d.getDerivedStateFromError!="function"?null:m.render();return o.flags|=1,r!==null&&B?(o.child=va(o,r.child,null,C),o.child=va(o,null,ee,C)):Ns(r,o,ee,C),o.memoizedState=m.state,y&&V_(o,d,!0),o.child}function Uy(r){var o=r.stateNode;o.pendingContext?q_(r,o.pendingContext,o.pendingContext!==o.context):o.context&&q_(r,o.context,!1),Jh(r,o.containerInfo)}function Wy(r,o,d,m,y){return ga(),Wh(y),o.flags|=256,Ns(r,o,d,m),o.child}var gf={dehydrated:null,treeContext:null,retryLane:0};function vf(r){return{baseLanes:r,cachePool:null,transitions:null}}function qy(r,o,d){var m=o.pendingProps,y=xn.current,C=!1,B=(o.flags&128)!==0,ee;if((ee=B)||(ee=r!==null&&r.memoizedState===null?!1:(y&2)!==0),ee?(C=!0,o.flags&=-129):(r===null||r.memoizedState!==null)&&(y|=1),an(xn,y&1),r===null)return Uh(o),r=o.memoizedState,r!==null&&(r=r.dehydrated,r!==null)?((o.mode&1)===0?o.lanes=1:r.data==="$!"?o.lanes=8:o.lanes=1073741824,null):(B=m.children,r=m.fallback,C?(m=o.mode,C=o.child,B={mode:"hidden",children:B},(m&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=B):C=Tu(B,m,0,null),r=To(r,m,d,null),C.return=o,r.return=o,C.sibling=r,o.child=C,o.child.memoizedState=vf(d),o.memoizedState=gf,r):_f(o,B));if(y=r.memoizedState,y!==null&&(ee=y.dehydrated,ee!==null))return O2(r,o,B,m,ee,y,d);if(C){C=m.fallback,B=o.mode,y=r.child,ee=y.sibling;var ce={mode:"hidden",children:m.children};return(B&1)===0&&o.child!==y?(m=o.child,m.childLanes=0,m.pendingProps=ce,o.deletions=null):(m=Kr(y,ce),m.subtreeFlags=y.subtreeFlags&14680064),ee!==null?C=Kr(ee,C):(C=To(C,B,d,null),C.flags|=2),C.return=o,m.return=o,m.sibling=C,o.child=m,m=C,C=o.child,B=r.child.memoizedState,B=B===null?vf(d):{baseLanes:B.baseLanes|d,cachePool:null,transitions:B.transitions},C.memoizedState=B,C.childLanes=r.childLanes&~d,o.memoizedState=gf,m}return C=r.child,r=C.sibling,m=Kr(C,{mode:"visible",children:m.children}),(o.mode&1)===0&&(m.lanes=d),m.return=o,m.sibling=null,r!==null&&(d=o.deletions,d===null?(o.deletions=[r],o.flags|=16):d.push(r)),o.child=m,o.memoizedState=null,m}function _f(r,o){return o=Tu({mode:"visible",children:o},r.mode,0,null),o.return=r,r.child=o}function wu(r,o,d,m){return m!==null&&Wh(m),va(o,r.child,null,d),r=_f(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function O2(r,o,d,m,y,C,B){if(d)return o.flags&256?(o.flags&=-257,m=hf(Error(n(422))),wu(r,o,B,m)):o.memoizedState!==null?(o.child=r.child,o.flags|=128,null):(C=m.fallback,y=o.mode,m=Tu({mode:"visible",children:m.children},y,0,null),C=To(C,y,B,null),C.flags|=2,m.return=o,C.return=o,m.sibling=C,o.child=m,(o.mode&1)!==0&&va(o,r.child,null,B),o.child.memoizedState=vf(B),o.memoizedState=gf,C);if((o.mode&1)===0)return wu(r,o,B,null);if(y.data==="$!"){if(m=y.nextSibling&&y.nextSibling.dataset,m)var ee=m.dgst;return m=ee,C=Error(n(419)),m=hf(C,m,void 0),wu(r,o,B,m)}if(ee=(B&r.childLanes)!==0,Bs||ee){if(m=Xn,m!==null){switch(B&-B){case 4:y=2;break;case 16:y=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:y=32;break;case 536870912:y=268435456;break;default:y=0}y=(y&(m.suspendedLanes|B))!==0?0:y,y!==0&&y!==C.retryLane&&(C.retryLane=y,dr(r,y),Mi(m,r,y,-1))}return Pf(),m=hf(Error(n(421))),wu(r,o,B,m)}return y.data==="$?"?(o.flags|=128,o.child=r.child,o=X2.bind(null,r),y._reactRetry=o,null):(r=C.treeContext,Js=Ir(y.nextSibling),Xs=o,vn=!0,Ri=null,r!==null&&(oi[ai++]=cr,oi[ai++]=ur,oi[ai++]=ko,cr=r.id,ur=r.overflow,ko=o),o=_f(o,m.children),o.flags|=4096,o)}function Ky(r,o,d){r.lanes|=o;var m=r.alternate;m!==null&&(m.lanes|=o),Yh(r.return,o,d)}function yf(r,o,d,m,y){var C=r.memoizedState;C===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:m,tail:d,tailMode:y}:(C.isBackwards=o,C.rendering=null,C.renderingStartTime=0,C.last=m,C.tail=d,C.tailMode=y)}function Vy(r,o,d){var m=o.pendingProps,y=m.revealOrder,C=m.tail;if(Ns(r,o,m.children,d),m=xn.current,(m&2)!==0)m=m&1|2,o.flags|=128;else{if(r!==null&&(r.flags&128)!==0)e:for(r=o.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Ky(r,d,o);else if(r.tag===19)Ky(r,d,o);else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===o)break e;for(;r.sibling===null;){if(r.return===null||r.return===o)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}m&=1}if(an(xn,m),(o.mode&1)===0)o.memoizedState=null;else switch(y){case"forwards":for(d=o.child,y=null;d!==null;)r=d.alternate,r!==null&&fu(r)===null&&(y=d),d=d.sibling;d=y,d===null?(y=o.child,o.child=null):(y=d.sibling,d.sibling=null),yf(o,!1,y,d,C);break;case"backwards":for(d=null,y=o.child,o.child=null;y!==null;){if(r=y.alternate,r!==null&&fu(r)===null){o.child=y;break}r=y.sibling,y.sibling=d,d=y,y=r}yf(o,!0,d,null,C);break;case"together":yf(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function bu(r,o){(o.mode&1)===0&&r!==null&&(r.alternate=null,o.alternate=null,o.flags|=2)}function fr(r,o,d){if(r!==null&&(o.dependencies=r.dependencies),Lo|=o.lanes,(d&o.childLanes)===0)return null;if(r!==null&&o.child!==r.child)throw Error(n(153));if(o.child!==null){for(r=o.child,d=Kr(r,r.pendingProps),o.child=d,d.return=o;r.sibling!==null;)r=r.sibling,d=d.sibling=Kr(r,r.pendingProps),d.return=o;d.sibling=null}return o.child}function B2(r,o,d){switch(o.tag){case 3:Uy(o),ga();break;case 5:ay(o);break;case 1:Os(o.type)&&su(o);break;case 4:Jh(o,o.stateNode.containerInfo);break;case 10:var m=o.type._context,y=o.memoizedProps.value;an(cu,m._currentValue),m._currentValue=y;break;case 13:if(m=o.memoizedState,m!==null)return m.dehydrated!==null?(an(xn,xn.current&1),o.flags|=128,null):(d&o.child.childLanes)!==0?qy(r,o,d):(an(xn,xn.current&1),r=fr(r,o,d),r!==null?r.sibling:null);an(xn,xn.current&1);break;case 19:if(m=(d&o.childLanes)!==0,(r.flags&128)!==0){if(m)return Vy(r,o,d);o.flags|=128}if(y=o.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),an(xn,xn.current),m)break;return null;case 22:case 23:return o.lanes=0,zy(r,o,d)}return fr(r,o,d)}var Yy,wf,Gy,Xy;Yy=function(r,o){for(var d=o.child;d!==null;){if(d.tag===5||d.tag===6)r.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===o)break;for(;d.sibling===null;){if(d.return===null||d.return===o)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},wf=function(){},Gy=function(r,o,d,m){var y=r.memoizedProps;if(y!==m){r=o.stateNode,No(zi.current);var C=null;switch(d){case"input":y=oe(r,y),m=oe(r,m),C=[];break;case"select":y=U({},y,{value:void 0}),m=U({},m,{value:void 0}),C=[];break;case"textarea":y=We(r,y),m=We(r,m),C=[];break;default:typeof y.onClick!="function"&&typeof m.onClick=="function"&&(r.onclick=eu)}Ze(d,m);var B;d=null;for(Ee in y)if(!m.hasOwnProperty(Ee)&&y.hasOwnProperty(Ee)&&y[Ee]!=null)if(Ee==="style"){var ee=y[Ee];for(B in ee)ee.hasOwnProperty(B)&&(d||(d={}),d[B]="")}else Ee!=="dangerouslySetInnerHTML"&&Ee!=="children"&&Ee!=="suppressContentEditableWarning"&&Ee!=="suppressHydrationWarning"&&Ee!=="autoFocus"&&(i.hasOwnProperty(Ee)?C||(C=[]):(C=C||[]).push(Ee,null));for(Ee in m){var ce=m[Ee];if(ee=y!=null?y[Ee]:void 0,m.hasOwnProperty(Ee)&&ce!==ee&&(ce!=null||ee!=null))if(Ee==="style")if(ee){for(B in ee)!ee.hasOwnProperty(B)||ce&&ce.hasOwnProperty(B)||(d||(d={}),d[B]="");for(B in ce)ce.hasOwnProperty(B)&&ee[B]!==ce[B]&&(d||(d={}),d[B]=ce[B])}else d||(C||(C=[]),C.push(Ee,d)),d=ce;else Ee==="dangerouslySetInnerHTML"?(ce=ce?ce.__html:void 0,ee=ee?ee.__html:void 0,ce!=null&&ee!==ce&&(C=C||[]).push(Ee,ce)):Ee==="children"?typeof ce!="string"&&typeof ce!="number"||(C=C||[]).push(Ee,""+ce):Ee!=="suppressContentEditableWarning"&&Ee!=="suppressHydrationWarning"&&(i.hasOwnProperty(Ee)?(ce!=null&&Ee==="onScroll"&&un("scroll",r),C||ee===ce||(C=[])):(C=C||[]).push(Ee,ce))}d&&(C=C||[]).push("style",d);var Ee=C;(o.updateQueue=Ee)&&(o.flags|=4)}},Xy=function(r,o,d,m){d!==m&&(o.flags|=4)};function Al(r,o){if(!vn)switch(r.tailMode){case"hidden":o=r.tail;for(var d=null;o!==null;)o.alternate!==null&&(d=o),o=o.sibling;d===null?r.tail=null:d.sibling=null;break;case"collapsed":d=r.tail;for(var m=null;d!==null;)d.alternate!==null&&(m=d),d=d.sibling;m===null?o||r.tail===null?r.tail=null:r.tail.sibling=null:m.sibling=null}}function Ss(r){var o=r.alternate!==null&&r.alternate.child===r.child,d=0,m=0;if(o)for(var y=r.child;y!==null;)d|=y.lanes|y.childLanes,m|=y.subtreeFlags&14680064,m|=y.flags&14680064,y.return=r,y=y.sibling;else for(y=r.child;y!==null;)d|=y.lanes|y.childLanes,m|=y.subtreeFlags,m|=y.flags,y.return=r,y=y.sibling;return r.subtreeFlags|=m,r.childLanes=d,o}function $2(r,o,d){var m=o.pendingProps;switch(Fh(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ss(o),null;case 1:return Os(o.type)&&nu(),Ss(o),null;case 3:return m=o.stateNode,wa(),dn(Ds),dn(ws),ef(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(r===null||r.child===null)&&(au(o)?o.flags|=4:r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Ri!==null&&(jf(Ri),Ri=null))),wf(r,o),Ss(o),null;case 5:Qh(o);var y=No(Cl.current);if(d=o.type,r!==null&&o.stateNode!=null)Gy(r,o,d,m,y),r.ref!==o.ref&&(o.flags|=512,o.flags|=2097152);else{if(!m){if(o.stateNode===null)throw Error(n(166));return Ss(o),null}if(r=No(zi.current),au(o)){m=o.stateNode,d=o.type;var C=o.memoizedProps;switch(m[$i]=o,m[wl]=C,r=(o.mode&1)!==0,d){case"dialog":un("cancel",m),un("close",m);break;case"iframe":case"object":case"embed":un("load",m);break;case"video":case"audio":for(y=0;y<vl.length;y++)un(vl[y],m);break;case"source":un("error",m);break;case"img":case"image":case"link":un("error",m),un("load",m);break;case"details":un("toggle",m);break;case"input":Ne(m,C),un("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!C.multiple},un("invalid",m);break;case"textarea":Re(m,C),un("invalid",m)}Ze(d,C),y=null;for(var B in C)if(C.hasOwnProperty(B)){var ee=C[B];B==="children"?typeof ee=="string"?m.textContent!==ee&&(C.suppressHydrationWarning!==!0&&Zc(m.textContent,ee,r),y=["children",ee]):typeof ee=="number"&&m.textContent!==""+ee&&(C.suppressHydrationWarning!==!0&&Zc(m.textContent,ee,r),y=["children",""+ee]):i.hasOwnProperty(B)&&ee!=null&&B==="onScroll"&&un("scroll",m)}switch(d){case"input":rt(m),V(m,C,!0);break;case"textarea":rt(m),st(m);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(m.onclick=eu)}m=y,o.updateQueue=m,m!==null&&(o.flags|=4)}else{B=y.nodeType===9?y:y.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=Xe(d)),r==="http://www.w3.org/1999/xhtml"?d==="script"?(r=B.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof m.is=="string"?r=B.createElement(d,{is:m.is}):(r=B.createElement(d),d==="select"&&(B=r,m.multiple?B.multiple=!0:m.size&&(B.size=m.size))):r=B.createElementNS(r,d),r[$i]=o,r[wl]=m,Yy(r,o,!1,!1),o.stateNode=r;e:{switch(B=se(d,m),d){case"dialog":un("cancel",r),un("close",r),y=m;break;case"iframe":case"object":case"embed":un("load",r),y=m;break;case"video":case"audio":for(y=0;y<vl.length;y++)un(vl[y],r);y=m;break;case"source":un("error",r),y=m;break;case"img":case"image":case"link":un("error",r),un("load",r),y=m;break;case"details":un("toggle",r),y=m;break;case"input":Ne(r,m),y=oe(r,m),un("invalid",r);break;case"option":y=m;break;case"select":r._wrapperState={wasMultiple:!!m.multiple},y=U({},m,{value:void 0}),un("invalid",r);break;case"textarea":Re(r,m),y=We(r,m),un("invalid",r);break;default:y=m}Ze(d,y),ee=y;for(C in ee)if(ee.hasOwnProperty(C)){var ce=ee[C];C==="style"?X(r,ce):C==="dangerouslySetInnerHTML"?(ce=ce?ce.__html:void 0,ce!=null&&Ke(r,ce)):C==="children"?typeof ce=="string"?(d!=="textarea"||ce!=="")&&wt(r,ce):typeof ce=="number"&&wt(r,""+ce):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(i.hasOwnProperty(C)?ce!=null&&C==="onScroll"&&un("scroll",r):ce!=null&&j(r,C,ce,B))}switch(d){case"input":rt(r),V(r,m,!1);break;case"textarea":rt(r),st(r);break;case"option":m.value!=null&&r.setAttribute("value",""+ne(m.value));break;case"select":r.multiple=!!m.multiple,C=m.value,C!=null?ke(r,!!m.multiple,C,!1):m.defaultValue!=null&&ke(r,!!m.multiple,m.defaultValue,!0);break;default:typeof y.onClick=="function"&&(r.onclick=eu)}switch(d){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}}m&&(o.flags|=4)}o.ref!==null&&(o.flags|=512,o.flags|=2097152)}return Ss(o),null;case 6:if(r&&o.stateNode!=null)Xy(r,o,r.memoizedProps,m);else{if(typeof m!="string"&&o.stateNode===null)throw Error(n(166));if(d=No(Cl.current),No(zi.current),au(o)){if(m=o.stateNode,d=o.memoizedProps,m[$i]=o,(C=m.nodeValue!==d)&&(r=Xs,r!==null))switch(r.tag){case 3:Zc(m.nodeValue,d,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&Zc(m.nodeValue,d,(r.mode&1)!==0)}C&&(o.flags|=4)}else m=(d.nodeType===9?d:d.ownerDocument).createTextNode(m),m[$i]=o,o.stateNode=m}return Ss(o),null;case 13:if(dn(xn),m=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(vn&&Js!==null&&(o.mode&1)!==0&&(o.flags&128)===0)Z_(),ga(),o.flags|=98560,C=!1;else if(C=au(o),m!==null&&m.dehydrated!==null){if(r===null){if(!C)throw Error(n(318));if(C=o.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[$i]=o}else ga(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Ss(o),C=!1}else Ri!==null&&(jf(Ri),Ri=null),C=!0;if(!C)return o.flags&65536?o:null}return(o.flags&128)!==0?(o.lanes=d,o):(m=m!==null,m!==(r!==null&&r.memoizedState!==null)&&m&&(o.child.flags|=8192,(o.mode&1)!==0&&(r===null||(xn.current&1)!==0?Hn===0&&(Hn=3):Pf())),o.updateQueue!==null&&(o.flags|=4),Ss(o),null);case 4:return wa(),wf(r,o),r===null&&_l(o.stateNode.containerInfo),Ss(o),null;case 10:return Vh(o.type._context),Ss(o),null;case 17:return Os(o.type)&&nu(),Ss(o),null;case 19:if(dn(xn),C=o.memoizedState,C===null)return Ss(o),null;if(m=(o.flags&128)!==0,B=C.rendering,B===null)if(m)Al(C,!1);else{if(Hn!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(B=fu(r),B!==null){for(o.flags|=128,Al(C,!1),m=B.updateQueue,m!==null&&(o.updateQueue=m,o.flags|=4),o.subtreeFlags=0,m=d,d=o.child;d!==null;)C=d,r=m,C.flags&=14680066,B=C.alternate,B===null?(C.childLanes=0,C.lanes=r,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=B.childLanes,C.lanes=B.lanes,C.child=B.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=B.memoizedProps,C.memoizedState=B.memoizedState,C.updateQueue=B.updateQueue,C.type=B.type,r=B.dependencies,C.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),d=d.sibling;return an(xn,xn.current&1|2),o.child}r=r.sibling}C.tail!==null&&W()>ka&&(o.flags|=128,m=!0,Al(C,!1),o.lanes=4194304)}else{if(!m)if(r=fu(B),r!==null){if(o.flags|=128,m=!0,d=r.updateQueue,d!==null&&(o.updateQueue=d,o.flags|=4),Al(C,!0),C.tail===null&&C.tailMode==="hidden"&&!B.alternate&&!vn)return Ss(o),null}else 2*W()-C.renderingStartTime>ka&&d!==1073741824&&(o.flags|=128,m=!0,Al(C,!1),o.lanes=4194304);C.isBackwards?(B.sibling=o.child,o.child=B):(d=C.last,d!==null?d.sibling=B:o.child=B,C.last=B)}return C.tail!==null?(o=C.tail,C.rendering=o,C.tail=o.sibling,C.renderingStartTime=W(),o.sibling=null,d=xn.current,an(xn,m?d&1|2:d&1),o):(Ss(o),null);case 22:case 23:return Tf(),m=o.memoizedState!==null,r!==null&&r.memoizedState!==null!==m&&(o.flags|=8192),m&&(o.mode&1)!==0?(Qs&1073741824)!==0&&(Ss(o),o.subtreeFlags&6&&(o.flags|=8192)):Ss(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function z2(r,o){switch(Fh(o),o.tag){case 1:return Os(o.type)&&nu(),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return wa(),dn(Ds),dn(ws),ef(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 5:return Qh(o),null;case 13:if(dn(xn),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));ga()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return dn(xn),null;case 4:return wa(),null;case 10:return Vh(o.type._context),null;case 22:case 23:return Tf(),null;case 24:return null;default:return null}}var Su=!1,xs=!1,F2=typeof WeakSet=="function"?WeakSet:Set,pt=null;function Sa(r,o){var d=r.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(m){Nn(r,o,m)}else d.current=null}function bf(r,o,d){try{d()}catch(m){Nn(r,o,m)}}var Jy=!1;function H2(r,o){if(Mh=wo,r=L_(),kh(r)){if("selectionStart"in r)var d={start:r.selectionStart,end:r.selectionEnd};else e:{d=(d=r.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var y=m.anchorOffset,C=m.focusNode;m=m.focusOffset;try{d.nodeType,C.nodeType}catch{d=null;break e}var B=0,ee=-1,ce=-1,Ee=0,Ue=0,Ye=r,Fe=null;t:for(;;){for(var lt;Ye!==d||y!==0&&Ye.nodeType!==3||(ee=B+y),Ye!==C||m!==0&&Ye.nodeType!==3||(ce=B+m),Ye.nodeType===3&&(B+=Ye.nodeValue.length),(lt=Ye.firstChild)!==null;)Fe=Ye,Ye=lt;for(;;){if(Ye===r)break t;if(Fe===d&&++Ee===y&&(ee=B),Fe===C&&++Ue===m&&(ce=B),(lt=Ye.nextSibling)!==null)break;Ye=Fe,Fe=Ye.parentNode}Ye=lt}d=ee===-1||ce===-1?null:{start:ee,end:ce}}else d=null}d=d||{start:0,end:0}}else d=null;for(Th={focusedElem:r,selectionRange:d},wo=!1,pt=o;pt!==null;)if(o=pt,r=o.child,(o.subtreeFlags&1028)!==0&&r!==null)r.return=o,pt=r;else for(;pt!==null;){o=pt;try{var mt=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(mt!==null){var _t=mt.memoizedProps,Mn=mt.memoizedState,we=o.stateNode,pe=we.getSnapshotBeforeUpdate(o.elementType===o.type?_t:Li(o.type,_t),Mn);we.__reactInternalSnapshotBeforeUpdate=pe}break;case 3:var be=o.stateNode.containerInfo;be.nodeType===1?be.textContent="":be.nodeType===9&&be.documentElement&&be.removeChild(be.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(et){Nn(o,o.return,et)}if(r=o.sibling,r!==null){r.return=o.return,pt=r;break}pt=o.return}return mt=Jy,Jy=!1,mt}function jl(r,o,d){var m=o.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var y=m=m.next;do{if((y.tag&r)===r){var C=y.destroy;y.destroy=void 0,C!==void 0&&bf(o,d,C)}y=y.next}while(y!==m)}}function xu(r,o){if(o=o.updateQueue,o=o!==null?o.lastEffect:null,o!==null){var d=o=o.next;do{if((d.tag&r)===r){var m=d.create;d.destroy=m()}d=d.next}while(d!==o)}}function Sf(r){var o=r.ref;if(o!==null){var d=r.stateNode;switch(r.tag){case 5:r=d;break;default:r=d}typeof o=="function"?o(r):o.current=r}}function Qy(r){var o=r.alternate;o!==null&&(r.alternate=null,Qy(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&(delete o[$i],delete o[wl],delete o[Oh],delete o[k2],delete o[C2])),r.stateNode=null,r.return=null,r.dependencies=null,r.memoizedProps=null,r.memoizedState=null,r.pendingProps=null,r.stateNode=null,r.updateQueue=null}function Zy(r){return r.tag===5||r.tag===3||r.tag===4}function ew(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||Zy(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function xf(r,o,d){var m=r.tag;if(m===5||m===6)r=r.stateNode,o?d.nodeType===8?d.parentNode.insertBefore(r,o):d.insertBefore(r,o):(d.nodeType===8?(o=d.parentNode,o.insertBefore(r,d)):(o=d,o.appendChild(r)),d=d._reactRootContainer,d!=null||o.onclick!==null||(o.onclick=eu));else if(m!==4&&(r=r.child,r!==null))for(xf(r,o,d),r=r.sibling;r!==null;)xf(r,o,d),r=r.sibling}function kf(r,o,d){var m=r.tag;if(m===5||m===6)r=r.stateNode,o?d.insertBefore(r,o):d.appendChild(r);else if(m!==4&&(r=r.child,r!==null))for(kf(r,o,d),r=r.sibling;r!==null;)kf(r,o,d),r=r.sibling}var ds=null,Ai=!1;function Fr(r,o,d){for(d=d.child;d!==null;)tw(r,o,d),d=d.sibling}function tw(r,o,d){if(Rt&&typeof Rt.onCommitFiberUnmount=="function")try{Rt.onCommitFiberUnmount(Qe,d)}catch{}switch(d.tag){case 5:xs||Sa(d,o);case 6:var m=ds,y=Ai;ds=null,Fr(r,o,d),ds=m,Ai=y,ds!==null&&(Ai?(r=ds,d=d.stateNode,r.nodeType===8?r.parentNode.removeChild(d):r.removeChild(d)):ds.removeChild(d.stateNode));break;case 18:ds!==null&&(Ai?(r=ds,d=d.stateNode,r.nodeType===8?Dh(r.parentNode,d):r.nodeType===1&&Dh(r,d),Tr(r)):Dh(ds,d.stateNode));break;case 4:m=ds,y=Ai,ds=d.stateNode.containerInfo,Ai=!0,Fr(r,o,d),ds=m,Ai=y;break;case 0:case 11:case 14:case 15:if(!xs&&(m=d.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){y=m=m.next;do{var C=y,B=C.destroy;C=C.tag,B!==void 0&&((C&2)!==0||(C&4)!==0)&&bf(d,o,B),y=y.next}while(y!==m)}Fr(r,o,d);break;case 1:if(!xs&&(Sa(d,o),m=d.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=d.memoizedProps,m.state=d.memoizedState,m.componentWillUnmount()}catch(ee){Nn(d,o,ee)}Fr(r,o,d);break;case 21:Fr(r,o,d);break;case 22:d.mode&1?(xs=(m=xs)||d.memoizedState!==null,Fr(r,o,d),xs=m):Fr(r,o,d);break;default:Fr(r,o,d)}}function nw(r){var o=r.updateQueue;if(o!==null){r.updateQueue=null;var d=r.stateNode;d===null&&(d=r.stateNode=new F2),o.forEach(function(m){var y=J2.bind(null,r,m);d.has(m)||(d.add(m),m.then(y,y))})}}function ji(r,o){var d=o.deletions;if(d!==null)for(var m=0;m<d.length;m++){var y=d[m];try{var C=r,B=o,ee=B;e:for(;ee!==null;){switch(ee.tag){case 5:ds=ee.stateNode,Ai=!1;break e;case 3:ds=ee.stateNode.containerInfo,Ai=!0;break e;case 4:ds=ee.stateNode.containerInfo,Ai=!0;break e}ee=ee.return}if(ds===null)throw Error(n(160));tw(C,B,y),ds=null,Ai=!1;var ce=y.alternate;ce!==null&&(ce.return=null),y.return=null}catch(Ee){Nn(y,o,Ee)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)sw(o,r),o=o.sibling}function sw(r,o){var d=r.alternate,m=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(ji(o,r),Hi(r),m&4){try{jl(3,r,r.return),xu(3,r)}catch(_t){Nn(r,r.return,_t)}try{jl(5,r,r.return)}catch(_t){Nn(r,r.return,_t)}}break;case 1:ji(o,r),Hi(r),m&512&&d!==null&&Sa(d,d.return);break;case 5:if(ji(o,r),Hi(r),m&512&&d!==null&&Sa(d,d.return),r.flags&32){var y=r.stateNode;try{wt(y,"")}catch(_t){Nn(r,r.return,_t)}}if(m&4&&(y=r.stateNode,y!=null)){var C=r.memoizedProps,B=d!==null?d.memoizedProps:C,ee=r.type,ce=r.updateQueue;if(r.updateQueue=null,ce!==null)try{ee==="input"&&C.type==="radio"&&C.name!=null&&me(y,C),se(ee,B);var Ee=se(ee,C);for(B=0;B<ce.length;B+=2){var Ue=ce[B],Ye=ce[B+1];Ue==="style"?X(y,Ye):Ue==="dangerouslySetInnerHTML"?Ke(y,Ye):Ue==="children"?wt(y,Ye):j(y,Ue,Ye,Ee)}switch(ee){case"input":Ce(y,C);break;case"textarea":_e(y,C);break;case"select":var Fe=y._wrapperState.wasMultiple;y._wrapperState.wasMultiple=!!C.multiple;var lt=C.value;lt!=null?ke(y,!!C.multiple,lt,!1):Fe!==!!C.multiple&&(C.defaultValue!=null?ke(y,!!C.multiple,C.defaultValue,!0):ke(y,!!C.multiple,C.multiple?[]:"",!1))}y[wl]=C}catch(_t){Nn(r,r.return,_t)}}break;case 6:if(ji(o,r),Hi(r),m&4){if(r.stateNode===null)throw Error(n(162));y=r.stateNode,C=r.memoizedProps;try{y.nodeValue=C}catch(_t){Nn(r,r.return,_t)}}break;case 3:if(ji(o,r),Hi(r),m&4&&d!==null&&d.memoizedState.isDehydrated)try{Tr(o.containerInfo)}catch(_t){Nn(r,r.return,_t)}break;case 4:ji(o,r),Hi(r);break;case 13:ji(o,r),Hi(r),y=r.child,y.flags&8192&&(C=y.memoizedState!==null,y.stateNode.isHidden=C,!C||y.alternate!==null&&y.alternate.memoizedState!==null||(Nf=W())),m&4&&nw(r);break;case 22:if(Ue=d!==null&&d.memoizedState!==null,r.mode&1?(xs=(Ee=xs)||Ue,ji(o,r),xs=Ee):ji(o,r),Hi(r),m&8192){if(Ee=r.memoizedState!==null,(r.stateNode.isHidden=Ee)&&!Ue&&(r.mode&1)!==0)for(pt=r,Ue=r.child;Ue!==null;){for(Ye=pt=Ue;pt!==null;){switch(Fe=pt,lt=Fe.child,Fe.tag){case 0:case 11:case 14:case 15:jl(4,Fe,Fe.return);break;case 1:Sa(Fe,Fe.return);var mt=Fe.stateNode;if(typeof mt.componentWillUnmount=="function"){m=Fe,d=Fe.return;try{o=m,mt.props=o.memoizedProps,mt.state=o.memoizedState,mt.componentWillUnmount()}catch(_t){Nn(m,d,_t)}}break;case 5:Sa(Fe,Fe.return);break;case 22:if(Fe.memoizedState!==null){ow(Ye);continue}}lt!==null?(lt.return=Fe,pt=lt):ow(Ye)}Ue=Ue.sibling}e:for(Ue=null,Ye=r;;){if(Ye.tag===5){if(Ue===null){Ue=Ye;try{y=Ye.stateNode,Ee?(C=y.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(ee=Ye.stateNode,ce=Ye.memoizedProps.style,B=ce!=null&&ce.hasOwnProperty("display")?ce.display:null,ee.style.display=Z("display",B))}catch(_t){Nn(r,r.return,_t)}}}else if(Ye.tag===6){if(Ue===null)try{Ye.stateNode.nodeValue=Ee?"":Ye.memoizedProps}catch(_t){Nn(r,r.return,_t)}}else if((Ye.tag!==22&&Ye.tag!==23||Ye.memoizedState===null||Ye===r)&&Ye.child!==null){Ye.child.return=Ye,Ye=Ye.child;continue}if(Ye===r)break e;for(;Ye.sibling===null;){if(Ye.return===null||Ye.return===r)break e;Ue===Ye&&(Ue=null),Ye=Ye.return}Ue===Ye&&(Ue=null),Ye.sibling.return=Ye.return,Ye=Ye.sibling}}break;case 19:ji(o,r),Hi(r),m&4&&nw(r);break;case 21:break;default:ji(o,r),Hi(r)}}function Hi(r){var o=r.flags;if(o&2){try{e:{for(var d=r.return;d!==null;){if(Zy(d)){var m=d;break e}d=d.return}throw Error(n(160))}switch(m.tag){case 5:var y=m.stateNode;m.flags&32&&(wt(y,""),m.flags&=-33);var C=ew(r);kf(r,C,y);break;case 3:case 4:var B=m.stateNode.containerInfo,ee=ew(r);xf(r,ee,B);break;default:throw Error(n(161))}}catch(ce){Nn(r,r.return,ce)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function U2(r,o,d){pt=r,iw(r)}function iw(r,o,d){for(var m=(r.mode&1)!==0;pt!==null;){var y=pt,C=y.child;if(y.tag===22&&m){var B=y.memoizedState!==null||Su;if(!B){var ee=y.alternate,ce=ee!==null&&ee.memoizedState!==null||xs;ee=Su;var Ee=xs;if(Su=B,(xs=ce)&&!Ee)for(pt=y;pt!==null;)B=pt,ce=B.child,B.tag===22&&B.memoizedState!==null?aw(y):ce!==null?(ce.return=B,pt=ce):aw(y);for(;C!==null;)pt=C,iw(C),C=C.sibling;pt=y,Su=ee,xs=Ee}rw(r)}else(y.subtreeFlags&8772)!==0&&C!==null?(C.return=y,pt=C):rw(r)}}function rw(r){for(;pt!==null;){var o=pt;if((o.flags&8772)!==0){var d=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:xs||xu(5,o);break;case 1:var m=o.stateNode;if(o.flags&4&&!xs)if(d===null)m.componentDidMount();else{var y=o.elementType===o.type?d.memoizedProps:Li(o.type,d.memoizedProps);m.componentDidUpdate(y,d.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var C=o.updateQueue;C!==null&&oy(o,C,m);break;case 3:var B=o.updateQueue;if(B!==null){if(d=null,o.child!==null)switch(o.child.tag){case 5:d=o.child.stateNode;break;case 1:d=o.child.stateNode}oy(o,B,d)}break;case 5:var ee=o.stateNode;if(d===null&&o.flags&4){d=ee;var ce=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":ce.autoFocus&&d.focus();break;case"img":ce.src&&(d.src=ce.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var Ee=o.alternate;if(Ee!==null){var Ue=Ee.memoizedState;if(Ue!==null){var Ye=Ue.dehydrated;Ye!==null&&Tr(Ye)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}xs||o.flags&512&&Sf(o)}catch(Fe){Nn(o,o.return,Fe)}}if(o===r){pt=null;break}if(d=o.sibling,d!==null){d.return=o.return,pt=d;break}pt=o.return}}function ow(r){for(;pt!==null;){var o=pt;if(o===r){pt=null;break}var d=o.sibling;if(d!==null){d.return=o.return,pt=d;break}pt=o.return}}function aw(r){for(;pt!==null;){var o=pt;try{switch(o.tag){case 0:case 11:case 15:var d=o.return;try{xu(4,o)}catch(ce){Nn(o,d,ce)}break;case 1:var m=o.stateNode;if(typeof m.componentDidMount=="function"){var y=o.return;try{m.componentDidMount()}catch(ce){Nn(o,y,ce)}}var C=o.return;try{Sf(o)}catch(ce){Nn(o,C,ce)}break;case 5:var B=o.return;try{Sf(o)}catch(ce){Nn(o,B,ce)}}}catch(ce){Nn(o,o.return,ce)}if(o===r){pt=null;break}var ee=o.sibling;if(ee!==null){ee.return=o.return,pt=ee;break}pt=o.return}}var W2=Math.ceil,ku=E.ReactCurrentDispatcher,Cf=E.ReactCurrentOwner,ui=E.ReactCurrentBatchConfig,Vt=0,Xn=null,Dn=null,hs=0,Qs=0,xa=Dr(0),Hn=0,Ml=null,Lo=0,Cu=0,Ef=0,Tl=null,$s=null,Nf=0,ka=1/0,pr=null,Eu=!1,Rf=null,Hr=null,Nu=!1,Ur=null,Ru=0,Pl=0,Lf=null,Lu=-1,Au=0;function Rs(){return(Vt&6)!==0?W():Lu!==-1?Lu:Lu=W()}function Wr(r){return(r.mode&1)===0?1:(Vt&2)!==0&&hs!==0?hs&-hs:N2.transition!==null?(Au===0&&(Au=nn()),Au):(r=Gt,r!==0||(r=window.event,r=r===void 0?16:ul(r.type)),r)}function Mi(r,o,d,m){if(50<Pl)throw Pl=0,Lf=null,Error(n(185));Si(r,d,m),((Vt&2)===0||r!==Xn)&&(r===Xn&&((Vt&2)===0&&(Cu|=d),Hn===4&&qr(r,hs)),zs(r,m),d===1&&Vt===0&&(o.mode&1)===0&&(ka=W()+500,iu&&Br()))}function zs(r,o){var d=r.callbackNode;Vs(r,o);var m=Lt(r,r===Xn?hs:0);if(m===0)d!==null&&Te(d),r.callbackNode=null,r.callbackPriority=0;else if(o=m&-m,r.callbackPriority!==o){if(d!=null&&Te(d),o===1)r.tag===0?E2(cw.bind(null,r)):Y_(cw.bind(null,r)),S2(function(){(Vt&6)===0&&Br()}),d=null;else{switch(rl(m)){case 1:d=Ae;break;case 4:d=Je;break;case 16:d=Pe;break;case 536870912:d=vt;break;default:d=Pe}d=vw(d,lw.bind(null,r))}r.callbackPriority=o,r.callbackNode=d}}function lw(r,o){if(Lu=-1,Au=0,(Vt&6)!==0)throw Error(n(327));var d=r.callbackNode;if(Ca()&&r.callbackNode!==d)return null;var m=Lt(r,r===Xn?hs:0);if(m===0)return null;if((m&30)!==0||(m&r.expiredLanes)!==0||o)o=ju(r,m);else{o=m;var y=Vt;Vt|=2;var C=dw();(Xn!==r||hs!==o)&&(pr=null,ka=W()+500,jo(r,o));do try{V2();break}catch(ee){uw(r,ee)}while(!0);Kh(),ku.current=C,Vt=y,Dn!==null?o=0:(Xn=null,hs=0,o=Hn)}if(o!==0){if(o===2&&(y=en(r),y!==0&&(m=y,o=Af(r,y))),o===1)throw d=Ml,jo(r,0),qr(r,m),zs(r,W()),d;if(o===6)qr(r,m);else{if(y=r.current.alternate,(m&30)===0&&!q2(y)&&(o=ju(r,m),o===2&&(C=en(r),C!==0&&(m=C,o=Af(r,C))),o===1))throw d=Ml,jo(r,0),qr(r,m),zs(r,W()),d;switch(r.finishedWork=y,r.finishedLanes=m,o){case 0:case 1:throw Error(n(345));case 2:Mo(r,$s,pr);break;case 3:if(qr(r,m),(m&130023424)===m&&(o=Nf+500-W(),10<o)){if(Lt(r,0)!==0)break;if(y=r.suspendedLanes,(y&m)!==m){Rs(),r.pingedLanes|=r.suspendedLanes&y;break}r.timeoutHandle=Ih(Mo.bind(null,r,$s,pr),o);break}Mo(r,$s,pr);break;case 4:if(qr(r,m),(m&4194240)===m)break;for(o=r.eventTimes,y=-1;0<m;){var B=31-ze(m);C=1<<B,B=o[B],B>y&&(y=B),m&=~C}if(m=y,m=W()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*W2(m/1960))-m,10<m){r.timeoutHandle=Ih(Mo.bind(null,r,$s,pr),m);break}Mo(r,$s,pr);break;case 5:Mo(r,$s,pr);break;default:throw Error(n(329))}}}return zs(r,W()),r.callbackNode===d?lw.bind(null,r):null}function Af(r,o){var d=Tl;return r.current.memoizedState.isDehydrated&&(jo(r,o).flags|=256),r=ju(r,o),r!==2&&(o=$s,$s=d,o!==null&&jf(o)),r}function jf(r){$s===null?$s=r:$s.push.apply($s,r)}function q2(r){for(var o=r;;){if(o.flags&16384){var d=o.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var m=0;m<d.length;m++){var y=d[m],C=y.getSnapshot;y=y.value;try{if(!Ni(C(),y))return!1}catch{return!1}}}if(d=o.child,o.subtreeFlags&16384&&d!==null)d.return=o,o=d;else{if(o===r)break;for(;o.sibling===null;){if(o.return===null||o.return===r)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function qr(r,o){for(o&=~Ef,o&=~Cu,r.suspendedLanes|=o,r.pingedLanes&=~o,r=r.expirationTimes;0<o;){var d=31-ze(o),m=1<<d;r[d]=-1,o&=~m}}function cw(r){if((Vt&6)!==0)throw Error(n(327));Ca();var o=Lt(r,0);if((o&1)===0)return zs(r,W()),null;var d=ju(r,o);if(r.tag!==0&&d===2){var m=en(r);m!==0&&(o=m,d=Af(r,m))}if(d===1)throw d=Ml,jo(r,0),qr(r,o),zs(r,W()),d;if(d===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=o,Mo(r,$s,pr),zs(r,W()),null}function Mf(r,o){var d=Vt;Vt|=1;try{return r(o)}finally{Vt=d,Vt===0&&(ka=W()+500,iu&&Br())}}function Ao(r){Ur!==null&&Ur.tag===0&&(Vt&6)===0&&Ca();var o=Vt;Vt|=1;var d=ui.transition,m=Gt;try{if(ui.transition=null,Gt=1,r)return r()}finally{Gt=m,ui.transition=d,Vt=o,(Vt&6)===0&&Br()}}function Tf(){Qs=xa.current,dn(xa)}function jo(r,o){r.finishedWork=null,r.finishedLanes=0;var d=r.timeoutHandle;if(d!==-1&&(r.timeoutHandle=-1,b2(d)),Dn!==null)for(d=Dn.return;d!==null;){var m=d;switch(Fh(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&nu();break;case 3:wa(),dn(Ds),dn(ws),ef();break;case 5:Qh(m);break;case 4:wa();break;case 13:dn(xn);break;case 19:dn(xn);break;case 10:Vh(m.type._context);break;case 22:case 23:Tf()}d=d.return}if(Xn=r,Dn=r=Kr(r.current,null),hs=Qs=o,Hn=0,Ml=null,Ef=Cu=Lo=0,$s=Tl=null,Eo!==null){for(o=0;o<Eo.length;o++)if(d=Eo[o],m=d.interleaved,m!==null){d.interleaved=null;var y=m.next,C=d.pending;if(C!==null){var B=C.next;C.next=y,m.next=B}d.pending=m}Eo=null}return r}function uw(r,o){do{var d=Dn;try{if(Kh(),pu.current=_u,mu){for(var m=kn.memoizedState;m!==null;){var y=m.queue;y!==null&&(y.pending=null),m=m.next}mu=!1}if(Ro=0,Gn=Fn=kn=null,El=!1,Nl=0,Cf.current=null,d===null||d.return===null){Hn=1,Ml=o,Dn=null;break}e:{var C=r,B=d.return,ee=d,ce=o;if(o=hs,ee.flags|=32768,ce!==null&&typeof ce=="object"&&typeof ce.then=="function"){var Ee=ce,Ue=ee,Ye=Ue.tag;if((Ue.mode&1)===0&&(Ye===0||Ye===11||Ye===15)){var Fe=Ue.alternate;Fe?(Ue.updateQueue=Fe.updateQueue,Ue.memoizedState=Fe.memoizedState,Ue.lanes=Fe.lanes):(Ue.updateQueue=null,Ue.memoizedState=null)}var lt=Iy(B);if(lt!==null){lt.flags&=-257,Dy(lt,B,ee,C,o),lt.mode&1&&Py(C,Ee,o),o=lt,ce=Ee;var mt=o.updateQueue;if(mt===null){var _t=new Set;_t.add(ce),o.updateQueue=_t}else mt.add(ce);break e}else{if((o&1)===0){Py(C,Ee,o),Pf();break e}ce=Error(n(426))}}else if(vn&&ee.mode&1){var Mn=Iy(B);if(Mn!==null){(Mn.flags&65536)===0&&(Mn.flags|=256),Dy(Mn,B,ee,C,o),Wh(ba(ce,ee));break e}}C=ce=ba(ce,ee),Hn!==4&&(Hn=2),Tl===null?Tl=[C]:Tl.push(C),C=B;do{switch(C.tag){case 3:C.flags|=65536,o&=-o,C.lanes|=o;var we=My(C,ce,o);ry(C,we);break e;case 1:ee=ce;var pe=C.type,be=C.stateNode;if((C.flags&128)===0&&(typeof pe.getDerivedStateFromError=="function"||be!==null&&typeof be.componentDidCatch=="function"&&(Hr===null||!Hr.has(be)))){C.flags|=65536,o&=-o,C.lanes|=o;var et=Ty(C,ee,o);ry(C,et);break e}}C=C.return}while(C!==null)}fw(d)}catch(yt){o=yt,Dn===d&&d!==null&&(Dn=d=d.return);continue}break}while(!0)}function dw(){var r=ku.current;return ku.current=_u,r===null?_u:r}function Pf(){(Hn===0||Hn===3||Hn===2)&&(Hn=4),Xn===null||(Lo&268435455)===0&&(Cu&268435455)===0||qr(Xn,hs)}function ju(r,o){var d=Vt;Vt|=2;var m=dw();(Xn!==r||hs!==o)&&(pr=null,jo(r,o));do try{K2();break}catch(y){uw(r,y)}while(!0);if(Kh(),Vt=d,ku.current=m,Dn!==null)throw Error(n(261));return Xn=null,hs=0,Hn}function K2(){for(;Dn!==null;)hw(Dn)}function V2(){for(;Dn!==null&&!Ge();)hw(Dn)}function hw(r){var o=gw(r.alternate,r,Qs);r.memoizedProps=r.pendingProps,o===null?fw(r):Dn=o,Cf.current=null}function fw(r){var o=r;do{var d=o.alternate;if(r=o.return,(o.flags&32768)===0){if(d=$2(d,o,Qs),d!==null){Dn=d;return}}else{if(d=z2(d,o),d!==null){d.flags&=32767,Dn=d;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Hn=6,Dn=null;return}}if(o=o.sibling,o!==null){Dn=o;return}Dn=o=r}while(o!==null);Hn===0&&(Hn=5)}function Mo(r,o,d){var m=Gt,y=ui.transition;try{ui.transition=null,Gt=1,Y2(r,o,d,m)}finally{ui.transition=y,Gt=m}return null}function Y2(r,o,d,m){do Ca();while(Ur!==null);if((Vt&6)!==0)throw Error(n(327));d=r.finishedWork;var y=r.finishedLanes;if(d===null)return null;if(r.finishedWork=null,r.finishedLanes=0,d===r.current)throw Error(n(177));r.callbackNode=null,r.callbackPriority=0;var C=d.lanes|d.childLanes;if(go(r,C),r===Xn&&(Dn=Xn=null,hs=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||Nu||(Nu=!0,vw(Pe,function(){return Ca(),null})),C=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||C){C=ui.transition,ui.transition=null;var B=Gt;Gt=1;var ee=Vt;Vt|=4,Cf.current=null,H2(r,d),sw(d,r),p2(Th),wo=!!Mh,Th=Mh=null,r.current=d,U2(d),gt(),Vt=ee,Gt=B,ui.transition=C}else r.current=d;if(Nu&&(Nu=!1,Ur=r,Ru=y),C=r.pendingLanes,C===0&&(Hr=null),ot(d.stateNode),zs(r,W()),o!==null)for(m=r.onRecoverableError,d=0;d<o.length;d++)y=o[d],m(y.value,{componentStack:y.stack,digest:y.digest});if(Eu)throw Eu=!1,r=Rf,Rf=null,r;return(Ru&1)!==0&&r.tag!==0&&Ca(),C=r.pendingLanes,(C&1)!==0?r===Lf?Pl++:(Pl=0,Lf=r):Pl=0,Br(),null}function Ca(){if(Ur!==null){var r=rl(Ru),o=ui.transition,d=Gt;try{if(ui.transition=null,Gt=16>r?16:r,Ur===null)var m=!1;else{if(r=Ur,Ur=null,Ru=0,(Vt&6)!==0)throw Error(n(331));var y=Vt;for(Vt|=4,pt=r.current;pt!==null;){var C=pt,B=C.child;if((pt.flags&16)!==0){var ee=C.deletions;if(ee!==null){for(var ce=0;ce<ee.length;ce++){var Ee=ee[ce];for(pt=Ee;pt!==null;){var Ue=pt;switch(Ue.tag){case 0:case 11:case 15:jl(8,Ue,C)}var Ye=Ue.child;if(Ye!==null)Ye.return=Ue,pt=Ye;else for(;pt!==null;){Ue=pt;var Fe=Ue.sibling,lt=Ue.return;if(Qy(Ue),Ue===Ee){pt=null;break}if(Fe!==null){Fe.return=lt,pt=Fe;break}pt=lt}}}var mt=C.alternate;if(mt!==null){var _t=mt.child;if(_t!==null){mt.child=null;do{var Mn=_t.sibling;_t.sibling=null,_t=Mn}while(_t!==null)}}pt=C}}if((C.subtreeFlags&2064)!==0&&B!==null)B.return=C,pt=B;else e:for(;pt!==null;){if(C=pt,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:jl(9,C,C.return)}var we=C.sibling;if(we!==null){we.return=C.return,pt=we;break e}pt=C.return}}var pe=r.current;for(pt=pe;pt!==null;){B=pt;var be=B.child;if((B.subtreeFlags&2064)!==0&&be!==null)be.return=B,pt=be;else e:for(B=pe;pt!==null;){if(ee=pt,(ee.flags&2048)!==0)try{switch(ee.tag){case 0:case 11:case 15:xu(9,ee)}}catch(yt){Nn(ee,ee.return,yt)}if(ee===B){pt=null;break e}var et=ee.sibling;if(et!==null){et.return=ee.return,pt=et;break e}pt=ee.return}}if(Vt=y,Br(),Rt&&typeof Rt.onPostCommitFiberRoot=="function")try{Rt.onPostCommitFiberRoot(Qe,r)}catch{}m=!0}return m}finally{Gt=d,ui.transition=o}}return!1}function pw(r,o,d){o=ba(d,o),o=My(r,o,1),r=zr(r,o,1),o=Rs(),r!==null&&(Si(r,1,o),zs(r,o))}function Nn(r,o,d){if(r.tag===3)pw(r,r,d);else for(;o!==null;){if(o.tag===3){pw(o,r,d);break}else if(o.tag===1){var m=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Hr===null||!Hr.has(m))){r=ba(d,r),r=Ty(o,r,1),o=zr(o,r,1),r=Rs(),o!==null&&(Si(o,1,r),zs(o,r));break}}o=o.return}}function G2(r,o,d){var m=r.pingCache;m!==null&&m.delete(o),o=Rs(),r.pingedLanes|=r.suspendedLanes&d,Xn===r&&(hs&d)===d&&(Hn===4||Hn===3&&(hs&130023424)===hs&&500>W()-Nf?jo(r,0):Ef|=d),zs(r,o)}function mw(r,o){o===0&&((r.mode&1)===0?o=1:(o=qe,qe<<=1,(qe&130023424)===0&&(qe=4194304)));var d=Rs();r=dr(r,o),r!==null&&(Si(r,o,d),zs(r,d))}function X2(r){var o=r.memoizedState,d=0;o!==null&&(d=o.retryLane),mw(r,d)}function J2(r,o){var d=0;switch(r.tag){case 13:var m=r.stateNode,y=r.memoizedState;y!==null&&(d=y.retryLane);break;case 19:m=r.stateNode;break;default:throw Error(n(314))}m!==null&&m.delete(o),mw(r,d)}var gw;gw=function(r,o,d){if(r!==null)if(r.memoizedProps!==o.pendingProps||Ds.current)Bs=!0;else{if((r.lanes&d)===0&&(o.flags&128)===0)return Bs=!1,B2(r,o,d);Bs=(r.flags&131072)!==0}else Bs=!1,vn&&(o.flags&1048576)!==0&&G_(o,ou,o.index);switch(o.lanes=0,o.tag){case 2:var m=o.type;bu(r,o),r=o.pendingProps;var y=fa(o,ws.current);ya(o,d),y=sf(null,o,m,r,y,d);var C=rf();return o.flags|=1,typeof y=="object"&&y!==null&&typeof y.render=="function"&&y.$$typeof===void 0?(o.tag=1,o.memoizedState=null,o.updateQueue=null,Os(m)?(C=!0,su(o)):C=!1,o.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,Xh(o),y.updater=yu,o.stateNode=y,y._reactInternals=o,df(o,m,r,d),o=mf(null,o,m,!0,C,d)):(o.tag=0,vn&&C&&zh(o),Ns(null,o,y,d),o=o.child),o;case 16:m=o.elementType;e:{switch(bu(r,o),r=o.pendingProps,y=m._init,m=y(m._payload),o.type=m,y=o.tag=Z2(m),r=Li(m,r),y){case 0:o=pf(null,o,m,r,d);break e;case 1:o=Hy(null,o,m,r,d);break e;case 11:o=Oy(null,o,m,r,d);break e;case 14:o=By(null,o,m,Li(m.type,r),d);break e}throw Error(n(306,m,""))}return o;case 0:return m=o.type,y=o.pendingProps,y=o.elementType===m?y:Li(m,y),pf(r,o,m,y,d);case 1:return m=o.type,y=o.pendingProps,y=o.elementType===m?y:Li(m,y),Hy(r,o,m,y,d);case 3:e:{if(Uy(o),r===null)throw Error(n(387));m=o.pendingProps,C=o.memoizedState,y=C.element,iy(r,o),hu(o,m,null,d);var B=o.memoizedState;if(m=B.element,C.isDehydrated)if(C={element:m,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},o.updateQueue.baseState=C,o.memoizedState=C,o.flags&256){y=ba(Error(n(423)),o),o=Wy(r,o,m,d,y);break e}else if(m!==y){y=ba(Error(n(424)),o),o=Wy(r,o,m,d,y);break e}else for(Js=Ir(o.stateNode.containerInfo.firstChild),Xs=o,vn=!0,Ri=null,d=ny(o,null,m,d),o.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(ga(),m===y){o=fr(r,o,d);break e}Ns(r,o,m,d)}o=o.child}return o;case 5:return ay(o),r===null&&Uh(o),m=o.type,y=o.pendingProps,C=r!==null?r.memoizedProps:null,B=y.children,Ph(m,y)?B=null:C!==null&&Ph(m,C)&&(o.flags|=32),Fy(r,o),Ns(r,o,B,d),o.child;case 6:return r===null&&Uh(o),null;case 13:return qy(r,o,d);case 4:return Jh(o,o.stateNode.containerInfo),m=o.pendingProps,r===null?o.child=va(o,null,m,d):Ns(r,o,m,d),o.child;case 11:return m=o.type,y=o.pendingProps,y=o.elementType===m?y:Li(m,y),Oy(r,o,m,y,d);case 7:return Ns(r,o,o.pendingProps,d),o.child;case 8:return Ns(r,o,o.pendingProps.children,d),o.child;case 12:return Ns(r,o,o.pendingProps.children,d),o.child;case 10:e:{if(m=o.type._context,y=o.pendingProps,C=o.memoizedProps,B=y.value,an(cu,m._currentValue),m._currentValue=B,C!==null)if(Ni(C.value,B)){if(C.children===y.children&&!Ds.current){o=fr(r,o,d);break e}}else for(C=o.child,C!==null&&(C.return=o);C!==null;){var ee=C.dependencies;if(ee!==null){B=C.child;for(var ce=ee.firstContext;ce!==null;){if(ce.context===m){if(C.tag===1){ce=hr(-1,d&-d),ce.tag=2;var Ee=C.updateQueue;if(Ee!==null){Ee=Ee.shared;var Ue=Ee.pending;Ue===null?ce.next=ce:(ce.next=Ue.next,Ue.next=ce),Ee.pending=ce}}C.lanes|=d,ce=C.alternate,ce!==null&&(ce.lanes|=d),Yh(C.return,d,o),ee.lanes|=d;break}ce=ce.next}}else if(C.tag===10)B=C.type===o.type?null:C.child;else if(C.tag===18){if(B=C.return,B===null)throw Error(n(341));B.lanes|=d,ee=B.alternate,ee!==null&&(ee.lanes|=d),Yh(B,d,o),B=C.sibling}else B=C.child;if(B!==null)B.return=C;else for(B=C;B!==null;){if(B===o){B=null;break}if(C=B.sibling,C!==null){C.return=B.return,B=C;break}B=B.return}C=B}Ns(r,o,y.children,d),o=o.child}return o;case 9:return y=o.type,m=o.pendingProps.children,ya(o,d),y=li(y),m=m(y),o.flags|=1,Ns(r,o,m,d),o.child;case 14:return m=o.type,y=Li(m,o.pendingProps),y=Li(m.type,y),By(r,o,m,y,d);case 15:return $y(r,o,o.type,o.pendingProps,d);case 17:return m=o.type,y=o.pendingProps,y=o.elementType===m?y:Li(m,y),bu(r,o),o.tag=1,Os(m)?(r=!0,su(o)):r=!1,ya(o,d),Ay(o,m,y),df(o,m,y,d),mf(null,o,m,!0,r,d);case 19:return Vy(r,o,d);case 22:return zy(r,o,d)}throw Error(n(156,o.tag))};function vw(r,o){return re(r,o)}function Q2(r,o,d,m){this.tag=r,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function di(r,o,d,m){return new Q2(r,o,d,m)}function If(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Z2(r){if(typeof r=="function")return If(r)?1:0;if(r!=null){if(r=r.$$typeof,r===D)return 11;if(r===M)return 14}return 2}function Kr(r,o){var d=r.alternate;return d===null?(d=di(r.tag,o,r.key,r.mode),d.elementType=r.elementType,d.type=r.type,d.stateNode=r.stateNode,d.alternate=r,r.alternate=d):(d.pendingProps=o,d.type=r.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=r.flags&14680064,d.childLanes=r.childLanes,d.lanes=r.lanes,d.child=r.child,d.memoizedProps=r.memoizedProps,d.memoizedState=r.memoizedState,d.updateQueue=r.updateQueue,o=r.dependencies,d.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},d.sibling=r.sibling,d.index=r.index,d.ref=r.ref,d}function Mu(r,o,d,m,y,C){var B=2;if(m=r,typeof r=="function")If(r)&&(B=1);else if(typeof r=="string")B=5;else e:switch(r){case G:return To(d.children,y,C,o);case K:B=8,y|=8;break;case Y:return r=di(12,d,o,y|2),r.elementType=Y,r.lanes=C,r;case I:return r=di(13,d,o,y),r.elementType=I,r.lanes=C,r;case O:return r=di(19,d,o,y),r.elementType=O,r.lanes=C,r;case T:return Tu(d,y,C,o);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case te:B=10;break e;case q:B=9;break e;case D:B=11;break e;case M:B=14;break e;case z:B=16,m=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return o=di(B,d,o,y),o.elementType=r,o.type=m,o.lanes=C,o}function To(r,o,d,m){return r=di(7,r,m,o),r.lanes=d,r}function Tu(r,o,d,m){return r=di(22,r,m,o),r.elementType=T,r.lanes=d,r.stateNode={isHidden:!1},r}function Df(r,o,d){return r=di(6,r,null,o),r.lanes=d,r}function Of(r,o,d){return o=di(4,r.children!==null?r.children:[],r.key,o),o.lanes=d,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function eN(r,o,d,m,y){this.tag=o,this.containerInfo=r,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=on(0),this.expirationTimes=on(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=on(0),this.identifierPrefix=m,this.onRecoverableError=y,this.mutableSourceEagerHydrationData=null}function Bf(r,o,d,m,y,C,B,ee,ce){return r=new eN(r,o,d,ee,ce),o===1?(o=1,C===!0&&(o|=8)):o=0,C=di(3,null,null,o),r.current=C,C.stateNode=r,C.memoizedState={element:m,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Xh(C),r}function tN(r,o,d){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:m==null?null:""+m,children:r,containerInfo:o,implementation:d}}function _w(r){if(!r)return Or;r=r._reactInternals;e:{if(gn(r)!==r||r.tag!==1)throw Error(n(170));var o=r;do{switch(o.tag){case 3:o=o.stateNode.context;break e;case 1:if(Os(o.type)){o=o.stateNode.__reactInternalMemoizedMergedChildContext;break e}}o=o.return}while(o!==null);throw Error(n(171))}if(r.tag===1){var d=r.type;if(Os(d))return K_(r,d,o)}return o}function yw(r,o,d,m,y,C,B,ee,ce){return r=Bf(d,m,!0,r,y,C,B,ee,ce),r.context=_w(null),d=r.current,m=Rs(),y=Wr(d),C=hr(m,y),C.callback=o??null,zr(d,C,y),r.current.lanes=y,Si(r,y,m),zs(r,m),r}function Pu(r,o,d,m){var y=o.current,C=Rs(),B=Wr(y);return d=_w(d),o.context===null?o.context=d:o.pendingContext=d,o=hr(C,B),o.payload={element:r},m=m===void 0?null:m,m!==null&&(o.callback=m),r=zr(y,o,B),r!==null&&(Mi(r,y,B,C),du(r,y,B)),B}function Iu(r){if(r=r.current,!r.child)return null;switch(r.child.tag){case 5:return r.child.stateNode;default:return r.child.stateNode}}function ww(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var d=r.retryLane;r.retryLane=d!==0&&d<o?d:o}}function $f(r,o){ww(r,o),(r=r.alternate)&&ww(r,o)}function nN(){return null}var bw=typeof reportError=="function"?reportError:function(r){console.error(r)};function zf(r){this._internalRoot=r}Du.prototype.render=zf.prototype.render=function(r){var o=this._internalRoot;if(o===null)throw Error(n(409));Pu(r,o,null,null)},Du.prototype.unmount=zf.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var o=r.containerInfo;Ao(function(){Pu(null,r,null,null)}),o[ar]=null}};function Du(r){this._internalRoot=r}Du.prototype.unstable_scheduleHydration=function(r){if(r){var o=ll();r={blockedOn:null,target:r,priority:o};for(var d=0;d<ki.length&&o!==0&&o<ki[d].priority;d++);ki.splice(d,0,r),d===0&&ys(r)}};function Ff(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function Ou(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function Sw(){}function sN(r,o,d,m,y){if(y){if(typeof m=="function"){var C=m;m=function(){var Ee=Iu(B);C.call(Ee)}}var B=yw(o,m,r,0,null,!1,!1,"",Sw);return r._reactRootContainer=B,r[ar]=B.current,_l(r.nodeType===8?r.parentNode:r),Ao(),B}for(;y=r.lastChild;)r.removeChild(y);if(typeof m=="function"){var ee=m;m=function(){var Ee=Iu(ce);ee.call(Ee)}}var ce=Bf(r,0,!1,null,null,!1,!1,"",Sw);return r._reactRootContainer=ce,r[ar]=ce.current,_l(r.nodeType===8?r.parentNode:r),Ao(function(){Pu(o,ce,d,m)}),ce}function Bu(r,o,d,m,y){var C=d._reactRootContainer;if(C){var B=C;if(typeof y=="function"){var ee=y;y=function(){var ce=Iu(B);ee.call(ce)}}Pu(o,B,r,y)}else B=sN(d,o,r,y,m);return Iu(B)}ol=function(r){switch(r.tag){case 3:var o=r.stateNode;if(o.current.memoizedState.isDehydrated){var d=ct(o.pendingLanes);d!==0&&(rr(o,d|1),zs(o,W()),(Vt&6)===0&&(ka=W()+500,Br()))}break;case 13:Ao(function(){var m=dr(r,1);if(m!==null){var y=Rs();Mi(m,r,1,y)}}),$f(r,1)}},Ps=function(r){if(r.tag===13){var o=dr(r,134217728);if(o!==null){var d=Rs();Mi(o,r,134217728,d)}$f(r,134217728)}},al=function(r){if(r.tag===13){var o=Wr(r),d=dr(r,o);if(d!==null){var m=Rs();Mi(d,r,o,m)}$f(r,o)}},ll=function(){return Gt},cl=function(r,o){var d=Gt;try{return Gt=r,o()}finally{Gt=d}},Pt=function(r,o,d){switch(o){case"input":if(Ce(r,d),o=d.name,d.type==="radio"&&o!=null){for(d=r;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+o)+'][type="radio"]'),o=0;o<d.length;o++){var m=d[o];if(m!==r&&m.form===r.form){var y=tu(m);if(!y)throw Error(n(90));je(m),Ce(m,y)}}}break;case"textarea":_e(r,d);break;case"select":o=d.value,o!=null&&ke(r,!!d.multiple,o,!1)}},Ut=Mf,dt=Ao;var iN={usingClientEntryPoint:!1,Events:[bl,da,tu,zt,Yt,Mf]},Il={findFiberByHostInstance:So,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},rN={bundleType:Il.bundleType,version:Il.version,rendererPackageName:Il.rendererPackageName,rendererConfig:Il.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(r){return r=us(r),r===null?null:r.stateNode},findFiberByHostInstance:Il.findFiberByHostInstance||nN,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 $u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$u.isDisabled&&$u.supportsFiber)try{Qe=$u.inject(rN),Rt=$u}catch{}}return Fs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=iN,Fs.createPortal=function(r,o){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ff(o))throw Error(n(200));return tN(r,o,null,d)},Fs.createRoot=function(r,o){if(!Ff(r))throw Error(n(299));var d=!1,m="",y=bw;return o!=null&&(o.unstable_strictMode===!0&&(d=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onRecoverableError!==void 0&&(y=o.onRecoverableError)),o=Bf(r,1,!1,null,null,d,!1,m,y),r[ar]=o.current,_l(r.nodeType===8?r.parentNode:r),new zf(o)},Fs.findDOMNode=function(r){if(r==null)return null;if(r.nodeType===1)return r;var o=r._reactInternals;if(o===void 0)throw typeof r.render=="function"?Error(n(188)):(r=Object.keys(r).join(","),Error(n(268,r)));return r=us(o),r=r===null?null:r.stateNode,r},Fs.flushSync=function(r){return Ao(r)},Fs.hydrate=function(r,o,d){if(!Ou(o))throw Error(n(200));return Bu(null,r,o,!0,d)},Fs.hydrateRoot=function(r,o,d){if(!Ff(r))throw Error(n(405));var m=d!=null&&d.hydratedSources||null,y=!1,C="",B=bw;if(d!=null&&(d.unstable_strictMode===!0&&(y=!0),d.identifierPrefix!==void 0&&(C=d.identifierPrefix),d.onRecoverableError!==void 0&&(B=d.onRecoverableError)),o=yw(o,null,r,1,d??null,y,!1,C,B),r[ar]=o.current,_l(r),m)for(r=0;r<m.length;r++)d=m[r],y=d._getVersion,y=y(d._source),o.mutableSourceEagerHydrationData==null?o.mutableSourceEagerHydrationData=[d,y]:o.mutableSourceEagerHydrationData.push(d,y);return new Du(o)},Fs.render=function(r,o,d){if(!Ou(o))throw Error(n(200));return Bu(null,r,o,!1,d)},Fs.unmountComponentAtNode=function(r){if(!Ou(r))throw Error(n(40));return r._reactRootContainer?(Ao(function(){Bu(null,null,r,!1,function(){r._reactRootContainer=null,r[ar]=null})}),!0):!1},Fs.unstable_batchedUpdates=Mf,Fs.unstable_renderSubtreeIntoContainer=function(r,o,d,m){if(!Ou(d))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return Bu(r,o,d,!1,m)},Fs.version="18.3.1-next-f1338f8080-20240426",Fs}var Aw;function pN(){if(Aw)return Wf.exports;Aw=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Wf.exports=fN(),Wf.exports}var jw;function mN(){if(jw)return zu;jw=1;var t=pN();return zu.createRoot=t.createRoot,zu.hydrateRoot=t.hydrateRoot,zu}var gN=mN();const vN=Yg(gN),dm="nc_token",hm="nc:auth-invalid",fm="nc:token-not-remembered";function _N(t){return typeof t=="string"&&t.startsWith("/api/")&&!t.startsWith("/api/route/")}const _c=(t,e)=>{try{return t()}catch{return e}};function b1(t={}){return{local:t.local!==void 0?t.local:_c(()=>globalThis.localStorage,null),session:t.session!==void 0?t.session:_c(()=>globalThis.sessionStorage,null)}}const Mw=t=>_c(()=>t?String(t.getItem(dm)||"").trim():"","");function yN(t){const{local:e,session:n}=b1(t);return Mw(e)||Mw(n)||""}function S1(t,{remember:e=!0,local:n,session:s}={}){const i=String(t||"").trim();if(!i)return{ok:!1,where:null};const a=b1({local:n,session:s}),c=e?[["local",a.local,a.session],["session",a.session,a.local]]:[["session",a.session,a.local],["local",a.local,a.session]];for(const[u,h,f]of c)if(h&&_c(()=>(h.setItem(dm,i),!0),!1))return _c(()=>{f&&f.removeItem(dm)},null),{ok:!0,where:u};return{ok:!1,where:null}}function Tw(t,e,n){if(!(!n||n.status!==401||!_N(t)))try{window.dispatchEvent(new CustomEvent(hm,{detail:{token:e,path:t}}))}catch{}}const wN=8e3,bN=4e3,x1=8e3;function SN(t){const e=new AbortController,n=setTimeout(()=>e.abort(new DOMException("timeout","TimeoutError")),t);return{signal:e.signal,cancel:()=>clearTimeout(n),controller:e}}function qn(t,e,n={}){const s=Number(n.timeoutMs);if(!Number.isFinite(s)||s<=0)return fetch(t,{...n,headers:{...n.headers||{},Authorization:`Bearer ${e}`}}).then(_=>(Tw(t,e,_),_));const{signal:i,cancel:a,controller:c}=SN(s),u=n.signal,h=()=>c.abort(u.reason),f=()=>{a(),u&&u.removeEventListener("abort",h)};if(u){if(u.aborted)return f(),c.abort(u.reason),Promise.reject(u.reason instanceof Error?u.reason:new DOMException("aborted","AbortError"));u.addEventListener("abort",h,{once:!0})}const{timeoutMs:g,...v}=n;return fetch(t,{...v,signal:i,headers:{...v.headers||{},Authorization:`Bearer ${e}`}}).then(_=>(_.__cleanupTimeout=f,Tw(t,e,_),_),_=>{throw f(),_})}const k1=t=>`nc_seen_${t}`;async function it(t,e,n={}){const s=await qn(t,e,{method:n.method||"GET",headers:{"content-type":"application/json"},body:n.body?JSON.stringify(n.body):void 0,timeoutMs:n.timeoutMs,signal:n.signal});let i;try{try{i=await s.json()}catch(a){if(a&&(a.name==="AbortError"||a.name==="TimeoutError"))throw a;i={}}}finally{typeof s.__cleanupTimeout=="function"&&s.__cleanupTimeout()}if(!s.ok){const a=new Error(i.error||`HTTP ${s.status}`);throw a.status=s.status,a.data=i,a}return i}const yn=t=>Array.isArray(t)&&t.length?`/api/route/${t.map(encodeURIComponent).join("/")}/_`:"/api",Pn=(t,e)=>`${yn(t)}/fleet/${e}`;async function xN(t,e,n,{signal:s}={}){const i=await qn(`${yn(e)}/panel/${encodeURIComponent(n)}/ticket`,t,{method:"POST",signal:s}),a=await i.json().catch(()=>({}));return i.status===200&&a&&typeof a.ticket=="string"?{ok:!0,ticket:a.ticket}:i.status===403&&a&&a.reason==="panel-not-granted"?{ok:!1,cause:"not-granted"}:i.status===403?{ok:!1,cause:"node-refused"}:i.status===404?{ok:!1,cause:"no-panel"}:i.status===401?{ok:!1,cause:"unauthorized"}:{ok:!1,cause:"denied"}}const Qa=(t,e,n)=>it(Pn(e,"status"),t,n),C1=6e4,kN=(t,e,n)=>it(Pn(n,"up"),t,{method:"POST",body:e,timeoutMs:C1}),E1=(t,e,n)=>it(Pn(n,"down"),t,{method:"POST",body:e,timeoutMs:C1}),N1=(t,e,n)=>it(Pn(n,"boot"),t,{method:"POST",body:e}),tc=(t,e,n)=>it(Pn(n,"restart"),t,{method:"POST",body:{cell:e}}),Gd=(t,e)=>it(Pn(e,"definitions"),t),CN=(t,e)=>it(Pn(e,"credentials/status"),t),Pw=(t,e,n,s)=>it(Pn(s,"credentials/set"),t,{method:"POST",body:{envKey:e,value:n}}),EN=(t,e,n)=>it(Pn(n,"credentials/remove"),t,{method:"POST",body:{envKey:e}}),NN=(t,e,n)=>it(Pn(n,"define-engine"),t,{method:"POST",body:{def:e}}),RN=(t,e,n,s,i)=>it(Pn(i,"edit-engine"),t,{method:"POST",body:{id:e,patch:n,envChanges:s}}),LN=(t,e,n)=>it(Pn(n,"remove-engine"),t,{method:"POST",body:{id:e}}),AN=(t,e,n)=>it(Pn(n,"define-model"),t,{method:"POST",body:{def:e}}),jN=(t,e,n,s)=>it(Pn(s,"remove-model"),t,{method:"POST",body:{id:e,engine:n}}),MN=(t,e,n,s)=>it(Pn(s,"model-test"),t,{method:"POST",body:{engine:e,model:n}}),TN=(t,e,n)=>it(Pn(n,"define-cell"),t,{method:"POST",body:{def:e}}),R1=(t,e,n,s)=>it(Pn(s,"edit-cell"),t,{method:"POST",body:{id:e,patch:n}}),L1=(t,e,n=!1,s)=>it(Pn(s,"remove-cell"),t,{method:"POST",body:{id:e,stop:n}}),PN=(t,e,n)=>it(Pn(n,"import-cell"),t,{method:"POST",body:e}),IN=(t,e,n)=>it(Pn(n,"restore-cells"),t,{method:"POST",body:{cells:e}}),DN=(t,e,n,s,i)=>it(Pn(s,"restore-engines"),t,{method:"POST",body:{engines:e,overwrite:!!n,...Array.isArray(i)&&i.length?{models:i}:{}}}),Xg=(t,e,n)=>it(`${yn(n)}/sessions/${encodeURIComponent(e)}`,t,{method:"DELETE"}),A1=(t,e,n,s)=>it(`${yn(s)}/sessions/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{technical:!!n}}),Jg=(t,e,n)=>it(`${yn(n)}/fs/dirs${e?`?path=${encodeURIComponent(e)}`:""}`,t),j1=(t,e={})=>it("/api/settings",t,e),ON=(t,e={})=>it("/api/nodes",t,e),BN=(t,e={})=>it("/api/peers",t,e),M1=(t,e=[],n={})=>it(`${yn(e)}/vl-nodes`,t,{timeoutMs:bN,...n}),Iw=(t,e,n,s={},i=[])=>it(`${yn(i)}/vl-nodes/${encodeURIComponent(e)}/commands`,t,{method:"POST",body:{kind:n,args:s}}),$N=(t,e,n=0,s=[])=>it(`${yn(s)}/vl-nodes/${encodeURIComponent(e)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,t),T1=(t,e={})=>it("/api/topology",t,e),Qg=(t,e,n={})=>it(`${yn(e)}/sessions`,t,n),Ic=(t,e,n={})=>it(`${yn(e)}/config`,t,n),Dw=(t,e,n={})=>it(`${yn(e)}/topology`,t,n),kd=(t,e)=>it("/api/settings/config",t,{method:"POST",body:e}),zN=t=>it("/api/settings/ai-desktop",t),P1=(t,e)=>it("/api/settings/ai-desktop",t,{method:"POST",body:{enabled:e}}),FN=t=>it("/api/settings/token/rotate",t,{method:"POST"}),HN=(t,e)=>it("/api/settings/nodes/pair",t,{method:"POST",body:e}),UN=(t,e,n=[])=>it(`${yn(n)}/settings/peering/invite`,t,{method:"POST",body:e||{}}),I1=(t,e,n)=>it(`/api/settings/nodes/${encodeURIComponent(e)}/label`,t,{method:"PATCH",body:{label:n}}),WN=(t,e={})=>it("/api/settings/node-aliases",t,e),qN=(t,e,n)=>it(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{alias:n}}),Ow=(t,e)=>it(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"DELETE"}),Vf=(t,e,n)=>it(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"PATCH",body:n}),KN=(t,e)=>it(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"DELETE"}),Zg=(t,e,n)=>it(`/api/settings/nodes/${encodeURIComponent(e)}/${n}`,t,{method:"POST"}),VN=(t,e,n)=>it(`/api/settings/nodes/${encodeURIComponent(e)}/share`,t,{method:"PATCH",body:{shared:n}}),YN=(t,e,n,s=[])=>it(`/api/settings/nodes/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{visibility:n,selected:s}}),GN=t=>it("/api/settings/audio",t),XN=(t,e)=>it("/api/settings/audio/consent",t,{method:"PATCH",body:{consent:e}}),JN=t=>it("/api/settings/audio/test",t,{method:"POST",body:{}}),QN=t=>it("/api/settings/audio/stop",t,{method:"POST",body:{}}),ZN=t=>it("/api/settings/audio/groups",t),e5=(t,e,n)=>it(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"PUT",body:n}),t5=(t,e)=>it(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"DELETE"}),n5=t=>it("/api/settings/service/regenerate",t,{method:"POST"}),s5=t=>it("/api/settings/update/check",t,{method:"POST"}),i5=t=>it("/api/settings/update/apply",t,{method:"POST"}),Xd=(t,e)=>`${yn(t)}/diagnostics/${e}`,r5=(t,e=[])=>it(Xd(e,"status"),t),o5=(t,{after:e=0,limit:n=200}={},s=[])=>it(`${Xd(s,"logs")}?after=${encodeURIComponent(e)}&limit=${encodeURIComponent(n)}`,t),Bw=(t,e,n,s=[])=>it(Xd(s,"verbose"),t,{method:"PATCH",body:{enabled:e,durationSeconds:n}}),a5=(t,e=[])=>it(Xd(e,"logs"),t,{method:"DELETE"}),l5=(t,e=!0)=>it(`/api/asks${e?"?open=1":""}`,t),c5=(t,e,n)=>it(`/api/asks/${encodeURIComponent(e)}/answer`,t,{method:"POST",body:{text:n}}),u5=(t,e)=>it(`/api/asks/${encodeURIComponent(e)}`,t,{method:"DELETE"}),d5=(t,{ownerId:e,askId:n,text:s,requestId:i})=>it("/api/asks-relay",t,{method:"POST",body:{ownerId:e,askId:n,text:s,requestId:i}}),h5=(t,{ownerId:e,askId:n,requestId:s})=>it("/api/asks-relay",t,{method:"POST",body:{action:"verify",ownerId:e,askId:n,requestId:s}}),f5=(t,{ownerId:e,askId:n},s={})=>it(`/api/asks-relay/capability?ownerId=${encodeURIComponent(e)}&askId=${encodeURIComponent(n)}&dismissals=1`,t,{timeoutMs:8e3,...s}),p5=t=>it("/api/asks-relay/state",t),m5=(t,{ownerId:e,askId:n})=>it("/api/asks-relay",t,{method:"POST",body:{action:"dismiss",ownerId:e,askId:n}}),g5=(t,{ownerId:e,askId:n})=>it("/api/asks-relay",t,{method:"POST",body:{action:"dismiss-local",ownerId:e,askId:n}}),v5=t=>it("/api/feed-state",t),Fu=(t,e=[])=>it(`${yn(e)}/decks`,t,e.length?{timeoutMs:wN}:{}),$w=(t,e,n=[])=>it(`${yn(n)}/decks`,t,{method:"POST",body:{name:e}}),Hu=(t,e,n,s,i=[],a)=>it(`${yn(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",body:{layout:n,expectedRevision:s,...a?{floating:a}:{}}}),_5=(t,e,n,s,i=[],a)=>qn(`${yn(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",keepalive:!0,headers:{"content-type":"application/json"},body:JSON.stringify({layout:n,expectedRevision:s,...a?{floating:a}:{}})}),y5=(t,e,n,s,i=[])=>it(`${yn(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{name:n,expectedRevision:s}}),w5=(t,e,n,s=[])=>it(`${yn(s)}/decks/${encodeURIComponent(e)}`,t,{method:"DELETE",body:{expectedRevision:n}}),Jd=(t,e=[],n)=>it(`${yn(e)}/live-host`,t,n),Qd=(t,e,n,s=[])=>it(`${yn(s)}/live-host/designate`,t,{method:"POST",body:{cellId:e,expectedRevision:n}}),Zd=(t,e,n=[])=>it(`${yn(n)}/live-host/clear`,t,{method:"POST",body:{expectedRevision:e}});function eh(){let t=0,e=!1;return{begin(){return e?null:(e=!0,t+=1,t)},end(n){n===t&&(e=!1)},reset(){t+=1,e=!1},isCurrent(n){return n!==null&&n===t}}}const D1=4e3,zw=3500,ro=new Map,O1=()=>typeof document<"u"&&document.visibilityState==="hidden";let Fw=!1;function b5(){Fw||typeof document>"u"||!document.addEventListener||(Fw=!0,document.addEventListener("visibilitychange",()=>{const t=O1();for(const e of ro.values())t?e.timer!==null&&(clearInterval(e.timer),e.timer=null):e.timer===null&&(e.timer=setInterval(e.cycle,D1),e.cycle())}))}const ev=(t,e)=>`${t}|${JSON.stringify(e||[])}`;function S5(t){return t&&t.length?`/api/route/${t.map(encodeURIComponent).join("/")}/_`:"/api"}function x5(t,e){const n=eh(),s={token:t,route:e,consumers:new Set,snapshot:null,timer:null},i=async()=>{const a=n.begin();if(a!==null)try{let c=null,u=null;try{c=await(await qn(`${S5(e)}/sessions`,t,{timeoutMs:zw})).json()}catch(g){u=g}let h=null,f=null;try{h=await Qa(t,e,{timeoutMs:zw})}catch(g){f=g}if(!n.isCurrent(a))return;s.snapshot={at:Date.now(),sessionsJson:c,sessionsError:u,fs:h,fleetError:f};for(const g of s.consumers)g(s.snapshot)}finally{n.end(a)}};return s.cycle=i,b5(),O1()||(s.timer=setInterval(i,D1)),i(),s}function Cd(t,e,n){const s=ev(t,e);let i=ro.get(s);return i||(i=x5(t,e),ro.set(s,i)),i.consumers.add(n),i.snapshot&&n(i.snapshot),()=>{const a=ro.get(s);a&&(a.consumers.delete(n),a.consumers.size===0&&(a.timer!==null&&clearInterval(a.timer),ro.delete(s)))}}function nc(t,e=null){if(e!==null){const s=ro.get(ev(e,t));return s?s.snapshot:null}const n=`|${JSON.stringify(t||[])}`;for(const[s,i]of ro)if(s.endsWith(n))return i.snapshot;return null}function sc(t,e=null){const n=`|${JSON.stringify(t||[])}`;for(const[s,i]of ro)(e!==null?s===ev(e,t):s.endsWith(n))&&i.cycle()}const k5={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"}),broadcast:l.jsxs(l.Fragment,{children:[l.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),l.jsx("path",{d:"M7.6 16.4a6.2 6.2 0 0 1 0-8.8"}),l.jsx("path",{d:"M16.4 7.6a6.2 6.2 0 0 1 0 8.8"}),l.jsx("path",{d:"M4.6 19.4a10.6 10.6 0 0 1 0-14.8"}),l.jsx("path",{d:"M19.4 4.6a10.6 10.6 0 0 1 0 14.8"})]}),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"})]}),download:l.jsxs(l.Fragment,{children:[l.jsx("path",{d:"M12 4v10"}),l.jsx("polyline",{points:"8 10 12 14 16 10"}),l.jsx("path",{d:"M5 15v4a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-4"})]}),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"})]}),gpu:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"}),l.jsx("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),l.jsx("path",{d:"M9 3v3M15 3v3M9 18v3M15 18v3M3 9h3M3 15h3M18 9h3M18 15h3"})]}),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"})]}),splitView:l.jsxs(l.Fragment,{children:[l.jsx("rect",{x:"3.5",y:"5.5",width:"17",height:"13",rx:"1.5"}),l.jsx("line",{x1:"14.5",y1:"5.5",x2:"14.5",y2:"18.5"})]}),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 Tt({name:t,size:e=20}){return l.jsx("svg",{className:"nc-icon",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:k5[t]||null})}const tv=["it","en","es"];function C5(){try{const t=typeof navigator<"u"&&navigator.language||"",e=String(t).slice(0,2).toLowerCase();return tv.includes(e)?e:"en"}catch{return"en"}}const cd=C5(),B1="nc_lang",pm="nc-lang";function $1(){return typeof localStorage<"u"?localStorage:null}const Uu={it:{"update-available":"nuova versione {v} disponibile","update-stale":"interfaccia non allineata: stai eseguendo la v{browser}, il nodo serve la v{ui}. ricarica senza cache; se persiste, riavvia il nodo","reload-no-cache":"ricarica senza cache","update-installed-restart":"versione {v} installata: riavvia il nodo","update-dismiss":"chiudi","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","node-sessions-unverified":"sessioni non verificate","tile-unverified":"dato non verificato","cell-working":"al lavoro","cell-idle":"in attesa","cell-stopped":"ferma","cell-permission":"attesa permesso","cell-unknown":"non verificato","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","power-starting":"avvio…","power-stopping":"arresto…","fleet-up-slow":"avvio in corso: controlla lo stato","fleet-down-slow":"arresto in corso: controlla lo stato","fleet-up-duplicate":"già in esecuzione",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):","auth-invalid":"Il nodo non accetta più questo token (ruotato o sostituito). Inserisci quello nuovo: le tue preferenze non vengono toccate.","auth-not-remembered":"Il browser non ha permesso di ricordare il token su questo device: dovrai reinserirlo alla prossima apertura.","remember-device":"ricorda su questo device","zoom-out":"testo più piccolo","zoom-in":"testo più grande","dual-swap":"scambia le due celle","dual-go-to":"Vai a {cell}","dual-close":"chiudi la seconda cella","dual-focus":"cella col focus","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"motore grafico: richiesto {requested}, in uso {effective} — tocca per cambiare (ricarica il terminale)",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-frame-loading":"pannello montato: caricamento in corso","panel-frame-error":"Il frame del pannello non si è caricato: il biglietto può essere scaduto (30 s di vita, monouso) o la destinazione è irraggiungibile. Riprova: verrà chiesto un biglietto nuovo.","popup-drag-hint":"trascina per spostare; doppio clic per tornare al centro","popup-resize-hint":"trascina per ridimensionare","panel-timeout":"Il pannello non ha risposto in tempo: servizio lento a partire o sovraccarico. Riprova tra poco.","panel-retry":"Riprova","live-host-indicator":"Live host: {cell} · {mode} · {state}","live-host-indicator-none":"Live host: nessuna cella designata","live-host-remote":"altro nodo","live-host-mode-native":"nativa (thread)","live-host-mode-tmux":"tmux","live-host-mode-unknown":"modalità sconosciuta","live-host-state-none":"nessuna designazione","live-host-state-designated":"designata, thread assente","live-host-state-thread-present":"thread presente ma inattivo","live-host-state-thread-active":"thread attivo","live-host-state-thread-unknown":"stato del thread sconosciuto","live-host-designated":"Live host: {cell}","live-host-cleared":"Live host rimosso","live-host-action-use":"Usa come host Live","live-host-action-remove":"Rimuovi host Live","cell-actions-title":"Azioni di {cell}","cell-actions-open":"Azioni cella","cell-actions-live-assign":"Assegna la Live","cell-actions-live-remove":"Togli la Live","cell-actions-pin":"Fissa in cima","cell-actions-unpin":"Togli in cima","cell-actions-boot":"Avvio al boot","cell-actions-watch":"Guarda dal vivo","bar-menu-open":"Altre azioni","bar-menu-keyboard":"Tastiera di scrittura","bar-menu-keyboard-desc":"sotto il terminale","bar-menu-files":"File della cella","bar-menu-files-desc":"inbox · outbox","bar-menu-files-setting-desc":"mostra il tasto nella barra","bar-menu-panel":"Pannello della cella","bar-menu-panel-desc":"solo se la cella ne ha uno","bar-menu-renderer":"Renderer GPU","bar-menu-renderer-desc":"cambiarlo ricarica la pagina","bar-keyboard-button":"Tasto tastiera in barra","bar-keyboard-button-desc":"mostra il tasto della tastiera di scrittura","bar-panel-button":"Tasto AI Desktop in barra","bar-panel-button-desc":"mostra il tasto, se la cella ha un pannello","cell-switcher-group":"Celle {node}","cell-switcher-group-local":"locale","cell-switcher-tap-hint":"Tocca una cella per l'anteprima · tocca di nuovo per aprirla","cell-switcher-two-taps":"2 tocchi = apri","cell-switcher-side-add":"affianca nella doppia vista","cell-switcher-side-remove":"togli dalla doppia vista","cell-switcher-preview-word":"ANTEPRIMA","cell-switcher-preview-readonly":"sola lettura","cell-peek-expand":"Apri la finestra","ai-desktop-title":"Desktop grafico","ai-desktop":"Desktop grafico attivo","ai-desktop-help":"Il container del desktop parte con la spunta e si ferma senza; il tasto del pannello appare solo con il desktop attivo.","ai-desktop-confirm-stop":"Il desktop è in esecuzione: spegnerlo chiude le sessioni aperte nel container. Continuare?","panel-start-desktop":"Avvia il desktop","live-host-stale-revision":"designazione non applicata: lo stato e' cambiato nel frattempo, riprova","live-host-not-local":"quella cella non appartiene a questo nodo","live-host-unavailable":"flotta non disponibile su questo nodo, riprova tra poco","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.","host-thread-designated":"cella designata; thread assente","host-thread-present":"thread presente ma inattivo","host-thread-active":"thread attivo","host-thread-unknown":"stato del thread sconosciuto",windows:"{n} finestre","empty-files":"vuota","files-download":"scarica file","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-inbox":"Inbox","attach-inbox-done":"{n} file aggiunti all'inbox","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-stale":"aggiornamento in ritardo","deck-stale-badge":"in ritardo","deck-owner-unavailable":"nodo owner non condiviso o non raggiungibile","deck-owner-reconnecting":"riconnessione…","deck-owner-stale":"owner stale (route in cache)","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","tile-detach":"Stacca e fai flottare","tile-reattach":"Rimetti nella griglia","tile-minimize":"Riduci","tile-restore":"Ripristina","grid-resize-cols":"Trascina per ridimensionare le due colonne; doppio clic: metà e metà. Alt: niente aggancio.","grid-resize-rows":"Trascina per ridimensionare le due finestre; doppio clic: metà e metà. Alt: niente aggancio.","device-name-ask-title":"Come si chiama questo dispositivo?","device-name-ask-text":"Il nome non è ricavabile dall’host: serve per mostrarti il nodo Locale e per presentarti ai nuovi nodi.","device-name-save":"Salva nome","device-name-later":"Più tardi","wizard-device-name":"Dai un nome a questo dispositivo (lo vedrai come nodo Locale e i nuovi nodi lo useranno).","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-stale":"Lettura della flotta non riuscita: l’elenco delle celle potrebbe non essere aggiornato.","reorder-blocked":"Riordino non applicato: la lista è incompleta in questo momento, il tuo ordine è al sicuro.","prefs-journal":"Diario preferenze (ultime 50 scritture)","prefs-journal-empty":"Nessuna modifica registrata finora.","prefs-journal-copy":"Copia diario","prefs-journal-clear":"Svuota diario","prefs-persist":"Storage persistente","prefs-persist-unknown":"non ancora verificato","prefs-before":"prima","prefs-after":"dopo","prefs-visible":"visibili","prefs-backup":"Backup preferenze","prefs-sync":"Copia sul nodo","prefs-conflict":"Le preferenze di questo dispositivo e la copia sul nodo sono diverse. Quale tieni?","prefs-keep-local":"Tieni questo dispositivo","prefs-use-server":"Usa la copia del nodo","prefs-export":"Esporta preferenze","prefs-import":"Importa preferenze","prefs-export-done":"File di preferenze creato (senza token).","prefs-import-done":"Preferenze importate.","prefs-import-confirm":"Sostituire le preferenze di questo dispositivo con quelle del file?","prefs-import-wrong":"Il file non è un file di preferenze NexusCrew.","prefs-import-bad":"Il file di preferenze non è valido: non è stato importato nulla.","prefs-import-storage":"Il browser ha rifiutato la scrittura: nulla è stato importato e le preferenze di questo dispositivo sono intatte.","fleet-off":"Flotta non disponibile: nessuna cella.","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-providers-shell":"shell dell'utente","fleet-credential-source-keys-file":"file chiavi","fleet-credential-source-secure-file":"file secure (precede)","fleet-credential-source-legacy":"file legacy","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. Alpha","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-readiness-degraded":"Avviata senza conferma di prontezza: potrebbe non elaborare subito. Verifica nel terminale prima di affidarle un incarico.","fleet-mcp-degraded":"Avviata in degrado, server MCP non pronti:","fleet-vl-prompt-degraded":"Avviata senza il prompt di cella: la versione di vl sul nodo non lo supporta (serve 0.3.1+). La cella lavora senza la sua identità: aggiorna vl prima di affidarle un incarico.","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-never":"mai controllato","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","peer-cause-assente":"peer non risponde — in attesa che torni (interrogazioni diradate)","peer-cause-nega":"peer nega l'accesso — concedi il permesso sul nodo remoto","peer-cause-rotta":"rotta inesistente sul peer — aggiorna il nodo","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","remote-notices-title":"Notifiche da altri nodi","ask-dismiss":"Scarta la domanda","ask-dismiss-local":"Scarta su questo nodo","ask-dismiss-local-pending":"Chiusura sul nodo origine in attesa","ask-dismiss-local-blocked":"Scarto solo locale: chiusura remota non autorizzata","ask-dismiss-unconfirmed":"Scarto locale non confermato: la domanda resta visibile.","ask-reply-ph":"scrivi la risposta…","push-enable":"attiva notifiche push","push-disable":"disattiva notifiche push","push-on":"push attive su questo device","push-local-off":"silenzia su questo browser","push-local-on":"riattiva su questo browser","push-local-help":"solo questo browser: la UI e le notifiche dell’owner restano attive","push-local-off-note":"avvisi di sistema spenti su questo browser; la UI resta attiva","push-local-disabled":"gli avvisi push sono spenti su questo browser: riattivali qui","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-preview-voice-error":"La prova vocale è fallita: voce o audio non disponibili. Controlla la voce selezionata e riprova.","notification-speech-preview-timeout":"La prova vocale è fallita: nessuna risposta dal motore vocale. Controlla la voce selezionata 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-verify-failed":"Verifica non riuscita: riprova tra poco.","cell-switcher-select":"seleziona una cella","cell-switcher-open":"apri cella","cell-switcher-show-all":"tutte","cell-switcher-title":"Celle","cell-switcher-filter":"filtro: attive o tutte","cell-switcher-live-strip":"Live su {cell} · {mode}","cell-switcher-show-active":"attive","cell-switcher-close":"chiudi selettore celle","cell-switcher-here":"sei qui","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","selection-changed":"il testo sotto la selezione è cambiato","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.","feed-owner":"da nodo federato","ask-remote-readonly":"Risposta non concessa per questo nodo: card in sola lettura.","ask-capability-loading":"Verifica del permesso di risposta…","ask-capability-unreachable":"Percorso di risposta non raggiungibile.","ask-capability-unsupported":"Questo nodo non supporta la verifica del permesso di risposta.","ask-remote-no-feed":"Non ricevi gli eventi di questo nodo: attiva la ricezione (nodes edit <peer> --events-receive true).","ask-feed-stale":"Feed di questo nodo non attivo (dati non aggiornati): la card potrebbe essere già chiusa altrove.","ask-dismiss-stale":"Scarta comunque: lo scarto parte via relay diretto, ma finché il feed è fermo la card può non riflettere lo stato reale.","ask-uncertain":"Esito incerto: la risposta potrebbe essere arrivata. Verifica lo stato prima di riprovare.","ask-reconcile":"Risposta bloccata da un invio precedente: riconcilia con il nodo che ha fatto la domanda. Nessun nuovo invio.","ask-verify":"Verifica stato","peer-access":"Ruolo del peer","peer-access-help":"Cosa questo peer può fare su questa installazione. Il nome è derivato dai permessi effettivi: applicare un preset riscrive l’intero vettore in una sola scrittura.","peer-access-current":"Adesso","peer-access-preset":"Preset da applicare","peer-access-preset-none":"scegli un preset","peer-access-matrix":"Cosa cambierebbe","peer-access-apply":"Applica il preset","peer-access-changed-hint":"Le righe evidenziate cambiano con la conferma.","peer-access-unchanged":"Il preset non cambierebbe nulla.","peer-access-conflict":"Questo peer è stato modificato altrove: stato ricaricato, riapplica il preset se serve.","access-label-admin":"amministratore","access-label-user":"utente","access-label-nexushost":"nexushost","access-label-custom":"personalizzato","access-label-unconfigured":"non configurato","access-grant-cellVisibility":"Celle visibili","access-grant-eventsAccess":"Eventi","access-grant-eventsReceive":"Ricezione eventi e notifiche","access-grant-nodeEventsAccess":"Eventi di nodo","access-grant-askReplyAccess":"Risposte alle domande","access-grant-filesReadAccess":"Lettura file","access-grant-liveHostAccess":"Host Live","access-grant-panelAccess":"Pannelli","access-grant-peerOperatorAccess":"Operatore dei peer","access-value-all":"tutte","access-value-selected":"selezionate","access-value-none":"nessuna","access-value-yes":"sì","access-value-no":"no","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","update-stale":"interface out of step: you are running v{browser}, the node is serving v{ui}. reload without cache; if it persists, restart the node","reload-no-cache":"reload without cache","update-installed-restart":"version {v} installed: restart the node","update-dismiss":"close","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","node-sessions-unverified":"sessions not verified","tile-unverified":"data not verified","cell-working":"working","cell-idle":"idle","cell-stopped":"stopped","cell-permission":"permission required","cell-unknown":"unverified","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","power-starting":"starting…","power-stopping":"stopping…","fleet-up-slow":"start still in progress: check the cell state","fleet-down-slow":"stop still in progress: check the cell state","fleet-up-duplicate":"already running",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):","auth-invalid":"The node no longer accepts this token (rotated or replaced). Enter the new one: your preferences are left untouched.","auth-not-remembered":"The browser did not allow remembering the token on this device: you will have to enter it again next time.","remember-device":"remember on this device","zoom-out":"smaller text","zoom-in":"bigger text","dual-swap":"swap the two cells","dual-go-to":"Go to {cell}","dual-close":"close the second cell","dual-focus":"focused cell","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"graphics renderer: requested {requested}, in use {effective} — tap to switch (reloads the terminal)",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-frame-loading":"panel mounted: loading in progress","panel-frame-error":"The panel frame did not load: the ticket may have expired (30 s lifetime, single-use) or the destination is unreachable. Retry: a fresh ticket will be requested.","popup-drag-hint":"drag to move; double-click to recenter","popup-resize-hint":"drag to resize","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-indicator":"Live host: {cell} · {mode} · {state}","live-host-indicator-none":"Live host: no cell designated","live-host-remote":"other node","live-host-mode-native":"native (thread)","live-host-mode-tmux":"tmux","live-host-mode-unknown":"unknown mode","live-host-state-none":"no designation","live-host-state-designated":"designated, no thread","live-host-state-thread-present":"thread present but idle","live-host-state-thread-active":"thread active","live-host-state-thread-unknown":"thread status unknown","live-host-designated":"Live host: {cell}","live-host-cleared":"Live host removed","live-host-action-use":"Use as Live host","live-host-action-remove":"Remove Live host","cell-actions-title":"Actions for {cell}","cell-actions-open":"Cell actions","cell-actions-live-assign":"Assign Live","cell-actions-live-remove":"Remove Live","cell-actions-pin":"Pin to top","cell-actions-unpin":"Unpin from top","cell-actions-boot":"Boot at startup","cell-actions-watch":"Watch live","bar-menu-open":"More actions","bar-menu-keyboard":"On-screen keyboard","bar-menu-keyboard-desc":"below the terminal","bar-menu-files":"Cell files","bar-menu-files-desc":"inbox · outbox","bar-menu-files-setting-desc":"show the button in the bar","bar-menu-panel":"Cell panel","bar-menu-panel-desc":"only if the cell has one","bar-menu-renderer":"GPU renderer","bar-menu-renderer-desc":"switching reloads the page","bar-keyboard-button":"Keyboard button in the bar","bar-keyboard-button-desc":"show the on-screen keyboard button","bar-panel-button":"AI Desktop button in the bar","bar-panel-button-desc":"show the button if the cell has a panel","cell-switcher-group":"Cells {node}","cell-switcher-group-local":"local","cell-switcher-tap-hint":"Tap a cell for the preview · tap again to open it","cell-switcher-two-taps":"2 taps = open","cell-switcher-side-add":"open side by side","cell-switcher-side-remove":"remove from side by side","cell-switcher-preview-word":"PREVIEW","cell-switcher-preview-readonly":"read only","cell-peek-expand":"Open window","ai-desktop-title":"Graphical desktop","ai-desktop":"Graphical desktop enabled","ai-desktop-help":"The desktop container starts with the switch and stops without it; the panel button appears only while the desktop is running.","ai-desktop-confirm-stop":"The desktop is running: stopping it closes the sessions open in the container. Continue?","panel-start-desktop":"Start the desktop","live-host-stale-revision":"designation not applied: the state changed meanwhile, try again","live-host-not-local":"that cell does not belong to this node","live-host-unavailable":"fleet not available on this node, try again shortly","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.","host-thread-designated":"cell designated; thread absent","host-thread-present":"thread present but idle","host-thread-active":"thread active","host-thread-unknown":"thread status unknown",windows:"{n} windows","empty-files":"empty","files-download":"download file","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-inbox":"Add Inbox","attach-inbox-done":"{n} file added to the inbox","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-stale":"refresh running late","deck-stale-badge":"running late","deck-owner-unavailable":"owner node is not shared or reachable","deck-owner-reconnecting":"reconnecting…","deck-owner-stale":"stale owner (cached route)","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","tile-detach":"Detach and float","tile-reattach":"Put back in the grid","tile-minimize":"Minimize","tile-restore":"Restore","grid-resize-cols":"Drag to resize the two columns; double click: half and half. Alt: no snapping.","grid-resize-rows":"Drag to resize the two windows; double click: half and half. Alt: no snapping.","visibility-relay":"relay only","device-name-ask-title":"What is this device called?","device-name-ask-text":"The name cannot be derived from the host: it labels your Locale node and introduces you to new nodes.","device-name-save":"Save name","device-name-later":"Later","wizard-device-name":"Name this device (you will see it as your Locale node; new nodes will use it).","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-stale":"Fleet read failed: the cell list may not be up to date.","reorder-blocked":"Reorder not applied: the list is incomplete right now, your order is safe.","prefs-journal":"Preferences journal (last 50 writes)","prefs-journal-empty":"No changes recorded yet.","prefs-journal-copy":"Copy journal","prefs-journal-clear":"Clear journal","prefs-persist":"Persistent storage","prefs-persist-unknown":"not checked yet","prefs-before":"before","prefs-after":"after","prefs-visible":"visible","prefs-backup":"Preferences backup","prefs-sync":"Copy on the node","prefs-conflict":"This device's preferences and the copy on the node differ. Which one do you keep?","prefs-keep-local":"Keep this device","prefs-use-server":"Use server copy","prefs-export":"Export preferences","prefs-import":"Import preferences","prefs-export-done":"Preferences file created (no token inside).","prefs-import-done":"Preferences imported.","prefs-import-confirm":"Replace this device's preferences with the ones in the file?","prefs-import-wrong":"The file is not a NexusCrew preferences file.","prefs-import-bad":"The preferences file is not valid: nothing was imported.","prefs-import-storage":"The browser refused the write: nothing was imported and this device's preferences are untouched.","fleet-off":"Fleet unavailable: no cells.","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-providers-shell":"user shell","fleet-credential-source-keys-file":"keys file","fleet-credential-source-secure-file":"secure file (wins)","fleet-credential-source-legacy":"legacy file","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. Alpha","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-readiness-degraded":"Started without readiness confirmation: it may not process right away. Check its terminal before assigning work.","fleet-mcp-degraded":"Started degraded, MCP servers not ready:","fleet-vl-prompt-degraded":"Started without its cell prompt: the vl version on this node does not support it (0.3.1+ required). The cell works without its identity: upgrade vl before assigning work.","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-never":"never checked","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","peer-cause-assente":"peer not responding — waiting for it to come back (polls spaced out)","peer-cause-nega":"peer denies access — grant permission on the remote node","peer-cause-rotta":"route no longer exists on the peer — update the node","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","remote-notices-title":"Notifications from other nodes","ask-dismiss":"Dismiss question","ask-dismiss-local":"Dismiss on this node","ask-dismiss-local-pending":"Closure on the origin node is pending","ask-dismiss-local-blocked":"Local dismissal only: remote closure is not authorized","ask-dismiss-unconfirmed":"Local dismissal was not confirmed: the question remains visible.","ask-reply-ph":"type your answer…","push-enable":"enable push notifications","push-disable":"disable push notifications","push-on":"push active on this device","push-local-off":"silence on this browser","push-local-on":"re-enable on this browser","push-local-help":"this browser only: the UI and the owner’s own notifications stay on","push-local-off-note":"system alerts off on this browser; the UI stays live","push-local-disabled":"push alerts are off on this browser: re-enable them here","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-preview-voice-error":"The voice test failed: voice or audio unavailable. Check the selected voice and try again.","notification-speech-preview-timeout":"The voice test failed: no response from the speech engine. Check the selected voice 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-verify-failed":"Could not verify: try again shortly.","cell-switcher-select":"select a cell","cell-switcher-open":"open cell","cell-switcher-show-all":"all","cell-switcher-title":"Cells","cell-switcher-filter":"filter: active or all","cell-switcher-live-strip":"Live on {cell} · {mode}","cell-switcher-show-active":"active","cell-switcher-close":"close cell switcher","cell-switcher-here":"you are here","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","selection-changed":"text under the selection changed","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.","feed-owner":"from federated node","ask-remote-readonly":"Reply not granted for this node: card is read-only.","ask-capability-loading":"Checking reply permission…","ask-capability-unreachable":"Reply route is unreachable.","ask-capability-unsupported":"This owner does not support reply capability.","ask-remote-no-feed":"You are not receiving this node’s events: enable receiving (nodes edit <peer> --events-receive true).","ask-feed-stale":"This node’s feed is inactive (stale data): the card may already be closed elsewhere.","ask-dismiss-stale":"Dismiss anyway: the dismissal is forwarded directly to the node, but while the feed is down the card may not reflect the live state.","ask-uncertain":"Uncertain outcome: the answer may have arrived. Verify the status before retrying.","ask-reconcile":"Answer blocked by a previous send: reconcile with the asking node. No blind resend.","ask-verify":"Verify status","peer-access":"Peer role","peer-access-help":"What this peer may do on this installation. The name is derived from the effective grants: applying a preset rewrites the whole vector in one write.","peer-access-current":"Now","peer-access-preset":"Preset to apply","peer-access-preset-none":"pick a preset","peer-access-matrix":"What would change","peer-access-apply":"Apply the preset","peer-access-changed-hint":"The highlighted rows change on confirmation.","peer-access-unchanged":"The preset would change nothing.","peer-access-conflict":"This peer was changed elsewhere: state reloaded, apply the preset again if needed.","access-label-admin":"administrator","access-label-user":"user","access-label-nexushost":"nexushost","access-label-custom":"custom","access-label-unconfigured":"not configured","access-grant-cellVisibility":"Visible cells","access-grant-eventsAccess":"Events","access-grant-eventsReceive":"Receive events and notifications","access-grant-nodeEventsAccess":"Node events","access-grant-askReplyAccess":"Ask replies","access-grant-filesReadAccess":"File reading","access-grant-liveHostAccess":"Live host","access-grant-panelAccess":"Panels","access-grant-peerOperatorAccess":"Peer operator","access-value-all":"all","access-value-selected":"selected","access-value-none":"none","access-value-yes":"yes","access-value-no":"no","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","update-stale":"interfaz desalineada: ejecutas la v{browser}, el nodo sirve la v{ui}. recarga sin caché; si persiste, reinicia el nodo","reload-no-cache":"recargar sin caché","update-installed-restart":"versión {v} instalada: reinicia el nodo","update-dismiss":"cerrar","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","node-sessions-unverified":"sesiones sin verificar","tile-unverified":"dato sin verificar","cell-working":"trabajando","cell-idle":"en espera","cell-stopped":"parada","cell-permission":"esperando permiso","cell-unknown":"sin verificar","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","power-starting":"iniciando…","power-stopping":"deteniendo…","fleet-up-slow":"inicio en curso: comprueba el estado","fleet-down-slow":"parada en curso: comprueba el estado","fleet-up-duplicate":"ya en ejecución",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):","auth-invalid":"El nodo ya no acepta este token (rotado o reemplazado). Introduce el nuevo: tus preferencias no se tocan.","auth-not-remembered":"El navegador no permitió recordar el token en este dispositivo: tendrás que introducirlo de nuevo la próxima vez.","remember-device":"recordar en este dispositivo","zoom-out":"texto más pequeño","zoom-in":"texto más grande","dual-swap":"intercambiar las dos celdas","dual-go-to":"Ir a {cell}","dual-close":"cerrar la segunda celda","dual-focus":"celda con el foco","terminal-renderer-webgl":"WebGL","terminal-renderer-dom":"DOM","terminal-renderer-switch":"motor gráfico: solicitado {requested}, en uso {effective} — toca para cambiar (recarga el terminal)",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-frame-loading":"panel montado: carga en curso","panel-frame-error":"El frame del panel no se ha cargado: el billete puede haber caducado (30 s de vida, monouso) o el destino es inaccesible. Reintenta: se pedirá un billete nuevo.","popup-drag-hint":"arrastra para mover; doble clic para volver al centro","popup-resize-hint":"arrastra para redimensionar","panel-timeout":"El panel no respondió a tiempo: servicio lento en arrancar o sobrecargado. Reintenta en un momento.","panel-retry":"Reintentar","live-host-indicator":"Live host: {cell} · {mode} · {state}","live-host-indicator-none":"Live host: ninguna celda designada","live-host-remote":"otro nodo","live-host-mode-native":"nativa (thread)","live-host-mode-tmux":"tmux","live-host-mode-unknown":"modo desconocido","live-host-state-none":"sin designación","live-host-state-designated":"designada, sin thread","live-host-state-thread-present":"thread presente pero inactivo","live-host-state-thread-active":"thread activo","live-host-state-thread-unknown":"estado del thread desconocido","live-host-designated":"Live host: {cell}","live-host-cleared":"Live host quitado","live-host-action-use":"Usar como host Live","live-host-action-remove":"Quitar host Live","cell-actions-title":"Acciones de {cell}","cell-actions-open":"Acciones de celda","cell-actions-live-assign":"Asignar Live","cell-actions-live-remove":"Quitar Live","cell-actions-pin":"Fijar arriba","cell-actions-unpin":"Quitar de arriba","cell-actions-boot":"Arranque al inicio","cell-actions-watch":"Ver en vivo","bar-menu-open":"Más acciones","bar-menu-keyboard":"Teclado en pantalla","bar-menu-keyboard-desc":"bajo el terminal","bar-menu-files":"Archivos de la celda","bar-menu-files-desc":"inbox · outbox","bar-menu-files-setting-desc":"muestra el botón en la barra","bar-menu-panel":"Panel de la celda","bar-menu-panel-desc":"solo si la celda tiene uno","bar-menu-renderer":"Renderer GPU","bar-menu-renderer-desc":"cambiarlo recarga la página","bar-keyboard-button":"Botón de teclado en la barra","bar-keyboard-button-desc":"muestra el botón del teclado en pantalla","bar-panel-button":"Botón de AI Desktop en la barra","bar-panel-button-desc":"muestra el botón si la celda tiene panel","cell-switcher-group":"Celdas {node}","cell-switcher-group-local":"local","cell-switcher-tap-hint":"Toca una celda para la vista previa · toca de nuevo para abrirla","cell-switcher-two-taps":"2 toques = abrir","cell-switcher-side-add":"abrir en paralelo","cell-switcher-side-remove":"quitar de la vista en paralelo","cell-switcher-preview-word":"VISTA PREVIA","cell-switcher-preview-readonly":"solo lectura","cell-peek-expand":"Abrir ventana","ai-desktop-title":"Escritorio gráfico","ai-desktop":"Escritorio gráfico activo","ai-desktop-help":"El contenedor del escritorio arranca con la casilla y se detiene sin ella; el botón del panel aparece solo con el escritorio activo.","ai-desktop-confirm-stop":"El escritorio está en ejecución: detenerlo cierra las sesiones abiertas en el contenedor. ¿Continuar?","panel-start-desktop":"Iniciar el escritorio","live-host-stale-revision":"designación no aplicada: el estado cambió mientras tanto, reintenta","live-host-not-local":"esa celda no pertenece a este nodo","live-host-unavailable":"flota no disponible en este nodo, reintenta en un momento","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.","host-thread-designated":"celda designada; thread ausente","host-thread-present":"thread presente pero inactivo","host-thread-active":"thread activo","host-thread-unknown":"estado del thread desconocido",windows:"{n} ventanas","empty-files":"vacía","files-download":"descargar archivo","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-inbox":"Inbox","attach-inbox-done":"{n} archivos añadidos a la bandeja","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-stale":"actualización con retraso","deck-stale-badge":"con retraso","deck-owner-unavailable":"el nodo propietario no está compartido o accesible","deck-owner-reconnecting":"reconectando…","deck-owner-stale":"owner stale (ruta en caché)","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.","tile-detach":"Desprender y flotar","tile-reattach":"Volver a la cuadrícula","tile-minimize":"Minimizar","tile-restore":"Restaurar","grid-resize-cols":"Arrastra para redimensionar las dos columnas; doble clic: mitad y mitad. Alt: sin imán.","grid-resize-rows":"Arrastra para redimensionar las dos ventanas; doble clic: mitad y mitad. Alt: sin imán.","scan-qr":"escanear QR","pairing-qr-invalid":"QR de emparejamiento no válido","device-name-ask-title":"¿Cómo se llama este dispositivo?","device-name-ask-text":"El nombre no se puede deducir del host: identifica tu nodo Locale y te presenta a los nodos nuevos.","device-name-save":"Guardar nombre","device-name-later":"Más tarde","wizard-device-name":"Ponle nombre a este dispositivo (lo verás como nodo Locale; los nodos nuevos lo usarán).","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-stale":"Fallo de lectura de la flota: la lista de celdas puede no estar actualizada.","reorder-blocked":"Reordenación no aplicada: la lista está incompleta ahora, tu orden está a salvo.","prefs-journal":"Diario de preferencias (últimas 50 escrituras)","prefs-journal-empty":"Aún no hay cambios registrados.","prefs-journal-copy":"Copiar diario","prefs-journal-clear":"Vaciar diario","prefs-persist":"Almacenamiento persistente","prefs-persist-unknown":"sin comprobar","prefs-before":"antes","prefs-after":"después","prefs-visible":"visibles","prefs-backup":"Copia de preferencias","prefs-sync":"Copia en el nodo","prefs-conflict":"Las preferencias de este dispositivo y la copia del nodo difieren. ¿Cuál conservas?","prefs-keep-local":"Conservar este dispositivo","prefs-use-server":"Usar la copia del nodo","prefs-export":"Exportar preferencias","prefs-import":"Importar preferencias","prefs-export-done":"Archivo de preferencias creado (sin token).","prefs-import-done":"Preferencias importadas.","prefs-import-confirm":"¿Reemplazar las preferencias de este dispositivo con las del archivo?","prefs-import-wrong":"El archivo no es un archivo de preferencias de NexusCrew.","prefs-import-bad":"El archivo de preferencias no es válido: no se importó nada.","prefs-import-storage":"El navegador rechazó la escritura: no se importó nada y las preferencias de este dispositivo están intactas.","fleet-off":"Flota no disponible: sin celdas.","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-providers-shell":"shell del usuario","fleet-credential-source-keys-file":"archivo de claves","fleet-credential-source-secure-file":"archivo secure (prevale)","fleet-credential-source-legacy":"archivo legacy","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-readiness-degraded":"Iniciada sin confirmación de preparación: puede que no procese de inmediato. Revisa su terminal antes de asignarle trabajo.","fleet-mcp-degraded":"Iniciada en degradación, servidores MCP no listos:","fleet-vl-prompt-degraded":"Iniciada sin el prompt de celda: la versión de vl en este nodo no lo admite (se requiere 0.3.1+). La celda trabaja sin su identidad: actualiza vl antes de asignarle trabajo.","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-never":"nunca comprobado","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","peer-cause-assente":"el peer no responde — esperando a que vuelva (consultas espaciadas)","peer-cause-nega":"el peer deniega el acceso — concede el permiso en el nodo remoto","peer-cause-rotta":"la ruta ya no existe en el peer — actualiza el nodo","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","remote-notices-title":"Notificaciones de otros nodos","ask-dismiss":"Descartar la pregunta","ask-dismiss-local":"Descartar en este nodo","ask-dismiss-local-pending":"Cierre en el nodo de origen pendiente","ask-dismiss-local-blocked":"Descarte solo local: el cierre remoto no está autorizado","ask-dismiss-unconfirmed":"Descarte local no confirmado: la pregunta sigue visible.","ask-reply-ph":"escribe la respuesta…","push-enable":"activar notificaciones push","push-disable":"desactivar notificaciones push","push-on":"push activas en este dispositivo","push-local-off":"silenciar en este navegador","push-local-on":"reactivar en este navegador","push-local-help":"solo este navegador: la UI y las notificaciones del owner siguen activas","push-local-off-note":"avisos del sistema apagados en este navegador; la UI sigue activa","push-local-disabled":"los avisos push están apagados en este navegador: reactívalos aquí","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-preview-voice-error":"La prueba de voz falló: voz o audio no disponibles. Comprueba la voz seleccionada e inténtalo de nuevo.","notification-speech-preview-timeout":"La prueba de voz falló: sin respuesta del motor de voz. Comprueba la voz seleccionada e inténtalo de nuevo.","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-verify-failed":"No se pudo verificar: inténtalo de nuevo dentro de poco.","cell-switcher-select":"selecciona una celda","cell-switcher-open":"abrir celda","cell-switcher-show-all":"todas","cell-switcher-title":"Celdas","cell-switcher-filter":"filtro: activas o todas","cell-switcher-live-strip":"Live en {cell} · {mode}","cell-switcher-show-active":"activas","cell-switcher-close":"cerrar selector de celdas","cell-switcher-here":"estás aquí","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","selection-changed":"el texto bajo la selección cambió","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.","feed-owner":"de nodo federado","ask-remote-readonly":"Respuesta no concedida para este nodo: tarjeta en solo lectura.","ask-capability-loading":"Comprobando el permiso de respuesta…","ask-capability-unreachable":"Ruta de respuesta no accesible.","ask-capability-unsupported":"Este nodo no admite la comprobación del permiso de respuesta.","ask-remote-no-feed":"No recibes los eventos de este nodo: activa la recepción (nodes edit <peer> --events-receive true).","ask-feed-stale":"El feed de este nodo está inactivo (datos no actualizados): la tarjeta puede estar ya cerrada en otro sitio.","ask-dismiss-stale":"Descartar igualmente: el descarto se reenvía directamente al nodo, pero con el feed caído la tarjeta puede no reflejar el estado real.","ask-uncertain":"Resultado incierto: la respuesta pudo llegar. Verifica el estado antes de reintentar.","ask-reconcile":"Respuesta bloqueada por un envío previo: reconcilia con el nodo que hizo la pregunta. Ningún reenvío a ciegas.","ask-verify":"Verificar estado","peer-access":"Rol del par","peer-access-help":"Lo que este par puede hacer en esta instalación. El nombre se deriva de los permisos efectivos: aplicar un preajuste reescribe todo el vector en una sola escritura.","peer-access-current":"Ahora","peer-access-preset":"Preajuste a aplicar","peer-access-preset-none":"elige un preajuste","peer-access-matrix":"Qué cambiaría","peer-access-apply":"Aplicar el preajuste","peer-access-changed-hint":"Las filas resaltadas cambian al confirmar.","peer-access-unchanged":"El preajuste no cambiaría nada.","peer-access-conflict":"Este par fue modificado en otro lugar: estado recargado, vuelve a aplicar el preajuste si hace falta.","access-label-admin":"administrador","access-label-user":"usuario","access-label-nexushost":"nexushost","access-label-custom":"personalizado","access-label-unconfigured":"no configurado","access-grant-cellVisibility":"Celdas visibles","access-grant-eventsAccess":"Eventos","access-grant-eventsReceive":"Recepción de eventos y notificaciones","access-grant-nodeEventsAccess":"Eventos de nodo","access-grant-askReplyAccess":"Respuestas a preguntas","access-grant-filesReadAccess":"Lectura de archivos","access-grant-liveHostAccess":"Host Live","access-grant-panelAccess":"Paneles","access-grant-peerOperatorAccess":"Operador de pares","access-value-all":"todas","access-value-selected":"seleccionadas","access-value-none":"ninguna","access-value-yes":"sí","access-value-no":"no","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 Ed(){const t=$1(),e=t?t.getItem(B1):null;return tv.includes(e)?e:cd}function E5(t){const e=$1();if(e)try{e.setItem(B1,t)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(pm))}function p(t){const e=Ed(),n=Uu[e]||Uu[cd];return Object.prototype.hasOwnProperty.call(n,t)?n[t]:Object.prototype.hasOwnProperty.call(Uu[cd],t)?Uu[cd][t]:t}function N5(t){return typeof window>"u"?()=>{}:(window.addEventListener(pm,t),()=>window.removeEventListener(pm,t))}const z1=tv,nv="nc_popup_assetto",R5=320,L5=240,A5=1100,j5=820,Hw=48,M5=44;function F1(){return{vw:window.innerWidth||1024,vh:window.innerHeight||768}}function ic(t){const{vw:e,vh:n}=F1(),s=Math.max(R5,Math.min(t.w,e)),i=Math.max(L5,Math.min(t.h,n)),a=Math.max(-(s-Hw),Math.min(t.x,e-Hw)),c=Math.max(0,Math.min(t.y,Math.max(0,n-M5)));return{x:a,y:c,w:s,h:i}}function Uw(){try{const t=window.localStorage.getItem(nv);if(!t)return null;const e=JSON.parse(t);return!e||![e.x,e.y,e.w,e.h].every(n=>typeof n=="number"&&Number.isFinite(n))?null:ic(e)}catch{return null}}function T5(t){try{window.localStorage.setItem(nv,JSON.stringify(t))}catch{}}function P5(){const[t,e]=w.useState(()=>typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 720px)").matches);return w.useEffect(()=>{if(typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 720px)"),s=i=>e(!!(i&&i.matches));if(typeof n.addEventListener=="function")return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),t}function H1({title:t,subtitle:e,onClose:n,children:s}){const i=w.useRef(null),a=w.useRef(null),c=P5(),[u,h]=w.useState(()=>c?null:Uw()),f=w.useRef(null),[g,v]=w.useState(!1),_=w.useCallback(()=>{n&&n()},[n]);w.useEffect(()=>{const R=S=>{S.key==="Escape"&&(S.stopPropagation(),_())};return document.addEventListener("keydown",R,!0),()=>document.removeEventListener("keydown",R,!0)},[_]),w.useEffect(()=>{const R=a.current;R&&typeof R.focus=="function"&&R.focus()},[]);const b=()=>{const{vw:R,vh:S}=F1(),j=Math.min(A5,Math.floor(R*.96)),E=Math.min(j5,Math.floor(S*.92));return ic({x:Math.round((R-j)/2),y:Math.round((S-E)/2),w:j,h:E})},x=R=>S=>{if(c||S.button!==0||S.target&&typeof S.target.closest=="function"&&S.target.closest(".nc-popup-chiudi"))return;S.preventDefault();const j=u||b();f.current={mode:R,startX:S.clientX,startY:S.clientY,base:j},h(j),v(!0)};w.useEffect(()=>{if(!g)return;const R=j=>{const E=f.current;if(!E)return;const F=j.clientX-E.startX,$=j.clientY-E.startY;E.mode==="move"?h(ic({...E.base,x:E.base.x+F,y:E.base.y+$})):h(ic({...E.base,w:E.base.w+F,h:E.base.h+$}))},S=()=>{f.current=null,v(!1),h(j=>(j&&T5(j),j))};return window.addEventListener("mousemove",R),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",S)}},[g]);const L=()=>{if(!c){f.current=null,v(!1),h(null);try{window.localStorage.removeItem(nv)}catch{}}};w.useEffect(()=>{if(c)return;const R=()=>h(S=>S&&ic(S));return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[c]),w.useEffect(()=>{c||h(R=>R||Uw())},[c]);const k=!!(u&&!c);return l.jsxs("div",{className:"nc-popup-velo",onMouseDown:R=>{R.target===R.currentTarget&&_()},role:"presentation",children:[l.jsxs("div",{className:k?"nc-popup nc-popup-libera":"nc-popup",style:k?{left:u.x,top:u.y,width:u.w,height:u.h}:void 0,ref:i,role:"dialog","aria-modal":"true","aria-label":t||p("panel"),children:[l.jsxs("header",{className:"nc-popup-testa",onMouseDown:x("move"),onDoubleClick:L,title:p("popup-drag-hint"),children:[l.jsxs("span",{className:"nc-popup-titolo",children:[t,e?l.jsx("small",{className:"nc-popup-sub",children:e}):null]}),l.jsx("button",{type:"button",ref:a,className:"nc-popup-chiudi",onClick:_,title:p("close"),"aria-label":p("close"),children:"✕"})]}),l.jsx("div",{className:"nc-popup-corpo",children:s}),!c&&l.jsx("div",{className:"nc-popup-angolo",onMouseDown:x("resize"),title:p("popup-resize-hint"),role:"presentation"})]}),g&&l.jsx("div",{className:"nc-popup-velo-drag",role:"presentation"})]})}const yc="none",U1="favorite",W1="designated",q1="thread-present",K1="thread-active",V1="thread-unknown",Y1=new Set([W1,q1,K1,V1]);function G1(t){return t==="absent"?W1:t==="present"?q1:t==="active"?K1:V1}function I5(t){return Y1.has(t)?`host-thread-${t.replace("thread-","")}`:null}function Nd({hostCell:t,threadStatus:e,pins:n=[],item:s}){const i=s&&s.value&&typeof s.value.cell=="string"?s.value.cell:null;return i!=null&&t===i?G1(e):Array.isArray(n)&&s&&n.includes(s.key)?U1:yc}const D5=Object.freeze(["live","grace","expired","none","unavailable"]);function mm(t,e){return!Y1.has(t)||!D5.includes(e)?null:`host-lease-${e}`}const O5="local";function Cs(t){return Array.isArray(t)&&t.length?t.join("/"):O5}function gm(t){return(t&&t.data&&typeof t.data=="object"?t.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":"live-host-error"}function Ww(t){const e=t&&t.status;return(t&&t.data&&typeof t.data=="object"?t.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":e===409?"live-host-stale-revision":e===404?"live-host-not-local":e===503?"live-host-unavailable":gm(t)}async function th({action:t,cellId:e,route:n=[],token:s,api:i={}}={}){const a=i.getLiveHost||(g=>Jd(s,g)),c=i.designateHostCell||((g,v,_)=>Qd(s,g,v,_)),u=i.clearHostCell||((g,v)=>Zd(s,g,v));let h;try{h=await a(n)}catch(g){return{ok:!1,messageKey:Ww(g),error:g}}const f=Number.isInteger(h&&h.revision)?h.revision:0;try{if(t==="remove"){const v=await u(f,n);return{ok:!0,messageKey:"live-host-cleared",hostCell:v&&typeof v.hostCell=="string"?v.hostCell:null,revision:v&&v.revision}}const g=await c(e,f,n);return{ok:!0,messageKey:"live-host-designated",hostCell:g&&typeof g.hostCell=="string"?g.hostCell:e,revision:g&&g.revision}}catch(g){return{ok:!1,messageKey:Ww(g),error:g}}}/**
|
|
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 X1=Object.defineProperty,B5=Object.getOwnPropertyDescriptor,$5=(t,e)=>{for(var n in e)X1(t,n,{get:e[n],enumerable:!0})},jn=(t,e,n,s)=>{for(var i=s>1?void 0:s?B5(e,n):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(i=(s?c(e,n,i):c(i))||i);return s&&i&&X1(e,n,i),i},at=(t,e)=>(n,s)=>e(n,s,t),qw="Terminal input",vm={get:()=>qw,set:t=>qw=t},Kw="Too much output to announce, navigate to rows manually to read",_m={get:()=>Kw,set:t=>Kw=t};function z5(t){return t.replace(/\r?\n/g,"\r")}function F5(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function H5(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function U5(t,e,n,s){if(t.stopPropagation(),t.clipboardData){let i=t.clipboardData.getData("text/plain");J1(i,e,n,s)}}function J1(t,e,n,s){t=z5(t),t=F5(t,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(t,!0),e.value=""}function Q1(t,e,n){let s=n.getBoundingClientRect(),i=t.clientX-s.left-10,a=t.clientY-s.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${i}px`,e.style.top=`${a}px`,e.style.zIndex="1000",e.focus()}function Vw(t,e,n,s,i){Q1(t,e,n),i&&s.rightClickSelect(t),e.value=s.selectionText,e.select()}function io(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function nh(t,e=0,n=t.length){let s="";for(let i=e;i<n;++i){let a=t[i];a>65535?(a-=65536,s+=String.fromCharCode((a>>10)+55296)+String.fromCharCode(a%1024+56320)):s+=String.fromCharCode(a)}return s}var W5=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,n){let s=e.length;if(!s)return 0;let i=0,a=0;if(this._interim){let c=e.charCodeAt(a++);56320<=c&&c<=57343?n[i++]=(this._interim-55296)*1024+c-56320+65536:(n[i++]=this._interim,n[i++]=c),this._interim=0}for(let c=a;c<s;++c){let u=e.charCodeAt(c);if(55296<=u&&u<=56319){if(++c>=s)return this._interim=u,i;let h=e.charCodeAt(c);56320<=h&&h<=57343?n[i++]=(u-55296)*1024+h-56320+65536:(n[i++]=u,n[i++]=h);continue}u!==65279&&(n[i++]=u)}return i}},q5=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,n){let s=e.length;if(!s)return 0;let i=0,a,c,u,h,f=0,g=0;if(this.interim[0]){let b=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let L=0,k;for(;(k=this.interim[++L]&63)&&L<4;)x<<=6,x|=k;let R=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,S=R-L;for(;g<S;){if(g>=s)return 0;if(k=e[g++],(k&192)!==128){g--,b=!0;break}else this.interim[L++]=k,x<<=6,x|=k&63}b||(R===2?x<128?g--:n[i++]=x:R===3?x<2048||x>=55296&&x<=57343||x===65279||(n[i++]=x):x<65536||x>1114111||(n[i++]=x)),this.interim.fill(0)}let v=s-4,_=g;for(;_<s;){for(;_<v&&!((a=e[_])&128)&&!((c=e[_+1])&128)&&!((u=e[_+2])&128)&&!((h=e[_+3])&128);)n[i++]=a,n[i++]=c,n[i++]=u,n[i++]=h,_+=4;if(a=e[_++],a<128)n[i++]=a;else if((a&224)===192){if(_>=s)return this.interim[0]=a,i;if(c=e[_++],(c&192)!==128){_--;continue}if(f=(a&31)<<6|c&63,f<128){_--;continue}n[i++]=f}else if((a&240)===224){if(_>=s)return this.interim[0]=a,i;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=s)return this.interim[0]=a,this.interim[1]=c,i;if(u=e[_++],(u&192)!==128){_--;continue}if(f=(a&15)<<12|(c&63)<<6|u&63,f<2048||f>=55296&&f<=57343||f===65279)continue;n[i++]=f}else if((a&248)===240){if(_>=s)return this.interim[0]=a,i;if(c=e[_++],(c&192)!==128){_--;continue}if(_>=s)return this.interim[0]=a,this.interim[1]=c,i;if(u=e[_++],(u&192)!==128){_--;continue}if(_>=s)return this.interim[0]=a,this.interim[1]=c,this.interim[2]=u,i;if(h=e[_++],(h&192)!==128){_--;continue}if(f=(a&7)<<18|(c&63)<<12|(u&63)<<6|h&63,f<65536||f>1114111)continue;n[i++]=f}}return i}},Z1="",oo=" ",Dc=class ex{constructor(){this.fg=0,this.bg=0,this.extended=new Rd}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new ex;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}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}},Rd=class tx{constructor(e=0,n=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new tx(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},bi=class nx extends Dc{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Rd,this.combinedData=""}static fromCharData(e){let n=new nx;return n.setFromCharData(e),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?io(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let n=!1;if(e[1].length>2)n=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(s-55296)*1024+i-56320+65536|e[2]<<22:n=!0}else n=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;n&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Yw="di$target",ym="di$dependencies",Yf=new Map;function K5(t){return t[ym]||[]}function as(t){if(Yf.has(t))return Yf.get(t);let e=function(n,s,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");V5(e,n,i)};return e._id=t,Yf.set(t,e),e}function V5(t,e,n){e[Yw]===e?e[ym].push({id:t,index:n}):(e[ym]=[{id:t,index:n}],e[Yw]=e)}var Ms=as("BufferService"),sx=as("CoreMouseService"),Zo=as("CoreService"),Y5=as("CharsetService"),sv=as("InstantiationService"),ix=as("LogService"),Ts=as("OptionsService"),rx=as("OscLinkService"),G5=as("UnicodeService"),Oc=as("DecorationService"),wm=class{constructor(e,n,s){this._bufferService=e,this._optionsService=n,this._oscLinkService=s}provideLinks(e,n){var v;let s=this._bufferService.buffer.lines.get(e-1);if(!s){n(void 0);return}let i=[],a=this._optionsService.rawOptions.linkHandler,c=new bi,u=s.getTrimmedLength(),h=-1,f=-1,g=!1;for(let _=0;_<u;_++)if(!(f===-1&&!s.hasContent(_))){if(s.loadCell(_,c),c.hasExtendedAttrs()&&c.extended.urlId)if(f===-1){f=_,h=c.extended.urlId;continue}else g=c.extended.urlId!==h;else f!==-1&&(g=!0);if(g||f!==-1&&_===u-1){let b=(v=this._oscLinkService.getLinkData(h))==null?void 0:v.uri;if(b){let x={start:{x:f+1,y:e},end:{x:_+(!g&&_===u-1?1:0),y:e}},L=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let k=new URL(b);["http:","https:"].includes(k.protocol)||(L=!0)}catch{L=!0}L||i.push({text:b,range:x,activate:(k,R)=>a?a.activate(k,R,x):X5(k,R),hover:(k,R)=>{var S;return(S=a==null?void 0:a.hover)==null?void 0:S.call(a,k,R,x)},leave:(k,R)=>{var S;return(S=a==null?void 0:a.leave)==null?void 0:S.call(a,k,R,x)}})}g=!1,c.hasExtendedAttrs()&&c.extended.urlId?(f=_,h=c.extended.urlId):(f=-1,h=-1)}}n(i)}};wm=jn([at(0,Ms),at(1,Ts),at(2,rx)],wm);function X5(t,e){if(confirm(`Do you want to navigate to ${e}?
|
|
52
|
-
|
|
53
|
-
WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var sh=as("CharSizeService"),Nr=as("CoreBrowserService"),iv=as("MouseService"),Rr=as("RenderService"),J5=as("SelectionService"),ox=as("CharacterJoinerService"),Za=as("ThemeService"),ax=as("LinkProviderService"),Q5=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Gw.isErrorNoTelemetry(e)?new Gw(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(n=>{n(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)}},Z5=new Q5;function ud(t){eR(t)||Z5.onUnexpectedError(t)}var bm="Canceled";function eR(t){return t instanceof tR?!0:t instanceof Error&&t.name===bm&&t.message===bm}var tR=class extends Error{constructor(){super(bm),this.name=this.message}};function nR(t){return new Error(`Illegal argument: ${t}`)}var Gw=class Sm extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Sm)return e;let n=new Sm;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},xm=class lx extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,lx.prototype)}};function Zs(t,e=0){return t[t.length-(1+e)]}var sR;(t=>{function e(a){return a<0}t.isLessThan=e;function n(a){return a<=0}t.isLessThanOrEqual=n;function s(a){return a>0}t.isGreaterThan=s;function i(a){return a===0}t.isNeitherLessOrGreaterThan=i,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(sR||(sR={}));function iR(t,e){let n=this,s=!1,i;return function(){return s||(s=!0,e||(i=t.apply(n,arguments))),i}}var cx;(t=>{function e(E){return E&&typeof E=="object"&&typeof E[Symbol.iterator]=="function"}t.is=e;let n=Object.freeze([]);function s(){return n}t.empty=s;function*i(E){yield E}t.single=i;function a(E){return e(E)?E:i(E)}t.wrap=a;function c(E){return E||n}t.from=c;function*u(E){for(let F=E.length-1;F>=0;F--)yield E[F]}t.reverse=u;function h(E){return!E||E[Symbol.iterator]().next().done===!0}t.isEmpty=h;function f(E){return E[Symbol.iterator]().next().value}t.first=f;function g(E,F){let $=0;for(let G of E)if(F(G,$++))return!0;return!1}t.some=g;function v(E,F){for(let $ of E)if(F($))return $}t.find=v;function*_(E,F){for(let $ of E)F($)&&(yield $)}t.filter=_;function*b(E,F){let $=0;for(let G of E)yield F(G,$++)}t.map=b;function*x(E,F){let $=0;for(let G of E)yield*F(G,$++)}t.flatMap=x;function*L(...E){for(let F of E)yield*F}t.concat=L;function k(E,F,$){let G=$;for(let K of E)G=F(G,K);return G}t.reduce=k;function*R(E,F,$=E.length){for(F<0&&(F+=E.length),$<0?$+=E.length:$>E.length&&($=E.length);F<$;F++)yield E[F]}t.slice=R;function S(E,F=Number.POSITIVE_INFINITY){let $=[];if(F===0)return[$,E];let G=E[Symbol.iterator]();for(let K=0;K<F;K++){let Y=G.next();if(Y.done)return[$,t.empty()];$.push(Y.value)}return[$,{[Symbol.iterator](){return G}}]}t.consume=S;async function j(E){let F=[];for await(let $ of E)F.push($);return Promise.resolve(F)}t.asyncToArray=j})(cx||(cx={}));function Go(t){if(cx.is(t)){let e=[];for(let n of t)if(n)try{n.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function rR(...t){return _n(()=>Go(t))}function _n(t){return{dispose:iR(()=>{t()})}}var ux=class dx{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{Go(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?dx.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};ux.DISABLE_DISPOSED_WARNING=!1;var uo=ux,$t=class{constructor(){this._store=new uo,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)}};$t.None=Object.freeze({dispose(){}});var Wa=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var n;this._isDisposed||e===this._value||((n=this._value)==null||n.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}},Sr=typeof window=="object"?window:globalThis,km=class Cm{constructor(e){this.element=e,this.next=Cm.Undefined,this.prev=Cm.Undefined}};km.Undefined=new km(void 0);var Cn=km,Xw=class{constructor(){this._first=Cn.Undefined,this._last=Cn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Cn.Undefined}clear(){let e=this._first;for(;e!==Cn.Undefined;){let n=e.next;e.prev=Cn.Undefined,e.next=Cn.Undefined,e=n}this._first=Cn.Undefined,this._last=Cn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,n){let s=new Cn(e);if(this._first===Cn.Undefined)this._first=s,this._last=s;else if(n){let a=this._last;this._last=s,s.prev=a,a.next=s}else{let a=this._first;this._first=s,s.next=a,a.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==Cn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Cn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Cn.Undefined&&e.next!==Cn.Undefined){let n=e.prev;n.next=e.next,e.next.prev=n}else e.prev===Cn.Undefined&&e.next===Cn.Undefined?(this._first=Cn.Undefined,this._last=Cn.Undefined):e.next===Cn.Undefined?(this._last=this._last.prev,this._last.next=Cn.Undefined):e.prev===Cn.Undefined&&(this._first=this._first.next,this._first.prev=Cn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Cn.Undefined;)yield e.element,e=e.next}},oR=globalThis.performance&&typeof globalThis.performance.now=="function",aR=class hx{static create(e){return new hx(e)}constructor(e){this._now=oR&&e===!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}},vs;(t=>{t.None=()=>$t.None;function e(D,I){return v(D,()=>{},0,void 0,!0,void 0,I)}t.defer=e;function n(D){return(I,O=null,M)=>{let z=!1,T;return T=D(A=>{if(!z)return T?T.dispose():z=!0,I.call(O,A)},null,M),z&&T.dispose(),T}}t.once=n;function s(D,I,O){return f((M,z=null,T)=>D(A=>M.call(z,I(A)),null,T),O)}t.map=s;function i(D,I,O){return f((M,z=null,T)=>D(A=>{I(A),M.call(z,A)},null,T),O)}t.forEach=i;function a(D,I,O){return f((M,z=null,T)=>D(A=>I(A)&&M.call(z,A),null,T),O)}t.filter=a;function c(D){return D}t.signal=c;function u(...D){return(I,O=null,M)=>{let z=rR(...D.map(T=>T(A=>I.call(O,A))));return g(z,M)}}t.any=u;function h(D,I,O,M){let z=O;return s(D,T=>(z=I(z,T),z),M)}t.reduce=h;function f(D,I){let O,M={onWillAddFirstListener(){O=D(z.fire,z)},onDidRemoveLastListener(){O==null||O.dispose()}},z=new nt(M);return I==null||I.add(z),z.event}function g(D,I){return I instanceof Array?I.push(D):I&&I.add(D),D}function v(D,I,O=100,M=!1,z=!1,T,A){let N,U,P,H=0,ie,J={leakWarningThreshold:T,onWillAddFirstListener(){N=D(ve=>{H++,U=I(U,ve),M&&!P&&(Q.fire(U),U=void 0),ie=()=>{let de=U;U=void 0,P=void 0,(!M||H>1)&&Q.fire(de),H=0},typeof O=="number"?(clearTimeout(P),P=setTimeout(ie,O)):P===void 0&&(P=0,queueMicrotask(ie))})},onWillRemoveListener(){z&&H>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,N.dispose()}},Q=new nt(J);return A==null||A.add(Q),Q.event}t.debounce=v;function _(D,I=0,O){return t.debounce(D,(M,z)=>M?(M.push(z),M):[z],I,void 0,!0,void 0,O)}t.accumulate=_;function b(D,I=(M,z)=>M===z,O){let M=!0,z;return a(D,T=>{let A=M||!I(T,z);return M=!1,z=T,A},O)}t.latch=b;function x(D,I,O){return[t.filter(D,I,O),t.filter(D,M=>!I(M),O)]}t.split=x;function L(D,I=!1,O=[],M){let z=O.slice(),T=D(U=>{z?z.push(U):N.fire(U)});M&&M.add(T);let A=()=>{z==null||z.forEach(U=>N.fire(U)),z=null},N=new nt({onWillAddFirstListener(){T||(T=D(U=>N.fire(U)),M&&M.add(T))},onDidAddFirstListener(){z&&(I?setTimeout(A):A())},onDidRemoveLastListener(){T&&T.dispose(),T=null}});return M&&M.add(N),N.event}t.buffer=L;function k(D,I){return(O,M,z)=>{let T=I(new S);return D(function(A){let N=T.evaluate(A);N!==R&&O.call(M,N)},void 0,z)}}t.chain=k;let R=Symbol("HaltChainable");class S{constructor(){this.steps=[]}map(I){return this.steps.push(I),this}forEach(I){return this.steps.push(O=>(I(O),O)),this}filter(I){return this.steps.push(O=>I(O)?O:R),this}reduce(I,O){let M=O;return this.steps.push(z=>(M=I(M,z),M)),this}latch(I=(O,M)=>O===M){let O=!0,M;return this.steps.push(z=>{let T=O||!I(z,M);return O=!1,M=z,T?z:R}),this}evaluate(I){for(let O of this.steps)if(I=O(I),I===R)break;return I}}function j(D,I,O=M=>M){let M=(...N)=>A.fire(O(...N)),z=()=>D.on(I,M),T=()=>D.removeListener(I,M),A=new nt({onWillAddFirstListener:z,onDidRemoveLastListener:T});return A.event}t.fromNodeEventEmitter=j;function E(D,I,O=M=>M){let M=(...N)=>A.fire(O(...N)),z=()=>D.addEventListener(I,M),T=()=>D.removeEventListener(I,M),A=new nt({onWillAddFirstListener:z,onDidRemoveLastListener:T});return A.event}t.fromDOMEventEmitter=E;function F(D){return new Promise(I=>n(D)(I))}t.toPromise=F;function $(D){let I=new nt;return D.then(O=>{I.fire(O)},()=>{I.fire(void 0)}).finally(()=>{I.dispose()}),I.event}t.fromPromise=$;function G(D,I){return D(O=>I.fire(O))}t.forward=G;function K(D,I,O){return I(O),D(M=>I(M))}t.runAndSubscribe=K;class Y{constructor(I,O){this._observable=I,this._counter=0,this._hasChanged=!1;let M={onWillAddFirstListener:()=>{I.addObserver(this)},onDidRemoveLastListener:()=>{I.removeObserver(this)}};this.emitter=new nt(M),O&&O.add(this.emitter)}beginUpdate(I){this._counter++}handlePossibleChange(I){}handleChange(I,O){this._hasChanged=!0}endUpdate(I){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function te(D,I){return new Y(D,I).emitter.event}t.fromObservable=te;function q(D){return(I,O,M)=>{let z=0,T=!1,A={beginUpdate(){z++},endUpdate(){z--,z===0&&(D.reportChanges(),T&&(T=!1,I.call(O)))},handlePossibleChange(){},handleChange(){T=!0}};D.addObserver(A),D.reportChanges();let N={dispose(){D.removeObserver(A)}};return M instanceof uo?M.add(N):Array.isArray(M)&&M.push(N),N}}t.fromObservableLight=q})(vs||(vs={}));var Em=class Nm{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Nm._idPool++}`,Nm.all.add(this)}start(e){this._stopWatch=new aR,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Em.all=new Set,Em._idPool=0;var lR=Em,cR=-1,fx=class px{constructor(e,n,s=(px._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,c]=this.getMostFrequentStack(),u=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${c}):`;console.warn(u),console.warn(a);let h=new hR(u,a);this._errorHandler(h)}return()=>{let a=this._stacks.get(e.value)||0;this._stacks.set(e.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,n=0;for(let[s,i]of this._stacks)(!e||n<i)&&(e=[s,i],n=i);return e}};fx._idPool=1;var uR=fx,dR=class mx{constructor(e){this.value=e}static create(){let e=new Error;return new mx(e.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
-
`).slice(2).join(`
|
|
59
|
-
`))}},hR=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},fR=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},pR=0,Gf=class{constructor(e){this.value=e,this.id=pR++}},mR=2,gR,nt=class{constructor(t){var e,n,s,i;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new uR((t==null?void 0:t.onListenerError)??ud,((n=this._options)==null?void 0:n.leakWarningThreshold)??cR):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new lR(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var t,e,n,s;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(e=this._options)==null?void 0:e.onDidRemoveLastListener)==null||n.call(e),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(t,e,n)=>{var c,u,h,f,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let v=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(v);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],b=new fR(`${v}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||ud)(b),$t.None}if(this._disposed)return $t.None;e&&(t=t.bind(e));let s=new Gf(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=dR.create(),i=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Gf?(this._deliveryQueue??(this._deliveryQueue=new vR),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(u=this._options)==null?void 0:u.onWillAddFirstListener)==null||h.call(u,this),this._listeners=s,(g=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||g.call(f,this)),this._size++;let a=_n(()=>{i==null||i(),this._removeListener(s)});return n instanceof uo?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(t){var i,a,c,u;if((a=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||a.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(u=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||u.call(c,this),this._size=0;return}let e=this._listeners,n=e.indexOf(t);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--,e[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*mR<=e.length){let h=0;for(let f=0;f<e.length;f++)e[f]?e[h++]=e[f]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=h}}_deliver(t,e){var s;if(!t)return;let n=((s=this._options)==null?void 0:s.onListenerError)||ud;if(!n){t.value(e);return}try{t.value(e)}catch(i){n(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){var e,n,s,i;if((e=this._deliveryQueue)!=null&&e.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 Gf)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(i=this._perfMon)==null||i.stop()}hasListeners(){return this._size>0}},vR=class{constructor(){this.i=-1,this.end=0}enqueue(e,n,s){this.i=0,this.end=s,this.current=e,this.value=n}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Rm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new nt,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new nt,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,n){if(this.getZoomLevel(n)===e)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),e)}setFullscreen(e,n){if(this.isFullscreen(n)===e)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Rm.INSTANCE=new Rm;var rv=Rm;function _R(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}rv.INSTANCE.onDidChangeZoomLevel;function yR(t){return rv.INSTANCE.getZoomFactor(t)}rv.INSTANCE.onDidChangeFullscreen;var el=typeof navigator=="object"?navigator.userAgent:"",Lm=el.indexOf("Firefox")>=0,wR=el.indexOf("AppleWebKit")>=0,ov=el.indexOf("Chrome")>=0,bR=!ov&&el.indexOf("Safari")>=0;el.indexOf("Electron/")>=0;el.indexOf("Android")>=0;var Xf=!1;if(typeof Sr.matchMedia=="function"){let t=Sr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Sr.matchMedia("(display-mode: fullscreen)");Xf=t.matches,_R(Sr,t,({matches:n})=>{Xf&&e.matches||(Xf=n)})}var Oa="en",Am=!1,jm=!1,dd=!1,gx=!1,Wu,hd=Oa,Jw=Oa,SR,Ti,Wo=globalThis,ms,m1;typeof Wo.vscode<"u"&&typeof Wo.vscode.process<"u"?ms=Wo.vscode.process:typeof process<"u"&&typeof((m1=process==null?void 0:process.versions)==null?void 0:m1.node)=="string"&&(ms=process);var g1,xR=typeof((g1=ms==null?void 0:ms.versions)==null?void 0:g1.electron)=="string",kR=xR&&(ms==null?void 0:ms.type)==="renderer",v1;if(typeof ms=="object"){Am=ms.platform==="win32",jm=ms.platform==="darwin",dd=ms.platform==="linux",dd&&ms.env.SNAP&&ms.env.SNAP_REVISION,ms.env.CI||ms.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Wu=Oa,hd=Oa;let t=ms.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Wu=e.userLocale,Jw=e.osLocale,hd=e.resolvedLanguage||Oa,SR=(v1=e.languagePack)==null?void 0:v1.translationsConfigFile}catch{}gx=!0}else typeof navigator=="object"&&!kR?(Ti=navigator.userAgent,Am=Ti.indexOf("Windows")>=0,jm=Ti.indexOf("Macintosh")>=0,(Ti.indexOf("Macintosh")>=0||Ti.indexOf("iPad")>=0||Ti.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,dd=Ti.indexOf("Linux")>=0,(Ti==null?void 0:Ti.indexOf("Mobi"))>=0,hd=globalThis._VSCODE_NLS_LANGUAGE||Oa,Wu=navigator.language.toLowerCase(),Jw=Wu):console.error("Unable to resolve platform.");var vx=Am,er=jm,CR=dd,Qw=gx,nr=Ti,Yr=hd,ER;(t=>{function e(){return Yr}t.value=e;function n(){return Yr.length===2?Yr==="en":Yr.length>=3?Yr[0]==="e"&&Yr[1]==="n"&&Yr[2]==="-":!1}t.isDefaultVariant=n;function s(){return Yr==="en"}t.isDefault=s})(ER||(ER={}));var NR=typeof Wo.postMessage=="function"&&!Wo.importScripts;(()=>{if(NR){let t=[];Wo.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,i=t.length;s<i;s++){let a=t[s];if(a.id===n.data.vscodeScheduleAsyncWork){t.splice(s,1),a.callback();return}}});let e=0;return n=>{let s=++e;t.push({id:s,callback:n}),Wo.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var RR=!!(nr&&nr.indexOf("Chrome")>=0);nr&&nr.indexOf("Firefox")>=0;!RR&&nr&&nr.indexOf("Safari")>=0;nr&&nr.indexOf("Edg/")>=0;nr&&nr.indexOf("Android")>=0;var Ea=typeof navigator=="object"?navigator:{};Qw||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ea&&Ea.clipboard&&Ea.clipboard.writeText,Qw||Ea&&Ea.clipboard&&Ea.clipboard.readText;var av=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,n){this._keyCodeToStr[e]=n,this._strToKeyCode[n.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Jf=new av,Zw=new av,eb=new av,LR=new Array(230),_x;(t=>{function e(u){return Jf.keyCodeToStr(u)}t.toString=e;function n(u){return Jf.strToKeyCode(u)}t.fromString=n;function s(u){return Zw.keyCodeToStr(u)}t.toUserSettingsUS=s;function i(u){return eb.keyCodeToStr(u)}t.toUserSettingsGeneral=i;function a(u){return Zw.strToKeyCode(u)||eb.strToKeyCode(u)}t.fromUserSettings=a;function c(u){if(u>=98&&u<=113)return null;switch(u){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Jf.keyCodeToStr(u)}t.toElectronAccelerator=c})(_x||(_x={}));var AR=class yx{constructor(e,n,s,i,a){this.ctrlKey=e,this.shiftKey=n,this.altKey=s,this.metaKey=i,this.keyCode=a}equals(e){return e instanceof yx&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",n=this.shiftKey?"1":"0",s=this.altKey?"1":"0",i=this.metaKey?"1":"0";return`K${e}${n}${s}${i}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new jR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},jR=class{constructor(t){if(t.length===0)throw nR("chords");this.chords=t}getHashCode(){let t="";for(let e=0,n=this.chords.length;e<n;e++)e!==0&&(t+=";"),t+=this.chords[e].getHashCode();return t}equals(t){if(t===null||this.chords.length!==t.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(t.chords[e]))return!1;return!0}};function MR(t){if(t.charCode){let n=String.fromCharCode(t.charCode).toUpperCase();return _x.fromString(n)}let e=t.keyCode;if(e===3)return 7;if(Lm)switch(e){case 59:return 85;case 60:if(CR)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(er)return 57;break}else if(wR&&(er&&e===93||!er&&e===92))return 57;return LR[e]||0}var TR=er?256:2048,PR=512,IR=1024,DR=er?2048:256,tb=class{constructor(t){var n;this._standardKeyboardEventBrand=!0;let e=t;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=(n=e.getModifierState)==null?void 0:n.call(e,"AltGraph"),this.keyCode=MR(e),this.code=e.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(t){return this._asKeybinding===t}_computeKeybinding(){let t=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode);let e=0;return this.ctrlKey&&(e|=TR),this.altKey&&(e|=PR),this.shiftKey&&(e|=IR),this.metaKey&&(e|=DR),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new AR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},nb=new WeakMap;function OR(t){if(!t.parent||t.parent===t)return null;try{let e=t.location,n=t.parent.location;if(e.origin!=="null"&&n.origin!=="null"&&e.origin!==n.origin)return null}catch{return null}return t.parent}var BR=class{static getSameOriginWindowChain(t){let e=nb.get(t);if(!e){e=[],nb.set(t,e);let n=t,s;do s=OR(n),s?e.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):e.push({window:new WeakRef(n),iframeElement:null}),n=s;while(n)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(t,e){if(!e||t===e)return{top:0,left:0};let n=0,s=0,i=this.getSameOriginWindowChain(t);for(let a of i){let c=a.window.deref();if(n+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===e||!a.iframeElement)break;let u=a.iframeElement.getBoundingClientRect();n+=u.top,s+=u.left}return{top:n,left:s}}},qu=class{constructor(e,n){this.timestamp=Date.now(),this.browserEvent=n,this.leftButton=n.button===0,this.middleButton=n.button===1,this.rightButton=n.button===2,this.buttons=n.buttons,this.target=n.target,this.detail=n.detail||1,n.type==="dblclick"&&(this.detail=2),this.ctrlKey=n.ctrlKey,this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.metaKey=n.metaKey,typeof n.pageX=="number"?(this.posx=n.pageX,this.posy=n.pageY):(this.posx=n.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=n.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=BR.getPositionOfChildWindowRelativeToAncestorWindow(e,n.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},sb=class{constructor(e,n=0,s=0){var a;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=n;let i=!1;if(ov){let c=navigator.userAgent.match(/Chrome\/(\d+)/);i=(c?parseInt(c[1]):123)<=122}if(e){let c=e,u=e,h=((a=e.view)==null?void 0:a.devicePixelRatio)||1;if(typeof c.wheelDeltaY<"u")i?this.deltaY=c.wheelDeltaY/(120*h):this.deltaY=c.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 f=e;f.deltaMode===f.DOM_DELTA_LINE?Lm&&!er?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof c.wheelDeltaX<"u")bR&&vx?this.deltaX=-(c.wheelDeltaX/120):i?this.deltaX=c.wheelDeltaX/(120*h):this.deltaX=c.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 f=e;f.deltaMode===f.DOM_DELTA_LINE?Lm&&!er?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?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()}},wx=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),$R;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof zR?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:vs.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:wx})})($R||($R={}));var zR=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?wx:(this._emitter||(this._emitter=new nt),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},lv=class{constructor(e,n){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof n=="number"&&this.setIfNotSet(e,n)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,n){if(this._isDisposed)throw new xm("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},n)}setIfNotSet(e,n){if(this._isDisposed)throw new xm("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},n))}},FR=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,n,s=globalThis){if(this.isDisposed)throw new xm("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},n);this.disposable=_n(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},HR;(t=>{async function e(s){let i,a=await Promise.all(s.map(c=>c.then(u=>u,u=>{i||(i=u)})));if(typeof i<"u")throw i;return a}t.settled=e;function n(s){return new Promise(async(i,a)=>{try{await s(i,a)}catch(c){a(c)}})}t.withAsyncBody=n})(HR||(HR={}));var ib=class fi{static fromArray(e){return new fi(n=>{n.emitMany(e)})}static fromPromise(e){return new fi(async n=>{n.emitMany(await e)})}static fromPromises(e){return new fi(async n=>{await Promise.all(e.map(async s=>n.emitOne(await s)))})}static merge(e){return new fi(async n=>{await Promise.all(e.map(async s=>{for await(let i of s)n.emitOne(i)}))})}constructor(e,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new nt,queueMicrotask(async()=>{let s={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(e(s)),this.resolve()}catch(i){this.reject(i)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await vs.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(e,n){return new fi(async s=>{for await(let i of e)s.emitOne(n(i))})}map(e){return fi.map(this,e)}static filter(e,n){return new fi(async s=>{for await(let i of e)n(i)&&s.emitOne(i)})}filter(e){return fi.filter(this,e)}static coalesce(e){return fi.filter(e,n=>!!n)}coalesce(){return fi.coalesce(this)}static async toPromise(e){let n=[];for await(let s of e)n.push(s);return n}toPromise(){return fi.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};ib.EMPTY=ib.fromArray([]);var{getWindow:Zi,getWindowId:UR,onDidRegisterWindow:WR}=(function(){let t=new Map,e={window:Sr,disposables:new uo};t.set(Sr.vscodeWindowId,e);let n=new nt,s=new nt,i=new nt;function a(c,u){return(typeof c=="number"?t.get(c):void 0)??(u?e:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:s.event,registerWindow(c){if(t.has(c.vscodeWindowId))return $t.None;let u=new uo,h={window:c,disposables:u.add(new uo)};return t.set(c.vscodeWindowId,h),u.add(_n(()=>{t.delete(c.vscodeWindowId),s.fire(c)})),u.add(Mt(c,es.BEFORE_UNLOAD,()=>{i.fire(c)})),n.fire(h),u},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return t.has(c)},getWindowById:a,getWindow(c){var f;let u=c;if((f=u==null?void 0:u.ownerDocument)!=null&&f.defaultView)return u.ownerDocument.defaultView.window;let h=c;return h!=null&&h.view?h.view.window:Sr},getDocument(c){return Zi(c).document}}})(),qR=class{constructor(e,n,s,i){this._node=e,this._type=n,this._handler=s,this._options=i||!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 Mt(t,e,n,s){return new qR(t,e,n,s)}var rb=function(t,e,n,s){return Mt(t,e,n,s)},cv,KR=class extends FR{constructor(t){super(),this.defaultTarget=t&&Zi(t)}cancelAndSet(t,e,n){return super.cancelAndSet(t,e,n??this.defaultTarget)}},ob=class{constructor(e,n=0){this._runner=e,this.priority=n,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){ud(e)}}static sort(e,n){return n.priority-e.priority}};(function(){let t=new Map,e=new Map,n=new Map,s=new Map,i=a=>{n.set(a,!1);let c=t.get(a)??[];for(e.set(a,c),t.set(a,[]),s.set(a,!0);c.length>0;)c.sort(ob.sort),c.shift().execute();s.set(a,!1)};cv=(a,c,u=0)=>{let h=UR(a),f=new ob(c,u),g=t.get(h);return g||(g=[],t.set(h,g)),g.push(f),n.get(h)||(n.set(h,!0),a.requestAnimationFrame(()=>i(h))),f}})();function VR(t){let e=t.getBoundingClientRect(),n=Zi(t);return{left:e.left+n.scrollX,top:e.top+n.scrollY,width:e.width,height:e.height}}var es={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"},YR=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let n=Hs(e);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let n=Hs(e);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(e){let n=Hs(e);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(e){let n=Hs(e);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(e){let n=Hs(e);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(e){let n=Hs(e);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(e){let n=Hs(e);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(e){let n=Hs(e);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let n=Hs(e);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let n=Hs(e);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let n=Hs(e);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let n=Hs(e);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let n=Hs(e);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let n=Hs(e);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,n){this.domNode.classList.toggle(e,n),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,n){this.domNode.setAttribute(e,n)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Hs(t){return typeof t=="number"?`${t}px`:t}function pc(t){return new YR(t)}var bx=class{constructor(){this._hooks=new uo,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,n){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(n)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,n,s,i,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=a;let c=e;try{e.setPointerCapture(n),this._hooks.add(_n(()=>{try{e.releasePointerCapture(n)}catch{}}))}catch{c=Zi(e)}this._hooks.add(Mt(c,es.POINTER_MOVE,u=>{if(u.buttons!==s){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(Mt(c,es.POINTER_UP,u=>this.stopMonitoring(!0)))}};function GR(t,e,n){let s=null,i=null;if(typeof n.value=="function"?(s="value",i=n.value,i.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof n.get=="function"&&(s="get",i=n.get),!i)throw new Error("not supported");let a=`$memoize$${e}`;n[s]=function(...c){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,c)}),this[a]}}var Vi;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(Vi||(Vi={}));var rc=class ks extends $t{constructor(){super(),this.dispatched=!1,this.targets=new Xw,this.ignoreTargets=new Xw,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(vs.runAndSubscribe(WR,({window:e,disposables:n})=>{n.add(Mt(e.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(Mt(e.document,"touchend",s=>this.onTouchEnd(e,s))),n.add(Mt(e.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Sr,disposables:this._store}))}static addTarget(e){if(!ks.isTouchDevice())return $t.None;ks.INSTANCE||(ks.INSTANCE=new ks);let n=ks.INSTANCE.targets.push(e);return _n(n)}static ignoreTarget(e){if(!ks.isTouchDevice())return $t.None;ks.INSTANCE||(ks.INSTANCE=new ks);let n=ks.INSTANCE.ignoreTargets.push(e);return _n(n)}static isTouchDevice(){return"ontouchstart"in Sr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let n=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,i=e.targetTouches.length;s<i;s++){let a=e.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 c=this.newGestureEvent(Vi.Start,a.target);c.pageX=a.pageX,c.pageY=a.pageY,this.dispatchEvent(c)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,n){let s=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,c=n.changedTouches.length;a<c;a++){let u=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(u.identifier))){console.warn("move of an UNKNOWN touch",u);continue}let h=this.activeTouches[u.identifier],f=Date.now()-h.initialTimeStamp;if(f<ks.HOLD_DELAY&&Math.abs(h.initialPageX-Zs(h.rollingPageX))<30&&Math.abs(h.initialPageY-Zs(h.rollingPageY))<30){let g=this.newGestureEvent(Vi.Tap,h.initialTarget);g.pageX=Zs(h.rollingPageX),g.pageY=Zs(h.rollingPageY),this.dispatchEvent(g)}else if(f>=ks.HOLD_DELAY&&Math.abs(h.initialPageX-Zs(h.rollingPageX))<30&&Math.abs(h.initialPageY-Zs(h.rollingPageY))<30){let g=this.newGestureEvent(Vi.Contextmenu,h.initialTarget);g.pageX=Zs(h.rollingPageX),g.pageY=Zs(h.rollingPageY),this.dispatchEvent(g)}else if(i===1){let g=Zs(h.rollingPageX),v=Zs(h.rollingPageY),_=Zs(h.rollingTimestamps)-h.rollingTimestamps[0],b=g-h.rollingPageX[0],x=v-h.rollingPageY[0],L=[...this.targets].filter(k=>h.initialTarget instanceof Node&&k.contains(h.initialTarget));this.inertia(e,L,s,Math.abs(b)/_,b>0?1:-1,g,Math.abs(x)/_,x>0?1:-1,v)}this.dispatchEvent(this.newGestureEvent(Vi.End,h.initialTarget)),delete this.activeTouches[u.identifier]}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,n){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=n,s.tapCount=0,s}dispatchEvent(e){if(e.type===Vi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>ks.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,e.tapCount=s}else(e.type===Vi.Change||e.type===Vi.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(e.initialTarget))return;let n=[];for(let s of this.targets)if(s.contains(e.initialTarget)){let i=0,a=e.initialTarget;for(;a&&a!==s;)i++,a=a.parentElement;n.push([i,s])}n.sort((s,i)=>s[0]-i[0]);for(let[s,i]of n)i.dispatchEvent(e),this.dispatched=!0}}inertia(e,n,s,i,a,c,u,h,f){this.handle=cv(e,()=>{let g=Date.now(),v=g-s,_=0,b=0,x=!0;i+=ks.SCROLL_FRICTION*v,u+=ks.SCROLL_FRICTION*v,i>0&&(x=!1,_=a*i*v),u>0&&(x=!1,b=h*u*v);let L=this.newGestureEvent(Vi.Change);L.translationX=_,L.translationY=b,n.forEach(k=>k.dispatchEvent(L)),x||this.inertia(e,n,g,i,a,c+_,u,h,f+b)})}onTouchMove(e){let n=Date.now();for(let s=0,i=e.changedTouches.length;s<i;s++){let a=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("end of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],u=this.newGestureEvent(Vi.Change,c.initialTarget);u.translationX=a.pageX-Zs(c.rollingPageX),u.translationY=a.pageY-Zs(c.rollingPageY),u.pageX=a.pageX,u.pageY=a.pageY,this.dispatchEvent(u),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(a.pageX),c.rollingPageY.push(a.pageY),c.rollingTimestamps.push(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};rc.SCROLL_FRICTION=-.005,rc.HOLD_DELAY=700,rc.CLEAR_TAP_COUNT_TIME=400,jn([GR],rc,"isTouchDevice",1);var XR=rc,uv=class extends $t{onclick(e,n){this._register(Mt(e,es.CLICK,s=>n(new qu(Zi(e),s))))}onmousedown(e,n){this._register(Mt(e,es.MOUSE_DOWN,s=>n(new qu(Zi(e),s))))}onmouseover(e,n){this._register(Mt(e,es.MOUSE_OVER,s=>n(new qu(Zi(e),s))))}onmouseleave(e,n){this._register(Mt(e,es.MOUSE_LEAVE,s=>n(new qu(Zi(e),s))))}onkeydown(e,n){this._register(Mt(e,es.KEY_DOWN,s=>n(new tb(s))))}onkeyup(e,n){this._register(Mt(e,es.KEY_UP,s=>n(new tb(s))))}oninput(e,n){this._register(Mt(e,es.INPUT,n))}onblur(e,n){this._register(Mt(e,es.BLUR,n))}onfocus(e,n){this._register(Mt(e,es.FOCUS,n))}onchange(e,n){this._register(Mt(e,es.CHANGE,n))}ignoreGesture(e){return XR.ignoreTarget(e)}},ab=11,JR=class extends uv{constructor(t){super(),this._onActivate=t.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=t.bgWidth+"px",this.bgDomNode.style.height=t.bgHeight+"px",typeof t.top<"u"&&(this.bgDomNode.style.top="0px"),typeof t.left<"u"&&(this.bgDomNode.style.left="0px"),typeof t.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof t.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=t.className,this.domNode.style.position="absolute",this.domNode.style.width=ab+"px",this.domNode.style.height=ab+"px",typeof t.top<"u"&&(this.domNode.style.top=t.top+"px"),typeof t.left<"u"&&(this.domNode.style.left=t.left+"px"),typeof t.bottom<"u"&&(this.domNode.style.bottom=t.bottom+"px"),typeof t.right<"u"&&(this.domNode.style.right=t.right+"px"),this._pointerMoveMonitor=this._register(new bx),this._register(rb(this.bgDomNode,es.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(rb(this.domNode,es.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new KR),this._pointerdownScheduleRepeatTimer=this._register(new lv)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Zi(t))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(t.target,t.pointerId,t.buttons,n=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),t.preventDefault()}},QR=class Mm{constructor(e,n,s,i,a,c,u){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(n=n|0,s=s|0,i=i|0,a=a|0,c=c|0,u=u|0),this.rawScrollLeft=i,this.rawScrollTop=u,n<0&&(n=0),i+n>s&&(i=s-n),i<0&&(i=0),a<0&&(a=0),u+a>c&&(u=c-a),u<0&&(u=0),this.width=n,this.scrollWidth=s,this.scrollLeft=i,this.height=a,this.scrollHeight=c,this.scrollTop=u}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,n){return new Mm(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new Mm(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,n){let s=this.width!==e.width,i=this.scrollWidth!==e.scrollWidth,a=this.scrollLeft!==e.scrollLeft,c=this.height!==e.height,u=this.scrollHeight!==e.scrollHeight,h=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:n,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:i,scrollLeftChanged:a,heightChanged:c,scrollHeightChanged:u,scrollTopChanged:h}}},ZR=class extends $t{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new QR(t.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(t){this._smoothScrollDuration=t}validateScrollPosition(t){return this._state.withScrollPosition(t)}getScrollDimensions(){return this._state}setScrollDimensions(t,e){var s;let n=this._state.withScrollDimensions(t,e);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(t){let e=this._state.withScrollPosition(t);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(t,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(t);if(this._smoothScrolling){t={scrollLeft:typeof t.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:t.scrollLeft,scrollTop:typeof t.scrollTop>"u"?this._smoothScrolling.to.scrollTop:t.scrollTop};let n=this._state.withScrollPosition(t);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let s;e?s=new cb(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(t);this._smoothScrolling=cb.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 t=this._smoothScrolling.tick(),e=this._state.withScrollPosition(t);if(this._setState(e,!0),!!this._smoothScrolling){if(t.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(t,e){let n=this._state;n.equals(t)||(this._state=t,this._onScroll.fire(this._state.createScrollEvent(n,e)))}},lb=class{constructor(e,n,s){this.scrollLeft=e,this.scrollTop=n,this.isDone=s}};function Qf(t,e){let n=e-t;return function(s){return t+n*nL(s)}}function eL(t,e,n){return function(s){return s<n?t(s/n):e((s-n)/(1-n))}}var cb=class Tm{constructor(e,n,s,i){this.from=e,this.to=n,this.duration=i,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(e,n,s){if(Math.abs(e-n)>2.5*s){let i,a;return e<n?(i=e+.75*s,a=n-.75*s):(i=e-.75*s,a=n+.75*s),eL(Qf(e,i),Qf(a,n),.33)}return Qf(e,n)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let n=(e-this.startTime)/this.duration;if(n<1){let s=this.scrollLeft(n),i=this.scrollTop(n);return new lb(s,i,!1)}return new lb(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,n,s){return Tm.start(e,n,s)}static start(e,n,s){s=s+10;let i=Date.now()-10;return new Tm(e,n,i,s)}};function tL(t){return Math.pow(t,3)}function nL(t){return 1-tL(1-t)}var sL=class extends $t{constructor(e,n,s){super(),this._visibility=e,this._visibleClassName=n,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new lv)}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 n;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(n=this._domNode)==null||n.setClassName(this._invisibleClassName+(e?" fade":"")))}},iL=140,Sx=class extends uv{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 sL(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new bx),this._shouldRender=!0,this.domNode=pc(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(Mt(this.domNode.domNode,es.POINTER_DOWN,n=>this._domNodePointerDown(n)))}_createArrow(e){let n=this._register(new JR(e));this.domNode.domNode.appendChild(n.bgDomNode),this.domNode.domNode.appendChild(n.domNode)}_createSlider(e,n,s,i){this.slider=pc(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(n),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Mt(this.slider.domNode,es.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.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 n=this.domNode.domNode.getClientRects()[0].top,s=n+this._scrollbarState.getSliderPosition(),i=n+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);s<=a&&a<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let n,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")n=e.offsetX,s=e.offsetY;else{let a=VR(this.domNode.domNode);n=e.pageX-a.left,s=e.pageY-a.top}let i=this._pointerDownRelativePosition(n,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let n=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let c=this._sliderOrthogonalPointerPosition(a),u=Math.abs(c-s);if(vx&&u>iL){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let h=this._sliderPointerPosition(a)-n;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(h))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let n={};this.writeScrollPosition(n,e),this._scrollable.setScrollPositionNow(n)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},xx=class Pm{constructor(e,n,s,i,a,c){this._scrollbarSize=Math.round(n),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=i,this._scrollSize=a,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Pm(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let n=Math.round(e);return this._visibleSize!==n?(this._visibleSize=n,this._refreshComputedValues(),!0):!1}setScrollSize(e){let n=Math.round(e);return this._scrollSize!==n?(this._scrollSize=n,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let n=Math.round(e);return this._scrollPosition!==n?(this._scrollPosition=n,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,n,s,i,a){let c=Math.max(0,s-e),u=Math.max(0,c-2*n),h=i>0&&i>s;if(!h)return{computedAvailableSize:Math.round(c),computedIsNeeded:h,computedSliderSize:Math.round(u),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*u/i))),g=(u-f)/(i-s),v=a*g;return{computedAvailableSize:Math.round(c),computedIsNeeded:h,computedSliderSize:Math.round(f),computedSliderRatio:g,computedSliderPosition:Math.round(v)}}_refreshComputedValues(){let e=Pm._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.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(e){if(!this._computedIsNeeded)return 0;let n=e-this._arrowSize-this._computedSliderSize/2;return Math.round(n/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let n=e-this._arrowSize,s=this._scrollPosition;return n<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let n=this._computedSliderPosition+e;return Math.round(n/this._computedSliderRatio)}},rL=class extends Sx{constructor(e,n,s){let i=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:s,scrollbarState:new xx(n.horizontalHasArrows?n.arrowSize:0,n.horizontal===2?0:n.horizontalScrollbarSize,n.vertical===2?0:n.verticalScrollbarSize,i.width,i.scrollWidth,a.scrollLeft),visibility:n.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:n.scrollByPage}),n.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((n.horizontalScrollbarSize-n.horizontalSliderSize)/2),0,void 0,n.horizontalSliderSize)}_updateSlider(e,n){this.slider.setWidth(e),this.slider.setLeft(n)}_renderDomNode(e,n){this.domNode.setWidth(e),this.domNode.setHeight(n),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,n){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,n){e.scrollLeft=n}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}},oL=class extends Sx{constructor(t,e,n){let s=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:n,scrollbarState:new xx(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,s.height,s.scrollHeight,i.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:t,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(t,e){this.slider.setHeight(t),this.slider.setTop(e)}_renderDomNode(t,e){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(t){return this._shouldRender=this._onElementScrollSize(t.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(t.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(t.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(t,e){return e}_sliderPointerPosition(t){return t.pageY}_sliderOrthogonalPointerPosition(t){return t.pageX}_updateScrollbarSize(t){this.slider.setWidth(t)}writeScrollPosition(t,e){t.scrollTop=e}updateOptions(t){this.updateScrollbarSize(t.vertical===2?0:t.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(t.vertical),this._scrollByPage=t.scrollByPage}},aL=500,ub=50,lL=class{constructor(e,n,s){this.timestamp=e,this.deltaX=n,this.deltaY=s,this.score=0}},Im=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,n=0,s=1,i=this._rear;do{let a=i===this._front?e:Math.pow(2,-s);if(e-=a,n+=this._memory[i].score*a,i===this._front)break;i=(this._capacity+i-1)%this._capacity,s++}while(!0);return n<=.5}acceptStandardWheelEvent(e){if(ov){let n=Zi(e.browserEvent),s=yR(n);this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,n,s){let i=null,a=new lL(e,n,s);this._front===-1&&this._rear===-1?(this._memory[0]=a,this._front=0,this._rear=0):(i=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,i)}_computeScore(e,n){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(s+=.25),n){let i=Math.abs(e.deltaX),a=Math.abs(e.deltaY),c=Math.abs(n.deltaX),u=Math.abs(n.deltaY),h=Math.max(Math.min(i,c),1),f=Math.max(Math.min(a,u),1),g=Math.max(i,c),v=Math.max(a,u);g%h===0&&v%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Im.INSTANCE=new Im;var cL=Im,uL=class extends uv{constructor(t,e,n){super(),this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new nt),this.onWillScroll=this._onWillScroll.event,this._options=hL(e),this._scrollable=n,this._register(this._scrollable.onScroll(i=>{this._onWillScroll.fire(i),this._onDidScroll(i),this._onScroll.fire(i)}));let s={onMouseWheel:i=>this._onMouseWheel(i),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new oL(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new rL(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(t),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=pc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=pc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=pc(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,i=>this._onMouseOver(i)),this.onmouseleave(this._listenOnDomNode,i=>this._onMouseLeave(i)),this._hideTimeout=this._register(new lv),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Go(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(t){this._verticalScrollbar.delegatePointerDown(t)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(t){this._scrollable.setScrollDimensions(t,!1)}updateClassName(t){this._options.className=t,er&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(t){typeof t.handleMouseWheel<"u"&&(this._options.handleMouseWheel=t.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof t.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=t.mouseWheelScrollSensitivity),typeof t.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=t.fastScrollSensitivity),typeof t.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=t.scrollPredominantAxis),typeof t.horizontal<"u"&&(this._options.horizontal=t.horizontal),typeof t.vertical<"u"&&(this._options.vertical=t.vertical),typeof t.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=t.horizontalScrollbarSize),typeof t.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=t.verticalScrollbarSize),typeof t.scrollByPage<"u"&&(this._options.scrollByPage=t.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(t){this._revealOnScroll=t}delegateScrollFromMouseWheelEvent(t){this._onMouseWheel(new sb(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=Go(this._mouseWheelToDispose),t)){let e=n=>{this._onMouseWheel(new sb(n))};this._mouseWheelToDispose.push(Mt(this._listenOnDomNode,es.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){var i;if((i=t.browserEvent)!=null&&i.defaultPrevented)return;let e=cL.INSTANCE;e.acceptStandardWheelEvent(t);let n=!1;if(t.deltaY||t.deltaX){let a=t.deltaY*this._options.mouseWheelScrollSensitivity,c=t.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+a===0?c=a=0:Math.abs(a)>=Math.abs(c)?c=0:a=0),this._options.flipAxes&&([a,c]=[c,a]);let u=!er&&t.browserEvent&&t.browserEvent.shiftKey;(this._options.scrollYToX||u)&&!c&&(c=a,a=0),t.browserEvent&&t.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),f={};if(a){let g=ub*a,v=h.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(f,v)}if(c){let g=ub*c,v=h.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(f,v)}f=this._scrollable.validateScrollPosition(f),(h.scrollLeft!==f.scrollLeft||h.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),n=!0)}let s=n;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(t.preventDefault(),t.stopPropagation())}_onDidScroll(t){this._shouldRender=this._horizontalScrollbar.onDidScroll(t)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(t)||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 t=this._scrollable.getCurrentScrollPosition(),e=t.scrollTop>0,n=t.scrollLeft>0,s=n?" left":"",i=e?" top":"",a=n||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(t){this._mouseIsOver=!1,this._hide()}_onMouseOver(t){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(),aL)}},dL=class extends uL{constructor(e,n,s){super(e,n,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function hL(t){let e={lazyRender:typeof t.lazyRender<"u"?t.lazyRender:!1,className:typeof t.className<"u"?t.className:"",useShadows:typeof t.useShadows<"u"?t.useShadows:!0,handleMouseWheel:typeof t.handleMouseWheel<"u"?t.handleMouseWheel:!0,flipAxes:typeof t.flipAxes<"u"?t.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof t.consumeMouseWheelIfScrollbarIsNeeded<"u"?t.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof t.alwaysConsumeMouseWheel<"u"?t.alwaysConsumeMouseWheel:!1,scrollYToX:typeof t.scrollYToX<"u"?t.scrollYToX:!1,mouseWheelScrollSensitivity:typeof t.mouseWheelScrollSensitivity<"u"?t.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof t.fastScrollSensitivity<"u"?t.fastScrollSensitivity:5,scrollPredominantAxis:typeof t.scrollPredominantAxis<"u"?t.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof t.mouseWheelSmoothScroll<"u"?t.mouseWheelSmoothScroll:!0,arrowSize:typeof t.arrowSize<"u"?t.arrowSize:11,listenOnDomNode:typeof t.listenOnDomNode<"u"?t.listenOnDomNode:null,horizontal:typeof t.horizontal<"u"?t.horizontal:1,horizontalScrollbarSize:typeof t.horizontalScrollbarSize<"u"?t.horizontalScrollbarSize:10,horizontalSliderSize:typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:0,horizontalHasArrows:typeof t.horizontalHasArrows<"u"?t.horizontalHasArrows:!1,vertical:typeof t.vertical<"u"?t.vertical:1,verticalScrollbarSize:typeof t.verticalScrollbarSize<"u"?t.verticalScrollbarSize:10,verticalHasArrows:typeof t.verticalHasArrows<"u"?t.verticalHasArrows:!1,verticalSliderSize:typeof t.verticalSliderSize<"u"?t.verticalSliderSize:0,scrollByPage:typeof t.scrollByPage<"u"?t.scrollByPage:!1};return e.horizontalSliderSize=typeof t.horizontalSliderSize<"u"?t.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof t.verticalSliderSize<"u"?t.verticalSliderSize:e.verticalScrollbarSize,er&&(e.className+=" mac"),e}var Dm=class extends $t{constructor(e,n,s,i,a,c,u,h){super(),this._bufferService=s,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new nt),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new ZR({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:g=>cv(i.window,g)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new dL(n,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},f)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(g=>{this._scrollableElement.updateOptions({handleMouseWheel:!(g&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(vs.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(_n(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),n.appendChild(this._styleElement),this._register(_n(()=>this._styleElement.remove())),this._register(vs.runAndSubscribe(c.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${c.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${c.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${c.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
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(g=>this._handleScroll(g)))}scrollLines(e){let n=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:n.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,n){n&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!n,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 n=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=n-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=n,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Dm=jn([at(2,Ms),at(3,Nr),at(4,sx),at(5,Za),at(6,Ts),at(7,Rr)],Dm);var Om=class extends $t{constructor(e,n,s,i,a){super(),this._screenElement=e,this._bufferService=n,this._coreBrowserService=s,this._decorationService=i,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(c=>this._removeDecoration(c))),this._register(_n(()=>{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 i;let n=this._coreBrowserService.mainDocument.createElement("div");n.classList.add("xterm-decoration"),n.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),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=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(n.style.display="none"),this._refreshXPosition(e,n),n}_refreshStyle(e){let n=e.marker.line-this._bufferService.buffers.active.ydisp;if(n<0||n>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${n*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,n=e.element){if(!n)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?n.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":n.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var n;(n=this._decorationElements.get(e))==null||n.remove(),this._decorationElements.delete(e),e.dispose()}};Om=jn([at(1,Ms),at(2,Nr),at(3,Oc),at(4,Rr)],Om);var fL=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 n of this._zones)if(n.color===e.options.overviewRulerOptions.color&&n.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(n,e.marker.line))return;if(this._lineAdjacentToZone(n,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(n,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,n){return n>=e.startBufferLine&&n<=e.endBufferLine}_lineAdjacentToZone(e,n,s){return n>=e.startBufferLine-this._linePadding[s||"full"]&&n<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,n){e.startBufferLine=Math.min(e.startBufferLine,n),e.endBufferLine=Math.max(e.endBufferLine,n)}},Ui={full:0,left:0,center:0,right:0},Gr={full:0,left:0,center:0,right:0},Ol={full:0,left:0,center:0,right:0},Ld=class extends $t{constructor(e,n,s,i,a,c,u,h){var g;super(),this._viewportElement=e,this._screenElement=n,this._bufferService=s,this._decorationService=i,this._renderService=a,this._optionsService=c,this._themeService=u,this._coreBrowserService=h,this._colorZoneStore=new fL,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(),(g=this._viewportElement.parentElement)==null||g.insertBefore(this._canvas,this._viewportElement),this._register(_n(()=>{var v;return(v=this._canvas)==null?void 0:v.remove()}));let f=this._canvas.getContext("2d");if(f)this._ctx=f;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),n=Math.ceil((this._canvas.width-1)/3);Gr.full=this._canvas.width,Gr.left=e,Gr.center=n,Gr.right=e,this._refreshDrawHeightConstants(),Ol.full=1,Ol.left=1,Ol.center=1+Gr.left,Ol.right=1+Gr.left+Gr.center}_refreshDrawHeightConstants(){Ui.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,n=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Ui.left=n,Ui.center=n,Ui.right=n}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ui.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 n of this._decorationService.decorations)this._colorZoneStore.addDecoration(n);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let n of e)n.position!=="full"&&this._renderColorZone(n);for(let n of e)n.position==="full"&&this._renderColorZone(n);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(Ol[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ui[e.position||"full"]/2),Gr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ui[e.position||"full"]))}_queueRefresh(e,n){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=n||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ld=jn([at(2,Ms),at(3,Oc),at(4,Rr),at(5,Ts),at(6,Za),at(7,Nr)],Ld);var Oe;(t=>(t.NUL="\0",t.SOH="",t.STX="",t.ETX="",t.EOT="",t.ENQ="",t.ACK="",t.BEL="\x07",t.BS="\b",t.HT=" ",t.LF=`
|
|
61
|
-
`,t.VT="\v",t.FF="\f",t.CR="\r",t.SO="",t.SI="",t.DLE="",t.DC1="",t.DC2="",t.DC3="",t.DC4="",t.NAK="",t.SYN="",t.ETB="",t.CAN="",t.EM="",t.SUB="",t.ESC="\x1B",t.FS="",t.GS="",t.RS="",t.US="",t.SP=" ",t.DEL=""))(Oe||(Oe={}));var fd;(t=>(t.PAD="",t.HOP="",t.BPH="",t.NBH="",t.IND="",t.NEL="
",t.SSA="",t.ESA="",t.HTS="",t.HTJ="",t.VTS="",t.PLD="",t.PLU="",t.RI="",t.SS2="",t.SS3="",t.DCS="",t.PU1="",t.PU2="",t.STS="",t.CCH="",t.MW="",t.SPA="",t.EPA="",t.SOS="",t.SGCI="",t.SCI="",t.CSI="",t.ST="",t.OSC="",t.PM="",t.APC=""))(fd||(fd={}));var kx;(t=>t.ST=`${Oe.ESC}\\`)(kx||(kx={}));var Bm=class{constructor(e,n,s,i,a,c){this._textarea=e,this._compositionView=n,this._bufferService=s,this._optionsService=i,this._coreService=a,this._renderService=c,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;n.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(n.start,this._compositionPosition.start):s=this._textarea.value.substring(n.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let n=this._textarea.value,s=n.replace(e,"");this._dataAlreadySent=s,n.length>e.length?this._coreService.triggerDataEvent(s,!0):n.length<e.length?this._coreService.triggerDataEvent(`${Oe.DEL}`,!0):n.length===e.length&&n!==e&&this._coreService.triggerDataEvent(n,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let c=this._compositionView.getBoundingClientRect();this._textarea.style.left=a+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(c.width,1)+"px",this._textarea.style.height=Math.max(c.height,1)+"px",this._textarea.style.lineHeight=c.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Bm=jn([at(2,Ms),at(3,Ts),at(4,Zo),at(5,Rr)],Bm);var ts=0,ns=0,ss=0,Ln=0,db={css:"#00000000",rgba:0},$n;(t=>{function e(i,a,c,u){return u!==void 0?`#${Po(i)}${Po(a)}${Po(c)}${Po(u)}`:`#${Po(i)}${Po(a)}${Po(c)}`}t.toCss=e;function n(i,a,c,u=255){return(i<<24|a<<16|c<<8|u)>>>0}t.toRgba=n;function s(i,a,c,u){return{css:t.toCss(i,a,c,u),rgba:t.toRgba(i,a,c,u)}}t.toColor=s})($n||($n={}));var fn;(t=>{function e(h,f){if(Ln=(f.rgba&255)/255,Ln===1)return{css:f.css,rgba:f.rgba};let g=f.rgba>>24&255,v=f.rgba>>16&255,_=f.rgba>>8&255,b=h.rgba>>24&255,x=h.rgba>>16&255,L=h.rgba>>8&255;ts=b+Math.round((g-b)*Ln),ns=x+Math.round((v-x)*Ln),ss=L+Math.round((_-L)*Ln);let k=$n.toCss(ts,ns,ss),R=$n.toRgba(ts,ns,ss);return{css:k,rgba:R}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function s(h,f,g){let v=pd.ensureContrastRatio(h.rgba,f.rgba,g);if(v)return $n.toColor(v>>24&255,v>>16&255,v>>8&255)}t.ensureContrastRatio=s;function i(h){let f=(h.rgba|255)>>>0;return[ts,ns,ss]=pd.toChannels(f),{css:$n.toCss(ts,ns,ss),rgba:f}}t.opaque=i;function a(h,f){return Ln=Math.round(f*255),[ts,ns,ss]=pd.toChannels(h.rgba),{css:$n.toCss(ts,ns,ss,Ln),rgba:$n.toRgba(ts,ns,ss,Ln)}}t.opacity=a;function c(h,f){return Ln=h.rgba&255,a(h,Ln*f/255)}t.multiplyOpacity=c;function u(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=u})(fn||(fn={}));var En;(t=>{let e,n;try{let i=document.createElement("canvas");i.width=1,i.height=1;let a=i.getContext("2d",{willReadFrequently:!0});a&&(e=a,e.globalCompositeOperation="copy",n=e.createLinearGradient(0,0,1,1))}catch{}function s(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return ts=parseInt(i.slice(1,2).repeat(2),16),ns=parseInt(i.slice(2,3).repeat(2),16),ss=parseInt(i.slice(3,4).repeat(2),16),$n.toColor(ts,ns,ss);case 5:return ts=parseInt(i.slice(1,2).repeat(2),16),ns=parseInt(i.slice(2,3).repeat(2),16),ss=parseInt(i.slice(3,4).repeat(2),16),Ln=parseInt(i.slice(4,5).repeat(2),16),$n.toColor(ts,ns,ss,Ln);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let a=i.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 ts=parseInt(a[1]),ns=parseInt(a[2]),ss=parseInt(a[3]),Ln=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),$n.toColor(ts,ns,ss,Ln);if(!e||!n)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=n,e.fillStyle=i,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[ts,ns,ss,Ln]=e.getImageData(0,0,1,1).data,Ln!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:$n.toRgba(ts,ns,ss,Ln),css:i}}t.toColor=s})(En||(En={}));var Ls;(t=>{function e(s){return n(s>>16&255,s>>8&255,s&255)}t.relativeLuminance=e;function n(s,i,a){let c=s/255,u=i/255,h=a/255,f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=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);return f*.2126+g*.7152+v*.0722}t.relativeLuminance2=n})(Ls||(Ls={}));var pd;(t=>{function e(c,u){if(Ln=(u&255)/255,Ln===1)return u;let h=u>>24&255,f=u>>16&255,g=u>>8&255,v=c>>24&255,_=c>>16&255,b=c>>8&255;return ts=v+Math.round((h-v)*Ln),ns=_+Math.round((f-_)*Ln),ss=b+Math.round((g-b)*Ln),$n.toRgba(ts,ns,ss)}t.blend=e;function n(c,u,h){let f=Ls.relativeLuminance(c>>8),g=Ls.relativeLuminance(u>>8);if(mr(f,g)<h){if(g<f){let b=s(c,u,h),x=mr(f,Ls.relativeLuminance(b>>8));if(x<h){let L=i(c,u,h),k=mr(f,Ls.relativeLuminance(L>>8));return x>k?b:L}return b}let v=i(c,u,h),_=mr(f,Ls.relativeLuminance(v>>8));if(_<h){let b=s(c,u,h),x=mr(f,Ls.relativeLuminance(b>>8));return _>x?v:b}return v}}t.ensureContrastRatio=n;function s(c,u,h){let f=c>>24&255,g=c>>16&255,v=c>>8&255,_=u>>24&255,b=u>>16&255,x=u>>8&255,L=mr(Ls.relativeLuminance2(_,b,x),Ls.relativeLuminance2(f,g,v));for(;L<h&&(_>0||b>0||x>0);)_-=Math.max(0,Math.ceil(_*.1)),b-=Math.max(0,Math.ceil(b*.1)),x-=Math.max(0,Math.ceil(x*.1)),L=mr(Ls.relativeLuminance2(_,b,x),Ls.relativeLuminance2(f,g,v));return(_<<24|b<<16|x<<8|255)>>>0}t.reduceLuminance=s;function i(c,u,h){let f=c>>24&255,g=c>>16&255,v=c>>8&255,_=u>>24&255,b=u>>16&255,x=u>>8&255,L=mr(Ls.relativeLuminance2(_,b,x),Ls.relativeLuminance2(f,g,v));for(;L<h&&(_<255||b<255||x<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),L=mr(Ls.relativeLuminance2(_,b,x),Ls.relativeLuminance2(f,g,v));return(_<<24|b<<16|x<<8|255)>>>0}t.increaseLuminance=i;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}t.toChannels=a})(pd||(pd={}));function Po(t){let e=t.toString(16);return e.length<2?"0"+e:e}function mr(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var pL=class extends Dc{constructor(e,n,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=n,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ad=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new bi}register(t){let e={id:this._nextCharacterJoinerId++,handler:t};return this._characterJoiners.push(e),e.id}deregister(t){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===t)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(t){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(t);if(!e||e.length===0)return[];let n=[],s=e.translateToString(!0),i=0,a=0,c=0,u=e.getFg(0),h=e.getBg(0);for(let f=0;f<e.getTrimmedLength();f++)if(e.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==u||this._workCell.bg!==h){if(f-i>1){let g=this._getJoinedRanges(s,c,a,e,i);for(let v=0;v<g.length;v++)n.push(g[v])}i=f,c=a,u=this._workCell.fg,h=this._workCell.bg}a+=this._workCell.getChars().length||oo.length}if(this._bufferService.cols-i>1){let f=this._getJoinedRanges(s,c,a,e,i);for(let g=0;g<f.length;g++)n.push(f[g])}return n}_getJoinedRanges(t,e,n,s,i){let a=t.substring(e,n),c=[];try{c=this._characterJoiners[0].handler(a)}catch(u){console.error(u)}for(let u=1;u<this._characterJoiners.length;u++)try{let h=this._characterJoiners[u].handler(a);for(let f=0;f<h.length;f++)Ad._mergeRanges(c,h[f])}catch(h){console.error(h)}return this._stringRangesToCellRanges(c,s,i),c}_stringRangesToCellRanges(t,e,n){let s=0,i=!1,a=0,c=t[s];if(c){for(let u=n;u<this._bufferService.cols;u++){let h=e.getWidth(u),f=e.getString(u).length||oo.length;if(h!==0){if(!i&&c[0]<=a&&(c[0]=u,i=!0),c[1]<=a){if(c[1]=u,c=t[++s],!c)break;c[0]<=a?(c[0]=u,i=!0):i=!1}a+=f}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(t,e){let n=!1;for(let s=0;s<t.length;s++){let i=t[s];if(n){if(e[1]<=i[0])return t[s-1][1]=e[1],t;if(e[1]<=i[1])return t[s-1][1]=Math.max(e[1],i[1]),t.splice(s,1),t;t.splice(s,1),s--}else{if(e[1]<=i[0])return t.splice(s,0,e),t;if(e[1]<=i[1])return i[0]=Math.min(e[0],i[0]),t;e[0]<i[1]&&(i[0]=Math.min(e[0],i[0]),n=!0);continue}}return n?t[t.length-1][1]=e[1]:t.push(e),t}};Ad=jn([at(0,Ms)],Ad);function mL(t){return 57508<=t&&t<=57558}function gL(t){return 9472<=t&&t<=9631}function vL(t){return mL(t)||gL(t)}function _L(){return{css:{canvas:Ku(),cell:Ku()},device:{canvas:Ku(),cell:Ku(),char:{width:0,height:0,left:0,top:0}}}}function Ku(){return{width:0,height:0}}var $m=class{constructor(e,n,s,i,a,c,u){this._document=e,this._characterJoinerService=n,this._optionsService=s,this._coreBrowserService=i,this._coreService=a,this._decorationService=c,this._themeService=u,this._workCell=new bi,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,n,s){this._selectionStart=e,this._selectionEnd=n,this._columnSelectMode=s}createRow(e,n,s,i,a,c,u,h,f,g,v){let _=[],b=this._characterJoinerService.getJoinedCharacters(n),x=this._themeService.colors,L=e.getNoBgTrimmedLength();s&&L<c+1&&(L=c+1);let k,R=0,S="",j=0,E=0,F=0,$=0,G=!1,K=0,Y=!1,te=0,q=0,D=[],I=g!==-1&&v!==-1;for(let O=0;O<L;O++){e.loadCell(O,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let z=!1,T=O>=q,A=O,N=this._workCell;if(b.length>0&&O===b[0][0]&&T){let oe=b.shift(),Ne=this._isCellInSelection(oe[0],n);for(j=oe[0]+1;j<oe[1];j++)T&&(T=Ne===this._isCellInSelection(j,n));T&&(T=!s||c<oe[0]||c>=oe[1]),T?(z=!0,N=new pL(this._workCell,e.translateToString(!0,oe[0],oe[1]),oe[1]-oe[0]),A=oe[1]-1,M=N.getWidth()):q=oe[1]}let U=this._isCellInSelection(O,n),P=s&&O===c,H=I&&O>=g&&O<=v,ie=!1;this._decorationService.forEachDecorationAtCell(O,n,void 0,oe=>{ie=!0});let J=N.getChars()||oo;if(J===" "&&(N.isUnderline()||N.isOverline())&&(J=" "),te=M*h-f.get(J,N.isBold(),N.isItalic()),!k)k=this._document.createElement("span");else if(R&&(U&&Y||!U&&!Y&&N.bg===E)&&(U&&Y&&x.selectionForeground||N.fg===F)&&N.extended.ext===$&&H===G&&te===K&&!P&&!z&&!ie&&T){N.isInvisible()?S+=oo:S+=J,R++;continue}else R&&(k.textContent=S),k=this._document.createElement("span"),R=0,S="";if(E=N.bg,F=N.fg,$=N.extended.ext,G=H,K=te,Y=U,z&&c>=O&&c<=A&&(c=O),!this._coreService.isCursorHidden&&P&&this._coreService.isCursorInitialized){if(D.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&D.push("xterm-cursor-blink"),D.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":D.push("xterm-cursor-outline");break;case"block":D.push("xterm-cursor-block");break;case"bar":D.push("xterm-cursor-bar");break;case"underline":D.push("xterm-cursor-underline");break}}if(N.isBold()&&D.push("xterm-bold"),N.isItalic()&&D.push("xterm-italic"),N.isDim()&&D.push("xterm-dim"),N.isInvisible()?S=oo:S=N.getChars()||oo,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),S===" "&&(S=" "),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())k.style.textDecorationColor=`rgb(${Dc.toColorRGB(N.getUnderlineColor()).join(",")})`;else{let oe=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&oe<8&&(oe+=8),k.style.textDecorationColor=x.ansi[oe].css}N.isOverline()&&(D.push("xterm-overline"),S===" "&&(S=" ")),N.isStrikethrough()&&D.push("xterm-strikethrough"),H&&(k.style.textDecoration="underline");let Q=N.getFgColor(),ve=N.getFgColorMode(),de=N.getBgColor(),ne=N.getBgColorMode(),xe=!!N.isInverse();if(xe){let oe=Q;Q=de,de=oe;let Ne=ve;ve=ne,ne=Ne}let $e,rt,je=!1;this._decorationService.forEachDecorationAtCell(O,n,void 0,oe=>{oe.options.layer!=="top"&&je||(oe.backgroundColorRGB&&(ne=50331648,de=oe.backgroundColorRGB.rgba>>8&16777215,$e=oe.backgroundColorRGB),oe.foregroundColorRGB&&(ve=50331648,Q=oe.foregroundColorRGB.rgba>>8&16777215,rt=oe.foregroundColorRGB),je=oe.options.layer==="top")}),!je&&U&&($e=this._coreBrowserService.isFocused?x.selectionBackgroundOpaque:x.selectionInactiveBackgroundOpaque,de=$e.rgba>>8&16777215,ne=50331648,je=!0,x.selectionForeground&&(ve=50331648,Q=x.selectionForeground.rgba>>8&16777215,rt=x.selectionForeground)),je&&D.push("xterm-decoration-top");let Ie;switch(ne){case 16777216:case 33554432:Ie=x.ansi[de],D.push(`xterm-bg-${de}`);break;case 50331648:Ie=$n.toColor(de>>16,de>>8&255,de&255),this._addStyle(k,`background-color:#${hb((de>>>0).toString(16),"0",6)}`);break;case 0:default:xe?(Ie=x.foreground,D.push("xterm-bg-257")):Ie=x.background}switch($e||N.isDim()&&($e=fn.multiplyOpacity(Ie,.5)),ve){case 16777216:case 33554432:N.isBold()&&Q<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Q+=8),this._applyMinimumContrast(k,Ie,x.ansi[Q],N,$e,void 0)||D.push(`xterm-fg-${Q}`);break;case 50331648:let oe=$n.toColor(Q>>16&255,Q>>8&255,Q&255);this._applyMinimumContrast(k,Ie,oe,N,$e,rt)||this._addStyle(k,`color:#${hb(Q.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(k,Ie,x.foreground,N,$e,rt)||xe&&D.push("xterm-fg-257")}D.length&&(k.className=D.join(" "),D.length=0),!P&&!z&&!ie&&T?R++:k.textContent=S,te!==this.defaultSpacing&&(k.style.letterSpacing=`${te}px`),_.push(k),O=A}return k&&R&&(k.textContent=S),_}_applyMinimumContrast(e,n,s,i,a,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||vL(i.getCode()))return!1;let u=this._getContrastCache(i),h;if(!a&&!c&&(h=u.getColor(n.rgba,s.rgba)),h===void 0){let f=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);h=fn.ensureContrastRatio(a||n,c||s,f),u.setColor((a||n).rgba,(c||s).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,n){e.setAttribute("style",`${e.getAttribute("style")||""}${n};`)}_isCellInSelection(e,n){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&n>=s[1]&&e<i[0]&&n<=i[1]:e<s[0]&&n>=s[1]&&e>=i[0]&&n<=i[1]:n>s[1]&&n<i[1]||s[1]===i[1]&&n===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&n===i[1]&&e<i[0]||s[1]<i[1]&&n===s[1]&&e>=s[0]}};$m=jn([at(1,ox),at(2,Ts),at(3,Nr),at(4,Zo),at(5,Oc),at(6,Za)],$m);function hb(t,e,n){for(;t.length<n;)t=e+t;return t}var yL=class{constructor(e,n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let c=e.createElement("span");c.classList.add("xterm-char-measure-element"),c.style.fontWeight="bold",c.style.fontStyle="italic",this._measureElements=[s,i,a,c],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(a),this._container.appendChild(c),n.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,n,s,i){e===this._font&&n===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=n,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,n,s){let i=0;if(!n&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let u=this._measure(e,0);return u>0&&(this._flat[i]=u),u}let a=e;n&&(a+="B"),s&&(a+="I");let c=this._holey.get(a);if(c===void 0){let u=0;n&&(u|=1),s&&(u|=2),c=this._measure(e,u),c>0&&this._holey.set(a,c)}return c}_measure(e,n){let s=this._measureElements[n];return s.textContent=e.repeat(32),s.offsetWidth/32}},wL=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,n,s,i=!1){if(this.selectionStart=n,this.selectionEnd=s,!n||!s||n[0]===s[0]&&n[1]===s[1]){this.clear();return}let a=e.buffers.active.ydisp,c=n[1]-a,u=s[1]-a,h=Math.max(c,0),f=Math.min(u,e.rows-1);if(h>=e.rows||f<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=c,this.viewportEndRow=u,this.viewportCappedStartRow=h,this.viewportCappedEndRow=f,this.startCol=n[0],this.endCol=s[0]}isCellSelected(e,n,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?n>=this.startCol&&s>=this.viewportCappedStartRow&&n<this.endCol&&s<=this.viewportCappedEndRow:n<this.startCol&&s>=this.viewportCappedStartRow&&n>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&n>=this.startCol&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&n>=this.startCol):!1}};function bL(){return new wL}var Zf="xterm-dom-renderer-owner-",hi="xterm-rows",Vu="xterm-fg-",fb="xterm-bg-",Bl="xterm-focus",Yu="xterm-selection",SL=1,zm=class extends $t{constructor(e,n,s,i,a,c,u,h,f,g,v,_,b,x){super(),this._terminal=e,this._document=n,this._element=s,this._screenElement=i,this._viewportElement=a,this._helperContainer=c,this._linkifier2=u,this._charSizeService=f,this._optionsService=g,this._bufferService=v,this._coreService=_,this._coreBrowserService=b,this._themeService=x,this._terminalClass=SL++,this._rowElements=[],this._selectionRenderModel=bL(),this.onRequestRedraw=this._register(new nt).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(Yu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=_L(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(L=>this._injectCss(L))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance($m,document),this._element.classList.add(Zf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(L=>this._handleLinkHover(L))),this._register(this._linkifier2.onHideLinkUnderline(L=>this._handleLinkLeave(L))),this._register(_n(()=>{this._element.classList.remove(Zf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new yL(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let n=`${this._terminalSelector} .${hi} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=n,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 n=`${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}`;n+=`${this._terminalSelector} .${hi} .xterm-dim { color: ${fn.multiplyOpacity(e.foreground,.5).css};}`,n+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;n+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,n+=`@keyframes ${i} { 50% { box-shadow: none; }}`,n+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,n+=`${this._terminalSelector} .${hi}.${Bl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${hi}.${Bl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${hi}.${Bl} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 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);}`,n+=`${this._terminalSelector} .${Yu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Yu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Yu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())n+=`${this._terminalSelector} .${Vu}${c} { color: ${u.css}; }${this._terminalSelector} .${Vu}${c}.xterm-dim { color: ${fn.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${fb}${c} { background-color: ${u.css}; }`;n+=`${this._terminalSelector} .${Vu}257 { color: ${fn.opaque(e.background).css}; }${this._terminalSelector} .${Vu}257.xterm-dim { color: ${fn.multiplyOpacity(fn.opaque(e.background),.5).css}; }${this._terminalSelector} .${fb}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=n}_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,n){for(let s=this._rowElements.length;s<=n;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>n;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,n){this._refreshRowElements(e,n),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(Bl),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Bl),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,n,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,n,s),this.renderRows(0,this._bufferService.rows-1),!e||!n||(this._selectionRenderModel.update(this._terminal,e,n,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,c=this._selectionRenderModel.viewportCappedStartRow,u=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(s){let f=e[0]>n[0];h.appendChild(this._createSelectionElement(c,f?n[0]:e[0],f?e[0]:n[0],u-c+1))}else{let f=i===c?e[0]:0,g=c===a?n[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(c,f,g));let v=u-c-1;if(h.appendChild(this._createSelectionElement(c+1,0,this._bufferService.cols,v)),c!==u){let _=a===u?n[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(u,0,_))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,n,s,i=1){let a=this._document.createElement("div"),c=n*this.dimensions.css.cell.width,u=this.dimensions.css.cell.width*(s-n);return c+u>this.dimensions.css.canvas.width&&(u=this.dimensions.css.canvas.width-c),a.style.height=`${i*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${c}px`,a.style.width=`${u}px`,a}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,n){let s=this._bufferService.buffer,i=s.ybase+s.y,a=Math.min(s.x,this._bufferService.cols-1),c=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,u=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let f=e;f<=n;f++){let g=f+s.ydisp,v=this._rowElements[f],_=s.lines.get(g);if(!v||!_)break;v.replaceChildren(...this._rowFactory.createRow(_,g,g===i,u,h,a,c,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Zf}${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,n,s,i,a,c){s<0&&(e=0),i<0&&(n=0);let u=this._bufferService.rows-1;s=Math.max(Math.min(s,u),0),i=Math.max(Math.min(i,u),0),a=Math.min(a,this._bufferService.cols);let h=this._bufferService.buffer,f=h.ybase+h.y,g=Math.min(h.x,a-1),v=this._optionsService.rawOptions.cursorBlink,_=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let x=s;x<=i;++x){let L=x+h.ydisp,k=this._rowElements[x],R=h.lines.get(L);if(!k||!R)break;k.replaceChildren(...this._rowFactory.createRow(R,L,L===f,_,b,g,v,this.dimensions.css.cell.width,this._widthCache,c?x===s?e:0:-1,c?(x===i?n:a)-1:-1))}}};zm=jn([at(7,sv),at(8,sh),at(9,Ts),at(10,Ms),at(11,Zo),at(12,Nr),at(13,Za)],zm);var Fm=class extends $t{constructor(e,n,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new nt),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new kL(this._optionsService))}catch{this._measureStrategy=this._register(new xL(e,n,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())}};Fm=jn([at(2,Ts)],Fm);var Cx=class extends $t{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(t,e){t!==void 0&&t>0&&e!==void 0&&e>0&&(this._result.width=t,this._result.height=e)}},xL=class extends Cx{constructor(t,e,n){super(),this._document=t,this._parentElement=e,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}},kL=class extends Cx{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let n=this._ctx.measureText("W");if(!("width"in n&&"fontBoundingBoxAscent"in n&&"fontBoundingBoxDescent"in n))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}},CL=class extends $t{constructor(e,n,s){super(),this._textarea=e,this._window=n,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new EL(this._window)),this._onDprChange=this._register(new nt),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new nt),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(vs.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Mt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Mt(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}},EL=class extends $t{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Wa),this._onDprChange=this._register(new nt),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_n(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Mt(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)}},NL=class extends $t{constructor(){super(),this.linkProviders=[],this._register(_n(()=>this.linkProviders.length=0))}registerLinkProvider(t){return this.linkProviders.push(t),{dispose:()=>{let e=this.linkProviders.indexOf(t);e!==-1&&this.linkProviders.splice(e,1)}}}};function dv(t,e,n){let s=n.getBoundingClientRect(),i=t.getComputedStyle(n),a=parseInt(i.getPropertyValue("padding-left")),c=parseInt(i.getPropertyValue("padding-top"));return[e.clientX-s.left-a,e.clientY-s.top-c]}function RL(t,e,n,s,i,a,c,u,h){if(!a)return;let f=dv(t,e,n);if(f)return f[0]=Math.ceil((f[0]+(h?c/2:0))/c),f[1]=Math.ceil(f[1]/u),f[0]=Math.min(Math.max(f[0],1),s+(h?1:0)),f[1]=Math.min(Math.max(f[1],1),i),f}var Hm=class{constructor(e,n){this._renderService=e,this._charSizeService=n}getCoords(e,n,s,i,a){return RL(window,e,n,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,n){let s=dv(window,e,n);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Hm=jn([at(0,Rr),at(1,sh)],Hm);var LL=class{constructor(e,n){this._renderCallback=e,this._coreBrowserService=n,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,n,s){this._rowCount=s,e=e!==void 0?e:0,n=n!==void 0?n: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,n):n,!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),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Ex={};$5(Ex,{getSafariVersion:()=>jL,isChromeOS:()=>Ax,isFirefox:()=>Nx,isIpad:()=>ML,isIphone:()=>TL,isLegacyEdge:()=>AL,isLinux:()=>hv,isMac:()=>jd,isNode:()=>ih,isSafari:()=>Rx,isWindows:()=>Lx});var ih=typeof process<"u"&&"title"in process,Bc=ih?"node":navigator.userAgent,$c=ih?"node":navigator.platform,Nx=Bc.includes("Firefox"),AL=Bc.includes("Edge"),Rx=/^((?!chrome|android).)*safari/i.test(Bc);function jL(){if(!Rx)return 0;let t=Bc.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var jd=["Macintosh","MacIntel","MacPPC","Mac68K"].includes($c),ML=$c==="iPad",TL=$c==="iPhone",Lx=["Windows","Win16","Win32","WinCE"].includes($c),hv=$c.indexOf("Linux")>=0,Ax=/\bCrOS\b/.test(Bc),jx=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,n=0,s=t.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),n=Math.max(e,n),i=t.timeRemaining(),n*1.5>i){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=i}this.clear()}},PL=class extends jx{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let n=performance.now()+e;return{timeRemaining:()=>Math.max(0,n-performance.now())}}},IL=class extends jx{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Md=!ih&&"requestIdleCallback"in window?IL:PL,DL=class{constructor(){this._queue=new Md}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Um=class extends $t{constructor(e,n,s,i,a,c,u,h,f){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=a,this._coreBrowserService=h,this._renderer=this._register(new Wa),this._pausedResizeTask=new DL,this._observerDisposable=this._register(new Wa),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 nt),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new nt),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new nt),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new nt),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new LL((g,v)=>this._renderRows(g,v),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new OL(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_n(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(u.onResize(()=>this._fullRefresh())),this._register(u.buffers.onBufferActivate(()=>{var g;return(g=this._renderer.value)==null?void 0:g.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(c.onDecorationRegistered(()=>this._fullRefresh())),this._register(c.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(u.cols,u.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(u.buffer.y,u.buffer.y,!0))),this._register(f.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,n),this._register(this._coreBrowserService.onWindowChange(g=>this._registerIntersectionObserver(g,n)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,n){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(n),this._observerDisposable.value=_n(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,n,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),n=Math.max(n,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,n,this._rowCount)}_renderRows(e,n){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}e=Math.min(e,this._rowCount-1),n=Math.min(n,this._rowCount-1),this._renderer.value.renderRows(e,n),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:n}),this._onRender.fire({start:e,end:n}),this._isNextRenderRedrawOnly=!0}}resize(e,n){this._rowCount=n,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(n=>this.refreshRows(n.start,n.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,n;this._renderer.value&&((n=(e=this._renderer.value).clearTextureAtlas)==null||n.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,n){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,n)}):this._renderer.value.handleResize(e,n),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,n,s){var i;this._selectionState.start=e,this._selectionState.end=n,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,n,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Um=jn([at(2,Ts),at(3,sh),at(4,Zo),at(5,Oc),at(6,Ms),at(7,Nr),at(8,Za)],Um);var OL=class{constructor(t,e,n){this._coreBrowserService=t,this._coreService=e,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(t,e){this._isBuffering?(this._start=Math.min(this._start,t),this._end=Math.max(this._end,e)):(this._start=t,this._end=e,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 t={start:this._start,end:this._end};return this._isBuffering=!1,t}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function BL(t,e,n,s){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return FL(i,a,t,e,n,s)+rh(a,e,n,s)+HL(i,a,t,e,n,s);let c;if(a===e)return c=i>t?"D":"C",bc(Math.abs(i-t),wc(c,s));c=a>e?"D":"C";let u=Math.abs(a-e),h=zL(a>e?t:i,n)+(u-1)*n.cols+1+$L(a>e?i:t);return bc(h,wc(c,s))}function $L(t,e){return t-1}function zL(t,e){return e.cols-t}function FL(t,e,n,s,i,a){return rh(e,s,i,a).length===0?"":bc(Tx(t,e,t,e-Xo(e,i),!1,i).length,wc("D",a))}function rh(t,e,n,s){let i=t-Xo(t,n),a=e-Xo(e,n),c=Math.abs(i-a)-UL(t,e,n);return bc(c,wc(Mx(t,e),s))}function HL(t,e,n,s,i,a){let c;rh(e,s,i,a).length>0?c=s-Xo(s,i):c=e;let u=s,h=WL(t,e,n,s,i,a);return bc(Tx(t,c,n,u,h==="C",i).length,wc(h,a))}function UL(t,e,n){var c;let s=0,i=t-Xo(t,n),a=e-Xo(e,n);for(let u=0;u<Math.abs(i-a);u++){let h=Mx(t,e)==="A"?-1:1;(c=n.buffer.lines.get(i+h*u))!=null&&c.isWrapped&&s++}return s}function Xo(t,e){let n=0,s=e.buffer.lines.get(t),i=s==null?void 0:s.isWrapped;for(;i&&t>=0&&t<e.rows;)n++,s=e.buffer.lines.get(--t),i=s==null?void 0:s.isWrapped;return n}function WL(t,e,n,s,i,a){let c;return rh(n,s,i,a).length>0?c=s-Xo(s,i):c=e,t<n&&c<=s||t>=n&&c<s?"C":"D"}function Mx(t,e){return t>e?"A":"B"}function Tx(t,e,n,s,i,a){let c=t,u=e,h="";for(;(c!==n||u!==s)&&u>=0&&u<a.buffer.lines.length;)c+=i?1:-1,i&&c>a.cols-1?(h+=a.buffer.translateBufferLineToString(u,!1,t,c),c=0,t=0,u++):!i&&c<0&&(h+=a.buffer.translateBufferLineToString(u,!1,0,t+1),c=a.cols-1,t=c,u--);return h+a.buffer.translateBufferLineToString(u,!1,t,c)}function wc(t,e){let n=e?"O":"[";return Oe.ESC+n+t}function bc(t,e){t=Math.floor(t);let n="";for(let s=0;s<t;s++)n+=e;return n}var qL=class{constructor(t){this._bufferService=t,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 t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?t%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)-1]:[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[t,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let t=this.selectionStart[0]+this.selectionStartLength;return t>this._bufferService.cols?[t%this._bufferService.cols,this.selectionStart[1]+Math.floor(t/this._bufferService.cols)]:[Math.max(t,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let t=this.selectionStart,e=this.selectionEnd;return!t||!e?!1:t[1]>e[1]||t[1]===e[1]&&t[0]>e[0]}handleTrim(t){return this.selectionStart&&(this.selectionStart[1]-=t),this.selectionEnd&&(this.selectionEnd[1]-=t),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function pb(t,e){if(t.start.y>t.end.y)throw new Error(`Buffer range end (${t.end.x}, ${t.end.y}) cannot be before start (${t.start.x}, ${t.start.y})`);return e*(t.end.y-t.start.y)+(t.end.x-t.start.x+1)}var ep=50,KL=15,VL=50,YL=500,GL=" ",XL=new RegExp(GL,"g"),Wm=class extends $t{constructor(e,n,s,i,a,c,u,h,f){super(),this._element=e,this._screenElement=n,this._linkifier=s,this._bufferService=i,this._coreService=a,this._mouseService=c,this._optionsService=u,this._renderService=h,this._coreBrowserService=f,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new bi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new nt),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new nt),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new nt),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new nt),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=g=>this._handleMouseMove(g),this._mouseUpListener=g=>this._handleMouseUp(g),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(g=>this._handleTrim(g)),this._register(this._bufferService.buffers.onBufferActivate(g=>this._handleBufferActivate(g))),this.enable(),this._model=new qL(this._bufferService),this._activeSelectionMode=0,this._register(_n(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(g=>{g.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,n=this._model.finalSelectionEnd;return!e||!n?!1:e[0]!==n[0]||e[1]!==n[1]}get selectionText(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;if(!e||!n)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===n[0])return"";let a=e[0]<n[0]?e[0]:n[0],c=e[0]<n[0]?n[0]:e[0];for(let u=e[1];u<=n[1];u++){let h=s.translateBufferLineToString(u,!0,a,c);i.push(h)}}else{let a=e[1]===n[1]?n[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],a));for(let c=e[1]+1;c<=n[1]-1;c++){let u=s.lines.get(c),h=s.translateBufferLineToString(c,!0);u!=null&&u.isWrapped?i[i.length-1]+=h:i.push(h)}if(e[1]!==n[1]){let c=s.lines.get(n[1]),u=s.translateBufferLineToString(n[1],!0,0,n[0]);c&&c.isWrapped?i[i.length-1]+=u:i.push(u)}}return i.map(a=>a.replace(XL," ")).join(Lx?`\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())),hv&&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 n=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!n?!1:this._areCoordsInSelection(n,s,i)}isCellInSelection(e,n){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,n],s,i)}_areCoordsInSelection(e,n,s){return e[1]>n[1]&&e[1]<s[1]||n[1]===s[1]&&e[1]===n[1]&&e[0]>=n[0]&&e[0]<s[0]||n[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||n[1]<s[1]&&e[1]===n[1]&&e[0]>=n[0]}_selectWordAtCursor(e,n){var a,c;let s=(c=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:c.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=pb(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,n),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,n){this._model.clearSelection(),e=Math.max(e,0),n=Math.min(n,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,n],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let n=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(n)return n[0]--,n[1]--,n[1]+=this._bufferService.buffer.ydisp,n}_getMouseEventScrollAmount(e){let n=dv(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return n>=0&&n<=s?0:(n>s&&(n-=s),n=Math.min(Math.max(n,-ep),ep),n/=ep,n/Math.abs(n)+Math.round(n*(KL-1)))}shouldForceSelection(e){return jd?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(),VL)}_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 n=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);n&&n.length!==this._model.selectionStart[0]&&n.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let n=this._getMouseBufferCoords(e);n&&(this._activeSelectionMode=2,this._selectLineAt(n[1]))}shouldColumnSelect(e){return e.altKey&&!(jd&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let n=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!n||n[0]!==this._model.selectionEnd[0]||n[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 n=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&n<YL&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=BL(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd,s=!!e&&!!n&&(e[0]!==n[0]||e[1]!==n[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,n,s);return}!e||!n||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||n[0]!==this._oldSelectionEnd[0]||n[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,n,s)}_fireOnSelectionChange(e,n,s){this._oldSelectionStart=e,this._oldSelectionEnd=n,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(n=>this._handleTrim(n))}_convertViewportColToCharacterIndex(e,n){let s=n;for(let i=0;n>=i;i++){let a=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:a>1&&n!==i&&(s+=a-1)}return s}setSelection(e,n,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,n],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,n,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,c=a.lines.get(e[1]);if(!c)return;let u=a.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(c,e[0]),f=h,g=e[0]-h,v=0,_=0,b=0,x=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;f<u.length&&u.charAt(f+1)===" ";)f++}else{let R=e[0],S=e[0];c.getWidth(R)===0&&(v++,R--),c.getWidth(S)===2&&(_++,S++);let j=c.getString(S).length;for(j>1&&(x+=j-1,f+=j-1);R>0&&h>0&&!this._isCharWordSeparator(c.loadCell(R-1,this._workCell));){c.loadCell(R-1,this._workCell);let E=this._workCell.getChars().length;this._workCell.getWidth()===0?(v++,R--):E>1&&(b+=E-1,h-=E-1),h--,R--}for(;S<c.length&&f+1<u.length&&!this._isCharWordSeparator(c.loadCell(S+1,this._workCell));){c.loadCell(S+1,this._workCell);let E=this._workCell.getChars().length;this._workCell.getWidth()===2?(_++,S++):E>1&&(x+=E-1,f+=E-1),f++,S++}}f++;let L=h+g-v+b,k=Math.min(this._bufferService.cols,f-h+v+_-b-x);if(!(!n&&u.slice(h,f).trim()==="")){if(s&&L===0&&c.getCodePoint(0)!==32){let R=a.lines.get(e[1]-1);if(R&&c.isWrapped&&R.getCodePoint(this._bufferService.cols-1)!==32){let S=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(S){let j=this._bufferService.cols-S.start;L-=j,k+=j}}}if(i&&L+k===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let R=a.lines.get(e[1]+1);if(R!=null&&R.isWrapped&&R.getCodePoint(0)!==32){let S=this._getWordAt([0,e[1]+1],!1,!1,!0);S&&(k+=S.length)}}return{start:L,length:k}}}_selectWordAt(e,n){let s=this._getWordAt(e,n);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let n=this._getWordAt(e,!0);if(n){let s=e[1];for(;n.start<0;)n.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;n.start+n.length>this._bufferService.cols;)n.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?n.start:n.start+n.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let n=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:n.first},end:{x:this._bufferService.cols-1,y:n.last}};this._model.selectionStart=[0,n.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=pb(s,this._bufferService.cols)}};Wm=jn([at(3,Ms),at(4,Zo),at(5,iv),at(6,Ts),at(7,Rr),at(8,Nr)],Wm);var mb=class{constructor(){this._data={}}set(e,n,s){this._data[e]||(this._data[e]={}),this._data[e][n]=s}get(e,n){return this._data[e]?this._data[e][n]:void 0}clear(){this._data={}}},gb=class{constructor(){this._color=new mb,this._css=new mb}setCss(e,n,s){this._css.set(e,n,s)}getCss(e,n){return this._css.get(e,n)}setColor(e,n,s){this._color.set(e,n,s)}getColor(e,n){return this._color.get(e,n)}clear(){this._color.clear(),this._css.clear()}},Un=Object.freeze((()=>{let t=[En.toColor("#2e3436"),En.toColor("#cc0000"),En.toColor("#4e9a06"),En.toColor("#c4a000"),En.toColor("#3465a4"),En.toColor("#75507b"),En.toColor("#06989a"),En.toColor("#d3d7cf"),En.toColor("#555753"),En.toColor("#ef2929"),En.toColor("#8ae234"),En.toColor("#fce94f"),En.toColor("#729fcf"),En.toColor("#ad7fa8"),En.toColor("#34e2e2"),En.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let n=0;n<216;n++){let s=e[n/36%6|0],i=e[n/6%6|0],a=e[n%6];t.push({css:$n.toCss(s,i,a),rgba:$n.toRgba(s,i,a)})}for(let n=0;n<24;n++){let s=8+n*10;t.push({css:$n.toCss(s,s,s),rgba:$n.toRgba(s,s,s)})}return t})()),Bo=En.toColor("#ffffff"),oc=En.toColor("#000000"),vb=En.toColor("#ffffff"),_b=oc,$l={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},JL=Bo,qm=class extends $t{constructor(e){super(),this._optionsService=e,this._contrastCache=new gb,this._halfContrastCache=new gb,this._onChangeColors=this._register(new nt),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Bo,background:oc,cursor:vb,cursorAccent:_b,selectionForeground:void 0,selectionBackgroundTransparent:$l,selectionBackgroundOpaque:fn.blend(oc,$l),selectionInactiveBackgroundTransparent:$l,selectionInactiveBackgroundOpaque:fn.blend(oc,$l),scrollbarSliderBackground:fn.opacity(Bo,.2),scrollbarSliderHoverBackground:fn.opacity(Bo,.4),scrollbarSliderActiveBackground:fn.opacity(Bo,.5),overviewRulerBorder:Bo,ansi:Un.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 n=this._colors;if(n.foreground=rn(e.foreground,Bo),n.background=rn(e.background,oc),n.cursor=fn.blend(n.background,rn(e.cursor,vb)),n.cursorAccent=fn.blend(n.background,rn(e.cursorAccent,_b)),n.selectionBackgroundTransparent=rn(e.selectionBackground,$l),n.selectionBackgroundOpaque=fn.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=rn(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=fn.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?rn(e.selectionForeground,db):void 0,n.selectionForeground===db&&(n.selectionForeground=void 0),fn.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=fn.opacity(n.selectionBackgroundTransparent,.3)),fn.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=fn.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.scrollbarSliderBackground=rn(e.scrollbarSliderBackground,fn.opacity(n.foreground,.2)),n.scrollbarSliderHoverBackground=rn(e.scrollbarSliderHoverBackground,fn.opacity(n.foreground,.4)),n.scrollbarSliderActiveBackground=rn(e.scrollbarSliderActiveBackground,fn.opacity(n.foreground,.5)),n.overviewRulerBorder=rn(e.overviewRulerBorder,JL),n.ansi=Un.slice(),n.ansi[0]=rn(e.black,Un[0]),n.ansi[1]=rn(e.red,Un[1]),n.ansi[2]=rn(e.green,Un[2]),n.ansi[3]=rn(e.yellow,Un[3]),n.ansi[4]=rn(e.blue,Un[4]),n.ansi[5]=rn(e.magenta,Un[5]),n.ansi[6]=rn(e.cyan,Un[6]),n.ansi[7]=rn(e.white,Un[7]),n.ansi[8]=rn(e.brightBlack,Un[8]),n.ansi[9]=rn(e.brightRed,Un[9]),n.ansi[10]=rn(e.brightGreen,Un[10]),n.ansi[11]=rn(e.brightYellow,Un[11]),n.ansi[12]=rn(e.brightBlue,Un[12]),n.ansi[13]=rn(e.brightMagenta,Un[13]),n.ansi[14]=rn(e.brightCyan,Un[14]),n.ansi[15]=rn(e.brightWhite,Un[15]),e.extendedAnsi){let s=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)n.ansi[i+16]=rn(e.extendedAnsi[i],Un[i+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 n=0;n<this._restoreColors.ansi.length;++n)this._colors.ansi[n]=this._restoreColors.ansi[n];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()}}};qm=jn([at(0,Ts)],qm);function rn(t,e){if(t!==void 0)try{return En.toColor(t)}catch{}return e}var QL=class{constructor(...e){this._entries=new Map;for(let[n,s]of e)this.set(n,s)}set(e,n){let s=this._entries.get(e);return this._entries.set(e,n),s}forEach(e){for(let[n,s]of this._entries.entries())e(n,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},ZL=class{constructor(){this._services=new QL,this._services.set(sv,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let n=K5(t).sort((a,c)=>a.index-c.index),s=[];for(let a of n){let c=this._services.get(a.id);if(!c)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${a.id._id}.`);s.push(c)}let i=n.length>0?n[0].index:e.length;if(e.length!==i)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${i+1} conflicts with ${e.length} static arguments`);return new t(...e,...s)}},eA={trace:0,debug:1,info:2,warn:3,error:4,off:5},tA="xterm.js: ",Km=class extends $t{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=eA[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let n=0;n<e.length;n++)typeof e[n]=="function"&&(e[n]=e[n]())}_log(e,n,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":tA)+n,...s)}trace(e,...n){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,n)}debug(e,...n){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,n)}info(e,...n){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,n)}warn(e,...n){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,n)}error(e,...n){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,n)}};Km=jn([at(0,Ts)],Km);var yb=class extends $t{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new nt),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new nt),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new nt),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 n=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)n[s]=this._array[this._getCyclicIndex(s)];this._array=n,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let n=this._length;n<e;n++)this._array[n]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,n){this._array[this._getCyclicIndex(e)]=n}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,n,...s){if(n){for(let i=e;i<this._length-n;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+n)];this._length-=n,this.onDeleteEmitter.fire({index:e,amount:n})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,n,s){if(!(n<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let a=n-1;a>=0;a--)this.set(e+a+s,this.get(e+a));let i=e+n+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<n;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Ot=3,On=Object.freeze(new Dc),Gu=0,tp=2,ac=class Px{constructor(e,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Ot);let i=n||bi.fromCharData([0,Z1,1,0]);for(let a=0;a<e;++a)this.setCell(a,i);this.length=e}get(e){let n=this._data[e*Ot+0],s=n&2097151;return[this._data[e*Ot+1],n&2097152?this._combined[e]:s?io(s):"",n>>22,n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,n){this._data[e*Ot+1]=n[0],n[1].length>1?(this._combined[e]=n[1],this._data[e*Ot+0]=e|2097152|n[2]<<22):this._data[e*Ot+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(e){return this._data[e*Ot+0]>>22}hasWidth(e){return this._data[e*Ot+0]&12582912}getFg(e){return this._data[e*Ot+1]}getBg(e){return this._data[e*Ot+2]}hasContent(e){return this._data[e*Ot+0]&4194303}getCodePoint(e){let n=this._data[e*Ot+0];return n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n&2097151}isCombined(e){return this._data[e*Ot+0]&2097152}getString(e){let n=this._data[e*Ot+0];return n&2097152?this._combined[e]:n&2097151?io(n&2097151):""}isProtected(e){return this._data[e*Ot+2]&536870912}loadCell(e,n){return Gu=e*Ot,n.content=this._data[Gu+0],n.fg=this._data[Gu+1],n.bg=this._data[Gu+2],n.content&2097152&&(n.combinedData=this._combined[e]),n.bg&268435456&&(n.extended=this._extendedAttrs[e]),n}setCell(e,n){n.content&2097152&&(this._combined[e]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[e]=n.extended),this._data[e*Ot+0]=n.content,this._data[e*Ot+1]=n.fg,this._data[e*Ot+2]=n.bg}setCellFromCodepoint(e,n,s,i){i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*Ot+0]=n|s<<22,this._data[e*Ot+1]=i.fg,this._data[e*Ot+2]=i.bg}addCodepointToCell(e,n,s){let i=this._data[e*Ot+0];i&2097152?this._combined[e]+=io(n):i&2097151?(this._combined[e]=io(i&2097151)+io(n),i&=-2097152,i|=2097152):i=n|1<<22,s&&(i&=-12582913,i|=s<<22),this._data[e*Ot+0]=i}insertCells(e,n,s){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),n<this.length-e){let i=new bi;for(let a=this.length-e-n-1;a>=0;--a)this.setCell(e+n+a,this.loadCell(e+a,i));for(let a=0;a<n;++a)this.setCell(e+a,s)}else for(let i=e;i<this.length;++i)this.setCell(i,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,n,s){if(e%=this.length,n<this.length-e){let i=new bi;for(let a=0;a<this.length-e-n;++a)this.setCell(e+a,this.loadCell(e+n+a,i));for(let a=this.length-n;a<this.length;++a)this.setCell(a,s)}else for(let i=e;i<this.length;++i)this.setCell(i,s);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,n,s,i=!1){if(i){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,s);e<n&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,s);e<n&&e<this.length;)this.setCell(e++,s)}resize(e,n){if(e===this.length)return this._data.length*4*tp<this._data.buffer.byteLength;let s=e*Ot;if(e>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let i=new Uint32Array(s);i.set(this._data),this._data=i}for(let i=this.length;i<e;++i)this.setCell(i,n)}else{this._data=this._data.subarray(0,s);let i=Object.keys(this._combined);for(let c=0;c<i.length;c++){let u=parseInt(i[c],10);u>=e&&delete this._combined[u]}let a=Object.keys(this._extendedAttrs);for(let c=0;c<a.length;c++){let u=parseInt(a[c],10);u>=e&&delete this._extendedAttrs[u]}}return this.length=e,s*4*tp<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*tp<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,n=!1){if(n){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,e);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let n in e._combined)this._combined[n]=e._combined[n];this._extendedAttrs={};for(let n in e._extendedAttrs)this._extendedAttrs[n]=e._extendedAttrs[n];this.isWrapped=e.isWrapped}clone(){let e=new Px(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let n in this._combined)e._combined[n]=this._combined[n];for(let n in this._extendedAttrs)e._extendedAttrs[n]=this._extendedAttrs[n];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Ot+0]&4194303)return e+(this._data[e*Ot+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Ot+0]&4194303||this._data[e*Ot+2]&50331648)return e+(this._data[e*Ot+0]>>22);return 0}copyCellsFrom(e,n,s,i,a){let c=e._data;if(a)for(let h=i-1;h>=0;h--){for(let f=0;f<Ot;f++)this._data[(s+h)*Ot+f]=c[(n+h)*Ot+f];c[(n+h)*Ot+2]&268435456&&(this._extendedAttrs[s+h]=e._extendedAttrs[n+h])}else for(let h=0;h<i;h++){for(let f=0;f<Ot;f++)this._data[(s+h)*Ot+f]=c[(n+h)*Ot+f];c[(n+h)*Ot+2]&268435456&&(this._extendedAttrs[s+h]=e._extendedAttrs[n+h])}let u=Object.keys(e._combined);for(let h=0;h<u.length;h++){let f=parseInt(u[h],10);f>=n&&(this._combined[f-n+s]=e._combined[f])}}translateToString(e,n,s,i){n=n??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),i&&(i.length=0);let a="";for(;n<s;){let c=this._data[n*Ot+0],u=c&2097151,h=c&2097152?this._combined[n]:u?io(u):oo;if(a+=h,i)for(let f=0;f<h.length;++f)i.push(n);n+=c>>22||1}return i&&i.push(n),a}};function nA(t,e,n,s,i,a){let c=[];for(let u=0;u<t.length-1;u++){let h=u,f=t.get(++h);if(!f.isWrapped)continue;let g=[t.get(u)];for(;h<t.length&&f.isWrapped;)g.push(f),f=t.get(++h);if(!a&&s>=u&&s<h){u+=g.length-1;continue}let v=0,_=Sc(g,v,e),b=1,x=0;for(;b<g.length;){let k=Sc(g,b,e),R=k-x,S=n-_,j=Math.min(R,S);g[v].copyCellsFrom(g[b],x,_,j,!1),_+=j,_===n&&(v++,_=0),x+=j,x===k&&(b++,x=0),_===0&&v!==0&&g[v-1].getWidth(n-1)===2&&(g[v].copyCellsFrom(g[v-1],n-1,_++,1,!1),g[v-1].setCell(n-1,i))}g[v].replaceCells(_,n,i);let L=0;for(let k=g.length-1;k>0&&(k>v||g[k].getTrimmedLength()===0);k--)L++;L>0&&(c.push(u+g.length-L),c.push(L)),u+=g.length-1}return c}function sA(t,e){let n=[],s=0,i=e[s],a=0;for(let c=0;c<t.length;c++)if(i===c){let u=e[++s];t.onDeleteEmitter.fire({index:c-a,amount:u}),c+=u-1,a+=u,i=e[++s]}else n.push(c);return{layout:n,countRemoved:a}}function iA(t,e){let n=[];for(let s=0;s<e.length;s++)n.push(t.get(e[s]));for(let s=0;s<n.length;s++)t.set(s,n[s]);t.length=e.length}function rA(t,e,n){let s=[],i=t.map((h,f)=>Sc(t,f,e)).reduce((h,f)=>h+f),a=0,c=0,u=0;for(;u<i;){if(i-u<n){s.push(i-u);break}a+=n;let h=Sc(t,c,e);a>h&&(a-=h,c++);let f=t[c].getWidth(a-1)===2;f&&a--;let g=f?n-1:n;s.push(g),u+=g}return s}function Sc(t,e,n){if(e===t.length-1)return t[e].getTrimmedLength();let s=!t[e].hasContent(n-1)&&t[e].getWidth(n-1)===1,i=t[e+1].getWidth(0)===2;return s&&i?n-1:n}var Ix=class Dx{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Dx._nextId++,this._onDispose=this.register(new nt),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Go(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Ix._nextId=1;var oA=Ix,Kn={},$o=Kn.B;Kn[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Kn.A={"#":"£"};Kn.B=void 0;Kn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Kn.C=Kn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Kn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Kn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Kn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Kn.E=Kn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Kn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Kn.H=Kn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Kn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var wb=4294967295,bb=class{constructor(t,e,n){this._hasScrollback=t,this._optionsService=e,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=On.clone(),this.savedCharset=$o,this.markers=[],this._nullCell=bi.fromCharData([0,Z1,1,0]),this._whitespaceCell=bi.fromCharData([0,oo,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Md,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new yb(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(t){return t?(this._nullCell.fg=t.fg,this._nullCell.bg=t.bg,this._nullCell.extended=t.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Rd),this._nullCell}getWhitespaceCell(t){return t?(this._whitespaceCell.fg=t.fg,this._whitespaceCell.bg=t.bg,this._whitespaceCell.extended=t.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Rd),this._whitespaceCell}getBlankLine(t,e){return new ac(this._bufferService.cols,this.getNullCell(t),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let t=this.ybase+this.y-this.ydisp;return t>=0&&t<this._rows}_getCorrectBufferLength(t){if(!this._hasScrollback)return t;let e=t+this._optionsService.rawOptions.scrollback;return e>wb?wb:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=On);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(t))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new yb(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let n=this.getNullCell(On),s=0,i=this._getCorrectBufferLength(e);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<t)for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(t,n);let a=0;if(this._rows<e)for(let c=this._rows;c<e;c++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ac(t,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 ac(t,n)));else for(let c=this._rows;c>e;c--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let c=this.lines.length-i;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=i}this.x=Math.min(this.x,t-1),this.y=Math.min(this.y,e-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,t-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(t,e),this._cols>t))for(let a=0;a<this.lines.length;a++)s+=+this.lines.get(a).resize(t,n);this._cols=t,this._rows=e,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let t=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,t=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return t}get _isReflowEnabled(){let t=this._optionsService.rawOptions.windowsPty;return t&&t.buildNumber?this._hasScrollback&&t.backend==="conpty"&&t.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(t,e){this._cols!==t&&(t>this._cols?this._reflowLarger(t,e):this._reflowSmaller(t,e))}_reflowLarger(t,e){let n=this._optionsService.rawOptions.reflowCursorLine,s=nA(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(On),n);if(s.length>0){let i=sA(this.lines,s);iA(this.lines,i.layout),this._reflowLargerAdjustViewport(t,e,i.countRemoved)}}_reflowLargerAdjustViewport(t,e,n){let s=this.getNullCell(On),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new ac(t,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(t,e){let n=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(On),i=[],a=0;for(let c=this.lines.length-1;c>=0;c--){let u=this.lines.get(c);if(!u||!u.isWrapped&&u.getTrimmedLength()<=t)continue;let h=[u];for(;u.isWrapped&&c>0;)u=this.lines.get(--c),h.unshift(u);if(!n){let j=this.ybase+this.y;if(j>=c&&j<c+h.length)continue}let f=h[h.length-1].getTrimmedLength(),g=rA(h,this._cols,t),v=g.length-h.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+v):_=Math.max(0,this.lines.length-this.lines.maxLength+v);let b=[];for(let j=0;j<v;j++){let E=this.getBlankLine(On,!0);b.push(E)}b.length>0&&(i.push({start:c+h.length+a,newLines:b}),a+=b.length),h.push(...b);let x=g.length-1,L=g[x];L===0&&(x--,L=g[x]);let k=h.length-v-1,R=f;for(;k>=0;){let j=Math.min(R,L);if(h[x]===void 0)break;if(h[x].copyCellsFrom(h[k],R-j,L-j,j,!0),L-=j,L===0&&(x--,L=g[x]),R-=j,R===0){k--;let E=Math.max(k,0);R=Sc(h,E,this._cols)}}for(let j=0;j<h.length;j++)g[j]<t&&h[j].setCell(g[j],s);let S=v-_;for(;S-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+v,this.ybase+e-1)}if(i.length>0){let c=[],u=[];for(let L=0;L<this.lines.length;L++)u.push(this.lines.get(L));let h=this.lines.length,f=h-1,g=0,v=i[g];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let _=0;for(let L=Math.min(this.lines.maxLength-1,h+a-1);L>=0;L--)if(v&&v.start>f+_){for(let k=v.newLines.length-1;k>=0;k--)this.lines.set(L--,v.newLines[k]);L++,c.push({index:f+1,amount:v.newLines.length}),_+=v.newLines.length,v=i[++g]}else this.lines.set(L,u[f--]);let b=0;for(let L=c.length-1;L>=0;L--)c[L].index+=b,this.lines.onInsertEmitter.fire(c[L]),b+=c[L].amount;let x=Math.max(0,h+a-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(t,e,n=0,s){let i=this.lines.get(t);return i?i.translateToString(e,n,s):""}getWrappedRangeForLine(t){let e=t,n=t;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:e,last:n}}setupTabStops(t){for(t!=null?this.tabs[t]||(t=this.prevStop(t)):(this.tabs={},t=0);t<this._cols;t+=this._optionsService.rawOptions.tabStopWidth)this.tabs[t]=!0}prevStop(t){for(t==null&&(t=this.x);!this.tabs[--t]&&t>0;);return t>=this._cols?this._cols-1:t<0?0:t}nextStop(t){for(t==null&&(t=this.x);!this.tabs[++t]&&t<this._cols;);return t>=this._cols?this._cols-1:t<0?0:t}clearMarkers(t){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===t&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].dispose();this.markers.length=0,this._isClearing=!1}addMarker(t){let e=new oA(t);return this.markers.push(e),e.register(this.lines.onTrim(n=>{e.line-=n,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(n=>{e.line>=n.index&&(e.line+=n.amount)})),e.register(this.lines.onDelete(n=>{e.line>=n.index&&e.line<n.index+n.amount&&e.dispose(),e.line>n.index&&(e.line-=n.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(t){this._isClearing||this.markers.splice(this.markers.indexOf(t),1)}},aA=class extends $t{constructor(e,n){super(),this._optionsService=e,this._bufferService=n,this._onBufferActivate=this._register(new nt),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 bb(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new bb(!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,n){this._normal.resize(e,n),this._alt.resize(e,n),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Ox=2,Bx=1,Vm=class extends $t{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new nt),this.onResize=this._onResize.event,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,Ox),this.rows=Math.max(t.rawOptions.rows||0,Bx),this.buffers=this._register(new aA(t,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(t,e){let n=this.cols!==t,s=this.rows!==e;this.cols=t,this.rows=e,this.buffers.resize(t,e),this._onResize.fire({cols:t,rows:e,colsChanged:n,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(t,e=!1){let n=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==t.fg||s.getBg(0)!==t.bg)&&(s=n.getBlankLine(t,e),this._cachedBlankLine=s),s.isWrapped=e;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let c=n.lines.isFull;a===n.lines.length-1?c?n.lines.recycle().copyFrom(s):n.lines.push(s.clone()):n.lines.splice(a+1,0,s.clone()),c?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let c=a-i+1;n.lines.shiftElements(i+1,c-1,-1),n.lines.set(a,s.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(t,e){let n=this.buffer;if(t<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else t+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let s=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+t,n.ybase),0),s!==n.ydisp&&(e||this._onScroll.fire(n.ydisp))}};Vm=jn([at(0,Ts)],Vm);var Na={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:jd,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},lA=["normal","bold","100","200","300","400","500","600","700","800","900"],cA=class extends $t{constructor(e){super(),this._onOptionChange=this._register(new nt),this.onOptionChange=this._onOptionChange.event;let n={...Na};for(let s in e)if(s in n)try{let i=e[s];n[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=n,this.options={...n},this._setupOptions(),this._register(_n(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,n){return this.onOptionChange(s=>{s===e&&n(this.rawOptions[e])})}onMultipleOptionChange(e,n){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&n()})}_setupOptions(){let e=s=>{if(!(s in Na))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},n=(s,i)=>{if(!(s in Na))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,n){switch(e){case"cursorStyle":if(n||(n=Na[e]),!uA(n))throw new Error(`"${n}" is not a valid value for ${e}`);break;case"wordSeparator":n||(n=Na[e]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=lA.includes(n)?n:Na[e];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${e} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(n*10)/10));break;case"scrollback":if(n=Math.min(n,4294967295),n<0)throw new Error(`${e} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${e} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{};break}return n}};function uA(t){return t==="block"||t==="underline"||t==="bar"}function lc(t,e=5){if(typeof t!="object")return t;let n=Array.isArray(t)?[]:{};for(let s in t)n[s]=e<=1?t[s]:t[s]&&lc(t[s],e-1);return n}var Sb=Object.freeze({insertMode:!1}),xb=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Ym=class extends $t{constructor(e,n,s){super(),this._bufferService=e,this._logService=n,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new nt),this.onData=this._onData.event,this._onUserInput=this._register(new nt),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new nt),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new nt),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=lc(Sb),this.decPrivateModes=lc(xb)}reset(){this.modes=lc(Sb),this.decPrivateModes=lc(xb)}triggerDataEvent(e,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),n&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.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(n=>n.charCodeAt(0))),this._onBinary.fire(e))}};Ym=jn([at(0,Ms),at(1,ix),at(2,Ts)],Ym);var kb={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:t=>t.button===4||t.action!==1?!1:(t.ctrl=!1,t.alt=!1,t.shift=!1,!0)},VT200:{events:19,restrict:t=>t.action!==32},DRAG:{events:23,restrict:t=>!(t.action===32&&t.button===3)},ANY:{events:31,restrict:t=>!0}};function np(t,e){let n=(t.ctrl?16:0)|(t.shift?4:0)|(t.alt?8:0);return t.button===4?(n|=64,n|=t.action):(n|=t.button&3,t.button&4&&(n|=64),t.button&8&&(n|=128),t.action===32?n|=32:t.action===0&&!e&&(n|=3)),n}var sp=String.fromCharCode,Cb={DEFAULT:t=>{let e=[np(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${sp(e[0])}${sp(e[1])}${sp(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${np(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${np(t,!0)};${t.x};${t.y}${e}`}},Gm=class extends $t{constructor(t,e,n){super(),this._bufferService=t,this._coreService=e,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new nt),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(kb))this.addProtocol(s,kb[s]);for(let s of Object.keys(Cb))this.addEncoding(s,Cb[s]);this.reset()}addProtocol(t,e){this._protocols[t]=e}addEncoding(t,e){this._encodings[t]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(t){if(!this._protocols[t])throw new Error(`unknown protocol "${t}"`);this._activeProtocol=t,this._onProtocolChange.fire(this._protocols[t].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(t){if(!this._encodings[t])throw new Error(`unknown encoding "${t}"`);this._activeEncoding=t}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(t,e,n){if(t.deltaY===0||t.shiftKey||e===void 0||n===void 0)return 0;let s=e/n,i=this._applyScrollModifier(t.deltaY,t);return t.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=s+0,Math.abs(t.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):t.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(t,e){return e.altKey||e.ctrlKey||e.shiftKey?t*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:t*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(t){if(t.col<0||t.col>=this._bufferService.cols||t.row<0||t.row>=this._bufferService.rows||t.button===4&&t.action===32||t.button===3&&t.action!==32||t.button!==4&&(t.action===2||t.action===3)||(t.col++,t.row++,t.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,t,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(t))return!1;let e=this._encodings[this._activeEncoding](t);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=t,!0}explainEvents(t){return{down:!!(t&1),up:!!(t&2),drag:!!(t&4),move:!!(t&8),wheel:!!(t&16)}}_equalEvents(t,e,n){if(n){if(t.x!==e.x||t.y!==e.y)return!1}else if(t.col!==e.col||t.row!==e.row)return!1;return!(t.button!==e.button||t.action!==e.action||t.ctrl!==e.ctrl||t.alt!==e.alt||t.shift!==e.shift)}};Gm=jn([at(0,Ms),at(1,Zo),at(2,Ts)],Gm);var ip=[[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]],dA=[[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]],Wn;function hA(t,e){let n=0,s=e.length-1,i;if(t<e[0][0]||t>e[s][1])return!1;for(;s>=n;)if(i=n+s>>1,t>e[i][1])n=i+1;else if(t<e[i][0])s=i-1;else return!0;return!1}var fA=class{constructor(){if(this.version="6",!Wn){Wn=new Uint8Array(65536),Wn.fill(1),Wn[0]=0,Wn.fill(0,1,32),Wn.fill(0,127,160),Wn.fill(2,4352,4448),Wn[9001]=2,Wn[9002]=2,Wn.fill(2,11904,42192),Wn[12351]=1,Wn.fill(2,44032,55204),Wn.fill(2,63744,64256),Wn.fill(2,65040,65050),Wn.fill(2,65072,65136),Wn.fill(2,65280,65377),Wn.fill(2,65504,65511);for(let e=0;e<ip.length;++e)Wn.fill(0,ip[e][0],ip[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Wn[e]:hA(e,dA)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,n){let s=this.wcwidth(e),i=s===0&&n!==0;if(i){let a=Fo.extractWidth(n);a===0?i=!1:a>s&&(s=a)}return Fo.createPropertyValue(0,s,i)}},Fo=class md{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new nt,this.onChange=this._onChange.event;let e=new fA;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,n,s=!1){return(e&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(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let n=0,s=0,i=e.length;for(let a=0;a<i;++a){let c=e.charCodeAt(a);if(55296<=c&&c<=56319){if(++a>=i)return n+this.wcwidth(c);let f=e.charCodeAt(a);56320<=f&&f<=57343?c=(c-55296)*1024+f-56320+65536:n+=this.wcwidth(f)}let u=this.charProperties(c,s),h=md.extractWidth(u);md.extractShouldJoin(u)&&(h-=md.extractWidth(s)),n+=h,s=u}return n}charProperties(e,n){return this._activeProvider.charProperties(e,n)}},pA=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,n){this._charsets[e]=n,this.glevel===e&&(this.charset=n)}};function Eb(t){var s;let e=(s=t.buffer.lines.get(t.buffer.ybase+t.buffer.y-1))==null?void 0:s.get(t.cols-1),n=t.buffer.lines.get(t.buffer.ybase+t.buffer.y);n&&e&&(n.isWrapped=e[3]!==0&&e[3]!==32)}var zl=2147483647,mA=256,$x=class Xm{constructor(e=32,n=32){if(this.maxLength=e,this.maxSubParamsLength=n,n>mA)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let n=new Xm;if(!e.length)return n;for(let s=Array.isArray(e[0])?1:0;s<e.length;++s){let i=e[s];if(Array.isArray(i))for(let a=0;a<i.length;++a)n.addSubParam(i[a]);else n.addParam(i)}return n}clone(){let e=new Xm(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let n=0;n<this.length;++n){e.push(this.params[n]);let s=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,i))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>zl?zl:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>zl?zl:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let n=this._subParamsIdx[e]>>8,s=this._subParamsIdx[e]&255;return s-n>0?this._subParams.subarray(n,s):null}getSubParamsAll(){let e={};for(let n=0;n<this.length;++n){let s=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-s>0&&(e[n]=this._subParams.slice(s,i))}return e}addDigit(e){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,i=s[n-1];s[n-1]=~i?Math.min(i*10+e,zl):e}},Fl=[],gA=class{constructor(){this._state=0,this._active=Fl,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(n),{dispose:()=>{let i=s.indexOf(n);i!==-1&&s.splice(i,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=Fl}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=Fl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Fl,!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,n,s){if(!this._active.length)this._handlerFb(this._id,"PUT",nh(e,n,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,n,s)}start(){this.reset(),this._state=1}put(e,n,s){if(this._state!==3){if(this._state===1)for(;n<s;){let i=e[n++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-n>0&&this._put(e,n,s)}}end(e,n=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,a=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=n,a=this._stack.fallThrough,this._stack.paused=!1),!a&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Fl,this._id=-1,this._state=0}}},ei=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,n,s){this._hitLimit||(this._data+=nh(e,n,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let n=!1;if(this._hitLimit)n=!1;else if(e&&(n=this._handler(this._data),n instanceof Promise))return n.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,n}},Hl=[],vA=class{constructor(){this._handlers=Object.create(null),this._active=Hl,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Hl}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(n),{dispose:()=>{let i=s.indexOf(n);i!==-1&&s.splice(i,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=Hl,this._ident=0}hook(e,n){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Hl,!this._active.length)this._handlerFb(this._ident,"HOOK",n);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(n)}put(e,n,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",nh(e,n,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,n,s)}unhook(e,n=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,a=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=n,a=this._stack.fallThrough,this._stack.paused=!1),!a&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Hl,this._ident=0}},cc=new $x;cc.addParam(0);var Nb=class{constructor(t){this._handler=t,this._data="",this._params=cc,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():cc,this._data="",this._hitLimit=!1}put(t,e,n){this._hitLimit||(this._data+=nh(t,e,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(t){let e=!1;if(this._hitLimit)e=!1;else if(t&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(n=>(this._params=cc,this._data="",this._hitLimit=!1,n));return this._params=cc,this._data="",this._hitLimit=!1,e}},_A=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,n){this.table.fill(e<<4|n)}add(e,n,s,i){this.table[n<<8|e]=s<<4|i}addMany(e,n,s,i){for(let a=0;a<e.length;a++)this.table[n<<8|e[a]]=s<<4|i}},gi=160,yA=(function(){let t=new _A(4095),e=Array.apply(null,Array(256)).map((u,h)=>h),n=(u,h)=>e.slice(u,h),s=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),c;t.setDefault(1,0),t.addMany(s,0,2,0);for(c in a)t.addMany([24,26,153,154],c,3,0),t.addMany(n(128,144),c,3,0),t.addMany(n(144,152),c,3,0),t.add(156,c,0,0),t.add(27,c,11,1),t.add(157,c,4,8),t.addMany([152,158,159],c,0,7),t.add(155,c,11,3),t.add(144,c,11,9);return t.addMany(i,0,3,0),t.addMany(i,1,3,1),t.add(127,1,0,1),t.addMany(i,8,0,8),t.addMany(i,3,3,3),t.add(127,3,0,3),t.addMany(i,4,3,4),t.add(127,4,0,4),t.addMany(i,6,3,6),t.addMany(i,5,3,5),t.add(127,5,0,5),t.addMany(i,2,3,2),t.add(127,2,0,2),t.add(93,1,4,8),t.addMany(s,8,5,8),t.add(127,8,5,8),t.addMany([156,27,24,26,7],8,6,0),t.addMany(n(28,32),8,0,8),t.addMany([88,94,95],1,0,7),t.addMany(s,7,0,7),t.addMany(i,7,0,7),t.add(156,7,0,0),t.add(127,7,0,7),t.add(91,1,11,3),t.addMany(n(64,127),3,7,0),t.addMany(n(48,60),3,8,4),t.addMany([60,61,62,63],3,9,4),t.addMany(n(48,60),4,8,4),t.addMany(n(64,127),4,7,0),t.addMany([60,61,62,63],4,0,6),t.addMany(n(32,64),6,0,6),t.add(127,6,0,6),t.addMany(n(64,127),6,0,0),t.addMany(n(32,48),3,9,5),t.addMany(n(32,48),5,9,5),t.addMany(n(48,64),5,0,6),t.addMany(n(64,127),5,7,0),t.addMany(n(32,48),4,9,5),t.addMany(n(32,48),1,9,2),t.addMany(n(32,48),2,9,2),t.addMany(n(48,127),2,10,0),t.addMany(n(48,80),1,10,0),t.addMany(n(81,88),1,10,0),t.addMany([89,90,92],1,10,0),t.addMany(n(96,127),1,10,0),t.add(80,1,11,9),t.addMany(i,9,0,9),t.add(127,9,0,9),t.addMany(n(28,32),9,0,9),t.addMany(n(32,48),9,9,12),t.addMany(n(48,60),9,8,10),t.addMany([60,61,62,63],9,9,10),t.addMany(i,11,0,11),t.addMany(n(32,128),11,0,11),t.addMany(n(28,32),11,0,11),t.addMany(i,10,0,10),t.add(127,10,0,10),t.addMany(n(28,32),10,0,10),t.addMany(n(48,60),10,8,10),t.addMany([60,61,62,63],10,0,11),t.addMany(n(32,48),10,9,12),t.addMany(i,12,0,12),t.add(127,12,0,12),t.addMany(n(28,32),12,0,12),t.addMany(n(32,48),12,9,12),t.addMany(n(48,64),12,0,11),t.addMany(n(64,127),12,12,13),t.addMany(n(64,127),10,12,13),t.addMany(n(64,127),9,12,13),t.addMany(i,13,13,13),t.addMany(s,13,13,13),t.add(127,13,0,13),t.addMany([27,156,24,26],13,14,0),t.add(gi,0,2,0),t.add(gi,8,5,8),t.add(gi,6,0,6),t.add(gi,11,0,11),t.add(gi,13,13,13),t})(),wA=class extends $t{constructor(e=yA){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 $x,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(n,s,i)=>{},this._executeHandlerFb=n=>{},this._csiHandlerFb=(n,s)=>{},this._escHandlerFb=n=>{},this._errorHandlerFb=n=>n,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(_n(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new gA),this._dcsParser=this._register(new vA),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,n=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;a<e.intermediates.length;++a){let c=e.intermediates.charCodeAt(a);if(32>c||c>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=c}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(n[0]>i||i>n[1])throw new Error(`final must be in range ${n[0]} .. ${n[1]}`);return s<<=8,s|=i,s}identToString(e){let n=[];for(;e;)n.push(String.fromCharCode(e&255)),e>>=8;return n.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,n){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(n),{dispose:()=>{let a=i.indexOf(n);a!==-1&&i.splice(a,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,n){this._executeHandlers[e.charCodeAt(0)]=n}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,n){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(n),{dispose:()=>{let a=i.indexOf(n);a!==-1&&i.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,n){return this._dcsParser.registerHandler(this._identifier(e),n)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,n){return this._oscParser.registerHandler(e,n)}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,n,s,i,a){this._parseStack.state=e,this._parseStack.handlers=n,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=a}parse(e,n,s){let i=0,a=0,c=0,u;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,c=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,f=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&f>-1){for(;f>=0&&(u=h[f](this._params),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 4:if(s===!1&&f>-1){for(;f>=0&&(u=h[f](),u!==!0);f--)if(u instanceof Promise)return this._parseStack.handlerPos=f,u}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],u=this._dcsParser.unhook(i!==24&&i!==26,s),u)return u;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],u=this._oscParser.end(i!==24&&i!==26,s),u)return u;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,c=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=c;h<n;++h){switch(i=e[h],a=this._transitions.table[this.currentState<<8|(i<160?i:gi)],a>>4){case 2:for(let b=h+1;;++b){if(b>=n||(i=e[b])<32||i>126&&i<gi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<gi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<gi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<gi){this._printHandler(e,h,b),h=b-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let f=this._csiHandlers[this._collect<<8|i],g=f?f.length-1:-1;for(;g>=0&&(u=f[g](this._params),u!==!0);g--)if(u instanceof Promise)return this._preserveStack(3,f,g,a,h),u;g<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++h<n&&(i=e[h])>47&&i<60);h--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let v=this._escHandlers[this._collect<<8|i],_=v?v.length-1:-1;for(;_>=0&&(u=v[_](),u!==!0);_--)if(u instanceof Promise)return this._preserveStack(4,v,_,a,h),u;_<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let b=h+1;;++b)if(b>=n||(i=e[b])===24||i===26||i===27||i>127&&i<gi){this._dcsParser.put(e,h,b),h=b-1;break}break;case 14:if(u=this._dcsParser.unhook(i!==24&&i!==26),u)return this._preserveStack(6,[],0,a,h),u;i===27&&(a|=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 b=h+1;;b++)if(b>=n||(i=e[b])<32||i>127&&i<gi){this._oscParser.put(e,h,b),h=b-1;break}break;case 6:if(u=this._oscParser.end(i!==24&&i!==26),u)return this._preserveStack(5,[],0,a,h),u;i===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},bA=/^([\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})$/,SA=/^[\da-f]+$/;function Rb(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let n=bA.exec(e);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(e.indexOf("#")===0&&(e=e.slice(1),SA.exec(e)&&[3,6,9,12].includes(e.length))){let n=e.length/3,s=[0,0,0];for(let i=0;i<3;++i){let a=parseInt(e.slice(n*i,n*i+n),16);s[i]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return s}}function rp(t,e){let n=t.toString(16),s=n.length<2?"0"+n:n;switch(e){case 4:return n[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function xA(t,e=16){let[n,s,i]=t;return`rgb:${rp(n,e)}/${rp(s,e)}/${rp(i,e)}`}var kA={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Xr=131072,Lb=10;function Ab(t,e){if(t>24)return e.setWinLines||!1;switch(t){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var jb=5e3,Mb=0,CA=class extends $t{constructor(t,e,n,s,i,a,c,u,h=new wA){super(),this._bufferService=t,this._charsetService=e,this._coreService=n,this._logService=s,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=c,this._unicodeService=u,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new W5,this._utf8Decoder=new q5,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=On.clone(),this._eraseAttrDataInternal=On.clone(),this._onRequestBell=this._register(new nt),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new nt),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new nt),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new nt),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new nt),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new nt),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new nt),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new nt),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new nt),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new nt),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new nt),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new nt),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 Jm(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:g.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,g,v)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:g,data:v})}),this._parser.setDcsHandlerFallback((f,g,v)=>{g==="HOOK"&&(v=v.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:g,payload:v})}),this._parser.setPrintHandler((f,g,v)=>this.print(f,g,v)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(Oe.BEL,()=>this.bell()),this._parser.setExecuteHandler(Oe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Oe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Oe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Oe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Oe.BS,()=>this.backspace()),this._parser.setExecuteHandler(Oe.HT,()=>this.tab()),this._parser.setExecuteHandler(Oe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Oe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(fd.IND,()=>this.index()),this._parser.setExecuteHandler(fd.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(fd.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ei(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new ei(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new ei(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new ei(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new ei(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new ei(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new ei(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new ei(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new ei(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new ei(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new ei(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new ei(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Kn)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Nb((f,g)=>this.requestStatusString(f,g)))}getAttrData(){return this._curAttrData}_preserveStack(t,e,n,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=t,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=n,this._parseStack.position=s}_logSlowResolvingAsync(t){this._logService.logLevel<=3&&Promise.race([t,new Promise((e,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),jb))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${jb} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(t,e){let n,s=this._activeBuffer.x,i=this._activeBuffer.y,a=0,c=this._parseStack.paused;if(c){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(n),n;s=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,t.length>Xr&&(a=this._parseStack.position+Xr)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof t=="string"?` "${t}"`:` "${Array.prototype.map.call(t,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof t=="string"?t.split("").map(f=>f.charCodeAt(0)):t),this._parseBuffer.length<t.length&&this._parseBuffer.length<Xr&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Xr))),c||this._dirtyRowTracker.clearRange(),t.length>Xr)for(let f=a;f<t.length;f+=Xr){let g=f+Xr<t.length?f+Xr:t.length,v=typeof t=="string"?this._stringDecoder.decode(t.substring(f,g),this._parseBuffer):this._utf8Decoder.decode(t.subarray(f,g),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,v))return this._preserveStack(s,i,v,f),this._logSlowResolvingAsync(n),n}else if(!c){let f=typeof t=="string"?this._stringDecoder.decode(t,this._parseBuffer):this._utf8Decoder.decode(t,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,i,f,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==s||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let u=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(u,this._bufferService.rows-1)})}print(t,e,n){let s,i,a=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,u=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,g=this._curAttrData,v=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-e>0&&v.getWidth(this._activeBuffer.x-1)===2&&v.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let _=this._parser.precedingJoinState;for(let b=e;b<n;++b){if(s=t[b],s<127&&a){let R=a[String.fromCharCode(s)];R&&(s=R.charCodeAt(0))}let x=this._unicodeService.charProperties(s,_);i=Fo.extractWidth(x);let L=Fo.extractShouldJoin(x),k=L?Fo.extractWidth(_):0;if(_=x,c&&this._onA11yChar.fire(io(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-k>u){if(h){let R=v,S=this._activeBuffer.x-k;for(this._activeBuffer.x=k,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),v=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),k>0&&v instanceof ac&&v.copyCellsFrom(R,S,0,k,!1);S<u;)R.setCellFromCodepoint(S++,0,1,g)}else if(this._activeBuffer.x=u-1,i===2)continue}if(L&&this._activeBuffer.x){let R=v.getWidth(this._activeBuffer.x-1)?1:2;v.addCodepointToCell(this._activeBuffer.x-R,s,i);for(let S=i-k;--S>=0;)v.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(f&&(v.insertCells(this._activeBuffer.x,i-k,this._activeBuffer.getNullCell(g)),v.getWidth(u-1)===2&&v.setCellFromCodepoint(u-1,0,1,g)),v.setCellFromCodepoint(this._activeBuffer.x++,s,i,g),i>0)for(;--i;)v.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=_,this._activeBuffer.x<u&&n-e>0&&v.getWidth(this._activeBuffer.x)===0&&!v.hasContent(this._activeBuffer.x)&&v.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(t,e){return t.final==="t"&&!t.prefix&&!t.intermediates?this._parser.registerCsiHandler(t,n=>Ab(n.params[0],this._optionsService.rawOptions.windowOptions)?e(n):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Nb(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new ei(e))}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 t;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&&((t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&t.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-t),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(t=this._bufferService.cols-1){this._activeBuffer.x=Math.min(t,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(t,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=t,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=t,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(t,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+t,this._activeBuffer.y+e)}cursorUp(t){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,t.params[0]||1)):this._moveCursor(0,-(t.params[0]||1)),!0}cursorDown(t){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,t.params[0]||1)):this._moveCursor(0,t.params[0]||1),!0}cursorForward(t){return this._moveCursor(t.params[0]||1,0),!0}cursorBackward(t){return this._moveCursor(-(t.params[0]||1),0),!0}cursorNextLine(t){return this.cursorDown(t),this._activeBuffer.x=0,!0}cursorPrecedingLine(t){return this.cursorUp(t),this._activeBuffer.x=0,!0}cursorCharAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(t){return this._setCursor(t.length>=2?(t.params[1]||1)-1:0,(t.params[0]||1)-1),!0}charPosAbsolute(t){return this._setCursor((t.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(t){return this._moveCursor(t.params[0]||1,0),!0}linePosAbsolute(t){return this._setCursor(this._activeBuffer.x,(t.params[0]||1)-1),!0}vPositionRelative(t){return this._moveCursor(0,t.params[0]||1),!0}hVPosition(t){return this.cursorPosition(t),!0}tabClear(t){let e=t.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(t){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=t.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(t){let e=t.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(t,e,n,s=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);a.replaceCells(e,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),s&&(a.isWrapped=!1)}_resetBufferLine(t,e=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+t),n.isWrapped=!1)}eraseInDisplay(t,e=!1){var s;this._restrictCursor(this._bufferService.cols);let n;switch(t.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,e);n<this._bufferService.rows;n++)this._resetBufferLine(n,e);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,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,e);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,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,0),this._onScroll.fire(0));break}return!0}eraseInLine(t,e=!1){switch(this._restrictCursor(this._bufferService.cols),t.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(t){this._restrictCursor();let e=t.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,i=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;e--;)this._activeBuffer.lines.splice(i-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(t){this._restrictCursor();let e=t.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;e--;)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(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,t.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(t){let e=t.params[0]||1;for(;e--;)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(t){let e=t.params[0]||1;for(;e--;)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(On));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.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,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.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,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.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,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(t){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=t.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,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(t){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(t.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(t){let e=this._parser.precedingJoinState;if(!e)return!0;let n=t.params[0]||1,s=Fo.extractWidth(e),i=this._activeBuffer.x-s,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),c=new Uint32Array(a.length*n),u=0;for(let f=0;f<a.length;){let g=a.codePointAt(f)||0;c[u++]=g,f+=g>65535?2:1}let h=u;for(let f=1;f<n;++f)c.copyWithin(h,0,u),h+=u;return this.print(c,0,h),!0}sendDeviceAttributesPrimary(t){return t.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Oe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Oe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Oe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Oe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Oe.ESC+"[>83;40003;0c")),!0}_is(t){return(this._optionsService.rawOptions.termName+"").indexOf(t)===0}setMode(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,$o),this._charsetService.setgCharset(1,$o),this._charsetService.setgCharset(2,$o),this._charsetService.setgCharset(3,$o);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(t){for(let e=0;e<t.length;e++)switch(t.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(t){for(let e=0;e<t.length;e++)switch(t.params[e]){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(),t.params[e]===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(t,e){(L=>(L[L.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",L[L.SET=1]="SET",L[L.RESET=2]="RESET",L[L.PERMANENTLY_SET=3]="PERMANENTLY_SET",L[L.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(n={}));let s=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,c=this._coreService,{buffers:u,cols:h}=this._bufferService,{active:f,alt:g}=u,v=this._optionsService.rawOptions,_=(L,k)=>(c.triggerDataEvent(`${Oe.ESC}[${e?"":"?"}${L};${k}$y`),!0),b=L=>L?1:2,x=t.params[0];return e?x===2?_(x,4):x===4?_(x,b(c.modes.insertMode)):x===12?_(x,3):x===20?_(x,b(v.convertEol)):_(x,0):x===1?_(x,b(s.applicationCursorKeys)):x===3?_(x,v.windowOptions.setWinLines?h===80?2:h===132?1:0:0):x===6?_(x,b(s.origin)):x===7?_(x,b(s.wraparound)):x===8?_(x,3):x===9?_(x,b(i==="X10")):x===12?_(x,b(v.cursorBlink)):x===25?_(x,b(!c.isCursorHidden)):x===45?_(x,b(s.reverseWraparound)):x===66?_(x,b(s.applicationKeypad)):x===67?_(x,4):x===1e3?_(x,b(i==="VT200")):x===1002?_(x,b(i==="DRAG")):x===1003?_(x,b(i==="ANY")):x===1004?_(x,b(s.sendFocus)):x===1005?_(x,4):x===1006?_(x,b(a==="SGR")):x===1015?_(x,4):x===1016?_(x,b(a==="SGR_PIXELS")):x===1048?_(x,1):x===47||x===1047||x===1049?_(x,b(f===g)):x===2004?_(x,b(s.bracketedPasteMode)):x===2026?_(x,b(s.synchronizedOutput)):_(x,0)}_updateAttrColor(t,e,n,s,i){return e===2?(t|=50331648,t&=-16777216,t|=Dc.fromColorRGB([n,s,i])):e===5&&(t&=-50331904,t|=33554432|n&255),t}_extractColor(t,e,n){let s=[0,0,-1,0,0,0],i=0,a=0;do{if(s[a+i]=t.params[e+a],t.hasSubParams(e+a)){let c=t.getSubParams(e+a),u=0;do s[1]===5&&(i=1),s[a+u+1+i]=c[u];while(++u<c.length&&u+a+1+i<s.length);break}if(s[1]===5&&a+i>=2||s[1]===2&&a+i>=5)break;s[1]&&(i=1)}while(++a+e<t.length&&a+i<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=0);switch(s[0]){case 38:n.fg=this._updateAttrColor(n.fg,s[1],s[3],s[4],s[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,s[1],s[3],s[4],s[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,s[1],s[3],s[4],s[5])}return a}_processUnderline(t,e){e.extended=e.extended.clone(),(!~t||t>5)&&(t=1),e.extended.underlineStyle=t,e.fg|=268435456,t===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(t){t.fg=On.fg,t.bg=On.bg,t.extended=t.extended.clone(),t.extended.underlineStyle=0,t.extended.underlineColor&=-67108864,t.updateExtended()}charAttributes(t){if(t.length===1&&t.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=t.length,n,s=this._curAttrData;for(let i=0;i<e;i++)n=t.params[i],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(t.hasSubParams(i)?t.getSubParams(i)[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|=On.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=On.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(t,i,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|=On.fg&16777215,s.bg&=-67108864,s.bg|=On.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${Oe.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Oe.ESC}[${e};${n}R`);break}return!0}deviceStatusPrivate(t){switch(t.params[0]){case 6:let e=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Oe.ESC}[?${e};${n}R`);break}return!0}softReset(t){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=On.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(t){let e=t.length===0?1:t.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){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=e%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(t){let e=t.params[0]||1,n;return(t.length<2||(n=t.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(t){if(!Ab(t.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=t.length>1?t.params[1]:0;switch(t.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Oe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Lb&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Lb&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(t){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(t){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(t){return this._windowTitle=t,this._onTitleChange.fire(t),!0}setIconName(t){return this._iconName=t,!0}setOrReportIndexedColor(t){let e=[],n=t.split(";");for(;n.length>1;){let s=n.shift(),i=n.shift();if(/^\d+$/.exec(s)){let a=parseInt(s);if(Tb(a))if(i==="?")e.push({type:0,index:a});else{let c=Rb(i);c&&e.push({type:1,index:a,color:c})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(t){let e=t.indexOf(";");if(e===-1)return!0;let n=t.slice(0,e).trim(),s=t.slice(e+1);return s?this._createHyperlink(n,s):n.trim()?!1:this._finishHyperlink()}_createHyperlink(t,e){this._getCurrentLinkId()&&this._finishHyperlink();let n=t.split(":"),s,i=n.findIndex(a=>a.startsWith("id="));return i!==-1&&(s=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(t,e){let n=t.split(";");for(let s=0;s<n.length&&!(e>=this._specialColors.length);++s,++e)if(n[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let i=Rb(n[s]);i&&this._onColor.fire([{type:1,index:this._specialColors[e],color:i}])}return!0}setOrReportFgColor(t){return this._setOrReportSpecialColor(t,0)}setOrReportBgColor(t){return this._setOrReportSpecialColor(t,1)}setOrReportCursorColor(t){return this._setOrReportSpecialColor(t,2)}restoreIndexedColor(t){if(!t)return this._onColor.fire([{type:2}]),!0;let e=[],n=t.split(";");for(let s=0;s<n.length;++s)if(/^\d+$/.exec(n[s])){let i=parseInt(n[s]);Tb(i)&&e.push({type:2,index:i})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(t){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(t){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(t){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,$o),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(kA[t[0]],Kn[t[1]]||$o),!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 t=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,t,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=On.clone(),this._eraseAttrDataInternal=On.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(t){return this._charsetService.setgLevel(t),!0}screenAlignmentPattern(){let t=new bi;t.content=1<<22|69,t.fg=this._curAttrData.fg,t.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let n=this._activeBuffer.ybase+this._activeBuffer.y+e,s=this._activeBuffer.lines.get(n);s&&(s.fill(t),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(t,e){let n=c=>(this._coreService.triggerDataEvent(`${Oe.ESC}${c}${Oe.ESC}\\`),!0),s=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(t==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:t==='"p'?'P1$r61;1"p':t==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:t==="m"?"P1$r0m":t===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(t,e){this._dirtyRowTracker.markRangeDirty(t,e)}},Jm=class{constructor(t){this._bufferService=t,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(t){t<this.start?this.start=t:t>this.end&&(this.end=t)}markRangeDirty(t,e){t>e&&(Mb=t,t=e,e=Mb),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Jm=jn([at(0,Ms)],Jm);function Tb(t){return 0<=t&&t<256}var EA=5e7,Pb=12,NA=50,RA=class extends $t{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 nt),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,n){if(n!==void 0&&this._syncCalls>n){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,n){if(this._pendingData>EA)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(n),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(n)}_innerWrite(e=0,n=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],a=this._action(i,n);if(a){let u=h=>performance.now()-s>=Pb?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(s,h);a.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(u);return}let c=this._callbacks[this._bufferOffset];if(c&&c(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=Pb)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>NA&&(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()}},Qm=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let n=this._bufferService.buffer;if(e.id===void 0){let h=n.addMarker(n.ybase+n.y),f={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(f,h)),this._dataByLinkId.set(f.id,f),f.id}let s=e,i=this._getEntryIdKey(s),a=this._entriesWithId.get(i);if(a)return this.addLineToLink(a.id,n.ybase+n.y),a.id;let c=n.addMarker(n.ybase+n.y),u={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(e,n){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==n)){let i=this._bufferService.buffer.addMarker(n);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var n;return(n=this._dataByLinkId.get(e))==null?void 0:n.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,n){let s=e.lines.indexOf(n);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Qm=jn([at(0,Ms)],Qm);var Ib=!1,LA=class extends $t{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Wa),this._onBinary=this._register(new nt),this.onBinary=this._onBinary.event,this._onData=this._register(new nt),this.onData=this._onData.event,this._onLineFeed=this._register(new nt),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new nt),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new nt),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new nt),this._instantiationService=new ZL,this.optionsService=this._register(new cA(e)),this._instantiationService.setService(Ts,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Vm)),this._instantiationService.setService(Ms,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Km)),this._instantiationService.setService(ix,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Ym)),this._instantiationService.setService(Zo,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Gm)),this._instantiationService.setService(sx,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Fo)),this._instantiationService.setService(G5,this.unicodeService),this._charsetService=this._instantiationService.createInstance(pA),this._instantiationService.setService(Y5,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Qm),this._instantiationService.setService(rx,this._oscLinkService),this._inputHandler=this._register(new CA(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(vs.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(vs.forward(this._bufferService.onResize,this._onResize)),this._register(vs.forward(this.coreService.onData,this._onData)),this._register(vs.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 RA((n,s)=>this._inputHandler.parse(n,s))),this._register(vs.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new nt),this._onScroll.event(e=>{var n;(n=this._onScrollApi)==null||n.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 n in e)this.optionsService.options[n]=e[n]}write(e,n){this._writeBuffer.write(e,n)}writeSync(e,n){this._logService.logLevel<=3&&!Ib&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ib=!0),this._writeBuffer.writeSync(e,n)}input(e,n=!0){this.coreService.triggerDataEvent(e,n)}resize(e,n){isNaN(e)||isNaN(n)||(e=Math.max(e,Ox),n=Math.max(n,Bx),this._bufferService.resize(e,n))}scroll(e,n=!1){this._bufferService.scroll(e,n)}scrollLines(e,n){this._bufferService.scrollLines(e,n)}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 n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}registerEscHandler(e,n){return this._inputHandler.registerEscHandler(e,n)}registerDcsHandler(e,n){return this._inputHandler.registerDcsHandler(e,n)}registerCsiHandler(e,n){return this._inputHandler.registerCsiHandler(e,n)}registerOscHandler(e,n){return this._inputHandler.registerOscHandler(e,n)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,n=this.optionsService.rawOptions.windowsPty;n&&n.buildNumber!==void 0&&n.buildNumber!==void 0?e=n.backend==="conpty"&&n.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(Eb.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Eb(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_n(()=>{for(let n of e)n.dispose()})}}},AA={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 jA(t,e,n,s){var c;let i={type:0,cancel:!1,key:void 0},a=(t.shiftKey?1:0)|(t.altKey?2:0)|(t.ctrlKey?4:0)|(t.metaKey?8:0);switch(t.keyCode){case 0:t.key==="UIKeyInputUpArrow"?e?i.key=Oe.ESC+"OA":i.key=Oe.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?i.key=Oe.ESC+"OD":i.key=Oe.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?i.key=Oe.ESC+"OC":i.key=Oe.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?i.key=Oe.ESC+"OB":i.key=Oe.ESC+"[B");break;case 8:i.key=t.ctrlKey?"\b":Oe.DEL,t.altKey&&(i.key=Oe.ESC+i.key);break;case 9:if(t.shiftKey){i.key=Oe.ESC+"[Z";break}i.key=Oe.HT,i.cancel=!0;break;case 13:i.key=t.altKey?Oe.ESC+Oe.CR:Oe.CR,i.cancel=!0;break;case 27:i.key=Oe.ESC,t.altKey&&(i.key=Oe.ESC+Oe.ESC),i.cancel=!0;break;case 37:if(t.metaKey)break;a?i.key=Oe.ESC+"[1;"+(a+1)+"D":e?i.key=Oe.ESC+"OD":i.key=Oe.ESC+"[D";break;case 39:if(t.metaKey)break;a?i.key=Oe.ESC+"[1;"+(a+1)+"C":e?i.key=Oe.ESC+"OC":i.key=Oe.ESC+"[C";break;case 38:if(t.metaKey)break;a?i.key=Oe.ESC+"[1;"+(a+1)+"A":e?i.key=Oe.ESC+"OA":i.key=Oe.ESC+"[A";break;case 40:if(t.metaKey)break;a?i.key=Oe.ESC+"[1;"+(a+1)+"B":e?i.key=Oe.ESC+"OB":i.key=Oe.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(i.key=Oe.ESC+"[2~");break;case 46:a?i.key=Oe.ESC+"[3;"+(a+1)+"~":i.key=Oe.ESC+"[3~";break;case 36:a?i.key=Oe.ESC+"[1;"+(a+1)+"H":e?i.key=Oe.ESC+"OH":i.key=Oe.ESC+"[H";break;case 35:a?i.key=Oe.ESC+"[1;"+(a+1)+"F":e?i.key=Oe.ESC+"OF":i.key=Oe.ESC+"[F";break;case 33:t.shiftKey?i.type=2:t.ctrlKey?i.key=Oe.ESC+"[5;"+(a+1)+"~":i.key=Oe.ESC+"[5~";break;case 34:t.shiftKey?i.type=3:t.ctrlKey?i.key=Oe.ESC+"[6;"+(a+1)+"~":i.key=Oe.ESC+"[6~";break;case 112:a?i.key=Oe.ESC+"[1;"+(a+1)+"P":i.key=Oe.ESC+"OP";break;case 113:a?i.key=Oe.ESC+"[1;"+(a+1)+"Q":i.key=Oe.ESC+"OQ";break;case 114:a?i.key=Oe.ESC+"[1;"+(a+1)+"R":i.key=Oe.ESC+"OR";break;case 115:a?i.key=Oe.ESC+"[1;"+(a+1)+"S":i.key=Oe.ESC+"OS";break;case 116:a?i.key=Oe.ESC+"[15;"+(a+1)+"~":i.key=Oe.ESC+"[15~";break;case 117:a?i.key=Oe.ESC+"[17;"+(a+1)+"~":i.key=Oe.ESC+"[17~";break;case 118:a?i.key=Oe.ESC+"[18;"+(a+1)+"~":i.key=Oe.ESC+"[18~";break;case 119:a?i.key=Oe.ESC+"[19;"+(a+1)+"~":i.key=Oe.ESC+"[19~";break;case 120:a?i.key=Oe.ESC+"[20;"+(a+1)+"~":i.key=Oe.ESC+"[20~";break;case 121:a?i.key=Oe.ESC+"[21;"+(a+1)+"~":i.key=Oe.ESC+"[21~";break;case 122:a?i.key=Oe.ESC+"[23;"+(a+1)+"~":i.key=Oe.ESC+"[23~";break;case 123:a?i.key=Oe.ESC+"[24;"+(a+1)+"~":i.key=Oe.ESC+"[24~";break;default:if(t.ctrlKey&&!t.shiftKey&&!t.altKey&&!t.metaKey)t.keyCode>=65&&t.keyCode<=90?i.key=String.fromCharCode(t.keyCode-64):t.keyCode===32?i.key=Oe.NUL:t.keyCode>=51&&t.keyCode<=55?i.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?i.key=Oe.DEL:t.keyCode===219?i.key=Oe.ESC:t.keyCode===220?i.key=Oe.FS:t.keyCode===221&&(i.key=Oe.GS);else if((!n||s)&&t.altKey&&!t.metaKey){let u=(c=AA[t.keyCode])==null?void 0:c[t.shiftKey?1:0];if(u)i.key=Oe.ESC+u;else if(t.keyCode>=65&&t.keyCode<=90){let h=t.ctrlKey?t.keyCode-64:t.keyCode+32,f=String.fromCharCode(h);t.shiftKey&&(f=f.toUpperCase()),i.key=Oe.ESC+f}else if(t.keyCode===32)i.key=Oe.ESC+(t.ctrlKey?Oe.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let h=t.code.slice(3,4);t.shiftKey||(h=h.toLowerCase()),i.key=Oe.ESC+h,i.cancel=!0}}else n&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&t.metaKey?t.keyCode===65&&(i.type=1):t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&t.keyCode>=48&&t.key.length===1?i.key=t.key:t.key&&t.ctrlKey&&(t.key==="_"&&(i.key=Oe.US),t.key==="@"&&(i.key=Oe.NUL));break}return i}var Tn=0,MA=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Md,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Md,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((a,c)=>this._getKey(a)-this._getKey(c)),n=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<i.length;a++)s>=this._array.length||this._getKey(e[n])<=this._getKey(this._array[s])?(i[a]=e[n],n++):i[a]=this._array[s++];this._array=i,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 n=this._getKey(e);if(n===void 0||(Tn=this._search(n),Tn===-1)||this._getKey(this._array[Tn])!==n)return!1;do if(this._array[Tn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Tn),!0;while(++Tn<this._array.length&&this._getKey(this._array[Tn])===n);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,c)=>a-c),n=0,s=new Array(this._array.length-e.length),i=0;for(let a=0;a<this._array.length;a++)e[n]===a?n++:s[i++]=this._array[a];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Tn=this._search(e),!(Tn<0||Tn>=this._array.length)&&this._getKey(this._array[Tn])===e))do yield this._array[Tn];while(++Tn<this._array.length&&this._getKey(this._array[Tn])===e)}forEachByKey(e,n){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Tn=this._search(e),!(Tn<0||Tn>=this._array.length)&&this._getKey(this._array[Tn])===e))do n(this._array[Tn]);while(++Tn<this._array.length&&this._getKey(this._array[Tn])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let n=0,s=this._array.length-1;for(;s>=n;){let i=n+s>>1,a=this._getKey(this._array[i]);if(a>e)s=i-1;else if(a<e)n=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return n}},op=0,Db=0,TA=class extends $t{constructor(){super(),this._decorations=new MA(t=>t==null?void 0:t.marker.line),this._onDecorationRegistered=this._register(new nt),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new nt),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_n(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new PA(t);if(e){let n=e.marker.onDispose(()=>e.dispose()),s=e.onDispose(()=>{s.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),n.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let t of this._decorations.values())t.dispose();this._decorations.clear()}*getDecorationsAtCell(t,e,n){let s=0,i=0;for(let a of this._decorations.getKeyIterator(e))s=a.options.x??0,i=s+(a.options.width??1),t>=s&&t<i&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(t,e,n,s){this._decorations.forEachByKey(e,i=>{op=i.options.x??0,Db=op+(i.options.width??1),t>=op&&t<Db&&(!n||(i.options.layer??"bottom")===n)&&s(i)})}},PA=class extends uo{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new nt),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new nt),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=t.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=En.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=En.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},IA=1e3,DA=class{constructor(e,n=IA){this._renderCallback=e,this._debounceThresholdMS=n,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,n,s){this._rowCount=s,e=e!==void 0?e:0,n=n!==void 0?n: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,n):n;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=i-this._lastRefreshMs,c=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},c)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n)}},Ob=20,Td=class extends $t{constructor(t,e,n,s){super(),this._terminal=t,this._coreBrowserService=n,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.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=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new DA(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(Mt(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(_n(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Ob+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
65
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Ob+1&&(this._liveRegion.textContent+=_m.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(t){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(t)||this._charsToConsume.push(t)}_refreshRows(t,e){this._liveRegionDebouncer.refresh(t,e,this._terminal.rows)}_renderRows(t,e){let n=this._terminal.buffer,s=n.lines.length.toString();for(let i=t;i<=e;i++){let a=n.lines.get(n.ydisp+i),c=[],u=(a==null?void 0:a.translateToString(!0,void 0,void 0,c))||"",h=(n.ydisp+i+1).toString(),f=this._rowElements[i];f&&(u.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=u,this._rowColumns.set(f,c)),f.setAttribute("aria-posinset",h),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(t,e){let n=t.target,s=this._rowElements[e===0?1:this._rowElements.length-2],i=n.getAttribute("aria-posinset"),a=e===0?"1":`${this._terminal.buffer.lines.length}`;if(i===a||t.relatedTarget!==s)return;let c,u;if(e===0?(c=n,u=this._rowElements.pop(),this._rowContainer.removeChild(u)):(c=this._rowElements.shift(),u=n,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),u.removeEventListener("focus",this._bottomBoundaryFocusListener),e===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),t.preventDefault(),t.stopImmediatePropagation()}_handleSelectionChange(){var u;if(this._rowElements.length===0)return;let t=this._coreBrowserService.mainDocument.getSelection();if(!t)return;if(t.isCollapsed){this._rowContainer.contains(t.anchorNode)&&this._terminal.clearSelection();return}if(!t.anchorNode||!t.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:t.anchorNode,offset:t.anchorOffset},n={node:t.focusNode,offset:t.focusOffset};if((e.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===n.node&&e.offset>n.offset)&&([e,n]=[n,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.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:((u=s.textContent)==null?void 0:u.length)??0}),!this._rowContainer.contains(n.node))return;let i=({node:h,offset:f})=>{let g=h instanceof Text?h.parentNode:h,v=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(v))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(g);if(!_)return console.warn("columns is null. Race condition?"),null;let b=f<_.length?_[f]:_.slice(-1)[0]+1;return b>=this._terminal.cols&&(++v,b=0),{row:v,column:b}},a=i(e),c=i(n);if(!(!a||!c)){if(a.row>c.row||a.row===c.row&&a.column>=c.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(c.row-a.row)*this._terminal.cols-a.column+c.column)}}_handleResize(t){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let t=this._coreBrowserService.mainDocument.createElement("div");return t.setAttribute("role","listitem"),t.tabIndex=-1,this._refreshRowDimensions(t),t}_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 t=0;t<this._terminal.rows;t++)this._refreshRowDimensions(this._rowElements[t]),this._alignRowWidth(this._rowElements[t])}}_refreshRowDimensions(t){t.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(t){var i,a;t.style.transform="";let e=t.getBoundingClientRect().width,n=(a=(i=this._rowColumns.get(t))==null?void 0:i.slice(-1))==null?void 0:a[0];if(!n)return;let s=n*this._renderService.dimensions.css.cell.width;t.style.transform=`scaleX(${s/e})`}};Td=jn([at(1,sv),at(2,Nr),at(3,Rr)],Td);var Zm=class extends $t{constructor(t,e,n,s,i){super(),this._element=t,this._mouseService=e,this._renderService=n,this._bufferService=s,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new nt),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new nt),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(_n(()=>{var a;Go(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(Mt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Mt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Mt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Mt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(t){this._lastMouseEvent=t;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let n=t.composedPath();for(let s=0;s<n.length;s++){let i=n[s];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(t){if(this._activeLine!==t.y||this._wasResized){this._clearCurrentLink(),this._askForLink(t,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,t)||(this._clearCurrentLink(),this._askForLink(t,!0))}_askForLink(t,e){var s,i;(!this._activeProviderReplies||!e)&&((s=this._activeProviderReplies)==null||s.forEach(a=>{a==null||a.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=t.y);let n=!1;for(let[a,c]of this._linkProviderService.linkProviders.entries())e?(i=this._activeProviderReplies)!=null&&i.get(a)&&(n=this._checkLinkProviderResult(a,t,n)):c.provideLinks(t.y,u=>{var f,g;if(this._isMouseOut)return;let h=u==null?void 0:u.map(v=>({link:v}));(f=this._activeProviderReplies)==null||f.set(a,h),n=this._checkLinkProviderResult(a,t,n),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(t.y,this._activeProviderReplies)})}_removeIntersectingLinks(t,e){let n=new Set;for(let s=0;s<e.size;s++){let i=e.get(s);if(i)for(let a=0;a<i.length;a++){let c=i[a],u=c.link.range.start.y<t?0:c.link.range.start.x,h=c.link.range.end.y>t?this._bufferService.cols:c.link.range.end.x;for(let f=u;f<=h;f++){if(n.has(f)){i.splice(a--,1);break}n.add(f)}}}}_checkLinkProviderResult(t,e,n){var a;if(!this._activeProviderReplies)return n;let s=this._activeProviderReplies.get(t),i=!1;for(let c=0;c<t;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(i=!0);if(!i&&s){let c=s.find(u=>this._linkAtPosition(u.link,e));c&&(n=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let c=0;c<this._activeProviderReplies.size;c++){let u=(a=this._activeProviderReplies.get(c))==null?void 0:a.find(h=>this._linkAtPosition(h.link,e));if(u){n=!0,this._handleNewLink(u);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(t){if(!this._currentLink)return;let e=this._positionFromMouseEvent(t,this._element,this._mouseService);e&&this._mouseDownLink&&OA(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(t,this._currentLink.link.text)}_clearCurrentLink(t,e){!this._currentLink||!this._lastMouseEvent||(!t||!e||this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Go(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(t){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(t.link,e)&&(this._currentLink=t,this._currentLink.state={decorations:{underline:t.link.decorations===void 0?!0:t.link.decorations.underline,pointerCursor:t.link.decorations===void 0?!0:t.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,t.link,this._lastMouseEvent),t.link.decorations={},Object.defineProperties(t.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,i,a;(s=this._currentLink)!=null&&s.state&&((a=(i=this._currentLink)==null?void 0:i.state)==null?void 0:a.decorations.underline)!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(t.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,i=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(s,i),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(t,e,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&t.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(n,e.text)}_fireUnderlineEvent(t,e){let n=t.range,s=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-s-1,n.end.x,n.end.y-s-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(t,e,n){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&t.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(n,e.text)}_linkAtPosition(t,e){let n=t.range.start.y*this._bufferService.cols+t.range.start.x,s=t.range.end.y*this._bufferService.cols+t.range.end.x,i=e.y*this._bufferService.cols+e.x;return n<=i&&i<=s}_positionFromMouseEvent(t,e,n){let s=n.getCoords(t,e,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(t,e,n,s,i){return{x1:t,y1:e,x2:n,y2:s,cols:this._bufferService.cols,fg:i}}};Zm=jn([at(1,iv),at(2,Rr),at(3,Ms),at(4,ax)],Zm);function OA(t,e){return t.text===e.text&&t.range.start.x===e.range.start.x&&t.range.start.y===e.range.start.y&&t.range.end.x===e.range.end.x&&t.range.end.y===e.range.end.y}var BA=class extends LA{constructor(e={}){super(e),this._linkifier=this._register(new Wa),this.browser=Ex,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Wa),this._onCursorMove=this._register(new nt),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new nt),this.onKey=this._onKey.event,this._onRender=this._register(new nt),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new nt),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new nt),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new nt),this.onBell=this._onBell.event,this._onFocus=this._register(new nt),this._onBlur=this._register(new nt),this._onA11yCharEmitter=this._register(new nt),this._onA11yTabEmitter=this._register(new nt),this._onWillOpen=this._register(new nt),this._setup(),this._decorationService=this._instantiationService.createInstance(TA),this._instantiationService.setService(Oc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(NL),this._instantiationService.setService(ax,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(wm)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(n=>this.refresh((n==null?void 0:n.start)??0,(n==null?void 0:n.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(n=>this._reportWindowsOptions(n))),this._register(this._inputHandler.onColor(n=>this._handleColorEvent(n))),this._register(vs.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(vs.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(vs.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(vs.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(n=>this._afterResize(n.cols,n.rows))),this._register(_n(()=>{var n,s;this._customKeyEventHandler=void 0,(s=(n=this.element)==null?void 0:n.parentNode)==null||s.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 n of e){let s,i="";switch(n.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+n.index}switch(n.type){case 0:let a=fn.toColorRGB(s==="ansi"?this._themeService.colors.ansi[n.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${Oe.ESC}]${i};${xA(a)}${kx.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(c=>c.ansi[n.index]=$n.toColor(...n.color));else{let c=s;this._themeService.modifyColors(u=>u[c]=$n.toColor(...n.color))}break;case 2:this._themeService.restoreColor(n.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(Td,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Oe.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(Oe.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,n=this.buffer.lines.get(e);if(!n)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,a=n.getWidth(s),c=this._renderService.dimensions.css.cell.width*a,u=this.buffer.y*this._renderService.dimensions.css.cell.height,h=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=u+"px",this.textarea.style.width=c+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Mt(this.element,"copy",n=>{this.hasSelection()&&H5(n,this._selectionService)}));let e=n=>U5(n,this.textarea,this.coreService,this.optionsService);this._register(Mt(this.textarea,"paste",e)),this._register(Mt(this.element,"paste",e)),Nx?this._register(Mt(this.element,"mousedown",n=>{n.button===2&&Vw(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Mt(this.element,"contextmenu",n=>{Vw(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),hv&&this._register(Mt(this.element,"auxclick",n=>{n.button===1&&Q1(n,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Mt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Mt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Mt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Mt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Mt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Mt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Mt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;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"),((a=this.element)==null?void 0:a.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 n=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),n.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Mt(this.screenElement,"mousemove",c=>this.updateCursorStyle(c))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),n.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",vm.get()),Ax||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(CL,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Nr,this._coreBrowserService),this._register(Mt(this.textarea,"focus",c=>this._handleTextAreaFocus(c))),this._register(Mt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Fm,this._document,this._helperContainer),this._instantiationService.setService(sh,this._charSizeService),this._themeService=this._instantiationService.createInstance(qm),this._instantiationService.setService(Za,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Ad),this._instantiationService.setService(ox,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Um,this.rows,this.screenElement)),this._instantiationService.setService(Rr,this._renderService),this._register(this._renderService.onRenderedViewportChange(c=>this._onRender.fire(c))),this.onResize(c=>this._renderService.resize(c.cols,c.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Bm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Hm),this._instantiationService.setService(iv,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Zm,this.screenElement));this.element.appendChild(n);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(Dm,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(c=>{super.scrollLines(c,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Wm,this.element,this.screenElement,i)),this._instantiationService.setService(J5,this._selectionService),this._register(this._selectionService.onRequestScrollLines(c=>this.scrollLines(c.amount,c.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(c=>this._renderService.handleSelectionChanged(c.start,c.end,c.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(c=>{this.textarea.value=c,this.textarea.focus(),this.textarea.select()})),this._register(vs.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var c;this._selectionService.refresh(),(c=this._viewport)==null||c.queueSync()})),this._register(this._instantiationService.createInstance(Om,this.screenElement)),this._register(Mt(this.element,"mousedown",c=>this._selectionService.handleMouseDown(c))),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(Td,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",c=>this._handleScreenReaderModeOptionChange(c))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ld,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",c=>{!this._overviewRulerRenderer&&c&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ld,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zm,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,n=this.element;function s(c){var g,v,_,b,x;let u=e._mouseService.getMouseReportCoords(c,e.screenElement);if(!u)return!1;let h,f;switch(c.overrideType||c.type){case"mousemove":f=32,c.buttons===void 0?(h=3,c.button!==void 0&&(h=c.button<3?c.button:3)):h=c.buttons&1?0:c.buttons&4?1:c.buttons&2?2:3;break;case"mouseup":f=0,h=c.button<3?c.button:3;break;case"mousedown":f=1,h=c.button<3?c.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(c)===!1)return!1;let L=c.deltaY;if(L===0||e.coreMouseService.consumeWheelEvent(c,(b=(_=(v=(g=e._renderService)==null?void 0:g.dimensions)==null?void 0:v.device)==null?void 0:_.cell)==null?void 0:b.height,(x=e._coreBrowserService)==null?void 0:x.dpr)===0)return!1;f=L<0?0:1,h=4;break;default:return!1}return f===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:f,ctrl:c.ctrlKey,alt:c.altKey,shift:c.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:c=>(s(c),c.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(c)),wheel:c=>(s(c),this.cancel(c,!0)),mousedrag:c=>{c.buttons&&s(c)},mousemove:c=>{c.buttons||s(c)}};this._register(this.coreMouseService.onProtocolChange(c=>{c?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(c)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),c&8?i.mousemove||(n.addEventListener("mousemove",a.mousemove),i.mousemove=a.mousemove):(n.removeEventListener("mousemove",i.mousemove),i.mousemove=null),c&16?i.wheel||(n.addEventListener("wheel",a.wheel,{passive:!1}),i.wheel=a.wheel):(n.removeEventListener("wheel",i.wheel),i.wheel=null),c&2?i.mouseup||(i.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),c&4?i.mousedrag||(i.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Mt(n,"mousedown",c=>{if(c.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(c)))return s(c),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(c)})),this._register(Mt(n,"wheel",c=>{var u,h,f,g,v;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(c)===!1)return!1;if(!this.buffer.hasScrollback){if(c.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(c,(g=(f=(h=(u=e._renderService)==null?void 0:u.dimensions)==null?void 0:h.device)==null?void 0:f.cell)==null?void 0:g.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return this.cancel(c,!0);let _=Oe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(c.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(_,!0),this.cancel(c,!0)}}},{passive:!1}))}refresh(e,n){var s;(s=this._renderService)==null||s.refreshRows(e,n)}updateCursorStyle(e){var n;(n=this._selectionService)!=null&&n.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,n){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,n),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 n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}paste(e){J1(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 n=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),n}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,n,s){this._selectionService.setSelection(e,n,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,n){var s;(s=this._selectionService)==null||s.selectLines(e,n)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let n=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!n&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!n&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=jA(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===Oe.ETX||s.key===Oe.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,n){let s=e.isMac&&!this.options.macOptionIsMeta&&n.altKey&&!n.ctrlKey&&!n.metaKey||e.isWindows&&n.altKey&&n.ctrlKey&&!n.metaKey||e.isWindows&&n.getModifierState("AltGraph");return n.type==="keypress"?s:s&&(!n.keyCode||n.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&($A(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let n;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)n=e.charCode;else if(e.which===null||e.which===void 0)n=e.keyCode;else if(e.which!==0&&e.charCode!==0)n=e.which;else return!1;return!n||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(n=String.fromCharCode(n),this._onKey.fire({key:n,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n,!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 n=e.data;return this.coreService.triggerDataEvent(n,!0),this.cancel(e),!0}return!1}resize(e,n){if(e===this.cols&&n===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,n)}_afterResize(e,n){var s;(s=this._charSizeService)==null||s.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(On));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var n;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(n=this._selectionService)==null||n.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(Oe.ESC+"[I"):this.coreService.triggerDataEvent(Oe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let n=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Oe.ESC}[4;${s};${n}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Oe.ESC}[6;${a};${i}t`);break}}cancel(e,n){if(!(!this.options.cancelEvents&&!n))return e.preventDefault(),e.stopPropagation(),!1}};function $A(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var zA=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,n){let s={instance:n,dispose:n.dispose,isDisposed:!1};this._addons.push(s),n.dispose=()=>this._wrappedAddonDispose(s),n.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let n=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){n=s;break}if(n===-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(n,1)}},FA=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,n){if(!(e<0||e>=this._line.length))return n?(this._line.loadCell(e,n),n):this._line.loadCell(e,new bi)}translateToString(e,n,s){return this._line.translateToString(e,n,s)}},Bb=class{constructor(t,e){this._buffer=t,this.type=e}init(t){return this._buffer=t,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(t){let e=this._buffer.lines.get(t);if(e)return new FA(e)}getNullCell(){return new bi}},HA=class extends $t{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new nt),this.onBufferChange=this._onBufferChange.event,this._normal=new Bb(this._core.buffers.normal,"normal"),this._alternate=new Bb(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)}},UA=class{constructor(t){this._core=t}registerCsiHandler(t,e){return this._core.registerCsiHandler(t,n=>e(n.toArray()))}addCsiHandler(t,e){return this.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._core.registerDcsHandler(t,(n,s)=>e(n,s.toArray()))}addDcsHandler(t,e){return this.registerDcsHandler(t,e)}registerEscHandler(t,e){return this._core.registerEscHandler(t,e)}addEscHandler(t,e){return this.registerEscHandler(t,e)}registerOscHandler(t,e){return this._core.registerOscHandler(t,e)}addOscHandler(t,e){return this.registerOscHandler(t,e)}},WA=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}},qA=["cols","rows"],Wi=0,KA=class extends $t{constructor(t){super(),this._core=this._register(new BA(t)),this._addonManager=this._register(new zA),this._publicOptions={...this._core.options};let e=s=>this._core.options[s],n=(s,i)=>{this._checkReadonlyOptions(s),this._core.options[s]=i};for(let s in this._core.options){let i={get:e.bind(this,s),set:n.bind(this,s)};Object.defineProperty(this._publicOptions,s,i)}}_checkReadonlyOptions(t){if(qA.includes(t))throw new Error(`Option "${t}" 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 UA(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new WA(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 HA(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let t=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:t.applicationCursorKeys,applicationKeypadMode:t.applicationKeypad,bracketedPasteMode:t.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:t.origin,reverseWraparoundMode:t.reverseWraparound,sendFocusMode:t.sendFocus,synchronizedOutputMode:t.synchronizedOutput,wraparoundMode:t.wraparound}}get options(){return this._publicOptions}set options(t){for(let e in t)this._publicOptions[e]=t[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(t,e=!0){this._core.input(t,e)}resize(t,e){this._verifyIntegers(t,e),this._core.resize(t,e)}open(t){this._core.open(t)}attachCustomKeyEventHandler(t){this._core.attachCustomKeyEventHandler(t)}attachCustomWheelEventHandler(t){this._core.attachCustomWheelEventHandler(t)}registerLinkProvider(t){return this._core.registerLinkProvider(t)}registerCharacterJoiner(t){return this._checkProposedApi(),this._core.registerCharacterJoiner(t)}deregisterCharacterJoiner(t){this._checkProposedApi(),this._core.deregisterCharacterJoiner(t)}registerMarker(t=0){return this._verifyIntegers(t),this._core.registerMarker(t)}registerDecoration(t){return this._checkProposedApi(),this._verifyPositiveIntegers(t.x??0,t.width??0,t.height??0),this._core.registerDecoration(t)}hasSelection(){return this._core.hasSelection()}select(t,e,n){this._verifyIntegers(t,e,n),this._core.select(t,e,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(t,e){this._verifyIntegers(t,e),this._core.selectLines(t,e)}dispose(){super.dispose()}scrollLines(t){this._verifyIntegers(t),this._core.scrollLines(t)}scrollPages(t){this._verifyIntegers(t),this._core.scrollPages(t)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(t){this._verifyIntegers(t),this._core.scrollToLine(t)}clear(){this._core.clear()}write(t,e){this._core.write(t,e)}writeln(t,e){this._core.write(t),this._core.write(`\r
|
|
66
|
-
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return vm.get()},set promptLabel(t){vm.set(t)},get tooMuchOutput(){return _m.get()},set tooMuchOutput(t){_m.set(t)}}}_verifyIntegers(...t){for(Wi of t)if(Wi===1/0||isNaN(Wi)||Wi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Wi of t)if(Wi&&(Wi===1/0||isNaN(Wi)||Wi%1!==0||Wi<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 VA=2,YA=1,GA=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){var v;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:((v=this._terminal.options.overviewRuler)==null?void 0:v.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),c={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},u=c.top+c.bottom,h=c.right+c.left,f=s-u,g=i-h-e;return{cols:Math.max(VA,Math.floor(g/t.css.cell.width)),rows:Math.max(YA,Math.floor(f/t.css.cell.height))}}};const XA=Object.freeze([[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,12350],[12352,12871],[12880,19903],[19968,42182],[43360,43388],[44032,55203],[63744,64255],[65040,65049],[65072,65131],[65281,65376],[65504,65510],[126976,127461],[127488,129791]]),JA=Object.freeze([[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1552,1562],[1611,1631],[1648,1648],[1750,1756],[1759,1764],[1767,1768],[1770,1773],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2275,2307],[2362,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[3134,3136],[3142,3144],[3146,3149],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3790],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[4038,4038],[4448,4607],[4957,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6155,6157],[6832,6911],[7616,7679],[8203,8207],[8232,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12335],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43204,43205],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[66045,66045],[66272,66272],[113824,113827],[119141,119145],[119149,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]]),QA="nc-15.1";function $b(t,e){let n=0,s=t.length-1;for(;n<=s;){const i=n+s>>1,[a,c]=t[i];if(e<a)s=i-1;else if(e>c)n=i+1;else return!0}return!1}function ZA(t,e,n){return(t&16777215)<<3|(e&3)<<1|(n?1:0)}function zb(t){const e=Number(t);return!Number.isFinite(e)||e<0||e<32||e>=127&&e<160||$b(JA,e)?0:$b(XA,e)?2:1}function ej(){return{version:QA,wcwidth:zb,charProperties(t,e){let n=zb(t),s=n===0&&e!==0;if(s){const i=e>>1&3;i===0?s=!1:i>n&&(n=i)}return ZA(t,n,s)}}}function tj(t){try{const e=t&&t.unicode;if(!e||typeof e.register!="function")return null;const n=ej();return e.versions.includes(n.version)||e.register(n),e.activeVersion=n.version,n}catch{return null}}/**
|
|
78
|
-
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
79
|
-
* @license MIT
|
|
80
|
-
*
|
|
81
|
-
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
82
|
-
* @license MIT
|
|
83
|
-
*
|
|
84
|
-
* Originally forked from (with the author's permission):
|
|
85
|
-
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
86
|
-
* http://bellard.org/jslinux/
|
|
87
|
-
* Copyright (c) 2011 Fabrice Bellard
|
|
88
|
-
*/var nj=(t,e,n,s)=>{for(var i=e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(i=c(i)||i);return i},sj=(t,e)=>(n,s)=>e(n,s,t),ij=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Fb.isErrorNoTelemetry(t)?new Fb(t.message+`
|
|
89
|
-
|
|
90
|
-
`+t.stack):new Error(t.message+`
|
|
91
|
-
|
|
92
|
-
`+t.stack):t},0)}}addListener(t){return this.listeners.push(t),()=>{this._removeListener(t)}}emit(t){this.listeners.forEach(e=>{e(t)})}_removeListener(t){this.listeners.splice(this.listeners.indexOf(t),1)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}onUnexpectedExternalError(t){this.unexpectedErrorHandler(t)}},rj=new ij;function ap(t){oj(t)||rj.onUnexpectedError(t)}var eg="Canceled";function oj(t){return t instanceof aj?!0:t instanceof Error&&t.name===eg&&t.message===eg}var aj=class extends Error{constructor(){super(eg),this.name=this.message}},Fb=class tg extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof tg)return e;let n=new tg;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},lj;(t=>{function e(a){return a<0}t.isLessThan=e;function n(a){return a<=0}t.isLessThanOrEqual=n;function s(a){return a>0}t.isGreaterThan=s;function i(a){return a===0}t.isNeitherLessOrGreaterThan=i,t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(lj||(lj={}));function cj(t,e){let n=this,s=!1,i;return function(){return s||(s=!0,e||(i=t.apply(n,arguments))),i}}var zx;(t=>{function e(E){return E&&typeof E=="object"&&typeof E[Symbol.iterator]=="function"}t.is=e;let n=Object.freeze([]);function s(){return n}t.empty=s;function*i(E){yield E}t.single=i;function a(E){return e(E)?E:i(E)}t.wrap=a;function c(E){return E||n}t.from=c;function*u(E){for(let F=E.length-1;F>=0;F--)yield E[F]}t.reverse=u;function h(E){return!E||E[Symbol.iterator]().next().done===!0}t.isEmpty=h;function f(E){return E[Symbol.iterator]().next().value}t.first=f;function g(E,F){let $=0;for(let G of E)if(F(G,$++))return!0;return!1}t.some=g;function v(E,F){for(let $ of E)if(F($))return $}t.find=v;function*_(E,F){for(let $ of E)F($)&&(yield $)}t.filter=_;function*b(E,F){let $=0;for(let G of E)yield F(G,$++)}t.map=b;function*x(E,F){let $=0;for(let G of E)yield*F(G,$++)}t.flatMap=x;function*L(...E){for(let F of E)yield*F}t.concat=L;function k(E,F,$){let G=$;for(let K of E)G=F(G,K);return G}t.reduce=k;function*R(E,F,$=E.length){for(F<0&&(F+=E.length),$<0?$+=E.length:$>E.length&&($=E.length);F<$;F++)yield E[F]}t.slice=R;function S(E,F=Number.POSITIVE_INFINITY){let $=[];if(F===0)return[$,E];let G=E[Symbol.iterator]();for(let K=0;K<F;K++){let Y=G.next();if(Y.done)return[$,t.empty()];$.push(Y.value)}return[$,{[Symbol.iterator](){return G}}]}t.consume=S;async function j(E){let F=[];for await(let $ of E)F.push($);return Promise.resolve(F)}t.asyncToArray=j})(zx||(zx={}));function Fx(t){if(zx.is(t)){let e=[];for(let n of t)if(n)try{n.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}else if(t)return t.dispose(),t}function Hx(...t){return Es(()=>Fx(t))}function Es(t){return{dispose:cj(()=>{t()})}}var Ux=class Wx{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{Fx(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Wx.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};Ux.DISABLE_DISPOSED_WARNING=!1;var Fa=Ux,Di=class{constructor(){this._store=new Fa,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};Di.None=Object.freeze({dispose(){}});var Ul=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){var e;this._isDisposed||t===this._value||((e=this._value)==null||e.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){var t;this._isDisposed=!0,(t=this._value)==null||t.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},fv=typeof process<"u"&&"title"in process,oh=fv?"node":navigator.userAgent,uj=fv?"node":navigator.platform,dj=oh.includes("Firefox"),hj=oh.includes("Edge"),qx=/^((?!chrome|android).)*safari/i.test(oh);function fj(){if(!qx)return 0;let t=oh.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}uj.indexOf("Linux")>=0;var pj="",is=0,rs=0,os=0,An=0,pi={css:"#00000000",rgba:0},js;(t=>{function e(i,a,c,u){return u!==void 0?`#${Io(i)}${Io(a)}${Io(c)}${Io(u)}`:`#${Io(i)}${Io(a)}${Io(c)}`}t.toCss=e;function n(i,a,c,u=255){return(i<<24|a<<16|c<<8|u)>>>0}t.toRgba=n;function s(i,a,c,u){return{css:t.toCss(i,a,c,u),rgba:t.toRgba(i,a,c,u)}}t.toColor=s})(js||(js={}));var uc;(t=>{function e(h,f){if(An=(f.rgba&255)/255,An===1)return{css:f.css,rgba:f.rgba};let g=f.rgba>>24&255,v=f.rgba>>16&255,_=f.rgba>>8&255,b=h.rgba>>24&255,x=h.rgba>>16&255,L=h.rgba>>8&255;is=b+Math.round((g-b)*An),rs=x+Math.round((v-x)*An),os=L+Math.round((_-L)*An);let k=js.toCss(is,rs,os),R=js.toRgba(is,rs,os);return{css:k,rgba:R}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function s(h,f,g){let v=qo.ensureContrastRatio(h.rgba,f.rgba,g);if(v)return js.toColor(v>>24&255,v>>16&255,v>>8&255)}t.ensureContrastRatio=s;function i(h){let f=(h.rgba|255)>>>0;return[is,rs,os]=qo.toChannels(f),{css:js.toCss(is,rs,os),rgba:f}}t.opaque=i;function a(h,f){return An=Math.round(f*255),[is,rs,os]=qo.toChannels(h.rgba),{css:js.toCss(is,rs,os,An),rgba:js.toRgba(is,rs,os,An)}}t.opacity=a;function c(h,f){return An=h.rgba&255,a(h,An*f/255)}t.multiplyOpacity=c;function u(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=u})(uc||(uc={}));var mj;(t=>{let e,n;try{let i=document.createElement("canvas");i.width=1,i.height=1;let a=i.getContext("2d",{willReadFrequently:!0});a&&(e=a,e.globalCompositeOperation="copy",n=e.createLinearGradient(0,0,1,1))}catch{}function s(i){if(i.match(/#[\da-f]{3,8}/i))switch(i.length){case 4:return is=parseInt(i.slice(1,2).repeat(2),16),rs=parseInt(i.slice(2,3).repeat(2),16),os=parseInt(i.slice(3,4).repeat(2),16),js.toColor(is,rs,os);case 5:return is=parseInt(i.slice(1,2).repeat(2),16),rs=parseInt(i.slice(2,3).repeat(2),16),os=parseInt(i.slice(3,4).repeat(2),16),An=parseInt(i.slice(4,5).repeat(2),16),js.toColor(is,rs,os,An);case 7:return{css:i,rgba:(parseInt(i.slice(1),16)<<8|255)>>>0};case 9:return{css:i,rgba:parseInt(i.slice(1),16)>>>0}}let a=i.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 is=parseInt(a[1]),rs=parseInt(a[2]),os=parseInt(a[3]),An=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),js.toColor(is,rs,os,An);if(!e||!n)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=n,e.fillStyle=i,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[is,rs,os,An]=e.getImageData(0,0,1,1).data,An!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:js.toRgba(is,rs,os,An),css:i}}t.toColor=s})(mj||(mj={}));var As;(t=>{function e(s){return n(s>>16&255,s>>8&255,s&255)}t.relativeLuminance=e;function n(s,i,a){let c=s/255,u=i/255,h=a/255,f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),g=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);return f*.2126+g*.7152+v*.0722}t.relativeLuminance2=n})(As||(As={}));var qo;(t=>{function e(c,u){if(An=(u&255)/255,An===1)return u;let h=u>>24&255,f=u>>16&255,g=u>>8&255,v=c>>24&255,_=c>>16&255,b=c>>8&255;return is=v+Math.round((h-v)*An),rs=_+Math.round((f-_)*An),os=b+Math.round((g-b)*An),js.toRgba(is,rs,os)}t.blend=e;function n(c,u,h){let f=As.relativeLuminance(c>>8),g=As.relativeLuminance(u>>8);if(gr(f,g)<h){if(g<f){let b=s(c,u,h),x=gr(f,As.relativeLuminance(b>>8));if(x<h){let L=i(c,u,h),k=gr(f,As.relativeLuminance(L>>8));return x>k?b:L}return b}let v=i(c,u,h),_=gr(f,As.relativeLuminance(v>>8));if(_<h){let b=s(c,u,h),x=gr(f,As.relativeLuminance(b>>8));return _>x?v:b}return v}}t.ensureContrastRatio=n;function s(c,u,h){let f=c>>24&255,g=c>>16&255,v=c>>8&255,_=u>>24&255,b=u>>16&255,x=u>>8&255,L=gr(As.relativeLuminance2(_,b,x),As.relativeLuminance2(f,g,v));for(;L<h&&(_>0||b>0||x>0);)_-=Math.max(0,Math.ceil(_*.1)),b-=Math.max(0,Math.ceil(b*.1)),x-=Math.max(0,Math.ceil(x*.1)),L=gr(As.relativeLuminance2(_,b,x),As.relativeLuminance2(f,g,v));return(_<<24|b<<16|x<<8|255)>>>0}t.reduceLuminance=s;function i(c,u,h){let f=c>>24&255,g=c>>16&255,v=c>>8&255,_=u>>24&255,b=u>>16&255,x=u>>8&255,L=gr(As.relativeLuminance2(_,b,x),As.relativeLuminance2(f,g,v));for(;L<h&&(_<255||b<255||x<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),L=gr(As.relativeLuminance2(_,b,x),As.relativeLuminance2(f,g,v));return(_<<24|b<<16|x<<8|255)>>>0}t.increaseLuminance=i;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}t.toChannels=a})(qo||(qo={}));function Io(t){let e=t.toString(16);return e.length<2?"0"+e:e}function gr(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function Bn(t){if(!t)throw new Error("value must not be falsy");return t}function pv(t){return 57508<=t&&t<=57558}function gj(t){return 57520<=t&&t<=57527}function vj(t){return 57344<=t&&t<=63743}function _j(t){return 9472<=t&&t<=9631}function yj(t){return t>=128512&&t<=128591||t>=127744&&t<=128511||t>=128640&&t<=128767||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=65024&&t<=65039||t>=129280&&t<=129535||t>=127462&&t<=127487}function wj(t,e,n,s){return e===1&&n>Math.ceil(s*1.5)&&t!==void 0&&t>255&&!yj(t)&&!pv(t)&&!vj(t)}function Kx(t){return pv(t)||_j(t)}function bj(){return{css:{canvas:Xu(),cell:Xu()},device:{canvas:Xu(),cell:Xu(),char:{width:0,height:0,left:0,top:0}}}}function Xu(){return{width:0,height:0}}function Sj(t,e,n=0){return(t-(Math.round(e)*2-n))%(Math.round(e)*2)}var fs=0,Qn=0,qi=!1,vr=!1,Ju=!1,Us,lp=0,xj=class{constructor(t,e,n,s,i,a){this._terminal=t,this._optionService=e,this._selectionRenderModel=n,this._decorationService=s,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(t,e,n,s){if(this.result.bg=t.bg,this.result.fg=t.fg,this.result.ext=t.bg&268435456?t.extended.ext:0,Qn=0,fs=0,vr=!1,qi=!1,Ju=!1,Us=this._themeService.colors,lp=0,t.getCode()!==0&&t.extended.underlineStyle===4){let i=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));lp=e*s%(Math.round(i)*2)}if(this._decorationService.forEachDecorationAtCell(e,n,"bottom",i=>{i.backgroundColorRGB&&(Qn=i.backgroundColorRGB.rgba>>8&16777215,vr=!0),i.foregroundColorRGB&&(fs=i.foregroundColorRGB.rgba>>8&16777215,qi=!0)}),Ju=this._selectionRenderModel.isCellSelected(this._terminal,e,n),Ju){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:Qn=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Qn=(this.result.fg&16777215)<<8|255;break;case 0:default:Qn=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:Qn=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Qn=(this.result.bg&16777215)<<8|255;break}Qn=qo.blend(Qn,(this._coreBrowserService.isFocused?Us.selectionBackgroundOpaque:Us.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else Qn=(this._coreBrowserService.isFocused?Us.selectionBackgroundOpaque:Us.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(vr=!0,Us.selectionForeground&&(fs=Us.selectionForeground.rgba>>8&16777215,qi=!0),Kx(t.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)fs=(this._coreBrowserService.isFocused?Us.selectionBackgroundOpaque:Us.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:fs=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:fs=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:fs=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:fs=(this.result.fg&16777215)<<8|255;break;case 0:default:fs=this._themeService.colors.foreground.rgba}fs=qo.blend(fs,(this._coreBrowserService.isFocused?Us.selectionBackgroundOpaque:Us.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}qi=!0}}this._decorationService.forEachDecorationAtCell(e,n,"top",i=>{i.backgroundColorRGB&&(Qn=i.backgroundColorRGB.rgba>>8&16777215,vr=!0),i.foregroundColorRGB&&(fs=i.foregroundColorRGB.rgba>>8&16777215,qi=!0)}),vr&&(Ju?Qn=t.bg&-16777216&-134217729|Qn|50331648:Qn=t.bg&-16777216|Qn|50331648),qi&&(fs=t.fg&-16777216&-67108865|fs|50331648),this.result.fg&67108864&&(vr&&!qi&&((this.result.bg&50331648)===0?fs=this.result.fg&-134217728|Us.background.rgba>>8&16777215&16777215|50331648:fs=this.result.fg&-134217728|this.result.bg&67108863,qi=!0),!vr&&qi&&((this.result.fg&50331648)===0?Qn=this.result.bg&-67108864|Us.foreground.rgba>>8&16777215&16777215|50331648:Qn=this.result.bg&-67108864|this.result.fg&67108863,vr=!0)),Us=void 0,this.result.bg=vr?Qn:this.result.bg,this.result.fg=qi?fs:this.result.fg,this.result.ext&=536870911,this.result.ext|=lp<<29&3758096384}},kj=.5,Vx=dj||hj?"bottom":"ideographic",Cj={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Ej={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},Nj={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"║":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╒":{1:(t,e)=>`M.5,1 L.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╓":{1:(t,e)=>`M${.5-t},1 L${.5-t},.5 L1,.5 M${.5+t},.5 L${.5+t},1`},"╔":{1:(t,e)=>`M1,${.5-e} L${.5-t},${.5-e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╕":{1:(t,e)=>`M0,${.5-e} L.5,${.5-e} L.5,1 M0,${.5+e} L.5,${.5+e}`},"╖":{1:(t,e)=>`M${.5+t},1 L${.5+t},.5 L0,.5 M${.5-t},.5 L${.5-t},1`},"╗":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5+t},${.5-e} L${.5+t},1`},"╘":{1:(t,e)=>`M.5,0 L.5,${.5+e} L1,${.5+e} M.5,${.5-e} L1,${.5-e}`},"╙":{1:(t,e)=>`M1,.5 L${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╚":{1:(t,e)=>`M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0 M1,${.5+e} L${.5-t},${.5+e} L${.5-t},0`},"╛":{1:(t,e)=>`M0,${.5+e} L.5,${.5+e} L.5,0 M0,${.5-e} L.5,${.5-e}`},"╜":{1:(t,e)=>`M0,.5 L${.5+t},.5 L${.5+t},0 M${.5-t},.5 L${.5-t},0`},"╝":{1:(t,e)=>`M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M0,${.5+e} L${.5+t},${.5+e} L${.5+t},0`},"╞":{1:(t,e)=>`M.5,0 L.5,1 M.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╟":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1 M${.5+t},.5 L1,.5`},"╠":{1:(t,e)=>`M${.5-t},0 L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╡":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L.5,${.5-e} M0,${.5+e} L.5,${.5+e}`},"╢":{1:(t,e)=>`M0,.5 L${.5-t},.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╣":{1:(t,e)=>`M${.5+t},0 L${.5+t},1 M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0`},"╤":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e} M.5,${.5+e} L.5,1`},"╥":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},1 M${.5+t},.5 L${.5+t},1`},"╦":{1:(t,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1`},"╧":{1:(t,e)=>`M.5,0 L.5,${.5-e} M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╨":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},.5 L${.5-t},0 M${.5+t},.5 L${.5+t},0`},"╩":{1:(t,e)=>`M0,${.5+e} L1,${.5+e} M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╪":{1:(t,e)=>`M.5,0 L.5,1 M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╫":{1:(t,e)=>`M0,.5 L1,.5 M${.5-t},0 L${.5-t},1 M${.5+t},0 L${.5+t},1`},"╬":{1:(t,e)=>`M0,${.5+e} L${.5-t},${.5+e} L${.5-t},1 M1,${.5+e} L${.5+t},${.5+e} L${.5+t},1 M0,${.5-e} L${.5-t},${.5-e} L${.5-t},0 M1,${.5-e} L${.5+t},${.5-e} L${.5+t},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,1,.5`},"╮":{1:(t,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,0,.5`},"╯":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,0,.5`},"╰":{1:(t,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,1,.5`}},xc={"":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};xc[""]=xc[""];xc[""]=xc[""];function Rj(t,e,n,s,i,a,c,u){let h=Cj[e];if(h)return Lj(t,h,n,s,i,a),!0;let f=Ej[e];if(f)return Aj(t,f,n,s,i,a),!0;let g=Nj[e];if(g)return jj(t,g,n,s,i,a,u),!0;let v=xc[e];return v?(Mj(t,v,n,s,i,a,c,u),!0):!1}function Lj(t,e,n,s,i,a){for(let c=0;c<e.length;c++){let u=e[c],h=i/8,f=a/8;t.fillRect(n+u.x*h,s+u.y*f,u.w*h,u.h*f)}}var Hb=new Map;function Aj(t,e,n,s,i,a){let c=Hb.get(e);c||(c=new Map,Hb.set(e,c));let u=t.fillStyle;if(typeof u!="string")throw new Error(`Unexpected fillStyle type "${u}"`);let h=c.get(u);if(!h){let f=e[0].length,g=e.length,v=t.canvas.ownerDocument.createElement("canvas");v.width=f,v.height=g;let _=Bn(v.getContext("2d")),b=new ImageData(f,g),x,L,k,R;if(u.startsWith("#"))x=parseInt(u.slice(1,3),16),L=parseInt(u.slice(3,5),16),k=parseInt(u.slice(5,7),16),R=u.length>7&&parseInt(u.slice(7,9),16)||1;else if(u.startsWith("rgba"))[x,L,k,R]=u.substring(5,u.length-1).split(",").map(S=>parseFloat(S));else throw new Error(`Unexpected fillStyle color format "${u}" when drawing pattern glyph`);for(let S=0;S<g;S++)for(let j=0;j<f;j++)b.data[(S*f+j)*4]=x,b.data[(S*f+j)*4+1]=L,b.data[(S*f+j)*4+2]=k,b.data[(S*f+j)*4+3]=e[S][j]*(R*255);_.putImageData(b,0,0),h=Bn(t.createPattern(v,null)),c.set(u,h)}t.fillStyle=h,t.fillRect(n,s,i,a)}function jj(t,e,n,s,i,a,c){t.strokeStyle=t.fillStyle;for(let[u,h]of Object.entries(e)){t.beginPath(),t.lineWidth=c*Number.parseInt(u);let f;if(typeof h=="function"){let g=.15/a*i;f=h(.15,g)}else f=h;for(let g of f.split(" ")){let v=g[0],_=Yx[v];if(!_){console.error(`Could not find drawing instructions for "${v}"`);continue}let b=g.substring(1).split(",");!b[0]||!b[1]||_(t,Gx(b,i,a,n,s,!0,c))}t.stroke(),t.closePath()}}function Mj(t,e,n,s,i,a,c,u){let h=new Path2D;h.rect(n,s,i,a),t.clip(h),t.beginPath();let f=c/12;t.lineWidth=u*f;for(let g of e.d.split(" ")){let v=g[0],_=Yx[v];if(!_){console.error(`Could not find drawing instructions for "${v}"`);continue}let b=g.substring(1).split(",");!b[0]||!b[1]||_(t,Gx(b,i,a,n,s,!1,u,(e.leftPadding??0)*(f/2),(e.rightPadding??0)*(f/2)))}e.type===1?(t.strokeStyle=t.fillStyle,t.stroke()):t.fill(),t.closePath()}function Ub(t,e,n=0){return Math.max(Math.min(t,e),n)}var Yx={C:(t,e)=>t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),L:(t,e)=>t.lineTo(e[0],e[1]),M:(t,e)=>t.moveTo(e[0],e[1])};function Gx(t,e,n,s,i,a,c,u=0,h=0){let f=t.map(g=>parseFloat(g)||parseInt(g));if(f.length<2)throw new Error("Too few arguments for instruction");for(let g=0;g<f.length;g+=2)f[g]*=e-u*c-h*c,a&&f[g]!==0&&(f[g]=Ub(Math.round(f[g]+.5)-.5,e,0)),f[g]+=s+u*c;for(let g=1;g<f.length;g+=2)f[g]*=n,a&&f[g]!==0&&(f[g]=Ub(Math.round(f[g]+.5)-.5,n,0)),f[g]+=i;return f}var Wb=class{constructor(){this._data={}}set(t,e,n){this._data[t]||(this._data[t]={}),this._data[t][e]=n}get(t,e){return this._data[t]?this._data[t][e]:void 0}clear(){this._data={}}},qb=class{constructor(){this._data=new Wb}set(t,e,n,s,i){this._data.get(t,e)||this._data.set(t,e,new Wb),this._data.get(t,e).set(n,s,i)}get(t,e,n,s){var i;return(i=this._data.get(t,e))==null?void 0:i.get(n,s)}clear(){this._data.clear()}},Xx=class{constructor(){this._tasks=[],this._i=0}enqueue(t){this._tasks.push(t),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(t){this._idleCallback=void 0;let e=0,n=0,s=t.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),n=Math.max(e,n),i=t.timeRemaining(),n*1.5>i){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=i}this.clear()}},Tj=class extends Xx{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let e=performance.now()+t;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},Pj=class extends Xx{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Ij=!fv&&"requestIdleCallback"in window?Pj:Tj,Ba=class Jx{constructor(){this.fg=0,this.bg=0,this.extended=new Qx}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new Jx;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}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}},Qx=class Zx{constructor(e=0,n=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new Zx(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Dj=globalThis.performance&&typeof globalThis.performance.now=="function",Oj=class ek{static create(e){return new ek(e)}constructor(e){this._now=Dj&&e===!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}},xr;(t=>{t.None=()=>Di.None;function e(D,I){return v(D,()=>{},0,void 0,!0,void 0,I)}t.defer=e;function n(D){return(I,O=null,M)=>{let z=!1,T;return T=D(A=>{if(!z)return T?T.dispose():z=!0,I.call(O,A)},null,M),z&&T.dispose(),T}}t.once=n;function s(D,I,O){return f((M,z=null,T)=>D(A=>M.call(z,I(A)),null,T),O)}t.map=s;function i(D,I,O){return f((M,z=null,T)=>D(A=>{I(A),M.call(z,A)},null,T),O)}t.forEach=i;function a(D,I,O){return f((M,z=null,T)=>D(A=>I(A)&&M.call(z,A),null,T),O)}t.filter=a;function c(D){return D}t.signal=c;function u(...D){return(I,O=null,M)=>{let z=Hx(...D.map(T=>T(A=>I.call(O,A))));return g(z,M)}}t.any=u;function h(D,I,O,M){let z=O;return s(D,T=>(z=I(z,T),z),M)}t.reduce=h;function f(D,I){let O,M={onWillAddFirstListener(){O=D(z.fire,z)},onDidRemoveLastListener(){O==null||O.dispose()}},z=new pn(M);return I==null||I.add(z),z.event}function g(D,I){return I instanceof Array?I.push(D):I&&I.add(D),D}function v(D,I,O=100,M=!1,z=!1,T,A){let N,U,P,H=0,ie,J={leakWarningThreshold:T,onWillAddFirstListener(){N=D(ve=>{H++,U=I(U,ve),M&&!P&&(Q.fire(U),U=void 0),ie=()=>{let de=U;U=void 0,P=void 0,(!M||H>1)&&Q.fire(de),H=0},typeof O=="number"?(clearTimeout(P),P=setTimeout(ie,O)):P===void 0&&(P=0,queueMicrotask(ie))})},onWillRemoveListener(){z&&H>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,N.dispose()}},Q=new pn(J);return A==null||A.add(Q),Q.event}t.debounce=v;function _(D,I=0,O){return t.debounce(D,(M,z)=>M?(M.push(z),M):[z],I,void 0,!0,void 0,O)}t.accumulate=_;function b(D,I=(M,z)=>M===z,O){let M=!0,z;return a(D,T=>{let A=M||!I(T,z);return M=!1,z=T,A},O)}t.latch=b;function x(D,I,O){return[t.filter(D,I,O),t.filter(D,M=>!I(M),O)]}t.split=x;function L(D,I=!1,O=[],M){let z=O.slice(),T=D(U=>{z?z.push(U):N.fire(U)});M&&M.add(T);let A=()=>{z==null||z.forEach(U=>N.fire(U)),z=null},N=new pn({onWillAddFirstListener(){T||(T=D(U=>N.fire(U)),M&&M.add(T))},onDidAddFirstListener(){z&&(I?setTimeout(A):A())},onDidRemoveLastListener(){T&&T.dispose(),T=null}});return M&&M.add(N),N.event}t.buffer=L;function k(D,I){return(O,M,z)=>{let T=I(new S);return D(function(A){let N=T.evaluate(A);N!==R&&O.call(M,N)},void 0,z)}}t.chain=k;let R=Symbol("HaltChainable");class S{constructor(){this.steps=[]}map(I){return this.steps.push(I),this}forEach(I){return this.steps.push(O=>(I(O),O)),this}filter(I){return this.steps.push(O=>I(O)?O:R),this}reduce(I,O){let M=O;return this.steps.push(z=>(M=I(M,z),M)),this}latch(I=(O,M)=>O===M){let O=!0,M;return this.steps.push(z=>{let T=O||!I(z,M);return O=!1,M=z,T?z:R}),this}evaluate(I){for(let O of this.steps)if(I=O(I),I===R)break;return I}}function j(D,I,O=M=>M){let M=(...N)=>A.fire(O(...N)),z=()=>D.on(I,M),T=()=>D.removeListener(I,M),A=new pn({onWillAddFirstListener:z,onDidRemoveLastListener:T});return A.event}t.fromNodeEventEmitter=j;function E(D,I,O=M=>M){let M=(...N)=>A.fire(O(...N)),z=()=>D.addEventListener(I,M),T=()=>D.removeEventListener(I,M),A=new pn({onWillAddFirstListener:z,onDidRemoveLastListener:T});return A.event}t.fromDOMEventEmitter=E;function F(D){return new Promise(I=>n(D)(I))}t.toPromise=F;function $(D){let I=new pn;return D.then(O=>{I.fire(O)},()=>{I.fire(void 0)}).finally(()=>{I.dispose()}),I.event}t.fromPromise=$;function G(D,I){return D(O=>I.fire(O))}t.forward=G;function K(D,I,O){return I(O),D(M=>I(M))}t.runAndSubscribe=K;class Y{constructor(I,O){this._observable=I,this._counter=0,this._hasChanged=!1;let M={onWillAddFirstListener:()=>{I.addObserver(this)},onDidRemoveLastListener:()=>{I.removeObserver(this)}};this.emitter=new pn(M),O&&O.add(this.emitter)}beginUpdate(I){this._counter++}handlePossibleChange(I){}handleChange(I,O){this._hasChanged=!0}endUpdate(I){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function te(D,I){return new Y(D,I).emitter.event}t.fromObservable=te;function q(D){return(I,O,M)=>{let z=0,T=!1,A={beginUpdate(){z++},endUpdate(){z--,z===0&&(D.reportChanges(),T&&(T=!1,I.call(O)))},handlePossibleChange(){},handleChange(){T=!0}};D.addObserver(A),D.reportChanges();let N={dispose(){D.removeObserver(A)}};return M instanceof Fa?M.add(N):Array.isArray(M)&&M.push(N),N}}t.fromObservableLight=q})(xr||(xr={}));var ng=class sg{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${sg._idPool++}`,sg.all.add(this)}start(e){this._stopWatch=new Oj,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};ng.all=new Set,ng._idPool=0;var Bj=ng,$j=-1,tk=class nk{constructor(e,n,s=(nk._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=n,this.name=s,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,n){let s=this.threshold;if(s<=0||n<s)return;this._stacks||(this._stacks=new Map);let i=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,i+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[a,c]=this.getMostFrequentStack(),u=`[${this.name}] potential listener LEAK detected, having ${n} listeners already. MOST frequent listener (${c}):`;console.warn(u),console.warn(a);let h=new Hj(u,a);this._errorHandler(h)}return()=>{let a=this._stacks.get(e.value)||0;this._stacks.set(e.value,a-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,n=0;for(let[s,i]of this._stacks)(!e||n<i)&&(e=[s,i],n=i);return e}};tk._idPool=1;var zj=tk,Fj=class sk{constructor(e){this.value=e}static create(){let e=new Error;return new sk(e.stack??"")}print(){console.warn(this.value.split(`
|
|
93
|
-
`).slice(2).join(`
|
|
94
|
-
`))}},Hj=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},Uj=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},Wj=0,cp=class{constructor(t){this.value=t,this.id=Wj++}},qj=2,Kj,pn=class{constructor(t){var e,n,s,i;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new zj((t==null?void 0:t.onListenerError)??ap,((n=this._options)==null?void 0:n.leakWarningThreshold)??$j):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Bj(this._options._profName):void 0,this._deliveryQueue=(i=this._options)==null?void 0:i.deliveryQueue}dispose(){var t,e,n,s;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(n=(e=this._options)==null?void 0:e.onDidRemoveLastListener)==null||n.call(e),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(t,e,n)=>{var c,u,h,f,g;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let v=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(v);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],b=new Uj(`${v}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||ap)(b),Di.None}if(this._disposed)return Di.None;e&&(t=t.bind(e));let s=new cp(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Fj.create(),i=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof cp?(this._deliveryQueue??(this._deliveryQueue=new Vj),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(u=this._options)==null?void 0:u.onWillAddFirstListener)==null||h.call(u,this),this._listeners=s,(g=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||g.call(f,this)),this._size++;let a=Es(()=>{i==null||i(),this._removeListener(s)});return n instanceof Fa?n.add(a):Array.isArray(n)&&n.push(a),a}),this._event}_removeListener(t){var i,a,c,u;if((a=(i=this._options)==null?void 0:i.onWillRemoveListener)==null||a.call(i,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(u=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||u.call(c,this),this._size=0;return}let e=this._listeners,n=e.indexOf(t);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--,e[n]=void 0;let s=this._deliveryQueue.current===this;if(this._size*qj<=e.length){let h=0;for(let f=0;f<e.length;f++)e[f]?e[h++]=e[f]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);e.length=h}}_deliver(t,e){var s;if(!t)return;let n=((s=this._options)==null?void 0:s.onListenerError)||ap;if(!n){t.value(e);return}try{t.value(e)}catch(i){n(i)}}_deliverQueue(t){let e=t.current._listeners;for(;t.i<t.end;)this._deliver(e[t.i++],t.value);t.reset()}fire(t){var e,n,s,i;if((e=this._deliveryQueue)!=null&&e.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 cp)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(i=this._perfMon)==null||i.stop()}hasListeners(){return this._size>0}},Vj=class{constructor(){this.i=-1,this.end=0}enqueue(t,e,n){this.i=0,this.end=n,this.current=t,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Kb={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},Wl=2,ql,eo=class Ia{constructor(e,n,s){this._document=e,this._config=n,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new qb,this._cacheMapCombined=new qb,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Ba,this._textureSize=512,this._onAddTextureAtlasCanvas=new pn,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new pn,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=ik(e,this._config.deviceCellWidth*4+Wl*2,this._config.deviceCellHeight+Wl*2),this._tmpCtx=Bn(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new Ij;for(let n=33;n<126;n++)e.enqueue(()=>{if(!this._cacheMap.get(n,0,0,0)){let s=this._drawToCache(n,0,0,0,!1,void 0);this._cacheMap.set(n,0,0,0,s)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Ia.maxAtlasPages&&this._pages.length>=Math.max(4,Ia.maxAtlasPages)){let n=this._pages.filter(f=>f.canvas.width*2<=(Ia.maxTextureSize||4096)).sort((f,g)=>g.canvas.width!==f.canvas.width?g.canvas.width-f.canvas.width:g.percentageUsed-f.percentageUsed),s=-1,i=0;for(let f=0;f<n.length;f++)if(n[f].canvas.width!==i)s=f,i=n[f].canvas.width;else if(f-s===3)break;let a=n.slice(s,s+4),c=a.map(f=>f.glyphs[0].texturePage).sort((f,g)=>f>g?1:-1),u=this.pages.length-a.length,h=this._mergePages(a,u);h.version++;for(let f=c.length-1;f>=0;f--)this._deletePage(c[f]);this.pages.push(h),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(h.canvas)}let e=new up(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,n){let s=e[0].canvas.width*2,i=new up(this._document,s,e);for(let[a,c]of e.entries()){let u=a*c.canvas.width%s,h=Math.floor(a/2)*c.canvas.height;i.ctx.drawImage(c.canvas,u,h);for(let g of c.glyphs)g.texturePage=n,g.sizeClipSpace.x=g.size.x/s,g.sizeClipSpace.y=g.size.y/s,g.texturePosition.x+=u,g.texturePosition.y+=h,g.texturePositionClipSpace.x=g.texturePosition.x/s,g.texturePositionClipSpace.y=g.texturePosition.y/s;this._onRemoveTextureAtlasCanvas.fire(c.canvas);let f=this._activePages.indexOf(c);f!==-1&&this._activePages.splice(f,1)}return i}_deletePage(e){this._pages.splice(e,1);for(let n=e;n<this._pages.length;n++){let s=this._pages[n];for(let i of s.glyphs)i.texturePage--;s.version++}}getRasterizedGlyphCombinedChar(e,n,s,i,a,c){return this._getFromCacheMap(this._cacheMapCombined,e,n,s,i,a,c)}getRasterizedGlyph(e,n,s,i,a,c){return this._getFromCacheMap(this._cacheMap,e,n,s,i,a,c)}_getFromCacheMap(e,n,s,i,a,c,u){return ql=e.get(n,s,i,a),ql||(ql=this._drawToCache(n,s,i,a,c,u),e.set(n,s,i,a,ql)),ql}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,n,s,i){if(this._config.allowTransparency)return pi;let a;switch(e){case 16777216:case 33554432:a=this._getColorFromAnsiIndex(n);break;case 50331648:let c=Ba.toColorRGB(n);a=js.toColor(c[0],c[1],c[2]);break;case 0:default:s?a=uc.opaque(this._config.colors.foreground):a=this._config.colors.background;break}return this._config.allowTransparency||(a=uc.opaque(a)),a}_getForegroundColor(e,n,s,i,a,c,u,h,f,g){let v=this._getMinimumContrastColor(e,n,s,i,a,c,u,f,h,g);if(v)return v;let _;switch(a){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&f&&c<8&&(c+=8),_=this._getColorFromAnsiIndex(c);break;case 50331648:let b=Ba.toColorRGB(c);_=js.toColor(b[0],b[1],b[2]);break;case 0:default:u?_=this._config.colors.background:_=this._config.colors.foreground}return this._config.allowTransparency&&(_=uc.opaque(_)),h&&(_=uc.multiplyOpacity(_,kj)),_}_resolveBackgroundRgba(e,n,s){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(n).rgba;case 50331648:return n<<8;case 0:default:return s?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,n,s,i){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&i&&n<8&&(n+=8),this._getColorFromAnsiIndex(n).rgba;case 50331648:return n<<8;case 0:default:return s?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,n,s,i,a,c,u,h,f,g){if(this._config.minimumContrastRatio===1||g)return;let v=this._getContrastCache(f),_=v.getColor(e,i);if(_!==void 0)return _||void 0;let b=this._resolveBackgroundRgba(n,s,u),x=this._resolveForegroundRgba(a,c,u,h),L=qo.ensureContrastRatio(b,x,this._config.minimumContrastRatio/(f?2:1));if(!L){v.setColor(e,i,null);return}let k=js.toColor(L>>24&255,L>>16&255,L>>8&255);return v.setColor(e,i,k),k}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,n,s,i,a,c){let u=typeof e=="number"?String.fromCharCode(e):e;c&&this._tmpCanvas.parentElement!==c&&(this._tmpCanvas.style.display="none",c.append(this._tmpCanvas));let h=Math.min(this._config.deviceCellWidth*Math.max(u.length,2)+Wl*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<h&&(this._tmpCanvas.width=h);let f=Math.min(this._config.deviceCellHeight+Wl*4,this._textureSize);if(this._tmpCanvas.height<f&&(this._tmpCanvas.height=f),this._tmpCtx.save(),this._workAttributeData.fg=s,this._workAttributeData.bg=n,this._workAttributeData.extended.ext=i,!!this._workAttributeData.isInvisible())return Kb;let g=!!this._workAttributeData.isBold(),v=!!this._workAttributeData.isInverse(),_=!!this._workAttributeData.isDim(),b=!!this._workAttributeData.isItalic(),x=!!this._workAttributeData.isUnderline(),L=!!this._workAttributeData.isStrikethrough(),k=!!this._workAttributeData.isOverline(),R=this._workAttributeData.getFgColor(),S=this._workAttributeData.getFgColorMode(),j=this._workAttributeData.getBgColor(),E=this._workAttributeData.getBgColorMode();if(v){let U=R;R=j,j=U;let P=S;S=E,E=P}let F=this._getBackgroundColor(E,j,v,_);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=F.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let $=g?this._config.fontWeightBold:this._config.fontWeight,G=b?"italic":"";this._tmpCtx.font=`${G} ${$} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=Vx;let K=u.length===1&&pv(u.charCodeAt(0)),Y=u.length===1&&gj(u.charCodeAt(0)),te=this._getForegroundColor(n,E,j,s,S,R,v,_,g,Kx(u.charCodeAt(0)));this._tmpCtx.fillStyle=te.css;let q=Y?0:Wl*2,D=!1;this._config.customGlyphs!==!1&&(D=Rj(this._tmpCtx,u,q,q,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let I=!K,O;if(typeof e=="number"?O=this._unicodeService.wcwidth(e):O=this._unicodeService.getStringCellWidth(e),x){this._tmpCtx.save();let U=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),P=U%2===1?.5:0;if(this._tmpCtx.lineWidth=U,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())I=!1,this._tmpCtx.strokeStyle=`rgb(${Ba.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{I=!1;let de=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&de<8&&(de+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(de).css}this._tmpCtx.beginPath();let H=q,ie=Math.ceil(q+this._config.deviceCharHeight)-P-(a?U*2:0),J=ie+U,Q=ie+U*2,ve=this._workAttributeData.getUnderlineVariantOffset();for(let de=0;de<O;de++){this._tmpCtx.save();let ne=H+de*this._config.deviceCellWidth,xe=H+(de+1)*this._config.deviceCellWidth,$e=ne+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(ne,ie),this._tmpCtx.lineTo(xe,ie),this._tmpCtx.moveTo(ne,Q),this._tmpCtx.lineTo(xe,Q);break;case 3:let rt=U<=1?Q:Math.ceil(q+this._config.deviceCharHeight-U/2)-P,je=U<=1?ie:Math.ceil(q+this._config.deviceCharHeight+U/2)-P,Ie=new Path2D;Ie.rect(ne,ie,this._config.deviceCellWidth,Q-ie),this._tmpCtx.clip(Ie),this._tmpCtx.moveTo(ne-this._config.deviceCellWidth/2,J),this._tmpCtx.bezierCurveTo(ne-this._config.deviceCellWidth/2,je,ne,je,ne,J),this._tmpCtx.bezierCurveTo(ne,rt,$e,rt,$e,J),this._tmpCtx.bezierCurveTo($e,je,xe,je,xe,J),this._tmpCtx.bezierCurveTo(xe,rt,xe+this._config.deviceCellWidth/2,rt,xe+this._config.deviceCellWidth/2,J);break;case 4:let oe=ve===0?0:ve>=U?U*2-ve:U-ve;ve>=U||oe===0?(this._tmpCtx.setLineDash([Math.round(U),Math.round(U)]),this._tmpCtx.moveTo(ne+oe,ie),this._tmpCtx.lineTo(xe,ie)):(this._tmpCtx.setLineDash([Math.round(U),Math.round(U)]),this._tmpCtx.moveTo(ne,ie),this._tmpCtx.lineTo(ne+oe,ie),this._tmpCtx.moveTo(ne+oe+U,ie),this._tmpCtx.lineTo(xe,ie)),ve=Sj(xe-ne,U,ve);break;case 5:let Ne=.6,me=.3,Ce=xe-ne,V=Math.floor(Ne*Ce),ge=Math.floor(me*Ce),Le=Ce-V-ge;this._tmpCtx.setLineDash([V,ge,Le]),this._tmpCtx.moveTo(ne,ie),this._tmpCtx.lineTo(xe,ie);break;case 1:default:this._tmpCtx.moveTo(ne,ie),this._tmpCtx.lineTo(xe,ie);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!D&&this._config.fontSize>=12&&!this._config.allowTransparency&&u!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let de=this._tmpCtx.measureText(u);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in de&&de.actualBoundingBoxDescent>0){this._tmpCtx.save();let ne=new Path2D;ne.rect(H,ie-Math.ceil(U/2),this._config.deviceCellWidth*O,Q-ie+Math.ceil(U/2)),this._tmpCtx.clip(ne),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=F.css,this._tmpCtx.strokeText(u,q,q+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(k){let U=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),P=U%2===1?.5:0;this._tmpCtx.lineWidth=U,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(q,q+P),this._tmpCtx.lineTo(q+this._config.deviceCharWidth*O,q+P),this._tmpCtx.stroke()}if(D||this._tmpCtx.fillText(u,q,q+this._config.deviceCharHeight),u==="_"&&!this._config.allowTransparency){let U=dp(this._tmpCtx.getImageData(q,q,this._config.deviceCellWidth,this._config.deviceCellHeight),F,te,I);if(U)for(let P=1;P<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=F.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(u,q,q+this._config.deviceCharHeight-P),U=dp(this._tmpCtx.getImageData(q,q,this._config.deviceCellWidth,this._config.deviceCellHeight),F,te,I),!!U);P++);}if(L){let U=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),P=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=U,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(q,q+Math.floor(this._config.deviceCharHeight/2)-P),this._tmpCtx.lineTo(q+this._config.deviceCharWidth*O,q+Math.floor(this._config.deviceCharHeight/2)-P),this._tmpCtx.stroke()}this._tmpCtx.restore();let M=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),z;if(this._config.allowTransparency?z=Yj(M):z=dp(M,F,te,I),z)return Kb;let T=this._findGlyphBoundingBox(M,this._workBoundingBox,h,Y,D,q),A,N;for(;;){if(this._activePages.length===0){let U=this._createNewPage();A=U,N=U.currentRow,N.height=T.size.y;break}A=this._activePages[this._activePages.length-1],N=A.currentRow;for(let U of this._activePages)T.size.y<=U.currentRow.height&&(A=U,N=U.currentRow);for(let U=this._activePages.length-1;U>=0;U--)for(let P of this._activePages[U].fixedRows)P.height<=N.height&&T.size.y<=P.height&&(A=this._activePages[U],N=P);if(T.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new up(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),A=this._overflowSizePage,N=this._overflowSizePage.currentRow,N.x+T.size.x>=A.canvas.width&&(N.x=0,N.y+=N.height,N.height=0);break}if(N.y+T.size.y>=A.canvas.height||N.height>T.size.y+2){let U=!1;if(A.currentRow.y+A.currentRow.height+T.size.y>=A.canvas.height){let P;for(let H of this._activePages)if(H.currentRow.y+H.currentRow.height+T.size.y<H.canvas.height){P=H;break}if(P)A=P;else if(Ia.maxAtlasPages&&this._pages.length>=Ia.maxAtlasPages&&N.y+T.size.y<=A.canvas.height&&N.height>=T.size.y&&N.x+T.size.x<=A.canvas.width)U=!0;else{let H=this._createNewPage();A=H,N=H.currentRow,N.height=T.size.y,U=!0}}U||(A.currentRow.height>0&&A.fixedRows.push(A.currentRow),N={x:0,y:A.currentRow.y+A.currentRow.height,height:T.size.y},A.fixedRows.push(N),A.currentRow={x:0,y:N.y+N.height,height:0})}if(N.x+T.size.x<=A.canvas.width)break;N===A.currentRow?(N.x=0,N.y+=N.height,N.height=0):A.fixedRows.splice(A.fixedRows.indexOf(N),1)}return T.texturePage=this._pages.indexOf(A),T.texturePosition.x=N.x,T.texturePosition.y=N.y,T.texturePositionClipSpace.x=N.x/A.canvas.width,T.texturePositionClipSpace.y=N.y/A.canvas.height,T.sizeClipSpace.x/=A.canvas.width,T.sizeClipSpace.y/=A.canvas.height,N.height=Math.max(N.height,T.size.y),N.x+=T.size.x,A.ctx.putImageData(M,T.texturePosition.x-this._workBoundingBox.left,T.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,T.size.x,T.size.y),A.addGlyph(T),A.version++,T}_findGlyphBoundingBox(e,n,s,i,a,c){n.top=0;let u=i?this._config.deviceCellHeight:this._tmpCanvas.height,h=i?this._config.deviceCellWidth:s,f=!1;for(let g=0;g<u;g++){for(let v=0;v<h;v++){let _=g*this._tmpCanvas.width*4+v*4+3;if(e.data[_]!==0){n.top=g,f=!0;break}}if(f)break}n.left=0,f=!1;for(let g=0;g<c+h;g++){for(let v=0;v<u;v++){let _=v*this._tmpCanvas.width*4+g*4+3;if(e.data[_]!==0){n.left=g,f=!0;break}}if(f)break}n.right=h,f=!1;for(let g=c+h-1;g>=c;g--){for(let v=0;v<u;v++){let _=v*this._tmpCanvas.width*4+g*4+3;if(e.data[_]!==0){n.right=g,f=!0;break}}if(f)break}n.bottom=u,f=!1;for(let g=u-1;g>=0;g--){for(let v=0;v<h;v++){let _=g*this._tmpCanvas.width*4+v*4+3;if(e.data[_]!==0){n.bottom=g,f=!0;break}}if(f)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:n.right-n.left+1,y:n.bottom-n.top+1},sizeClipSpace:{x:n.right-n.left+1,y:n.bottom-n.top+1},offset:{x:-n.left+c+(i||a?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-n.top+c+(i||a?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},up=class{constructor(t,e,n){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],n)for(let s of n)this._glyphs.push(...s.glyphs),this._usedPixels+=s._usedPixels;this.canvas=ik(t,e,e),this.ctx=Bn(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function dp(t,e,n,s){let i=e.rgba>>>24,a=e.rgba>>>16&255,c=e.rgba>>>8&255,u=n.rgba>>>24,h=n.rgba>>>16&255,f=n.rgba>>>8&255,g=Math.floor((Math.abs(i-u)+Math.abs(a-h)+Math.abs(c-f))/12),v=!0;for(let _=0;_<t.data.length;_+=4)t.data[_]===i&&t.data[_+1]===a&&t.data[_+2]===c||s&&Math.abs(t.data[_]-i)+Math.abs(t.data[_+1]-a)+Math.abs(t.data[_+2]-c)<g?t.data[_+3]=0:v=!1;return v}function Yj(t){for(let e=0;e<t.data.length;e+=4)if(t.data[e+3]>0)return!1;return!0}function ik(t,e,n){let s=t.createElement("canvas");return s.width=e,s.height=n,s}function Gj(t,e,n,s,i,a,c,u){let h={foreground:a.foreground,background:a.background,cursor:pi,cursorAccent:pi,selectionForeground:pi,selectionBackgroundTransparent:pi,selectionBackgroundOpaque:pi,selectionInactiveBackgroundTransparent:pi,selectionInactiveBackgroundOpaque:pi,overviewRulerBorder:pi,scrollbarSliderBackground:pi,scrollbarSliderHoverBackground:pi,scrollbarSliderActiveBackground:pi,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:c,deviceMaxTextureSize:u,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:t,deviceCellHeight:e,deviceCharWidth:n,deviceCharHeight:s,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:h}}function Vb(t,e){for(let n=0;n<t.colors.ansi.length;n++)if(t.colors.ansi[n].rgba!==e.colors.ansi[n].rgba)return!1;return t.devicePixelRatio===e.devicePixelRatio&&t.customGlyphs===e.customGlyphs&&t.lineHeight===e.lineHeight&&t.letterSpacing===e.letterSpacing&&t.fontFamily===e.fontFamily&&t.fontSize===e.fontSize&&t.fontWeight===e.fontWeight&&t.fontWeightBold===e.fontWeightBold&&t.allowTransparency===e.allowTransparency&&t.deviceCharWidth===e.deviceCharWidth&&t.deviceCharHeight===e.deviceCharHeight&&t.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&t.minimumContrastRatio===e.minimumContrastRatio&&t.colors.foreground.rgba===e.colors.foreground.rgba&&t.colors.background.rgba===e.colors.background.rgba}function Xj(t){return(t&50331648)===16777216||(t&50331648)===33554432}var vi=[];function rk(t,e,n,s,i,a,c,u,h){let f=Gj(s,i,a,c,e,n,u,h);for(let _=0;_<vi.length;_++){let b=vi[_],x=b.ownedBy.indexOf(t);if(x>=0){if(Vb(b.config,f))return b.atlas;b.ownedBy.length===1?(b.atlas.dispose(),vi.splice(_,1)):b.ownedBy.splice(x,1);break}}for(let _=0;_<vi.length;_++){let b=vi[_];if(Vb(b.config,f))return b.ownedBy.push(t),b.atlas}let g=t._core,v={atlas:new eo(document,f,g.unicodeService),config:f,ownedBy:[t]};return vi.push(v),v.atlas}function Yb(t){for(let e=0;e<vi.length;e++){let n=vi[e].ownedBy.indexOf(t);if(n!==-1){vi[e].ownedBy.length===1?(vi[e].atlas.dispose(),vi.splice(e,1)):vi[e].ownedBy.splice(n,1);break}}}var Qu=600,Jj=class{constructor(t,e){this._renderCallback=t,this._coreBrowserService=e,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(t=Qu){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Qu-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=Qu-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Qu)},t)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function Gb(t,e,n){let s=new e.ResizeObserver(i=>{let a=i.find(h=>h.target===t);if(!a)return;if(!("devicePixelContentBoxSize"in a)){s==null||s.disconnect(),s=void 0;return}let c=a.devicePixelContentBoxSize[0].inlineSize,u=a.devicePixelContentBoxSize[0].blockSize;c>0&&u>0&&n(c,u)});try{s.observe(t,{box:["device-pixel-content-box"]})}catch{s.disconnect(),s=void 0}return Es(()=>s==null?void 0:s.disconnect())}function Qj(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}var Xb=class ok extends Ba{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Qx,this.combinedData=""}static fromCharData(e){let n=new ok;return n.setFromCharData(e),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Qj(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let n=!1;if(e[1].length>2)n=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let i=e[1].charCodeAt(1);56320<=i&&i<=57343?this.content=(s-55296)*1024+i-56320+65536|e[2]<<22:n=!0}else n=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;n&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ak=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function lk(t,e,n){let s=Bn(t.createProgram());if(t.attachShader(s,Bn(Jb(t,t.VERTEX_SHADER,e))),t.attachShader(s,Bn(Jb(t,t.FRAGMENT_SHADER,n))),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS))return s;console.error(t.getProgramInfoLog(s)),t.deleteProgram(s)}function Jb(t,e,n){let s=Bn(t.createShader(e));if(t.shaderSource(s,n),t.compileShader(s),t.getShaderParameter(s,t.COMPILE_STATUS))return s;console.error(t.getShaderInfoLog(s)),t.deleteShader(s)}function Zj(t,e){let n=Math.min(t.length*2,e),s=new Float32Array(n);for(let i=0;i<t.length;i++)s[i]=t[i];return s}var eM=class{constructor(t){this.texture=t,this.version=-1}},tM=`#version 300 es
|
|
95
|
-
layout (location = 0) in vec2 a_unitquad;
|
|
96
|
-
layout (location = 1) in vec2 a_cellpos;
|
|
97
|
-
layout (location = 2) in vec2 a_offset;
|
|
98
|
-
layout (location = 3) in vec2 a_size;
|
|
99
|
-
layout (location = 4) in float a_texpage;
|
|
100
|
-
layout (location = 5) in vec2 a_texcoord;
|
|
101
|
-
layout (location = 6) in vec2 a_texsize;
|
|
102
|
-
|
|
103
|
-
uniform mat4 u_projection;
|
|
104
|
-
uniform vec2 u_resolution;
|
|
105
|
-
|
|
106
|
-
out vec2 v_texcoord;
|
|
107
|
-
flat out int v_texpage;
|
|
108
|
-
|
|
109
|
-
void main() {
|
|
110
|
-
vec2 zeroToOne = (a_offset / u_resolution) + a_cellpos + (a_unitquad * a_size);
|
|
111
|
-
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
112
|
-
v_texpage = int(a_texpage);
|
|
113
|
-
v_texcoord = a_texcoord + a_unitquad * a_texsize;
|
|
114
|
-
}`;function nM(t){let e="";for(let n=1;n<t;n++)e+=` else if (v_texpage == ${n}) { outColor = texture(u_texture[${n}], v_texcoord); }`;return`#version 300 es
|
|
115
|
-
precision lowp float;
|
|
116
|
-
|
|
117
|
-
in vec2 v_texcoord;
|
|
118
|
-
flat in int v_texpage;
|
|
119
|
-
|
|
120
|
-
uniform sampler2D u_texture[${t}];
|
|
121
|
-
|
|
122
|
-
out vec4 outColor;
|
|
123
|
-
|
|
124
|
-
void main() {
|
|
125
|
-
if (v_texpage == 0) {
|
|
126
|
-
outColor = texture(u_texture[0], v_texcoord);
|
|
127
|
-
} ${e}
|
|
128
|
-
}`}var to=11,Ra=to*Float32Array.BYTES_PER_ELEMENT,sM=2,Rn=0,hn,hp=0,Kl=0,iM=class extends Di{constructor(t,e,n,s){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._optionsService=s,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let i=this._gl;eo.maxAtlasPages===void 0&&(eo.maxAtlasPages=Math.min(32,Bn(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS))),eo.maxTextureSize=Bn(i.getParameter(i.MAX_TEXTURE_SIZE))),this._program=Bn(lk(i,tM,nM(eo.maxAtlasPages))),this._register(Es(()=>i.deleteProgram(this._program))),this._projectionLocation=Bn(i.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Bn(i.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Bn(i.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),c=i.createBuffer();this._register(Es(()=>i.deleteBuffer(c))),i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let u=new Uint8Array([0,1,2,3]),h=i.createBuffer();this._register(Es(()=>i.deleteBuffer(h))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,h),i.bufferData(i.ELEMENT_ARRAY_BUFFER,u,i.STATIC_DRAW),this._attributesBuffer=Bn(i.createBuffer()),this._register(Es(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,Ra,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,Ra,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,Ra,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,Ra,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,Ra,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Ra,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let f=new Int32Array(eo.maxAtlasPages);for(let g=0;g<eo.maxAtlasPages;g++)f[g]=g;i.uniform1iv(this._textureLocation,f),i.uniformMatrix4fv(this._projectionLocation,!1,ak),this._atlasTextures=[];for(let g=0;g<eo.maxAtlasPages;g++){let v=new eM(Bn(i.createTexture()));this._register(Es(()=>i.deleteTexture(v.texture))),i.activeTexture(i.TEXTURE0+g),i.bindTexture(i.TEXTURE_2D,v.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[g]=v}i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(t,e,n,s,i,a,c,u,h){this._updateCell(this._vertices.attributes,t,e,n,s,i,a,c,u,h)}_updateCell(t,e,n,s,i,a,c,u,h,f){if(Rn=(n*this._terminal.cols+e)*to,s===0||s===void 0){t.fill(0,Rn,Rn+to-1-sM);return}this._atlas&&(u&&u.length>1?hn=this._atlas.getRasterizedGlyphCombinedChar(u,i,a,c,!1,this._terminal.element):hn=this._atlas.getRasterizedGlyph(s,i,a,c,!1,this._terminal.element),hp=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==f&&hn.offset.x>hp?(Kl=hn.offset.x-hp,t[Rn]=-(hn.offset.x-Kl)+this._dimensions.device.char.left,t[Rn+1]=-hn.offset.y+this._dimensions.device.char.top,t[Rn+2]=(hn.size.x-Kl)/this._dimensions.device.canvas.width,t[Rn+3]=hn.size.y/this._dimensions.device.canvas.height,t[Rn+4]=hn.texturePage,t[Rn+5]=hn.texturePositionClipSpace.x+Kl/this._atlas.pages[hn.texturePage].canvas.width,t[Rn+6]=hn.texturePositionClipSpace.y,t[Rn+7]=hn.sizeClipSpace.x-Kl/this._atlas.pages[hn.texturePage].canvas.width,t[Rn+8]=hn.sizeClipSpace.y):(t[Rn]=-hn.offset.x+this._dimensions.device.char.left,t[Rn+1]=-hn.offset.y+this._dimensions.device.char.top,t[Rn+2]=hn.size.x/this._dimensions.device.canvas.width,t[Rn+3]=hn.size.y/this._dimensions.device.canvas.height,t[Rn+4]=hn.texturePage,t[Rn+5]=hn.texturePositionClipSpace.x,t[Rn+6]=hn.texturePositionClipSpace.y,t[Rn+7]=hn.sizeClipSpace.x,t[Rn+8]=hn.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&wj(s,h,hn.size.x,this._dimensions.device.cell.width)&&(t[Rn+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,e=t.cols*t.rows*to;this._vertices.count!==e?this._vertices.attributes=new Float32Array(e):this._vertices.attributes.fill(0);let n=0;for(;n<this._vertices.attributesBuffers.length;n++)this._vertices.count!==e?this._vertices.attributesBuffers[n]=new Float32Array(e):this._vertices.attributesBuffers[n].fill(0);this._vertices.count=e,n=0;for(let s=0;s<t.rows;s++)for(let i=0;i<t.cols;i++)this._vertices.attributes[n+9]=i/t.cols,this._vertices.attributes[n+10]=s/t.rows,n+=to}handleResize(){let t=this._gl;t.useProgram(this._program),t.viewport(0,0,t.canvas.width,t.canvas.height),t.uniform2f(this._resolutionLocation,t.canvas.width,t.canvas.height),this.clear()}render(t){if(!this._atlas)return;let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let n=this._vertices.attributesBuffers[this._activeBuffer],s=0;for(let i=0;i<t.lineLengths.length;i++){let a=i*this._terminal.cols*to,c=this._vertices.attributes.subarray(a,a+t.lineLengths[i]*to);n.set(c,s),s+=c.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,n.subarray(0,s),e.STREAM_DRAW);for(let i=0;i<this._atlas.pages.length;i++)this._atlas.pages[i].version!==this._atlasTextures[i].version&&this._bindAtlasPageTexture(e,this._atlas,i);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,s/to)}setAtlas(t){this._atlas=t;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(t,e,n){t.activeTexture(t.TEXTURE0+n),t.bindTexture(t.TEXTURE_2D,this._atlasTextures[n].texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e.pages[n].canvas),t.generateMipmap(t.TEXTURE_2D),this._atlasTextures[n].version=e.pages[n].version}setDimensions(t){this._dimensions=t}},rM=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(t,e,n,s=!1){if(this.selectionStart=e,this.selectionEnd=n,!e||!n||e[0]===n[0]&&e[1]===n[1]){this.clear();return}let i=t.buffers.active.ydisp,a=e[1]-i,c=n[1]-i,u=Math.max(a,0),h=Math.min(c,t.rows-1);if(u>=t.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=a,this.viewportEndRow=c,this.viewportCappedStartRow=u,this.viewportCappedEndRow=h,this.startCol=e[0],this.endCol=n[0]}isCellSelected(t,e,n){return this.hasSelection?(n-=t.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&n>=this.viewportCappedStartRow&&e<this.endCol&&n<=this.viewportCappedEndRow:e<this.startCol&&n>=this.viewportCappedStartRow&&e>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&e>=this.startCol):!1}};function oM(){return new rM}var Pd=4,gd=1,vd=2,fp=3,aM=2147483648,lM=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=oM()}resize(t,e){let n=t*e*Pd;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(e))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},cM=`#version 300 es
|
|
129
|
-
layout (location = 0) in vec2 a_position;
|
|
130
|
-
layout (location = 1) in vec2 a_size;
|
|
131
|
-
layout (location = 2) in vec4 a_color;
|
|
132
|
-
layout (location = 3) in vec2 a_unitquad;
|
|
133
|
-
|
|
134
|
-
uniform mat4 u_projection;
|
|
135
|
-
|
|
136
|
-
out vec4 v_color;
|
|
137
|
-
|
|
138
|
-
void main() {
|
|
139
|
-
vec2 zeroToOne = a_position + (a_unitquad * a_size);
|
|
140
|
-
gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
|
|
141
|
-
v_color = a_color;
|
|
142
|
-
}`,uM=`#version 300 es
|
|
143
|
-
precision lowp float;
|
|
144
|
-
|
|
145
|
-
in vec4 v_color;
|
|
146
|
-
|
|
147
|
-
out vec4 outColor;
|
|
148
|
-
|
|
149
|
-
void main() {
|
|
150
|
-
outColor = v_color;
|
|
151
|
-
}`,yr=8,pp=yr*Float32Array.BYTES_PER_ELEMENT,dM=20*yr,Qb=class{constructor(){this.attributes=new Float32Array(dM),this.count=0}},_r=0,Zb=0,e0=0,t0=0,n0=0,s0=0,i0=0,hM=class extends Di{constructor(t,e,n,s){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._themeService=s,this._vertices=new Qb,this._verticesCursor=new Qb;let i=this._gl;this._program=Bn(lk(i,cM,uM)),this._register(Es(()=>i.deleteProgram(this._program))),this._projectionLocation=Bn(i.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),c=i.createBuffer();this._register(Es(()=>i.deleteBuffer(c))),i.bindBuffer(i.ARRAY_BUFFER,c),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let u=new Uint8Array([0,1,2,3]),h=i.createBuffer();this._register(Es(()=>i.deleteBuffer(h))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,h),i.bufferData(i.ELEMENT_ARRAY_BUFFER,u,i.STATIC_DRAW),this._attributesBuffer=Bn(i.createBuffer()),this._register(Es(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,pp,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,pp,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,pp,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(s.colors),this._register(this._themeService.onChangeColors(f=>{this._updateCachedColors(f),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(t){let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),e.uniformMatrix4fv(this._projectionLocation,!1,ak),e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,t.attributes,e.DYNAMIC_DRAW),e.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,t.count)}handleResize(){this._updateViewportRectangle()}setDimensions(t){this._dimensions=t}_updateCachedColors(t){this._bgFloat=this._colorToFloat32Array(t.background),this._cursorFloat=this._colorToFloat32Array(t.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(t){let e=this._terminal,n=this._vertices,s=1,i,a,c,u,h,f,g,v,_,b,x;for(i=0;i<e.rows;i++){for(c=-1,u=0,h=0,f=!1,a=0;a<e.cols;a++)g=(i*e.cols+a)*Pd,v=t.cells[g+gd],_=t.cells[g+vd],b=!!(_&67108864),(v!==u||_!==h&&(f||b))&&((u!==0||f&&h!==0)&&(x=s++*yr,this._updateRectangle(n,x,h,u,c,a,i)),c=a,u=v,h=_,f=b);(u!==0||f&&h!==0)&&(x=s++*yr,this._updateRectangle(n,x,h,u,c,e.cols,i))}n.count=s}updateCursor(t){let e=this._verticesCursor,n=t.cursor;if(!n||n.style==="block"){e.count=0;return}let s,i=0;(n.style==="bar"||n.style==="outline")&&(s=i++*yr,this._addRectangleFloat(e.attributes,s,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style==="bar"?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style==="underline"||n.style==="outline")&&(s=i++*yr,this._addRectangleFloat(e.attributes,s,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style==="outline"&&(s=i++*yr,this._addRectangleFloat(e.attributes,s,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),s=i++*yr,this._addRectangleFloat(e.attributes,s,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),e.count=i}_updateRectangle(t,e,n,s,i,a,c){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:_r=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:_r=(n&16777215)<<8;break;case 0:default:_r=this._themeService.colors.foreground.rgba}else switch(s&50331648){case 16777216:case 33554432:_r=this._themeService.colors.ansi[s&255].rgba;break;case 50331648:_r=(s&16777215)<<8;break;case 0:default:_r=this._themeService.colors.background.rgba}t.attributes.length<e+4&&(t.attributes=Zj(t.attributes,this._terminal.rows*this._terminal.cols*yr)),Zb=i*this._dimensions.device.cell.width,e0=c*this._dimensions.device.cell.height,t0=(_r>>24&255)/255,n0=(_r>>16&255)/255,s0=(_r>>8&255)/255,i0=1,this._addRectangle(t.attributes,e,Zb,e0,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,t0,n0,s0,i0)}_addRectangle(t,e,n,s,i,a,c,u,h,f){t[e]=n/this._dimensions.device.canvas.width,t[e+1]=s/this._dimensions.device.canvas.height,t[e+2]=i/this._dimensions.device.canvas.width,t[e+3]=a/this._dimensions.device.canvas.height,t[e+4]=c,t[e+5]=u,t[e+6]=h,t[e+7]=f}_addRectangleFloat(t,e,n,s,i,a,c){t[e]=n/this._dimensions.device.canvas.width,t[e+1]=s/this._dimensions.device.canvas.height,t[e+2]=i/this._dimensions.device.canvas.width,t[e+3]=a/this._dimensions.device.canvas.height,t[e+4]=c[0],t[e+5]=c[1],t[e+6]=c[2],t[e+7]=c[3]}_colorToFloat32Array(t){return new Float32Array([(t.rgba>>24&255)/255,(t.rgba>>16&255)/255,(t.rgba>>8&255)/255,(t.rgba&255)/255])}},fM=class extends Di{constructor(t,e,n,s,i,a,c,u){super(),this._container=e,this._alpha=i,this._coreBrowserService=a,this._optionsService=c,this._themeService=u,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=s.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(h=>{this._refreshCharAtlas(t,h),this.reset(t)})),this._register(Es(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Bn(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(t){}handleFocus(t){}handleCursorMove(t){}handleGridChanged(t,e,n){}handleSelectionChanged(t,e,n,s=!1){}_setTransparency(t,e){if(e===this._alpha)return;let n=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(t,this._themeService.colors),this.handleGridChanged(t,0,t.rows-1)}_refreshCharAtlas(t,e){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=rk(t,this._optionsService.rawOptions,e,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(t,e){this._deviceCellWidth=e.device.cell.width,this._deviceCellHeight=e.device.cell.height,this._deviceCharWidth=e.device.char.width,this._deviceCharHeight=e.device.char.height,this._deviceCharLeft=e.device.char.left,this._deviceCharTop=e.device.char.top,this._canvas.width=e.device.canvas.width,this._canvas.height=e.device.canvas.height,this._canvas.style.width=`${e.css.canvas.width}px`,this._canvas.style.height=`${e.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(t,this._themeService.colors)}_fillBottomLineAtCells(t,e,n=1){this._ctx.fillRect(t*this._deviceCellWidth,(e+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(t,e,n,s){this._alpha?this._ctx.clearRect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,s*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,s*this._deviceCellHeight))}_fillCharTrueColor(t,e,n,s){this._ctx.font=this._getFont(t,!1,!1),this._ctx.textBaseline=Vx,this._clipCell(n,s,e.getWidth()),this._ctx.fillText(e.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,s*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(t,e,n){this._ctx.beginPath(),this._ctx.rect(t*this._deviceCellWidth,e*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(t,e,n){let s=e?t.options.fontWeightBold:t.options.fontWeight;return`${n?"italic":""} ${s} ${t.options.fontSize*this._coreBrowserService.dpr}px ${t.options.fontFamily}`}},pM=class extends fM{constructor(t,e,n,s,i,a,c){super(n,t,"link",e,!0,i,a,c),this._register(s.onShowLinkUnderline(u=>this._handleShowLinkUnderline(u))),this._register(s.onHideLinkUnderline(u=>this._handleHideLinkUnderline(u)))}resize(t,e){super.resize(t,e),this._state=void 0}reset(t){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let t=this._state.y2-this._state.y1-1;t>0&&this._clearCells(0,this._state.y1+1,this._state.cols,t),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(t){if(t.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:t.fg!==void 0&&Xj(t.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[t.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,t.y1===t.y2)this._fillBottomLineAtCells(t.x1,t.y1,t.x2-t.x1);else{this._fillBottomLineAtCells(t.x1,t.y1,t.cols-t.x1);for(let e=t.y1+1;e<t.y2;e++)this._fillBottomLineAtCells(0,e,t.cols);this._fillBottomLineAtCells(0,t.y2,t.x2)}this._state=t}_handleHideLinkUnderline(t){this._clearCurrentLink()}},Ho=typeof window=="object"?window:globalThis,ig=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new pn,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new pn,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,n){if(this.getZoomLevel(n)===e)return;let s=this.getWindowId(n);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,n){this.mapWindowIdToZoomFactor.set(this.getWindowId(n),e)}setFullscreen(e,n){if(this.isFullscreen(n)===e)return;let s=this.getWindowId(n);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};ig.INSTANCE=new ig;var ck=ig;function mM(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}ck.INSTANCE.onDidChangeZoomLevel;ck.INSTANCE.onDidChangeFullscreen;var tl=typeof navigator=="object"?navigator.userAgent:"";tl.indexOf("Firefox")>=0;tl.indexOf("AppleWebKit")>=0;var gM=tl.indexOf("Chrome")>=0;!gM&&tl.indexOf("Safari")>=0;tl.indexOf("Electron/")>=0;tl.indexOf("Android")>=0;var mp=!1;if(typeof Ho.matchMedia=="function"){let t=Ho.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Ho.matchMedia("(display-mode: fullscreen)");mp=t.matches,mM(Ho,t,({matches:n})=>{mp&&e.matches||(mp=n)})}var $a="en",gp=!1,uk=!1,Zu,_d=$a,r0=$a,vM,Pi,Ko=globalThis,gs,_1;typeof Ko.vscode<"u"&&typeof Ko.vscode.process<"u"?gs=Ko.vscode.process:typeof process<"u"&&typeof((_1=process==null?void 0:process.versions)==null?void 0:_1.node)=="string"&&(gs=process);var y1,_M=typeof((y1=gs==null?void 0:gs.versions)==null?void 0:y1.electron)=="string",yM=_M&&(gs==null?void 0:gs.type)==="renderer",w1;if(typeof gs=="object"){gs.platform,gs.platform,gp=gs.platform==="linux",gp&&gs.env.SNAP&&gs.env.SNAP_REVISION,gs.env.CI||gs.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Zu=$a,_d=$a;let t=gs.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Zu=e.userLocale,r0=e.osLocale,_d=e.resolvedLanguage||$a,vM=(w1=e.languagePack)==null?void 0:w1.translationsConfigFile}catch{}uk=!0}else typeof navigator=="object"&&!yM?(Pi=navigator.userAgent,Pi.indexOf("Windows")>=0,Pi.indexOf("Macintosh")>=0,(Pi.indexOf("Macintosh")>=0||Pi.indexOf("iPad")>=0||Pi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,gp=Pi.indexOf("Linux")>=0,(Pi==null?void 0:Pi.indexOf("Mobi"))>=0,_d=globalThis._VSCODE_NLS_LANGUAGE||$a,Zu=navigator.language.toLowerCase(),r0=Zu):console.error("Unable to resolve platform.");var o0=uk,sr=Pi,Jr=_d,wM;(t=>{function e(){return Jr}t.value=e;function n(){return Jr.length===2?Jr==="en":Jr.length>=3?Jr[0]==="e"&&Jr[1]==="n"&&Jr[2]==="-":!1}t.isDefaultVariant=n;function s(){return Jr==="en"}t.isDefault=s})(wM||(wM={}));var bM=typeof Ko.postMessage=="function"&&!Ko.importScripts;(()=>{if(bM){let t=[];Ko.addEventListener("message",n=>{if(n.data&&n.data.vscodeScheduleAsyncWork)for(let s=0,i=t.length;s<i;s++){let a=t[s];if(a.id===n.data.vscodeScheduleAsyncWork){t.splice(s,1),a.callback();return}}});let e=0;return n=>{let s=++e;t.push({id:s,callback:n}),Ko.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var SM=!!(sr&&sr.indexOf("Chrome")>=0);sr&&sr.indexOf("Firefox")>=0;!SM&&sr&&sr.indexOf("Safari")>=0;sr&&sr.indexOf("Edg/")>=0;sr&&sr.indexOf("Android")>=0;var La=typeof navigator=="object"?navigator:{};o0||document.queryCommandSupported&&document.queryCommandSupported("copy")||La&&La.clipboard&&La.clipboard.writeText,o0||La&&La.clipboard&&La.clipboard.readText;var mv=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(t,e){this._keyCodeToStr[t]=e,this._strToKeyCode[e.toLowerCase()]=t}keyCodeToStr(t){return this._keyCodeToStr[t]}strToKeyCode(t){return this._strToKeyCode[t.toLowerCase()]||0}},vp=new mv,a0=new mv,l0=new mv;new Array(230);var xM;(t=>{function e(u){return vp.keyCodeToStr(u)}t.toString=e;function n(u){return vp.strToKeyCode(u)}t.fromString=n;function s(u){return a0.keyCodeToStr(u)}t.toUserSettingsUS=s;function i(u){return l0.keyCodeToStr(u)}t.toUserSettingsGeneral=i;function a(u){return a0.strToKeyCode(u)||l0.strToKeyCode(u)}t.fromUserSettings=a;function c(u){if(u>=98&&u<=113)return null;switch(u){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return vp.keyCodeToStr(u)}t.toElectronAccelerator=c})(xM||(xM={}));var dk=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),kM;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof CM?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:xr.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:dk})})(kM||(kM={}));var CM=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?dk:(this._emitter||(this._emitter=new pn),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},EM;(t=>{async function e(s){let i,a=await Promise.all(s.map(c=>c.then(u=>u,u=>{i||(i=u)})));if(typeof i<"u")throw i;return a}t.settled=e;function n(s){return new Promise(async(i,a)=>{try{await s(i,a)}catch(c){a(c)}})}t.withAsyncBody=n})(EM||(EM={}));var c0=class mi{static fromArray(e){return new mi(n=>{n.emitMany(e)})}static fromPromise(e){return new mi(async n=>{n.emitMany(await e)})}static fromPromises(e){return new mi(async n=>{await Promise.all(e.map(async s=>n.emitOne(await s)))})}static merge(e){return new mi(async n=>{await Promise.all(e.map(async s=>{for await(let i of s)n.emitOne(i)}))})}constructor(e,n){this._state=0,this._results=[],this._error=null,this._onReturn=n,this._onStateChanged=new pn,queueMicrotask(async()=>{let s={emitOne:i=>this.emitOne(i),emitMany:i=>this.emitMany(i),reject:i=>this.reject(i)};try{await Promise.resolve(e(s)),this.resolve()}catch(i){this.reject(i)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await xr.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(e,n){return new mi(async s=>{for await(let i of e)s.emitOne(n(i))})}map(e){return mi.map(this,e)}static filter(e,n){return new mi(async s=>{for await(let i of e)n(i)&&s.emitOne(i)})}filter(e){return mi.filter(this,e)}static coalesce(e){return mi.filter(e,n=>!!n)}coalesce(){return mi.coalesce(this)}static async toPromise(e){let n=[];for await(let s of e)n.push(s);return n}toPromise(){return mi.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};c0.EMPTY=c0.fromArray([]);var{getWindow:NM}=(function(){let t=new Map,e={window:Ho,disposables:new Fa};t.set(Ho.vscodeWindowId,e);let n=new pn,s=new pn,i=new pn;function a(c,u){return(typeof c=="number"?t.get(c):void 0)??(u?e:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:s.event,registerWindow(c){if(t.has(c.vscodeWindowId))return Di.None;let u=new Fa,h={window:c,disposables:u.add(new Fa)};return t.set(c.vscodeWindowId,h),u.add(Es(()=>{t.delete(c.vscodeWindowId),s.fire(c)})),u.add(rg(c,LM.BEFORE_UNLOAD,()=>{i.fire(c)})),n.fire(h),u},getWindows(){return t.values()},getWindowsCount(){return t.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return t.has(c)},getWindowById:a,getWindow(c){var f;let u=c;if((f=u==null?void 0:u.ownerDocument)!=null&&f.defaultView)return u.ownerDocument.defaultView.window;let h=c;return h!=null&&h.view?h.view.window:Ho},getDocument(c){return NM(c).document}}})(),RM=class{constructor(t,e,n,s){this._node=t,this._type=e,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 rg(t,e,n,s){return new RM(t,e,n,s)}var LM={BEFORE_UNLOAD:"beforeunload"},AM=class extends Di{constructor(t,e,n,s,i,a,c,u,h){super(),this._terminal=t,this._characterJoinerService=e,this._charSizeService=n,this._coreBrowserService=s,this._coreService=i,this._decorationService=a,this._optionsService=c,this._themeService=u,this._cursorBlinkStateManager=new Ul,this._charAtlasDisposable=this._register(new Ul),this._observerDisposable=this._register(new Ul),this._model=new lM,this._workCell=new Xb,this._workCell2=new Xb,this._rectangleRenderer=this._register(new Ul),this._glyphRenderer=this._register(new Ul),this._onChangeTextureAtlas=this._register(new pn),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new pn),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new pn),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new pn),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new pn),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let f={antialias:!1,depth:!1,preserveDrawingBuffer:h};if(this._gl=this._canvas.getContext("webgl2",f),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new xj(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new pM(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,c,this._themeService)],this.dimensions=bj(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(c.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(rg(this._canvas,"webglcontextlost",g=>{console.log("webglcontextlost event received"),g.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(g)},3e3)})),this._register(rg(this._canvas,"webglcontextrestored",g=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Yb(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=Gb(this._canvas,this._coreBrowserService.window,(g,v)=>this._setCanvasDevicePixelDimensions(g,v)),this._register(this._coreBrowserService.onWindowChange(g=>{this._observerDisposable.value=Gb(this._canvas,g,(v,_)=>this._setCanvasDevicePixelDimensions(v,_))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(Es(()=>{var g;for(let v of this._renderLayers)v.dispose();(g=this._canvas.parentElement)==null||g.removeChild(this._canvas),Yb(this._terminal)}))}get textureAtlas(){var t;return(t=this._charAtlas)==null?void 0:t.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(t,e){var n,s,i,a;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let c of this._renderLayers)c.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,(n=this._rectangleRenderer.value)==null||n.setDimensions(this.dimensions),(s=this._rectangleRenderer.value)==null||s.handleResize(),(i=this._glyphRenderer.value)==null||i.setDimensions(this.dimensions),(a=this._glyphRenderer.value)==null||a.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var t;for(let e of this._renderLayers)e.handleBlur(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.pause(),this._requestRedrawViewport()}handleFocus(){var t;for(let e of this._renderLayers)e.handleFocus(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.resume(),this._requestRedrawViewport()}handleSelectionChanged(t,e,n){for(let s of this._renderLayers)s.handleSelectionChanged(this._terminal,t,e,n);this._model.selection.update(this._core,t,e,n),this._requestRedrawViewport()}handleCursorMove(){var t;for(let e of this._renderLayers)e.handleCursorMove(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new hM(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new iM(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let t=rk(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==t&&(this._onChangeTextureAtlas.fire(t.pages[0].canvas),this._charAtlasDisposable.value=Hx(xr.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),xr.forward(t.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=t,this._charAtlas.warmUp(),(e=this._glyphRenderer.value)==null||e.setAtlas(this._charAtlas)}_clearModel(t){var e;this._model.clear(),t&&((e=this._glyphRenderer.value)==null||e.clear())}clearTextureAtlas(){var t;(t=this._charAtlas)==null||t.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var t;this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);(t=this._cursorBlinkStateManager.value)==null||t.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(t,e){var n;if(!this._isAttached)if((n=this._core.screenElement)!=null&&n.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let s of this._renderLayers)s.handleGridChanged(this._terminal,t,e);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(t,e),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new Jj(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(t,e){let n=this._core,s=this._workCell,i,a,c,u,h,f,g=0,v=!0,_,b,x,L,k,R,S,j,E;t=u0(t,n.rows-1,0),e=u0(e,n.rows-1,0);let F=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??"block",$=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,G=$-n.buffer.ydisp,K=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),Y=-1,te=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let q=!1;for(a=t;a<=e;a++)for(c=a+n.buffer.ydisp,u=n.buffer.lines.get(c),this._model.lineLengths[a]=0,x=$===c,g=0,h=this._characterJoinerService.getJoinedCharacters(c),j=0;j<n.cols;j++){if(i=this._cellColorResolver.result.bg,u.loadCell(j,s),j===0&&(i=this._cellColorResolver.result.bg),f=!1,v=j>=g,_=j,h.length>0&&j===h[0][0]&&v){b=h.shift();let D=this._model.selection.isCellSelected(this._terminal,b[0],c);for(S=b[0]+1;S<b[1];S++)v&&(v=D===this._model.selection.isCellSelected(this._terminal,S,c));v&&(v=!x||K<b[0]||K>=b[1]),v?(f=!0,s=new jM(s,u.translateToString(!0,b[0],b[1]),b[1]-b[0]),_=b[1]-1):g=b[1]}if(L=s.getChars(),k=s.getCode(),S=(a*n.cols+j)*Pd,this._cellColorResolver.resolve(s,j,c,this.dimensions.device.cell.width),te&&c===$&&(j===K&&(this._model.cursor={x:K,y:G,width:s.getWidth(),style:this._coreBrowserService.isFocused?F:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},Y=K+s.getWidth()-1),j>=K&&j<=Y&&(this._coreBrowserService.isFocused&&F==="block"||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),k!==0&&(this._model.lineLengths[a]=j+1),!(this._model.cells[S]===k&&this._model.cells[S+gd]===this._cellColorResolver.result.bg&&this._model.cells[S+vd]===this._cellColorResolver.result.fg&&this._model.cells[S+fp]===this._cellColorResolver.result.ext)&&(q=!0,L.length>1&&(k|=aM),this._model.cells[S]=k,this._model.cells[S+gd]=this._cellColorResolver.result.bg,this._model.cells[S+vd]=this._cellColorResolver.result.fg,this._model.cells[S+fp]=this._cellColorResolver.result.ext,R=s.getWidth(),this._glyphRenderer.value.updateCell(j,a,k,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,L,R,i),f)){for(s=this._workCell,j++;j<=_;j++)E=(a*n.cols+j)*Pd,this._glyphRenderer.value.updateCell(j,a,0,0,0,0,pj,0,0),this._model.cells[E]=0,this._model.cells[E+gd]=this._cellColorResolver.result.bg,this._model.cells[E+vd]=this._cellColorResolver.result.fg,this._model.cells[E+fp]=this._cellColorResolver.result.ext;j--}}q&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(t,e){this._canvas.width===t&&this._canvas.height===e||(this._canvas.width=t,this._canvas.height=e,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let t=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:t,end:t})}},jM=class extends Ba{constructor(t,e,n){super(),this.content=0,this.combinedData="",this.fg=t.fg,this.bg=t.bg,this.combinedData=e,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(t){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function u0(t,e,n=0){return Math.max(Math.min(t,e),n)}var d0="di$target",h0="di$dependencies",_p=new Map;function ir(t){if(_p.has(t))return _p.get(t);let e=function(n,s,i){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");MM(e,n,i)};return e._id=t,_p.set(t,e),e}function MM(t,e,n){e[d0]===e?e[h0].push({id:t,index:n}):(e[h0]=[{id:t,index:n}],e[d0]=e)}ir("BufferService");ir("CoreMouseService");ir("CoreService");ir("CharsetService");ir("InstantiationService");ir("LogService");var TM=ir("OptionsService");ir("OscLinkService");ir("UnicodeService");ir("DecorationService");var PM={trace:0,debug:1,info:2,warn:3,error:4,off:5},IM="xterm.js: ",f0=class extends Di{constructor(t){super(),this._optionsService=t,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=PM[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(t){for(let e=0;e<t.length;e++)typeof t[e]=="function"&&(t[e]=t[e]())}_log(t,e,n){this._evalLazyOptionalParams(n),t.call(console,(this._optionsService.options.logger?"":IM)+e,...n)}trace(t,...e){var n;this._logLevel<=0&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.trace.bind(this._optionsService.options.logger))??console.log,t,e)}debug(t,...e){var n;this._logLevel<=1&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.debug.bind(this._optionsService.options.logger))??console.log,t,e)}info(t,...e){var n;this._logLevel<=2&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.info.bind(this._optionsService.options.logger))??console.info,t,e)}warn(t,...e){var n;this._logLevel<=3&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.warn.bind(this._optionsService.options.logger))??console.warn,t,e)}error(t,...e){var n;this._logLevel<=4&&this._log(((n=this._optionsService.options.logger)==null?void 0:n.error.bind(this._optionsService.options.logger))??console.error,t,e)}};f0=nj([sj(0,TM)],f0);var DM=class extends Di{constructor(t){if(qx&&fj()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=t,this._onChangeTextureAtlas=this._register(new pn),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new pn),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new pn),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new pn),this.onContextLoss=this._onContextLoss.event}activate(t){let e=t._core;if(!t.element){this._register(e.onWillOpen(()=>this.activate(t)));return}this._terminal=t;let n=e.coreService,s=e.optionsService,i=e,a=i._renderService,c=i._characterJoinerService,u=i._charSizeService,h=i._coreBrowserService,f=i._decorationService;i._logService;let g=i._themeService;this._renderer=this._register(new AM(t,c,u,h,n,f,s,g,this._preserveDrawingBuffer)),this._register(xr.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(xr.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(xr.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(xr.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(Es(()=>{if(this._terminal._core._store._isDisposed)return;let v=this._terminal._core._renderService;v.setRenderer(this._terminal._core._createRenderer()),v.handleResize(t.cols,t.rows)}))}get textureAtlas(){var t;return(t=this._renderer)==null?void 0:t.textureAtlas}clearTextureAtlas(){var t;(t=this._renderer)==null||t.clearTextureAtlas()}};const hk="nc-terminal-renderer",po="webgl",mo="dom";function fk(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function kc(t){const e=fk(t);try{return e&&e.getItem(hk)===mo?mo:po}catch{return po}}function pk(t,e){const n=t===mo?mo:po,s=fk(e);try{s&&s.setItem(hk,n)}catch{}return n}function OM(t){return t===mo?po:mo}function BM(t,{preference:e,createAddon:n,onFallback:s}={}){const i=e||kc(),a={kind:mo,dispose:()=>{}};if(i!==po||!t||typeof t.loadAddon!="function"||typeof n!="function")return a;let c;try{if(c=n(),!c)return a;t.loadAddon(c)}catch{try{c&&c.dispose()}catch{}return s&&s("unavailable"),a}let u=!1;const h=()=>{if(!u){u=!0;try{c.dispose()}catch{}}};return typeof c.onContextLoss=="function"&&c.onContextLoss(()=>{h(),s&&s("context-loss")}),{kind:po,dispose:h}}const $M=Object.freeze({retryBaseMs:250,retryMaxMs:5e3,pingMs:5e3,deadMs:1e4,queuedInputBytes:4096,overlayDelayMs:1e3}),zM=(t,e)=>{const n=Number(t);return Number.isFinite(n)&&n>0?n:e};function mk(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},n={};for(const[s,i]of Object.entries($M))n[s]=zM(e[s],i);return n}let og=mk(null);function FM(t){return og=mk(t),{...og}}function gk(){return{...og}}function HM(t,e,n=null,s=null){if(!t)return"/ws";let a=`/api/route/${String(t).split("/").map(encodeURIComponent).join("/")}/_/ws?token=${encodeURIComponent(e||"")}`;return n&&(a+=`&attachId=${encodeURIComponent(n)}`,s&&(a+=`&attachSession=${encodeURIComponent(s)}`)),a}function UM(t,e,n=null){const s=n===null?typeof sessionStorage<"u"?sessionStorage:null:n;if(!s)return null;const i=`nc-attach:${e||"local"}:${String(t||"")}`;try{const a=s.getItem(i);if(typeof a=="string"&&/^[0-9a-f]{32}$/.test(a))return a;const c=new Uint8Array(16),u=globalThis.crypto;if(!u||typeof u.getRandomValues!="function")return null;u.getRandomValues(c);const h=Array.from(c).map(f=>f.toString(16).padStart(2,"0")).join("");return s.setItem(i,h),h}catch{return null}}function WM({session:t,node:e,token:n,cols:s,rows:i,readonly:a=!1,takeSize:c,focused:u,onData:h,onExit:f,onFiles:g,onSnapshot:v,onLink:_,retryBaseMs:b,retryMaxMs:x,retryStableMs:L=5e3,onRetryScheduled:k,pingMs:R,deadMs:S,queuedInputBytes:j,onQueued:E}){const F=gk(),$=b===void 0?F.retryBaseMs:b,G=x===void 0?F.retryMaxMs:x,K=R===void 0?F.pingMs:R,Y=S===void 0?F.deadMs:S,te=j===void 0?F.queuedInputBytes:j,q=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!q)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const D=location.protocol==="https:"?"wss":"ws",I=UM(t,e),O=`${D}://${location.host}${HM(e,n,I,t)}`;let M=null,z=!1,T=!1,A=null,N=null,U=0,P=null,H=!1,ie=null,J=0,Q=null;const ve=Math.max(1,Number(te)||4096);let de=[],ne=0;const xe=()=>{if(typeof E=="function")try{E(ne)}catch{}},$e=()=>{if(!M||M.readyState!==1||!de.length)return;const me=de;de=[],ne=0;for(const Ce of me)try{M.send(Ce)}catch{}xe()},rt=()=>{ie&&(clearInterval(ie),ie=null)},je=me=>{rt(),J=Date.now();const Ce=Math.max(1,Number(K)||5e3),V=Math.max(1,Number(Y)||1e4);ie=setInterval(()=>{if(M!==me||z||T){rt();return}if(Date.now()-J>V){rt();try{me.close(4e3,"liveness timeout")}catch{}return}if(me.readyState===1)try{me.send(JSON.stringify({type:"ping",t:Date.now()}))}catch{}},Ce),typeof ie.unref=="function"&&ie.unref()};let Ie=u;const oe=()=>{if(z||T||A)return;const me=Math.min(G,Math.max(0,$)*2**Math.min(U++,5));typeof k=="function"&&k(me),A=setTimeout(()=>{A=null,Ne()},me)},Ne=()=>{if(z||T)return;const me=new WebSocket(O);M=me,me.binaryType="arraybuffer",me.onopen=()=>{if(M!==me||z)return;N&&clearTimeout(N);const Ce=Number(L),V=Number.isFinite(Ce)?Math.max(0,Ce):5e3;N=setTimeout(()=>{N=null,M===me&&me.readyState===1&&(U=0)},V),typeof N.unref=="function"&&N.unref();const ge={type:"attach",session:t,token:n,cols:s,rows:i,readonly:a};P&&(ge.reconnectToken=P),c!==void 0&&(ge.takeSize=c),me.send(JSON.stringify(ge)),Ie!==void 0&&me.send(JSON.stringify({type:"focus",on:!!Ie})),H&&me.send(JSON.stringify(Q===null?{type:"resync"}:{type:"resume",seq:Q})),$e(),je(me)},me.onmessage=Ce=>{if(!(M!==me||z))if(J=Date.now(),typeof Ce.data=="string"){let V;try{V=JSON.parse(Ce.data)}catch{return}if(V.type==="attached"&&typeof V.reconnectToken=="string"&&V.reconnectToken&&(P=V.reconnectToken),V.type==="exit"&&(T=!0,f&&f(V.code)),V.type==="files"&&g&&g(V),V.type==="snapshot"&&v&&v(typeof V.data=="string"?V.data:""),V.type==="link"&&_&&_(V.state==="live"?"live":"reconnecting"),V.type==="resync-needed")try{me.send(JSON.stringify({type:"resync"}))}catch{}}else{let V=new Uint8Array(Ce.data);try{Ce.data&&Ce.data.byteLength>=4&&(Q=new DataView(Ce.data).getUint32(0),V=new Uint8Array(Ce.data,4))}catch{}h&&h(V)}},me.onerror=()=>{if(M===me)try{me.close()}catch{}},me.onclose=Ce=>{rt(),!(M!==me||z||T)&&(N&&(clearTimeout(N),N=null),![4401,4403,4404].includes(Ce==null?void 0:Ce.code)&&(H=!0,_&&_("reconnecting"),oe()))}};return Ne(),{sendInput:me=>{const Ce=typeof me=="string"?new TextEncoder().encode(me):me;if(M&&M.readyState===1)try{return M.send(Ce),!0}catch{try{M.close()}catch{}}return ne+Ce.length>ve?!1:(de.push(Ce),ne+=Ce.length,xe(),!0)},isReady:()=>!!M&&M.readyState===1,resize:(me,Ce)=>{s=me,i=Ce,(M==null?void 0:M.readyState)===1&&M.send(JSON.stringify({type:"resize",cols:me,rows:Ce}))},action:me=>{(M==null?void 0:M.readyState)===1&&M.send(JSON.stringify({type:"action",name:me}))},focus:me=>{Ie=me,(M==null?void 0:M.readyState)===1&&M.send(JSON.stringify({type:"focus",on:!!me}))},close:()=>{if(z=!0,rt(),A&&clearTimeout(A),N&&clearTimeout(N),A=null,N=null,M)try{M.close()}catch{}},get raw(){return M}}}const vk=1e3;function qM(t,e,n=vk){if(t==null)return!1;const s=Number(e)-Number(t);return Number.isFinite(s)?s>=Math.max(0,Number(n)||0):!1}function KM(t={},e={}){const n=Number(t.viewportY)||0,s=Number(t.baseY)||0,i=Math.max(0,Number(e.baseY)||0);return n>=s?{atBottom:!0,line:null}:{atBottom:!1,line:Math.min(n,i)}}function VM(t){return t?`\r
|
|
152
|
-
\x1B[2m── riconnesso ──\x1B[0m\r
|
|
153
|
-
`:""}function YM(t,{ctrl:e=!1,alt:n=!1}={}){if(!t||!e&&!n)return t;const s=t.charCodeAt(0);let i=s;return e&&(s>=97&&s<=122?i=s-96:s>=64&&s<=95?i=s-64:s===32&&(i=0)),(n?"\x1B":"")+String.fromCharCode(i)+t.slice(1)}async function ag(t){const e=String(t||"");if(!e)return!1;try{if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,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 GM="\r";function XM(t){const e=String(t||"");let n=e.length;for(;n>0;){const s=e.charCodeAt(n-1);if(s===10||s===13)n-=1;else break}return e.slice(0,n)}function JM({isReady:t,paste:e,send:n}){return s=>{if(!s||!t())return!1;try{return e(s)===!1||!t()?!1:n(GM)!==!1}catch{return!1}}}function QM(t){return!t||typeof t!="object"?!1:!!t.shiftKey}function ZM(t){return!t||typeof t!="object"||String(t.key||"").toLowerCase()!=="c"?!1:!!(t.metaKey||t.ctrlKey&&t.shiftKey)}function eT(t){return/mac|iphone|ipad/i.test(String(t||""))?"⌘C":"Ctrl+Shift+C"}const tT=450,p0=8;function m0(t,e,n,s){return Math.abs(Number(n)-Number(t))>p0||Math.abs(Number(s)-Number(e))>p0}function nT({range:t,cell:e,cols:n}){const s=Number(n),i=Number(t.start.row)*s+Number(t.start.col),a=Number(t.end.row)*s+Number(t.end.col),c=Number(e.row)*s+Number(e.col),u={start:{row:t.start.row,col:t.start.col},end:{row:t.end.row,col:t.end.col},moved:null};if(c<i)u.start={row:Number(e.row),col:Number(e.col)},u.moved="start";else if(c>a)u.end={row:Number(e.row),col:Number(e.col)},u.moved="end";else{if(c===i||c===a)return u;c-i<=a-c?(u.start={row:Number(e.row),col:Number(e.col)},u.moved="start"):(u.end={row:Number(e.row),col:Number(e.col)},u.moved="end")}return u}function sT(t){const e=t!=="mouse";return{handles:e,magnifier:e}}function iT(t,e){if(!t||!t.start||!t.end)return null;const n=Number(e);if(!Number.isFinite(n)||n<=0)return null;const s=Number(t.start.y)*n+Number(t.start.x),i=Number(t.end.y)*n+Number(t.end.x),a=Math.min(s,i),c=Math.max(a,Math.max(s,i)-1);return{start:{row:Math.floor(a/n),col:a%n},end:{row:Math.floor(c/n),col:c%n}}}function g0(t,e,n){const s=Number(t.row)*Number(n)+Number(t.col),i=Number(e.row)*Number(n)+Number(e.col);return s<=i?{start:{row:t.row,col:t.col},end:{row:e.row,col:e.col}}:{start:{row:e.row,col:e.col},end:{row:t.row,col:t.col}}}function rT({moving:t,fixed:e,which:n,cols:s,maxRow:i}){const a=Number(s);let c=Math.max(0,Math.min(Number(i),Number(t.row))),u=Math.max(0,Math.min(a-1,Number(t.col)));const h=c*a+u,f=Number(e.row)*a+Number(e.col);return n==="start"&&h>f&&(c=Number(e.row),u=Number(e.col)),n==="end"&&h<f&&(c=Number(e.row),u=Number(e.col)),{row:c,col:u}}function Aa({line:t,col:e,side:n,cols:s}){const i=Math.max(0,Math.min(Number(s)-1,Number(e))),a=t&&typeof t.getCell=="function"?t.getCell(i):null;return(a&&typeof a.getWidth=="function"?Number(a.getWidth()):1)!==0?i:n==="end"?Math.min(Number(s)-1,i+1):Math.max(0,i-1)}function v0({line:t,col:e,cols:n}){const s=Math.max(0,Math.min(Number(n)-1,Number(e))),i=u=>{const h=t&&typeof t.getCell=="function"?t.getCell(u):null;return h&&typeof h.getChars=="function"?h.getChars():""};if(i(s)===""||i(s)===" ")return{start:s,end:s};let a=s;for(;a>0;){const u=i(a-1);if(u===""||u===" ")break;a-=1}let c=s;for(;c<Number(n)-1;){const u=i(c+1);if(u===""||u===" ")break;c+=1}return{start:a,end:c}}function oT({startLeft:t,endLeft:e,targetWidth:n=46}){return Math.abs(Number(e)-Number(t))<Number(n)}function aT({anchorLeft:t,anchorTop:e,hostWidth:n,hostHeight:s,bubbleWidth:i,bubbleHeight:a,pinHeight:c=30,margin:u=4,gap:h=8}){const f=Number(i),g=Number(a),v=Number(u),_=Math.max(v,Number(n)-v-f),b=Math.max(v,Math.min(_,Number(t)-Math.round(f/2)));let x=Number(e)-Number(h)-g,L=!1;x<v&&(x=Number(e)+Number(c)+Number(h),L=!0);const k=Math.max(v,Number(s)-v-g);return x>k&&(x=k),{left:b,top:x,flipped:L}}function _0(t,e){const n=Number(e),s=Number(t.start.row)*n+Number(t.start.col),i=Number(t.end.row)*n+Number(t.end.col);return{col:t.start.col,row:t.start.row,length:i-s+1}}const y0=28,lT=50;function cT({range:t,viewportY:e,rows:n,cols:s=0,cellWidth:i,cellHeight:a,screenLeft:c=0,screenTop:u=0}){const h={},f=Number(s)*Number(i);for(const g of["start","end"]){const v=t[g],_=Number(v.row)-Number(e),b=_>=0&&_<Number(n),x=(g==="start"?Number(v.col):Number(v.col)+1)*Number(i),L=g==="start"?x-y0<0:x+y0>f;h[g]={left:Number(c)+x,top:Number(u)+(_+1)*Number(a),visible:b,flip:L}}return h}function uT({visibleRow:t,rows:e}){const n=Number(t);return n<=0?-1:n>=Number(e)-1?1:0}function dT({range:t,side:e,line:n,cols:s}){if(!t||!t.start||!t.end||!n)return null;const i=Math.max(0,Number(s)-1),a=e==="end"?t.end:t.start,c=Number(a.row);let u,h;Number(t.start.row)===Number(t.end.row)?(u=Number(t.start.col),h=Number(t.end.col)):c===Number(t.start.row)?(u=Number(t.start.col),h=i):c===Number(t.end.row)?(u=0,h=Number(t.end.col)):(u=0,h=i),u=Math.max(0,Math.min(i,u)),h=Math.max(u,Math.min(i,h));const f=n.translateToString(!0,0,u);let g=n.translateToString(!1,u,h+1);g.replace(/\s+$/,"")===""&&(g="");const v=n.translateToString(!0,Math.min(i+1,h+1),i+1);return{row:c,before:f,sel:g,after:v}}const lg="(min-width:1024px) and (pointer:fine)";function _k(){const[t,e]=w.useState(()=>window.matchMedia(lg).matches);return w.useEffect(()=>{const n=window.matchMedia(lg),s=i=>e(i.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),t}const hT=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function yp(t){return t?t.files&&t.files.length>0||Array.from(t.items||[]).some(e=>e&&e.kind==="file")?!0:Array.from(t.types||[]).includes("Files"):!1}function w0(t){if(!t)return[];const e=Array.from(t.files||[]).filter(Boolean);return e.length?e:Array.from(t.items||[]).filter(n=>n&&n.kind==="file"&&typeof n.getAsFile=="function").map(n=>n.getAsFile()).filter(Boolean)}function fT(t,e=0,n=Date.now()){const s=String((t==null?void 0:t.name)||"").trim();if(s)return s;const i=hT.get(String((t==null?void 0:t.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${e+1}.${i}`}async function cg({files:t,token:e,session:n,node:s="",paste:i=!0,fetchImpl:a=qn,onProgress:c=()=>{},now:u=Date.now()}={}){const h=Array.from(t||[]).filter(Boolean),f=[],g=[];if(!n||!h.length)return{paths:f,errors:g};const v=yn(s?String(s).split("/"):[]);for(let _=0;_<h.length;_+=1){const b=h[_],x=fT(b,_,u);c({index:_,total:h.length,name:x,state:"uploading"});try{const L=new FormData;L.append("session",n),L.append("paste",i?"true":"false"),L.append("file",b,x);const k=await a(`${v}/files/upload`,e,{method:"POST",body:L}),R=await k.json().catch(()=>({}));if(!k.ok||R.error)throw new Error(R.error||`HTTP ${k.status}`);f.push(R.path),c({index:_,total:h.length,name:x,state:"done",path:R.path})}catch(L){const k=String((L==null?void 0:L.message)||L);g.push({name:x,message:k}),c({index:_,total:h.length,name:x,state:"error",error:k})}}return{paths:f,errors:g}}const pT=420,mT=32;function gT(t){if(!t||typeof t!="object")return!1;const e=String(t.tagName||"").toLowerCase();return e==="textarea"||e==="input"||t.isContentEditable===!0}function ug({documentRef:t,navigatorRef:e}={}){const n=t||(typeof document<"u"?document:null),s=e||(typeof navigator<"u"?navigator:null);let i=!1;try{s!=null&&s.virtualKeyboard&&typeof s.virtualKeyboard.hide=="function"&&(s.virtualKeyboard.hide(),i=!0)}catch{}const a=n&&n.activeElement;let c=!1;if(gT(a)&&typeof a.blur=="function")try{a.blur(),c=!0}catch{}return{blurred:c,apiRequested:i}}function yk(t,e,n=!1){const s=t&&t.textarea;if(!s)return null;const a=e==="single-tap"||e==="double-tap"&&n?"text":"none";return s.inputMode=a,s.setAttribute("inputmode",a),a}function vT(t,e){if(!t||!t.textarea)return!1;yk(t,"double-tap",!0);try{t.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 _T(t,e,n){return t==="never"?{open:!1,next:null}:t==="single-tap"?{open:!0,next:null}:!n||!Number.isFinite(n.at)||!Number.isFinite(n.x)||!Number.isFinite(n.y)?{open:!1,next:null}:e&&n.at>=e.at&&n.at-e.at<=pT&&Math.hypot(n.x-e.x,n.y-e.y)<=mT?{open:!0,next:null}:{open:!1,next:n}}const yT=24,b0=80,wk=8,wT="\x1B[5~",bT="\x1B[6~",ST=64,xT=65;function kT(t,e,n){const s=t==="up"?ST:xT,i=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${s};${i(e)};${i(n)}M`}function CT({alternateScreen:t=!1,readonly:e=!1,mouseTracking:n=!1}={}){return e?"scroll":n?"mouse":t?"page":"scroll"}function ET(t,e){return t==="page"?Number.isFinite(e)&&e>0?Math.max(b0,e):b0:Number.isFinite(e)&&e>0?e:yT}function NT({mode:t="scroll",accumulated:e=0,threshold:n=0}={}){const s=ET(t,n);if(!Number.isFinite(e))return{mode:t,up:0,down:0,remainder:0};const i=Math.abs(e);if(i<s)return{mode:t,up:0,down:0,remainder:e};const a=Math.floor(i/s),c=Math.min(a,wk),u=(e>=0?1:-1)*(i%s);return{mode:t,up:e>0?c:0,down:e<0?c:0,remainder:u}}function RT(t,e=null){const n=[],s=e&&Number.isFinite(e.col)?e.col:1,i=e&&Number.isFinite(e.row)?e.row:1,a=u=>Math.min(wk,Number.isFinite(u)?Math.max(0,Math.floor(u)):0),c=u=>t.mode==="mouse"?{kind:"input",seq:kT(u,s,i)}:t.mode==="page"?{kind:"input",seq:u==="up"?wT:bT}:{kind:"action",name:u==="up"?"scroll-up":"scroll-down"};for(let u=0;u<a(t.up);u+=1)n.push(c("up"));for(let u=0;u<a(t.down);u+=1)n.push(c("down"));return n}function mc({session:t,node:e,token:n,readonly:s,takeSize:i,focused:a,sendRef:c,composerRef:u,actionRef:h,ctrlRef:f,setCtrlArmed:g,altRef:v,setAltArmed:_,keyboardRef:b,onFiles:x,fontSize:L=13,selectionMode:k=!1,onSelectionModeChange:R,keyboardGesture:S="double-tap",onRendererChange:j}){const E=w.useRef(null),F=w.useRef(null),$=w.useRef(null),G=w.useRef(L);G.current=L;const K=w.useRef(a);K.current=a;const Y=w.useRef(k);Y.current=k;const te=w.useRef(S);te.current=S;const[q,D]=w.useState(""),[I,O]=w.useState(""),[M,z]=w.useState(null),[T,A]=w.useState(null),[N,U]=w.useState(!1),[P,H]=w.useState(0),ie=w.useRef(null),J=w.useRef(null),[Q,ve]=w.useState(!1),[de,ne]=w.useState(null),xe=w.useRef(null),[$e,rt]=w.useState(null),[je,Ie]=w.useState(0),[oe,Ne]=w.useState(null),[me,Ce]=w.useState("start"),[V,ge]=w.useState(null),[Le,ke]=w.useState(!1),[We,Re]=w.useState(null),[_e,st]=w.useState(null),Xe=w.useRef(null),De=w.useRef(null),[He,Ke]=w.useState(!1),wt=async()=>{var ht,Pt,St,Nt;const se=((Pt=(ht=F.current)==null?void 0:ht.term)==null?void 0:Pt.getSelection())||q;if(!se){O(p("copy-empty")),setTimeout(()=>O(""),1500);return}const Be=await ag(se);O(p(Be?"copied":"copy-manual")),Be&&((Nt=(St=F.current)==null?void 0:St.term)==null||Nt.clearSelection(),D(""),ve(!1),R==null||R(!1)),setTimeout(()=>O(""),1800)},fe=w.useRef(wt);fe.current=wt;const he=w.useRef({startHandleDrag:()=>{}}),Z=w.useRef(null);Z.current=$e,w.useEffect(()=>{const se=E.current;se&&(se.dataset.selectionOrigin=_e||"")},[_e]),w.useEffect(()=>{const se=F.current;se&&se.sock&&se.sock.focus&&se.sock.focus(!!a)},[a]),w.useEffect(()=>{const se=F.current;se&&(se.term.options.fontSize=L,se.fit.fit(),se.sock.resize(se.term.cols,se.term.rows))},[L]),w.useEffect(()=>{var se,Be;(Be=(se=F.current)==null?void 0:se.setKeyboardGesture)==null||Be.call(se,S)},[S]),w.useEffect(()=>{var Bi,Tr,Ci,wo,na,Kc,sa,bo,ia,ul,Ei;const se=new KA({cursorBlink:!0,fontSize:G.current,scrollback:1e3,allowProposedApi:!0,theme:{background:"#0a0e0a"}}),Be=new GA;se.loadAddon(Be),se.open(E.current),Be.fit(),tj(se);const ht=BM(se,{preference:kc(),createAddon:()=>new DM,onFallback:()=>{j&&j("dom")}});$.current=ht,j&&j(ht.kind);let Pt=!1,St=!1;const Nt=ye=>Ve=>{for(const tt of Ve){const ft=Array.isArray(tt)?tt[0]:tt;ft===1006&&(Pt=ye),ft===1016&&(St=ye)}return!1};(Tr=(Bi=se.parser)==null?void 0:Bi.registerCsiHandler)==null||Tr.call(Bi,{prefix:"?",final:"h"},Nt(!0)),(wo=(Ci=se.parser)==null?void 0:Ci.registerCsiHandler)==null||wo.call(Ci,{prefix:"?",final:"l"},Nt(!1)),(Kc=(na=se.parser)==null?void 0:na.registerEscHandler)==null||Kc.call(na,{final:"c"},()=>(Pt=!1,St=!1,!1));const ut=()=>{const ye=Pt&&!St&&(se.modes&&se.modes.mouseTrackingMode||"none")!=="none",Ve=E.current;return Ve&&(Ve.dataset.mouseTracking=ye?"on":"off"),ye},zt=new TextDecoder;let Yt=te.current==="single-tap",Ut=null;const dt=()=>{Yt=te.current==="single-tap",yk(se,te.current,Yt)},qt=ye=>{te.current=ye,Ut=null,dt()},In=()=>te.current==="never"?!1:(Yt=!0,vT(se));b&&(b.current=In),dt();const Kt=se.textarea,wn=()=>{te.current==="double-tap"&&dt()};Kt==null||Kt.addEventListener("blur",wn);let tn=!1,bn=0;const Ft=()=>{tn=!0,bn=Date.now()+2e3},Jt=()=>{tn=!1};(sa=E.current)==null||sa.addEventListener("paste",Ft,!0),(bo=E.current)==null||bo.addEventListener("keydown",Jt,!0);let Qt;try{Qt=WM({session:t,node:e,token:n,readonly:s,takeSize:i,focused:K.current,onFiles:x,cols:se.cols,rows:se.rows,onData:ye=>se.write(zt.decode(ye)),onExit:()=>se.write(`\r
|
|
154
|
-
\x1B[33m[sessione finita]\x1B[0m\r
|
|
155
|
-
`),onSnapshot:ye=>{try{const Ve=se.buffer&&se.buffer.active,tt=KM({viewportY:Ve?Ve.viewportY:0,baseY:Ve?Ve.baseY:0},{baseY:Ve?Ve.baseY:0});se.reset(),se.write(ye),!tt.atBottom&&tt.line!==null&&typeof se.scrollToLine=="function"&&se.scrollToLine(tt.line)}catch{}},onQueued:ye=>H(ye),onLink:ye=>{if(J.current&&(clearTimeout(J.current),J.current=null),ye==="live"){const Ve=ie.current!==null&&qM(ie.current,Date.now());if(ie.current=null,U(!1),Ve)try{se.write(VM(!0))}catch{}return}ie.current===null&&(ie.current=Date.now()),J.current=setTimeout(()=>{J.current=null,U(!0)},gk().overlayDelayMs||vk)}})}catch(ye){return se.write(`\r
|
|
156
|
-
\x1B[31m${ye.message}\x1B[0m\r
|
|
157
|
-
`),b&&(b.current=null),Kt==null||Kt.removeEventListener("blur",wn),(ia=E.current)==null||ia.removeEventListener("paste",Ft,!0),(ul=E.current)==null||ul.removeEventListener("keydown",Jt,!0),()=>{var Ve,tt;try{(tt=(Ve=$.current)==null?void 0:Ve.dispose)==null||tt.call(Ve)}catch{}$.current=null,se.dispose()}}F.current={term:se,fit:Be,sock:Qt,setKeyboardGesture:qt};let Zt=null;const ls=se.onData(ye=>{if(s){Zt&&(Zt.ok=!1);return}const Ve=tn&&Date.now()<bn;Jt(),!Zt&&!Ve&&ye.length>=1&&(f&&f.current||v&&v.current)&&(ye=YM(ye,{ctrl:!!(f&&f.current),alt:!!(v&&v.current)}),f&&(f.current=!1),v&&(v.current=!1),g&&g(!1),_&&_(!1));const tt=Qt.sendInput(ye);Zt&&(Zt.seen=!0,Zt.ok=Zt.ok&&tt)});c&&(c.current=ye=>Qt.sendInput(ye)),h&&(h.current=ye=>Qt.action(ye)),u&&(u.current=JM({isReady:()=>!s&&Qt.isReady(),paste:ye=>{const Ve={seen:!1,ok:!0};Zt=Ve;try{se.paste(ye)}catch{Ve.ok=!1}finally{Zt=null}return Ve.seen&&Ve.ok},send:ye=>Qt.sendInput(ye)}));const cs=ye=>{Xe.current=ye,st(ye)};let mn=null;const gn=se.onSelectionChange(()=>{const ye=se.getSelection();ye?(D(ye),ve(!1)):ve(!0);const Ve=iT(se.getSelectionPosition(),se.cols),tt=Ve?g0(Ve.start,Ve.end,se.cols):null;ne(tt),xe.current=tt,tt||cs(null),!tt&&mn&&jr();let ft=null;if(tt&&typeof se.buffer.active.getLine=="function"){const Et=[];for(let At=tt.start.row;At<=tt.end.row;At++){const It=se.buffer.active.getLine(At);Et.push(It?It.translateToString():"")}ft={startRow:tt.start.row,endRow:tt.end.row,lines:Et}}De.current=ft,Ke(!1)}),qs=se.onRender(ye=>{var Ve;if((Ve=se.hasSelection)!=null&&Ve.call(se)){const tt=De.current,ft=ye&&ye.start,Et=ye&&ye.end;if(tt&&Number.isInteger(ft)&&Number.isInteger(Et)&&typeof se.buffer.active.getLine=="function"){const At=Number(se.buffer.active.viewportY)||0,It=Math.max(At+ft,tt.startRow),sn=Math.min(At+Et,tt.endRow);for(let Yn=It;Yn<=sn;Yn++){const cn=se.buffer.active.getLine(Yn);if((cn?cn.translateToString():"")!==tt.lines[Yn-tt.startRow]){Ke(!0);break}}}Ie(At=>At+1)}}),Vn=se.onScroll(()=>{var ye;(ye=se.hasSelection)!=null&&ye.call(se)&&Ie(Ve=>Ve+1)});se.attachCustomKeyEventHandler(ye=>(ye.ctrlKey||ye.metaKey)&&ye.key.toLowerCase()==="c"&&se.getSelection()?(ye.type==="keydown"&&ag(se.getSelection()),!1):!0);const bt=E.current;let us=!1;const le=async ye=>{if(!ye.length||us)return;if(s){z({error:p("settings-readonly")});return}us=!0,z({current:0,total:ye.length,name:""});const Ve=await cg({files:ye,token:n,session:t,node:e,paste:!0,onProgress:({index:tt,total:ft,name:Et,state:At,error:It})=>z({current:tt+1,total:ft,name:Et,...At==="error"?{error:It}:{}})});us=!1,Ve.errors.length?z({error:Ve.errors.map(tt=>`${tt.name}: ${tt.message}`).join(" · ")}):(z({done:!0,total:Ve.paths.length}),setTimeout(()=>z(null),1600))},re=ye=>{const Ve=ye.clipboardData;if(!yp(Ve))return;const tt=w0(Ve);tt.length&&(ye.preventDefault(),ye.stopPropagation(),le(tt))},Te=ye=>{yp(ye.dataTransfer)&&(ye.preventDefault(),ye.stopPropagation())},Ge=ye=>{yp(ye.dataTransfer)&&(ye.preventDefault(),ye.stopPropagation(),le(w0(ye.dataTransfer)))};bt.addEventListener("paste",re,!0),bt.addEventListener("dragenter",Te,!0),bt.addEventListener("dragover",Te,!0),bt.addEventListener("drop",Ge,!0);const gt=24,W=(ye,Ve)=>{const ft=(bt.querySelector(".xterm-screen")||bt).getBoundingClientRect(),Et=Math.floor((ye-ft.left)/Math.max(1,ft.width)*se.cols)+1,At=Math.floor((Ve-ft.top)/Math.max(1,ft.height)*se.rows)+1;return{col:Math.max(1,Math.min(se.cols,Et)),row:Math.max(1,Math.min(se.rows,At))}},ae=(ye,Ve={mode:null,remainder:0},tt=null,ft=null)=>{const Et=E.current,At=Et?Et.getBoundingClientRect().height:gt,It=CT({alternateScreen:se.buffer.active.type==="alternate",readonly:s,mouseTracking:ut()}),sn=It==="mouse"?"mouse":tt||It,Yn=Ve.mode===sn?Ve.remainder+ye:ye,cn=NT({mode:sn,accumulated:Yn,threshold:sn==="page"?At:gt});for(const Is of RT(cn,ft))Is.kind==="input"?Qt.sendInput(Is.seq):Qt.action(Is.name);return{mode:sn,remainder:cn.remainder}};let Ae=null,Je=null,Pe=null,xt=null,vt=!1,Qe=!1,Rt={mode:null,remainder:0},ot=null,ze=null,Wt=null,Sn=!1;const Se=750;let Me=0;const qe=()=>{Wt&&clearTimeout(Wt),Wt=null},ct=(ye,Ve)=>{const ft=(bt.querySelector(".xterm-screen")||bt).getBoundingClientRect(),Et=Math.max(0,Math.min(se.cols-1,Math.floor((ye-ft.left)/Math.max(1,ft.width)*se.cols))),At=Math.max(0,Math.min(se.rows-1,Math.floor((Ve-ft.top)/Math.max(1,ft.height)*se.rows)));return{col:Et,row:se.buffer.active.viewportY+At}},Lt=()=>{const tt=(bt.querySelector(".xterm-screen")||bt).getBoundingClientRect().height/Math.max(1,se.rows),ft=bt.querySelector(".nc-sel-handle"),Et=ft?ft.getBoundingClientRect().height:0;return-.3*(Et>0?Et:tt)},Ks=(ye,Ve)=>ct(ye.clientX,ye.clientY+Ve),Vs=ye=>{const tt=(bt.querySelector(".xterm-screen")||bt).getBoundingClientRect(),ft=bt.getBoundingClientRect(),Et=tt.width/Math.max(1,se.cols),At=tt.height/Math.max(1,se.rows),It=Number(se.buffer.active.viewportY)||0,sn=Math.max(0,Math.min(se.rows-1,ye.row-It));A({left:`${tt.left-ft.left+ye.col*Et}px`,top:`${tt.top-ft.top+sn*At}px`,width:`${Et}px`,height:`${At}px`})},en=ye=>{if(Me=Date.now(),cs("touch"),qe(),Sn=!1,vt=!1,Qe||ye.touches.length!==1){Qe=!0,vt=!0,Ut=null,A(null),Ae=null,Je=null,Pe=null,xt=null;return}if(Y.current){ye.preventDefault(),ye.stopPropagation();const tt=ct(ye.touches[0].clientX,ye.touches[0].clientY),ft=se.buffer.active.getLine(tt.row),Et=Aa({line:ft,col:tt.col,side:"start",cols:se.cols}),At=v0({line:ft,col:Et,cols:se.cols});ze={row:tt.row,col:At.start};const It={row:tt.row,col:At.end};se.clearSelection(),cs("touch"),ke(!0),Ce("end"),se.select(At.start,tt.row,At.end-At.start+1),Vs(It);return}Ae=ye.touches[0].clientY,Je=ye.touches[0].clientX,Pe=Je,xt=Ae,Rt={mode:null,remainder:0},ot=null;const Ve={x:Je,y:Ae};Wt=setTimeout(()=>{var sn;Wt=null,Sn=!0,vt=!0,Ut=null,Y.current=!0,R==null||R(!0);const tt=ct(Ve.x,Ve.y),ft=se.buffer.active.getLine(tt.row),Et=Aa({line:ft,col:tt.col,side:"start",cols:se.cols}),At=v0({line:ft,col:Et,cols:se.cols});ze={row:tt.row,col:At.start};const It={row:tt.row,col:At.end};se.clearSelection(),cs("touch"),ke(!0),Ce("end"),se.select(At.start,tt.row,At.end-At.start+1),Vs(It);try{(sn=navigator.vibrate)==null||sn.call(navigator,10)}catch{}Ae=null,Je=null,ot=null,Rt={mode:null,remainder:0}},tT)},nn=ye=>{if(Sn&&ze&&ye.touches.length===1){ye.preventDefault(),ye.stopPropagation();const ft=ct(ye.touches[0].clientX,ye.touches[0].clientY),Et=ze.row*se.cols+ze.col,At=ft.row*se.cols+ft.col,It=Et<=At?"end":"start",sn=se.buffer.active.getLine(ft.row),Yn=Aa({line:sn,col:ft.col,side:It,cols:se.cols}),cn={row:ft.row,col:Yn},Is=cn.row*se.cols+cn.col,ri=Et<=Is?ze:cn;Ce(It),se.select(ri.col,ri.row,Math.abs(Is-Et)+1),Vs(cn);return}if(Y.current&&ze&&ye.touches.length===1){ye.preventDefault(),ye.stopPropagation();const ft=ct(ye.touches[0].clientX,ye.touches[0].clientY),Et=ze.row*se.cols+ze.col,At=ft.row*se.cols+ft.col,It=Et<=At?"end":"start",sn=se.buffer.active.getLine(ft.row),Yn=Aa({line:sn,col:ft.col,side:It,cols:se.cols}),cn={row:ft.row,col:Yn},Is=cn.row*se.cols+cn.col,ri=Et<=Is?ze:cn;Ce(It),se.select(ri.col,ri.row,Math.abs(Is-Et)+1),Vs(cn);return}if(Ae===null||ye.touches.length!==1)return;ye.preventDefault(),ye.stopPropagation();const Ve=ye.touches[0];if(m0(Pe,xt,Ve.clientX,Ve.clientY)&&(vt=!0,Ut=null,Wt&&qe()),ot===null&&(Math.abs(Ve.clientY-Ae)>8||Math.abs(Ve.clientX-Je)>8)&&(ot=Math.abs(Ve.clientY-Ae)>Math.abs(Ve.clientX-Je)),!ot)return;const tt=Ve.clientY-Ae;Ae=Ve.clientY,Rt=ae(tt,Rt,"scroll",W(Ve.clientX,Ve.clientY))},on=()=>{qe(),Ae=null,Je=null,Pe=null,xt=null,ze=null,Sn=!1,vt=!1,Qe=!1,A(null),ke(!1),Rt={mode:null,remainder:0},Me=Date.now()},Si=ye=>{if(Qe){Ut=null,qe(),(!ye.touches||ye.touches.length===0)&&on();return}const Ve=ye.changedTouches&&ye.changedTouches[0];if(!vt&&!Sn&&!Y.current&&Ve){const tt={at:Date.now(),x:Ve.clientX,y:Ve.clientY},ft=_T(te.current,Ut,tt);Ut=ft.next,ft.open&&In()}on()},go=()=>{Ut=null,on()};let rr={mode:null,remainder:0};const Gt=ye=>{ye.preventDefault(),ye.stopPropagation(),rr=ae(-ye.deltaY,rr,"scroll",W(ye.clientX,ye.clientY))};bt.addEventListener("touchstart",en,{passive:!1}),bt.addEventListener("touchmove",nn,{passive:!1,capture:!0}),bt.addEventListener("touchend",Si,{passive:!0}),bt.addEventListener("touchcancel",go,{passive:!0});const rl=()=>{typeof window.matchMedia=="function"&&window.matchMedia(lg).matches||!Y.current&&te.current==="double-tap"&&In()};bt.addEventListener("dblclick",rl);const ol=ye=>{(Y.current||Sn)&&(ye.preventDefault(),ye.stopPropagation())};bt.addEventListener("contextmenu",ol,!0),bt.addEventListener("wheel",Gt,{passive:!1,capture:!0});let Ps=null;const al=ye=>{Date.now()-Me>=Se&&cs("mouse"),QM(ye)&&(ye.preventDefault(),ye.stopPropagation(),Ps={cell:ct(ye.clientX,ye.clientY),clientX:ye.clientX,clientY:ye.clientY,extendFrom:xe.current,dragged:!1})},ll=ye=>{var It;if(!Ps){(It=se.hasSelection)!=null&&It.call(se)&&ut()&&(ye.preventDefault(),ye.stopPropagation());return}if(ye.preventDefault(),ye.stopPropagation(),!Ps.dragged&&!m0(Ps.clientX,Ps.clientY,ye.clientX,ye.clientY))return;Ps.dragged=!0;const Ve=Ps.cell,tt=ct(ye.clientX,ye.clientY),ft=Ve.row*se.cols+Ve.col,Et=tt.row*se.cols+tt.col,At=ft<=Et?Ve:tt;se.select(At.col,At.row,Math.abs(Et-ft)+1)},cl=ye=>{if(!Ps)return;ye.stopPropagation();const{cell:Ve,extendFrom:tt,dragged:ft}=Ps;if(Ps=null,ft||!tt)return;const Et=nT({range:tt,cell:Ve,cols:se.cols});if(!Et.moved)return;const At=Et[Et.moved],It=se.buffer.active.getLine(At.row);At.col=Aa({line:It,col:At.col,side:Et.moved,cols:se.cols});const sn=_0({start:Et.start,end:Et.end},se.cols);se.select(sn.col,sn.row,sn.length)};bt.addEventListener("mousedown",al,!0),bt.addEventListener("mousemove",ll,!0),bt.addEventListener("mouseup",cl,!0);let Ar=null,ni={x:0,y:0,type:"touch"};const Ys=()=>{Ar&&(clearInterval(Ar),Ar=null)},xi=(ye,Ve,tt)=>{if(!mn||!mn.fixed)return;const ft=mn.fixed,Et=tt==="mouse"?ct(ye,Ve):Ks({clientX:ye,clientY:Ve},Lt()),At=se.buffer.active.getLine(Et.row),It={row:Et.row,col:Aa({line:At,col:Et.col,side:mn.which,cols:se.cols})},sn=Math.max(0,Number(se.buffer.active.baseY||0)+se.rows-1),Yn=rT({moving:It,fixed:ft,which:mn.which,cols:se.cols,maxRow:sn}),cn=_0(g0(Yn,ft,se.cols),se.cols);se.select(cn.col,cn.row,cn.length);const Is=Number(se.buffer.active.viewportY)||0,ri=uT({visibleRow:Yn.row-Is,rows:se.rows});Ys(),!(ri===0||se.buffer.active.type==="alternate")&&(Ar=setInterval(()=>{const dl=Number(se.buffer.active.viewportY)||0;if(se.scrollLines(ri),(Number(se.buffer.active.viewportY)||0)===dl){Ys();return}xi(ni.x-mn.offsetX,ni.y-mn.offsetY,ni.type)},130))},si=ye=>{mn&&(ye.preventDefault(),ni={x:ye.clientX,y:ye.clientY,type:ye.pointerType||ni.type},xi(ye.clientX-mn.offsetX,ye.clientY-mn.offsetY,ni.type))},jr=()=>{mn=null,Ys(),Ne(null),window.removeEventListener("pointermove",si),window.removeEventListener("pointerup",ii),window.removeEventListener("pointercancel",ii)},ii=()=>jr();he.current={startHandleDrag:(ye,Ve)=>{if(!se.getSelectionPosition())return;Ve.preventDefault(),Ve.stopPropagation();const tt=Z.current&&Z.current[ye],ft=bt.getBoundingClientRect();mn={which:ye,offsetX:tt?Ve.clientX-(ft.left+tt.left):0,offsetY:tt?Ve.clientY-(ft.top+tt.top):0,fixed:xe.current?ye==="start"?xe.current.end:xe.current.start:null},ni={x:Ve.clientX,y:Ve.clientY,type:Ve.pointerType||"touch"},Ne(ye),Ce(ye),window.addEventListener("pointermove",si),window.addEventListener("pointerup",ii),window.addEventListener("pointercancel",ii)}};const ki=ye=>{!ZM(ye)||!(F.current&&F.current.term&&F.current.term.getSelection())||(ye.preventDefault(),ye.stopPropagation(),fe.current&&fe.current())};bt.addEventListener("keydown",ki,!0);const Mr=()=>{Be.fit(),Qt.resize(se.cols,se.rows)};window.addEventListener("resize",Mr);const Gs=window.visualViewport;let or=Gs&&Number(Gs.height);const qc=()=>{const ye=Gs&&Number(Gs.height);Yt&&te.current==="double-tap"&&Number.isFinite(or)&&Number.isFinite(ye)&&ye>or+80&&dt(),or=ye,Mr()};Gs&&(Gs.addEventListener("resize",qc),Gs.addEventListener("scroll",Mr));const ys=typeof navigator<"u"?navigator.virtualKeyboard:null,vo=()=>{var ye;Yt&&te.current==="double-tap"&&Number(((ye=ys==null?void 0:ys.boundingRect)==null?void 0:ye.height)||0)===0&&dt()};(Ei=ys==null?void 0:ys.addEventListener)==null||Ei.call(ys,"geometrychange",vo);let _o=null,yo=0;return typeof ResizeObserver<"u"&&(_o=new ResizeObserver(()=>{yo&&cancelAnimationFrame(yo),yo=requestAnimationFrame(Mr)}),_o.observe(bt)),()=>{var ye,Ve,tt;F.current=null,b&&(b.current=null),J.current&&(clearTimeout(J.current),J.current=null),c&&(c.current=()=>!1),u&&(u.current=()=>!1),h&&(h.current=()=>!1),ls.dispose(),gn.dispose(),qs.dispose(),Vn.dispose(),Ys(),window.removeEventListener("pointermove",si),window.removeEventListener("pointerup",ii),window.removeEventListener("pointercancel",ii),he.current={startHandleDrag:()=>{}},bt.removeEventListener("touchstart",en),bt.removeEventListener("touchmove",nn,{capture:!0}),bt.removeEventListener("touchend",Si),bt.removeEventListener("touchcancel",go),bt.removeEventListener("dblclick",rl),bt.removeEventListener("contextmenu",ol,!0),qe(),bt.removeEventListener("wheel",Gt,{capture:!0}),bt.removeEventListener("mousedown",al,!0),bt.removeEventListener("mousemove",ll,!0),bt.removeEventListener("mouseup",cl,!0),bt.removeEventListener("keydown",ki,!0),bt.removeEventListener("paste",re,!0),bt.removeEventListener("dragenter",Te,!0),bt.removeEventListener("dragover",Te,!0),bt.removeEventListener("drop",Ge,!0),window.removeEventListener("resize",Mr),Gs&&(Gs.removeEventListener("resize",qc),Gs.removeEventListener("scroll",Mr)),(ye=ys==null?void 0:ys.removeEventListener)==null||ye.call(ys,"geometrychange",vo),Kt==null||Kt.removeEventListener("blur",wn),(Ve=E.current)==null||Ve.removeEventListener("paste",Ft,!0),(tt=E.current)==null||tt.removeEventListener("keydown",Jt,!0),_o&&_o.disconnect(),yo&&cancelAnimationFrame(yo),Qt.close(),se.dispose()}},[t,e,n,s,i,c,u,h,f,g,x]),w.useEffect(()=>{const se=E.current,Be=F.current?F.current.term:null;if(!se||!Be||!de){rt(null),ge(null),Re(null);return}const Pt=(se.querySelector(".xterm-screen")||se).getBoundingClientRect(),St=se.getBoundingClientRect(),Nt=Pt.width/Math.max(1,Be.cols),ut=Pt.height/Math.max(1,Be.rows),zt=cT({range:de,viewportY:Number(Be.buffer.active.viewportY)||0,rows:Be.rows,cols:Be.cols,cellWidth:Nt,cellHeight:ut,screenLeft:Pt.left-St.left,screenTop:Pt.top-St.top});rt(zt);let Yt=null;const Ut=de[me==="end"?"end":"start"].row;typeof Be.buffer.active.getLine=="function"&&(Yt=Be.buffer.active.getLine(Number(Ut)));const dt=Math.max(16,Math.round(ut*2)),qt=Yt?{...dT({range:de,side:me,line:Yt,cols:Be.cols}),fontSize:dt}:null;ge(qt);const In=oe!==null||Le,Kt=zt[me==="end"?"end":"start"];if(!In||!qt||!Kt||!Kt.visible){Re(null);return}const wn=(qt.before+qt.sel+qt.after).length,tn=Nt*(dt/Math.max(1,ut)),bn=Math.min(St.width-8,Math.round(wn*tn)+16),Ft=Math.round(dt*1.25)+12;Re(aT({anchorLeft:Kt.left,anchorTop:Kt.top,hostWidth:St.width,hostHeight:St.height,bubbleWidth:bn,bubbleHeight:Ft}))},[de,je,me,oe,Le]);const X=sT(_e),ue=w.useRef({}),Ze=(se,Be)=>{if(oe!==se)return ue.current[se]={flip:Be,ts:0},Be;const ht=ue.current[se]||{flip:Be,ts:0};if(ht.flip===Be)return ue.current[se]=ht,Be;const Pt=Date.now();return Pt-ht.ts<lT?ht.flip:(ue.current[se]={flip:Be,ts:Pt},Be)};return l.jsxs("div",{className:`nc-terminal${k?" selecting":""}`,children:[l.jsx("div",{className:"nc-terminal-host",ref:E}),N&&l.jsxs("div",{className:"nc-terminal-link-overlay",children:["riconnessione…",P>0?` (${P} byte in coda)`:""]}),T&&l.jsx("div",{className:"nc-touch-selection-caret",style:T,"aria-hidden":"true"}),de&&$e&&X.handles&&["start","end"].map(se=>$e[se].visible&&l.jsx("div",{className:`nc-sel-handle ${se}${oe===se?" dragging":""}${Ze(se,$e[se].flip)?" flip":""}${oT({startLeft:$e.start.left,endLeft:$e.end.left})?" tight":""}`,style:{left:`${$e[se].left}px`,top:`${$e[se].top}px`},onPointerDown:Be=>he.current.startHandleDrag(se,Be),"aria-hidden":"true"},`nc-sel-handle-${se}`)),de&&V&&X.magnifier&&We&&l.jsx("div",{className:`nc-zoom-bubble${We.flipped?" flipped":""}`,style:{left:`${We.left}px`,top:`${We.top}px`},"aria-hidden":"true",children:l.jsxs("pre",{className:"nc-zoom-line",style:{fontSize:`${V.fontSize}px`},children:[l.jsx("span",{children:V.before}),l.jsx("span",{className:"nc-zoom-sel",children:V.sel}),l.jsx("span",{children:V.after})]})}),M&&l.jsx("div",{className:`nc-upload-state${M.error?" error":""}`,role:"status",children:M.error?M.error:M.done?p("attach-uploaded").replace("{n}",String(M.total||0)):p("attach-upload-progress").replace("{n}",String(M.current||0)).replace("{total}",String(M.total||0))}),(q||k)&&l.jsxs("div",{className:"nc-selection-tools",children:[q?l.jsx("button",{type:"button",onClick:wt,children:I||`${p("copy")} · ${eT(typeof navigator<"u"?navigator.userAgent:"")}`}):l.jsx("span",{children:p("select-drag")}),q&&Q&&l.jsx("span",{className:"nc-selection-held",children:p("selection-held")}),q&&!Q&&He&&l.jsx("span",{className:"nc-selection-changed",children:p("selection-changed")}),l.jsx("button",{type:"button",onClick:()=>{var se,Be;(Be=(se=F.current)==null?void 0:se.term)==null||Be.clearSelection(),D(""),ve(!1),R==null||R(!1)},children:p("cancel")}),I===p("copy-manual")&&l.jsx("textarea",{readOnly:!0,value:q,onFocus:se=>se.target.select()})]})]})}function Cc(t,e,n){const s=c=>Number.isInteger(c)&&c>0&&c<65536?c:0;if(t==null)return s(n);if(!Array.isArray(t))return 0;if(t.length===0)return s(n);const i=typeof t[0]=="string"?t[0]:null;return i?s((e&&typeof e=="object"?e:{})[i]):0}const LT=6901;function gv({cellId:t,panelUrl:e,route:n=[],panelPort:s=0,token:i,title:a,requestTimeoutMs:c=4e3}){const[u,h]=w.useState(t&&i?"requesting":"none"),[f,g]=w.useState(""),v=Array.isArray(n)?n.join("\0"):"",_=w.useMemo(()=>Array.isArray(n)?n:[],[v]),b=w.useRef(0),x=w.useCallback(async()=>{if(!t||!i||!e){h("none");return}const D=b.current+=1;h("requesting");const I=new AbortController,O=setTimeout(()=>I.abort(),c);try{const M=await xN(i,_,t,{signal:I.signal});if(clearTimeout(O),D!==b.current)return;if(M.ok){let z="/";try{z=new URL(e).pathname||"/"}catch{}const T=s?`http://127.0.0.1:${s}`:yn(_);g(`${T}/panel/${encodeURIComponent(t)}${z}?ticket=${encodeURIComponent(M.ticket)}`),h("ready")}else h(M.cause)}catch(M){if(clearTimeout(O),D!==b.current)return;h(M&&M.name==="AbortError"?"timeout":"unreachable")}},[t,e,_,s,i,c]),L=w.useCallback(()=>{h(D=>D==="ready"?"loaded":D)},[]),k=w.useCallback(()=>{h(D=>D==="ready"||D==="loaded"?"frame-error":D)},[]),R=w.useRef(null),S=w.useCallback(D=>{D&&(R.current=D,D.onload=L,D.onerror=k)},[L,k]);w.useEffect(()=>{x()},[x]);const E=w.useMemo(()=>{try{return Number(new URL(e).port)===LT}catch{return!1}},[e])&&_.length===0,[F,$]=w.useState(!1),[G,K]=w.useState("");w.useEffect(()=>{const D=I=>{const O=R.current;if(!O||!O.contentWindow||I.source!==O.contentWindow)return;let M=null;try{M=new URL(f,window.location.href).origin}catch{return}!M||I.origin!==M||!I.data||I.data.type!=="nc-panel-unreachable"||h(z=>z==="ready"||z==="loaded"?"unreachable":z)};return window.addEventListener("message",D),()=>window.removeEventListener("message",D)},[f]);const Y=w.useCallback(async()=>{if(!i||F)return;$(!0),K("");let D=!1;try{const I=await P1(i,!0);I&&I.ok===!1&&(K(I.error||"comando fallito"),D=!0)}catch(I){K(String(I&&I.message||I)),D=!0}$(!1),D||x()},[i,F,x]),te=(D,I=!0,O=null)=>l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsx("span",{children:p(D)}),I&&l.jsxs("span",{className:"nc-cellpanel-actions",children:[O,l.jsx("button",{type:"button",title:p("panel-retry"),onClick:()=>x(),children:p("panel-retry")})]})]}),q=E?l.jsx("button",{type:"button",disabled:F,onClick:Y,children:p("panel-start-desktop")}):null;return u==="none"||u==="no-panel"?te("panel-none",!1):u==="requesting"?l.jsx("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:l.jsx("span",{children:p("panel-checking")})}):u==="not-granted"?te("panel-not-granted",!1):u==="node-refused"?te("panel-node-refused",!1):u==="unauthorized"?te("panel-unauthorized",!1):u==="denied"?te("panel-denied"):u==="timeout"?te("panel-timeout"):u==="unreachable"?l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsxs("span",{children:[p("panel-unreachable"),G?` — ${G}`:""]}),l.jsxs("span",{className:"nc-cellpanel-actions",children:[q,l.jsx("button",{type:"button",title:p("panel-retry"),onClick:()=>x(),children:p("panel-retry")})]})]}):u==="frame-error"?te("panel-frame-error",!0,q):l.jsxs(l.Fragment,{children:[u==="ready"&&l.jsx("div",{className:"nc-cellpanel-loading",role:"status",children:p("panel-frame-loading")}),l.jsx("iframe",{ref:S,className:"nc-cellpanel nc-cellpanel-frame","data-frame-state":u,src:f,title:a||p("panel"),allowFullScreen:!0})]})}const AT=1800*1e3;function dg(t,e,n=Date.now()){const s=Number(e);if(!Number.isFinite(s)||s<=0)return"";const i=n-s;if(i<0||i>AT)return"";if(i<60*1e3)return`${t("cell-activity")} ${t("cell-activity-now")}`;const a=Math.floor(i/6e4);return a<60?`${t("cell-activity")} ${a}m`:`${t("cell-activity")} ${Math.floor(a/60)}h`}function hg(t,e){if(!e||typeof e!="object")return"";const n=[];return Number.isInteger(e.contextFreePct)&&n.push(`${t("cell-tele-ctx")} ${e.contextFreePct}% ${t("cell-tele-free")}`),Number.isInteger(e.tier5hUsedPct)&&n.push(`${t("cell-tele-5h")} ${e.tier5hUsedPct}%`),Number.isInteger(e.tier7dUsedPct)&&n.push(`${t("cell-tele-7d")} ${e.tier7dUsedPct}%`),n.join(" · ")}function vv({row:t,token:e,panelPort:n=0,liveHost:s=null,onLiveHostApplied:i,source:a,onSourceChange:c,fontSize:u,readOnly:h=!1,chrome:f=!0}){const g=K=>c&&c(K),v=w.useRef(()=>{}),_=w.useRef(()=>!1),b=w.useRef(()=>{}),x=w.useRef(!1),[L,k]=w.useState(!1),[R,S]=w.useState(""),[j,E]=w.useState(!1),F=!!(s&&s.cell&&s.cell===t.cellName),$=async()=>{E(!0);const K=await th({action:F?"remove":"use",cellId:t.cellName,route:t.route||[],token:e,api:{getLiveHost:Y=>Jd(e,Y),designateHostCell:(Y,te,q)=>Qd(e,Y,te,q),clearHostCell:(Y,te)=>Zd(e,Y,te)}});E(!1),S(p(K.messageKey).replace("{cell}",K.hostCell||t.cellName)),K.ok&&i&&i({route:t.route||[],hostCell:K.hostCell,revision:K.revision})},G=[["preview",p("cell-peek-preview")],["stream",p("cell-peek-stream")],...t.panelUrl?[["panel",p("cell-peek-panel")]]:[]];return l.jsxs(l.Fragment,{children:[f&&l.jsx("div",{className:"nc-peek-sorgenti",role:"tablist",children:G.map(([K,Y])=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===K,className:`nc-peek-sorgente${a===K?" attiva":""}`,onClick:()=>g(K),children:Y},K))}),f&&l.jsxs("div",{className:"nc-peek-host",children:[l.jsx("button",{type:"button",className:"nc-peek-host-btn",disabled:j,onClick:$,children:p(F?"live-host-action-remove":"live-host-action-use")}),R&&l.jsx("div",{className:"nc-peek-notice",role:"status",children:R})]}),a==="stream"?l.jsx("div",{className:"nc-peek-stream",children:l.jsx(mc,{session:t.session,node:t.node||void 0,token:e,readonly:h,takeSize:!1,focused:!0,sendRef:v,composerRef:_,actionRef:b,ctrlRef:x,setCtrlArmed:k,fontSize:u},`peek:${t.key}`)}):a==="panel"?l.jsx(gv,{cellId:t.cellName,panelUrl:t.panelUrl,route:t.route||[],panelPort:n,token:e,title:t.cellName}):l.jsxs(l.Fragment,{children:[l.jsx("pre",{className:"nc-peek-testo",children:t.preview||p("cell-peek-vuoto")}),[dg(p,t.activity),hg(p,t.telemetry)].filter(Boolean).join(" · ")&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:[dg(p,t.activity),hg(p,t.telemetry)].filter(Boolean).join(" · ")})]})]})}function bk({row:t,token:e,initialSource:n="preview",panelPort:s=0,onClose:i,liveHost:a=null,onLiveHostApplied:c}){const[u,h]=w.useState(n==="panel"&&!t.panelUrl?"preview":n);return l.jsx(H1,{title:t.cellName,subtitle:[t.nodeLabel,t.subtitle].filter(Boolean).join(" · "),onClose:i,children:l.jsx(vv,{row:t,token:e,panelPort:s,liveHost:a,onLiveHostApplied:c,source:u,onSourceChange:h})})}const Ec="nc_order_journal_v1",jT=50,wp="__corrupt",MT=200,TT=200,PT=["reason","key","position","source","target","note"],IT=["before","after","visible"],Sk=t=>String(t).slice(0,TT),DT=t=>Array.isArray(t)?t.slice(0,MT).map(Sk):void 0,ah=t=>{try{return t||globalThis.localStorage}catch{return null}};function OT(t){const e={t:Date.now()};for(const n of PT)t[n]!==void 0&&t[n]!==null&&(e[n]=Sk(t[n]));for(const n of IT){const s=DT(t[n]);s&&(e[n]=s)}return e}function _v(t,e,n){const s=ah(n);if(!s||e===null||e===void 0)return!1;try{if(s.getItem(t+wp)===e)return!1;s.setItem(t+wp,e)}catch{return!1}return t!==Ec&&Ji({reason:"corrupt-preserved",key:t,note:`${String(e).length} caratteri conservati in ${t}${wp}`},s),!0}function fg(t){const e=ah(t);if(!e)return[];let n=null;try{n=e.getItem(Ec)}catch{return[]}if(n===null)return[];try{const s=JSON.parse(n);if(Array.isArray(s))return s}catch{}return _v(Ec,n,e),[]}function Ji(t,e){const n=ah(e);if(!(!n||!t))try{const s=[...fg(n),OT(t)].slice(-jT);n.setItem(Ec,JSON.stringify(s))}catch{}}function BT(t){const e=ah(t);if(e)try{e.removeItem(Ec)}catch{}}function Lr(t,{parse:e,fallback:n,storage:s}={}){let i=s;try{i=i||globalThis.localStorage}catch{return n()}let a=null;try{a=i.getItem(t)}catch{return n()}if(a==null)return n();try{const c=e(JSON.parse(a));if(c!==void 0)return c}catch{}return _v(t,a,i),n()}function yi(t,e,{storage:n}={}){let s=n;try{s=s||globalThis.localStorage}catch(i){return i}try{const i=s.getItem(t);if(i!=null)try{JSON.parse(i)}catch{_v(t,i,s)}return s.setItem(t,JSON.stringify(e)),null}catch(i){return i instanceof Error?i:new Error(String(i))}}const $T=["all","pinned","active","off","technical"],Jo="nc_sidebar_views_v1",Qo="nc_sidebar_order_v1";function xk(t){return $T.includes(t)?t:"all"}function zT(t,e=[],n="all"){const s=xk(n);return s==="technical"?t.technical===!0:t.technical===!0?!1:s==="pinned"?e.includes(t.key):s==="active"?!!t.live:s==="off"?!t.live:!0}function FT(t,e,n=[],s=[]){const i=n.indexOf(t.key),a=n.indexOf(e.key),c=i===-1?Number.MAX_SAFE_INTEGER:i,u=a===-1?Number.MAX_SAFE_INTEGER:a,h=s.indexOf(t.key),f=s.indexOf(e.key),g=h===-1?Number.MAX_SAFE_INTEGER:h,v=f===-1?Number.MAX_SAFE_INTEGER:f;return c-u||g-v||+!!e.live-+!!t.live||+!!e.fresh-+!!t.fresh||Number(e.activity||0)-Number(t.activity||0)||String(t.label||"").localeCompare(String(e.label||""))||String(t.key||"").localeCompare(String(e.key||""))}function dc(t=globalThis.localStorage){return Lr(Qo,{storage:t,fallback:()=>({}),parse:e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const n={};for(const[s,i]of Object.entries(e).slice(0,64)){if(typeof s!="string"||!s||s.length>160||!Array.isArray(i))continue;const a=[...new Set(i.filter(c=>typeof c=="string"&&c&&c.length<=256))].slice(0,128);a.length&&(n[s]=a)}return n}})}function wi(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function HT(t,e=globalThis.localStorage){return yi(Qo,t,{storage:e}),t}function UT(t,e,n,s,i=[]){if(typeof e!="string"||!e||n===s)return t;const a=[...new Set(i.filter(_=>typeof _=="string"&&_))];if(!a.includes(n)||!a.includes(s))return t;const c=wi(t,e),u=[...c,...a.filter(_=>!c.includes(_))],h=u.indexOf(n),f=u.indexOf(s);u.splice(h,1);const g=u.indexOf(s),v=h<f?g+1:g;return u.splice(v,0,n),{...t,[e]:u}}function yd(t=globalThis.localStorage){return Lr(Jo,{storage:t,fallback:()=>({}),parse:e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0})}function S0(t,e){var n,s;return{open:((n=t==null?void 0:t[e])==null?void 0:n.open)!==!1,filter:xk((s=t==null?void 0:t[e])==null?void 0:s.filter)}}function WT(t,e=globalThis.localStorage){return yi(Jo,t,{storage:e}),t}function x0(t,e=""){const n=String(e||"").trim().toLocaleLowerCase();return n?[t.label,t.key,t.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function kr(t=[],e=[],n="all",s=[]){return[...t].filter(i=>zT(i,e,n)).sort((i,a)=>FT(i,a,e,s))}function zn(){return[w.useSyncExternalStore(N5,Ed,Ed),E5]}function Id({cell:t,token:e,route:n=[],onConfirm:s,onClose:i}){var z,T;zn();const a=!!(t&&t.active),c=Array.isArray(n)?n.join("/"):"",[u,h]=w.useState([]),[f,g]=w.useState(!1);w.useEffect(()=>{let A=!0;return(async()=>{if(e)try{const N=await Qa(e,c?c.split("/"):[]);if(!A)return;if(g(N.provider==="builtin"&&(N.capabilities||[]).includes("edit")),N.provider==="builtin"&&(N.capabilities||[]).includes("definitions")){const U=await Gd(e,c?c.split("/"):[]);if(!A)return;const P=new Map((N.engines||[]).map(H=>[H.id,H]));h((U.engines||[]).map(H=>{var ie,J,Q,ve,de,ne,xe;return{id:H.id,label:H.label||H.id,client:((ie=H.managed)==null?void 0:ie.client)||"",models:[...new Set([...((J=P.get(H.id))==null?void 0:J.models)||[],...((Q=H.managedInfo)==null?void 0:Q.models)||[]])].filter(Boolean),defaultModel:((ve=H.managed)==null?void 0:ve.model)||((de=H.managedInfo)==null?void 0:de.defaultModel)||"",policyDefault:((ne=H.managed)==null?void 0:ne.permissionPolicy)||((xe=H.managed)!=null&&xe.client&&H.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{A=!1}},[e,c]);const v=(t==null?void 0:t.engine)||((z=u[0])==null?void 0:z.id)||"",_=A=>(t==null?void 0:t.models)&&t.models[A]||"",b=A=>{const N=(t==null?void 0:t.permissionPolicies)&&t.permissionPolicies[A];if(N==="standard"||N==="unsafe")return N;const U=u.find(P=>P.id===A);return U?U.policyDefault:"standard"},[x,L]=w.useState(v),[k,R]=w.useState((t==null?void 0:t.model)||""),S=(t==null?void 0:t.permissionPolicy)==="standard"||(t==null?void 0:t.permissionPolicy)==="unsafe"?t.permissionPolicy:((T=t==null?void 0:t.permissionPolicies)==null?void 0:T[t==null?void 0:t.engine])||"",[j,E]=w.useState(S),[F,$]=w.useState((t==null?void 0:t.boot)??!0),[G,K]=w.useState(!1),[Y,te]=w.useState(null);w.useEffect(()=>{u.length&&(L(A=>A||v),R(A=>A||_((t==null?void 0:t.engine)||v)||""),E(A=>A==="standard"||A==="unsafe"?A:b((t==null?void 0:t.engine)||v)))},[u.length]);const q=w.useMemo(()=>u.find(A=>A.id===x)||null,[u,x]),D=!!(q&&["claude","codex","codex-vl","agy","kimi"].includes(q.client)),I=(q==null?void 0:q.client)==="shell";function O(A){L(A);const N=u.find(U=>U.id===A);R(_(A)||(N==null?void 0:N.defaultModel)||""),E(b(A))}async function M(A){A.preventDefault(),K(!0),te(null);try{if(a)await s({action:"down",boot:F});else{const N=j==="standard"||j==="unsafe"?j:(q==null?void 0:q.policyDefault)||"standard";await s({action:"up",...f?{engine:x,model:k||"",...D?{permissionPolicy:N}:(q==null?void 0:q.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:F})}i()}catch(N){te(String(N&&N.message||N)),K(!1)}}return l.jsx("div",{className:"nc-sheet-overlay nc-launch-overlay",onClick:i,children:l.jsxs("form",{className:"nc-sheet nc-power-sheet nc-launch-sheet",onClick:A=>A.stopPropagation(),onSubmit:M,children:[l.jsxs("div",{className:"nc-sheet-head",children:[l.jsx("b",{children:t==null?void 0:t.cell}),l.jsx("span",{className:"nc-sheet-state",children:p(a?"state-on":"state-off")})]}),a?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:p("engine")}),l.jsx("b",{children:(t==null?void 0:t.engine)||"—"}),(t==null?void 0:t.model)&&l.jsxs("small",{children:[p("model"),": ",t.model]}),l.jsx("small",{children:p("power-on-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:F,onChange:A=>$(A.target.checked)}),p("remove-boot")]})]}):l.jsxs(l.Fragment,{children:[f&&u.length>0?l.jsxs("div",{className:"nc-launch-fields",children:[l.jsxs("label",{className:"nc-field",children:[p("engine"),l.jsx("select",{value:x,onChange:A=>O(A.target.value),children:u.map(A=>l.jsx("option",{value:A.id,children:A.label},A.id))})]}),!I&&l.jsxs("label",{className:"nc-field",children:[p("model"),l.jsx("input",{value:k,list:"nc-launch-models",placeholder:p("model-default"),onChange:A=>R(A.target.value)}),l.jsx("datalist",{id:"nc-launch-models",children:((q==null?void 0:q.models)||[]).map(A=>l.jsx("option",{value:A},A))})]}),D?l.jsxs("label",{className:"nc-field",children:[p("permissions"),l.jsxs("select",{value:j,onChange:A=>E(A.target.value),children:[l.jsx("option",{value:"standard",children:p("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:p("fleet-unsafe-permissions")})]})]}):l.jsx("small",{className:"nc-note",children:p("fleet-standard-permissions")}),D&&j==="unsafe"&&l.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),l.jsx("small",{className:"nc-note",children:p(I?"fleet-shell-launch-help":"launch-engine-help")})]}):l.jsxs("div",{className:"nc-power-config",children:[l.jsx("span",{children:p("engine")}),l.jsx("b",{children:(t==null?void 0:t.engine)||"—"}),(t==null?void 0:t.model)&&l.jsxs("small",{children:[p("model"),": ",t.model]}),l.jsx("small",{children:p("launch-unavailable-hint")})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:F,onChange:A=>$(A.target.checked)}),p("boot-persist")]})]}),Y&&l.jsx("div",{className:"nc-err",children:Y}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:i,children:p("cancel")}),l.jsx("button",{type:"submit",className:"nc-btn primary",disabled:G,children:p(G?a?"power-stopping":"power-starting":a?"power-off":"save-and-start")})]})]})})}const k0=/^[a-z0-9-]{1,32}$/;function qa(t,e){const n=Array.isArray(t)?t:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${e}`:String(e)}function qT(t,e,n){const s={};for(const i of Array.isArray(e)?e:[]){const a=Array.isArray(i==null?void 0:i.route)?i.route:typeof(i==null?void 0:i.name)=="string"?[i.name]:[];if(!a.length)continue;const c=a.join("/"),u=i.status==="up"||i.tunnel&&i.tunnel.status==="up",h=i.status==="passive"||i.tunnel&&i.tunnel.status==="passive";!u&&!h&&i.status!=="pending"&&!i.checking&&(s[c]=t&&t[c]||n)}return s}function pg(t,e,n,s=!1){return!t||!Array.isArray(t.cells)?[]:t.cells.map(i=>({...i,route:e,key:`${n}:${i.tmuxSession||i.cell}`,...s?{preserved:!0}:{}}))}function Vl(t,e,n){if(!t)return{};const s=mg(t);return!hc(t,s)||s!=="stale"?{}:{cells:pg(t,e,n,!0),fleetState:"stale",fleetAvailable:!1,cellsPreserved:!0}}function mg(t){return(t==null?void 0:t.fleetState)==="stale"?"stale":(t==null?void 0:t.fleetState)==="disabled"?"disabled":(t==null?void 0:t.available)===!0&&Array.isArray(t.cells)?"available":(t==null?void 0:t.available)===!1?"disabled":"stale"}function hc(t,e){return(e==="available"||e==="stale")&&Array.isArray(t==null?void 0:t.cells)}function C0(t,e){const n=t?e&&e.at:e&&e.lastGoodAt;return Number.isFinite(n)?n:null}function E0({nodes:t,topology:e,remote:n,down:s,fleet:i,aliases:a,pendingReads:c,previousGroups:u}={}){var x,L,k,R;const h=[],f=new Set,g=new Set,v=(S,j)=>!!(c&&(c.has(S)||c.has(`${S}#${j}`))),_=(S,j,E)=>Array.isArray(u)?u.find(F=>F.name===j&&F.instanceId===E&&(Array.isArray(F.route)?F.route.join("/"):"")===S):null;function b(S,j){const E=_(S,j.name,j.instanceId),F=v(S,"sessions"),$=v(S,"fleet"),G=(n==null?void 0:n[S])||(F&&E?{sessions:E.sessionsAvailable?E.sessions:void 0,at:E.verifiedAt,lastGoodAt:E.verifiedAt,...E.sessionsAvailable===!1&&E.cause?{cause:E.cause}:{}}:null),K=(i==null?void 0:i[S])||($&&E?{available:E.fleetAvailable,cells:E.cells,fleetState:E.fleetState,capabilities:E.capabilities,engines:E.engines,provider:E.fleetProvider,cellsPreserved:E.cellsPreserved,...E.fleetState==="stale"&&E.cause?{cause:E.cause}:{}}:null);return(F||$)&&(j.checking=!0,j.sessionsPending=F,j.fleetPending=$),{r:G,f:K,previous:E,pending:F||$,rereading:E&&(F||$)&&!(n!=null&&n[S])&&!(i!=null&&i[S])}}for(const S of Array.isArray(t)?t:[]){if(!S||typeof S.name!="string"||!k0.test(S.name)||S.direction==="inbound"&&S.shared!==!0)continue;const j=[S.name],E=S.name;f.add(E);const F=((x=S.tunnel)==null?void 0:x.status)||"unknown",$=F==="up",G={name:S.name,label:S.label||S.name,originalLabel:S.label||S.name,alias:null,route:j,direct:!0,instanceId:S.nodeId||null,shared:S.shared===!0,stale:S.stale===!0,tunnelStatus:F,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&&g.add(S.nodeId),!S.nodeId&&S.paired===!1){h.push({...G,status:"needs-repair",downSince:s&&s[E]||null,...Vl(i&&(i[E]||i[S.name]),j,E)});continue}if(((L=S.health)==null?void 0:L.auth)==="failed"||F==="degraded"&&((k=S.health)==null?void 0:k.status)==="degraded"){h.push({...G,status:"needs-repair",downSince:s&&s[E]||null,...Vl(i&&(i[E]||i[S.name]),j,E)});continue}if(F==="passive"||((R=S.health)==null?void 0:R.status)==="passive"){h.push({...G,status:"passive",downSince:null,...Vl(i&&(i[E]||i[S.name]),j,E)});continue}if(!$){h.push({...G,status:"down",downSince:s&&s[E]||null,...Vl(i&&(i[E]||i[S.name]),j,E)});continue}const{r:K,f:Y,previous:te,pending:q,rereading:D}=b(E,G);if(D){h.push({...te,checking:!0,sessionsPending:G.sessionsPending,fleetPending:G.fleetPending});continue}const I=!!(K&&!K.error&&Array.isArray(K.sessions)),O=mg(Y),M=O==="available"&&hc(Y,O),z=hc(Y,O);if(q&&!K&&!Y){h.push({...G,status:(te==null?void 0:te.status)||"pending",pendingRead:!0,verifiedAt:(te==null?void 0:te.verifiedAt)??null});continue}if(!I&&!z){h.push({...G,status:q?(te==null?void 0:te.status)||"pending":"unreachable",cause:K&&K.cause||null});continue}const T=(I?K.sessions:[]).filter(U=>U&&typeof U.name=="string"&&U.name).map(U=>({...U,node:E,route:j,key:`${E}:${U.name}`})),A=pg(Y,j,E),N=new Set(A.map(U=>U.tmuxSession).filter(Boolean));h.push({...G,status:"up",sessions:T,cells:A,unmanaged:T.filter(U=>!N.has(U.name)),fleetAvailable:M,fleetState:O,...Y!=null&&Y.cellsPreserved?{cellsPreserved:!0}:{},...K!=null&&K.cause||Y!=null&&Y.cause?{cause:(K==null?void 0:K.cause)||(Y==null?void 0:Y.cause)}:{},capabilities:Y&&Y.capabilities||[],engines:Y&&Y.engines||[],fleetProvider:Y&&Y.provider||null,sessionsAvailable:I,inventoryPartial:!I,verifiedAt:C0(I,K)})}for(const S of Array.isArray(e)?e:[]){if(!S||!Array.isArray(S.route)||S.route.length<1||S.route.some(N=>!k0.test(N)))continue;const j=S.route.join("/");if(f.has(j)||S.instanceId&&g.has(S.instanceId))continue;S.instanceId&&g.add(S.instanceId);const E=S.label||S.route.join(" › "),F=S.instanceId&&a&&typeof a[S.instanceId]=="string"?a[S.instanceId]:null,$={name:S.name,label:F||E,originalLabel:E,alias:F,route:[...S.route],direct:!1,instanceId:S.instanceId||null,shared:!0,stale:S.stale===!0,tunnelStatus:null,sessions:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:S.health||null,lastSeen:S.lastSeen||null};if(S.stale){h.push({...$,status:"offline",downSince:s&&s[j]||S.lastSeen||null,...Vl(i&&i[j],S.route,j)});continue}const{r:G,f:K,previous:Y,pending:te,rereading:q}=b(j,$);if(q){h.push({...Y,checking:!0,sessionsPending:$.sessionsPending,fleetPending:$.fleetPending});continue}const D=!!(G&&!G.error&&Array.isArray(G.sessions)),I=mg(K),O=I==="available"&&hc(K,I),M=hc(K,I);if(te&&!G&&!K){h.push({...$,status:(Y==null?void 0:Y.status)||"pending",pendingRead:!0,verifiedAt:(Y==null?void 0:Y.verifiedAt)??null});continue}if(!D&&!M){h.push({...$,status:te?(Y==null?void 0:Y.status)||"pending":"unreachable",downSince:s&&s[j]||null,cause:G&&G.cause||null});continue}const z=(D?G.sessions:[]).filter(N=>N&&typeof N.name=="string"&&N.name).map(N=>({...N,node:j,route:S.route,key:`${j}:${N.name}`})),T=pg(K,S.route,j),A=new Set(T.map(N=>N.tmuxSession).filter(Boolean));h.push({...$,status:"up",sessions:z,cells:T,unmanaged:z.filter(N=>!A.has(N.name)),fleetAvailable:O,fleetState:I,...K!=null&&K.cellsPreserved?{cellsPreserved:!0}:{},...G!=null&&G.cause||K!=null&&K.cause?{cause:(G==null?void 0:G.cause)||(K==null?void 0:K.cause)}:{},capabilities:K&&K.capabilities||[],engines:K&&K.engines||[],fleetProvider:K&&K.provider||null,lastSeen:S.lastSeen||null,sessionsAvailable:D,inventoryPartial:!D,verifiedAt:C0(D,G)})}return h.sort((S,j)=>S.label.localeCompare(j.label))}const gg="nc_route_alias_v1",KT="nexuscrew-roster-preferences",N0="nc_pins",VT=/^[a-f0-9]{16,64}$/;let yv=new Map;const YT=t=>Array.isArray(t==null?void 0:t.route)&&t.route.length?t.route.join("/"):String((t==null?void 0:t.name)||"");function bp(t,e=yv){if(t==="local"||typeof t!="string")return t;const n=e.get(t);return n?`id:${n}`:t}const R0=(t,e,n)=>typeof t=="string"&&t.startsWith(`${e}:`)?`${n}:${t.slice(e.length+1)}`:t,L0=t=>[...new Set(t)];function Sp(t,e){return Lr(t,{storage:e,fallback:()=>({}),parse:n=>n&&typeof n=="object"&&!Array.isArray(n)?n:void 0})}function ja(t,e=yv){const n={...t||{}};for(const[s,i]of e)t&&t[`id:${i}`]!==void 0&&(n[s]=t[`id:${i}`]);return n}function GT(t,{storage:e=globalThis.localStorage}={}){const n=new Map,s=new Map;for(const L of Array.isArray(t)?t:[]){const k=String((L==null?void 0:L.instanceId)||""),R=YT(L);if(!(VT.test(k)&&R)||n.has(R))continue;n.set(R,k);const S=L.status==="up"&&L.stale!==!0;(!s.has(k)||S&&!s.get(k).up)&&s.set(k,{name:R,up:S})}if(yv=n,!n.size)return!1;const i=Sp(gg,e);let a=Sp(Qo,e),c=Sp(Jo,e),u=Lr(N0,{storage:e,fallback:()=>[],parse:L=>Array.isArray(L)?L:void 0});const h={...i},f={...a},g={...c};let v=[...u];const _={aliases:!1,orders:!1,views:!1,pins:!1};for(const[L,{name:k}]of s){const R=`id:${L}`,S=typeof i[L]=="string"?i[L]:"",j=S&&S!==k&&(!n.has(S)||n.get(S)===L)?S:"";j&&(v=L0([...v,...u.filter(E=>E.startsWith(`${j}:`)).map(E=>R0(E,j,k))]),_.pins=_.pins||v.length!==u.length);for(const[E,F,$]of[[a,f,"orders"],[c,g,"views"]]){const G=E[R]!==void 0?E[R]:j&&E[j]!==void 0?E[j]:E[k];if(G===void 0)continue;let K=G;$==="orders"&&Array.isArray(K)&&(K=L0(K.map(Y=>j?R0(Y,j,k):Y))),JSON.stringify(F[R])!==JSON.stringify(K)&&(F[R]=K,_[$]=!0)}i[L]!==k&&(h[L]=k,_.aliases=!0),j&&Ji({reason:"route-renamed",key:L,note:`${j} -> ${k}`})}const b=[];_.pins&&b.push(yi(N0,v,{storage:e})),_.orders&&b.push(yi(Qo,f,{storage:e})),_.views&&b.push(yi(Jo,g,{storage:e})),_.aliases&&b.push(yi(gg,h,{storage:e}));const x=Object.values(_).some(Boolean);if(x)try{window.dispatchEvent(new Event(KT))}catch{}return x&&b.every(L=>!L)}const kk="nc_last_roster_v1",XT=64,JT=["cell","tmuxSession","engine","model","label","boot"],Ck=t=>Lr(kk,{storage:t,fallback:()=>({}),parse:e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0});function Ka(t,e,n=globalThis.localStorage){if(!t)return;const s={...Ck(n)};!Array.isArray(e)||!e.length?delete s[t]:s[t]={at:Date.now(),cells:e.slice(0,XT).filter(i=>i&&typeof i.cell=="string").map(i=>Object.fromEntries(JT.filter(a=>i[a]!==void 0&&i[a]!==null).map(a=>[a,i[a]])))},yi(kk,s,{storage:n})}function wv(t,e=globalThis.localStorage){const n=t?Ck(e)[t]:null;return!n||!Array.isArray(n.cells)?[]:n.cells.map(s=>({...s,tmux:!1,active:!1,preserved:!0,degraded:!1}))}function Ek(t,e={}){if(!t||typeof t!="object")return null;const n=typeof t.nodeId=="string"?t.nodeId:"";if(!n)return null;const s=typeof t.label=="string"&&t.label.trim()||typeof t.cell=="string"&&t.cell.trim()||n,i=Array.isArray(e.route)?[...e.route]:[];return{kind:"vl",nodeId:n,name:n,label:s,cell:t.cell??null,paired:!!t.pairedAt,online:!!t.online,lastSeen:t.lastSeen??null,generation:t.generation??null,version:t.version??null,health:t.health??null,session:t.session??null,capabilities:Array.isArray(t.capabilities)?t.capabilities:[],inflight:t.inflight??null,lastAck:t.lastAck??null,canManage:!!t.canManage,route:i,isLocal:i.length===0,ownerInstanceId:typeof e.instanceId=="string"?e.instanceId:null,ownerLabel:typeof e.label=="string"&&e.label?e.label:null}}function QT(t){var n;const e=[];for(const s of Array.isArray(t)?t:[]){if(!s||s.kind!=="vl"||!s.nodeId)continue;const i=s.online===!0,a=i&&((n=s.session)==null?void 0:n.attached)===!0,c=s.ownerInstanceId||"local";e.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:i?"up":"offline",downSince:i?null:s.lastSeen??null,sessions:a?[{key:`vl:${c}:${s.nodeId}`,name:s.session.profile,attached:!0}]:[],cells:[],unmanaged:[],fleetAvailable:!1,capabilities:[],engines:[],health:s.health??null,stale:s.stale===!0,fleetState:s.stale===!0?"stale":null,peer:s})}return e}function Nk(t,e){const n=t&&Array.isArray(t.nodes)?t.nodes:[],s=new Set([e]),i=[];for(const a of n){const c=a&&typeof a.instanceId=="string"?a.instanceId:"";if(!c||s.has(c)||a.stale===!0||!Array.isArray(a.route)||a.route.length===0)continue;s.add(c);const u=typeof a.label=="string"&&a.label||typeof a.name=="string"&&a.name||a.route.join(" › ");i.push({instanceId:c,route:[...a.route],label:u})}return i}const ZT=/fleet\.json/;function bv({fs:t=null,error:e=null}={}){if(e)return{kind:"stale"};if(!t)return{kind:"stale"};if(t.available===!0)return{kind:"data",cells:t.cells||[],capabilities:t.capabilities||[]};const n=typeof t.reason=="string"?t.reason:"";return typeof t.migrationCode=="string"&&t.migrationCode?{kind:"disabled",reason:n||null}:ZT.test(n)?{kind:"stale"}:{kind:"disabled",reason:n||null}}const Rk={baseMs:4e3,capMs:6e4},Lk="peer-assente",Ak="peer-nega",jk="rotta-inesistente";function xp(t){const e=t&&t.status;return e===403?Ak:e===404?jk:Lk}function eP(t,{baseMs:e,capMs:n}=Rk){return!Number.isFinite(t)||t<1?0:Math.min(e*2**(t-1),n)}function A0(t,e,n){const s=t&&t[e];return!s||!(s.failures>=1)?!0:n>=s.nextAtMs}function j0(t,e,n,s,i=Rk){const c=(t&&t[e]||{failures:0}).failures+1;return{...t,[e]:{failures:c,cause:n,nextAtMs:s+eP(c,i)}}}function M0(t,e){if(!t||!(e in t))return t;const n={...t};return delete n[e],n}const tP=4e3,Sv=600*1e3,Mk="nc-sticky-owners-v1";function nP(){try{const t=localStorage.getItem(Mk);if(!t)return null;const e=JSON.parse(t);return!e||!Array.isArray(e.nodes)||!Array.isArray(e.topology)?null:e}catch{return null}}function sP(t){try{localStorage.setItem(Mk,JSON.stringify(t))}catch{}}function ed(t,e,n,s,i){if(!e){for(const c of t.values())c.data={...c.data,stale:!0};return t}const a=new Map(n.map(c=>[s(c),c]));for(const[c,u]of t)a.has(c)?(u.data=a.get(c),u.missingSince=null,a.delete(c)):(u.missingSince??(u.missingSince=i),i-u.missingSince>Sv?t.delete(c):u.data={...u.data,stale:!0});for(const[c,u]of a)t.set(c,{data:u,missingSince:null});return t}function xv(t,e=!0,n=0){const[s,i]=w.useState([]),a=w.useRef([]),c=w.useRef({}),u=w.useRef({}),h=w.useRef({remote:{},fleet:{}}),f=w.useRef(null),g=w.useRef(null),v=w.useRef(new Map),_=w.useRef(new Map),b=w.useRef(new Set),x=w.useRef(eh()),L=w.useRef(null);return w.useEffect(()=>{if(!e||!t){i([]);return}let k=!0;const R=f.current!==null&&f.current!==t;f.current!==t&&(f.current=t,u.current={},h.current={remote:{},fleet:{}},v.current.clear(),_.current.clear(),b.current.clear(),c.current={},a.current=[],i([]));const S={instanceId:"",nodes:new Map,topology:new Map},j=R?null:nP();if(j){S.instanceId=j.instanceId||"";for(const $ of j.nodes)S.nodes.set($.name,{data:$,missingSince:null});for(const $ of j.topology)S.topology.set($.route.join("/"),{data:$,missingSince:null})}async function E(){const $=x.current,G=Date.now(),K=$.begin();if(K===null)return;const Y=new AbortController;L.current=Y;const te={timeoutMs:x1,signal:Y.signal},q=()=>k&&$.isCurrent(K);let D=[],I=[],O={},M="",z=!1,T=!1,A="pending",N="pending";const U={},P={},H=new Set,ie=new Set,J=new Set;let Q=new Map;const ve=[],de=()=>{Q=new Map([...I.filter(Re=>Array.isArray(Re.route)).map(Re=>[Re.route.join("/"),Re.instanceId]),...D.map(Re=>[Re.name,Re.nodeId])].filter(([,Re])=>typeof Re=="string"&&Re))},ne=Re=>{const _e=Q.get(Re),st=_e?wv(`id:${_e}`):[];return st.length?{available:!1,cells:st,fleetState:"stale"}:null},xe=()=>{if(!q()||!M)return!1;const Re=[],_e=Date.now();for(const[He,Ke]of _.current){if(_e-Ke.at>Sv){_.current.delete(He);continue}const wt=He.slice(3),fe=v.current.get(wt);if(Ke.ownerInstanceId!=null&&fe!==void 0&&fe!==Ke.ownerInstanceId){_.current.delete(He);continue}const he=b.current.has(He.slice(3)),Z=Ke.round!==K||Ke.identityUnknown===!0||he;for(const X of Ke.peers)Re.push({...X,stale:Z})}const st=a.current,Xe=E0({nodes:D,topology:I,remote:U,fleet:P,aliases:O,down:c.current,pendingReads:H,previousGroups:st});c.current=qT(c.current,Xe,Math.floor(Date.now()/1e3));const De=[...E0({nodes:D,topology:I,remote:U,fleet:P,aliases:O,down:c.current,pendingReads:H,previousGroups:a.current}),...QT(Re)];return GT(De),a.current=De,i(De),!0};let $e=[],rt=[];const je=()=>{var Re;if(q()&&M){z?ed(S.nodes,!0,$e,_e=>_e&&_e.name,G):A==="error"&&ed(S.nodes,!1,$e,_e=>_e&&_e.name,G),T?ed(S.topology,!0,rt,_e=>Array.isArray(_e&&_e.route)?_e.route.join("/"):"",G):N==="error"&&ed(S.topology,!1,rt,_e=>Array.isArray(_e&&_e.route)?_e.route.join("/"):"",G),D=[...S.nodes.values()].map(_e=>_e.data),I=[...S.topology.values()].map(_e=>_e.data),de();for(const[_e,st]of Q){const Xe=v.current.get(_e);Xe&&Xe!==st&&(delete h.current.remote[_e],delete h.current.fleet[_e],delete u.current[_e],delete u.current[`vl:${_e}`],delete c.current[_e],_.current.delete(`vl:${_e}`)),v.current.set(_e,st)}for(const _e of v.current.keys())if(!Q.has(_e)){const st=_.current.get(`vl:${_e}`);st&&(st.identityUnknown=!0)}b.current=new Set(I.filter(_e=>!_e.stale&&Array.isArray(_e.route)&&_e.route.length>0&&!Q.has(_e.route.join("/"))).map(_e=>_e.route.join("/")));for(const _e of D){if(((Re=_e.tunnel)==null?void 0:Re.status)==="up")continue;const st=h.current.fleet[_e.name];st&&!P[_e.name]&&(P[_e.name]={...st,available:!1,fleetState:"stale"})}for(const _e of I){if(!_e.stale||!Array.isArray(_e.route)||!_e.route.length)continue;const st=_e.route.join("/"),Xe=h.current.fleet[st];Xe&&!P[st]&&(P[st]={...Xe,available:!1,fleetState:"stale"})}(z||T)&&sP({instanceId:S.instanceId,savedAt:G,nodes:[...S.nodes.values()].map(_e=>_e.data),topology:[...S.topology.values()].map(_e=>_e.data)}),V(),xe()}},Ie=(Re,_e)=>{q()&&(A=Re?"success":"error",z=Re,$e=Re?_e:[],je())},oe=(Re,_e)=>{q()&&(N=Re?"success":"error",T=Re,rt=Re?_e:[],je())},Ne=Re=>{q()&&(M=Re&&typeof Re.instanceId=="string"?Re.instanceId:"",M&&(S.instanceId!==M||g.current!==M)?(S.instanceId!==M&&(S.nodes.clear(),S.topology.clear()),a.current=[],c.current={},u.current={},h.current={remote:{},fleet:{}},v.current.clear(),_.current.clear(),b.current.clear()):M&&(S.instanceId=M),g.current=M||null,S.instanceId=M,je())};function me(){const Re=[{instanceId:M||null,route:[],label:null},...Nk({nodes:I},M)];for(const _e of Re){const st=`${_e.instanceId}:${_e.route.join("/")}`;if(J.has(st))continue;J.add(st);const Xe=`vl:${_e.route.join("/")}`;ve.push((async()=>{if(A0(u.current,Xe,G))try{const De=await M1(t,_e.route,{signal:Y.signal});if(!q())return;const He=v.current.get(_e.route.join("/"));if(He!==void 0&&He!==_e.instanceId||b.current.has(_e.route.join("/")))return;u.current=M0(u.current,Xe);const Ke=[];for(const wt of De.nodes||[]){const fe=Ek(wt,_e);fe&&Ke.push(fe)}_.current.set(Xe,{peers:Ke,ownerInstanceId:_e.instanceId??null,at:G,round:K}),xe()}catch(De){if(!q())return;const He=v.current.get(_e.route.join("/"));if(He!==void 0&&He!==_e.instanceId||b.current.has(_e.route.join("/")))return;u.current=j0(u.current,Xe,xp(De),G)}})())}}async function Ce(Re){const _e=Re.join("/"),st=h.current.remote[_e]||null;if(!A0(u.current,_e,G)){H.delete(`${_e}#sessions`),H.delete(`${_e}#fleet`);const He=u.current[_e];U[_e]={error:"unreachable",cause:He&&He.cause||null,lastGoodAt:st?st.at:null};const Ke=h.current.fleet[_e]||ne(_e);Ke&&(P[_e]={...Ke,available:!1,fleetState:"stale"});return}H.add(`${_e}#sessions`),H.add(`${_e}#fleet`);const Xe=(async()=>{let He=!1;try{const Ke=await Qg(t,Re,te);if(!q())return;He=!0,U[_e]={...Ke,at:G},h.current.remote[_e]={payload:Ke,at:G}}catch(Ke){if(!q())return;U[_e]={error:"unreachable",cause:xp(Ke),lastGoodAt:st?st.at:null}}finally{H.delete(`${_e}#sessions`)}u.current=He?M0(u.current,_e):j0(u.current,_e,U[_e].cause,G),xe()})(),De=(async()=>{const He=h.current.fleet[_e]||ne(_e);try{const Ke=await Qa(t,Re,te);if(!q())return;const wt=bv({fs:Ke});wt.kind==="data"?(P[_e]={...Ke,available:!0,cells:wt.cells,fleetState:"available"},Q.get(_e)&&Ka(`id:${Q.get(_e)}`,wt.cells)):wt.kind==="disabled"?(P[_e]={...Ke,available:!1,cells:[],fleetState:"disabled"},Q.get(_e)&&Ka(`id:${Q.get(_e)}`,[])):P[_e]={...He||{},available:!1,cells:Array.isArray(He==null?void 0:He.cells)?He.cells:[],fleetState:"stale",...Ke!=null&&Ke.reason?{reason:Ke.reason}:{}},h.current.fleet[_e]=P[_e]}catch(Ke){if(!q())return;P[_e]={...He||{},available:!1,cells:Array.isArray(He==null?void 0:He.cells)?He.cells:[],fleetState:"stale",cause:xp(Ke)},h.current.fleet[_e]=P[_e]}H.delete(`${_e}#fleet`),xe()})();await Promise.allSettled([Xe,De])}function V(){var st,Xe;if(!q()||!M)return;me();const Re=new Set(D.map(De=>De.name)),_e=De=>{const He=De.join("/");ie.has(He)||(ie.add(He),ve.push(Ce(De)))};for(const De of D)z&&!De.stale&&((st=De.tunnel)==null?void 0:st.status)==="up"&&(De.nodeId||De.paired!==!1)&&(De.direction!=="inbound"||De.shared===!0)?_e([De.name]):A==="pending"&&!De.stale&&((Xe=De.tunnel)==null?void 0:Xe.status)==="up"&&(H.add(`${De.name}#sessions`),H.add(`${De.name}#fleet`));for(const De of I)if(!De.stale&&Array.isArray(De.route)&&De.route.length>0&&!(De.route.length===1&&Re.has(De.route[0]))){const He=De.route.join("/");T?_e(De.route):N==="pending"&&(H.add(`${He}#sessions`),H.add(`${He}#fleet`))}}const ge=ON(t,te).then(Re=>{Ie(!0,Array.isArray(Re.nodes)?Re.nodes:[])},()=>{Ie(!1,[])}),Le=T1(t,te).then(Re=>{oe(!0,Array.isArray(Re.nodes)?Re.nodes:[])},()=>{oe(!1,[])}),ke=WN(t,te).then(Re=>{q()&&(O=Re&&typeof Re.aliasesByInstanceId=="object"?Re.aliasesByInstanceId:{},xe())},()=>{}),We=Ic(t,[],te).then(Re=>{Ne(Re)},()=>{});try{await Promise.allSettled([ge,Le,ke,We]),await Promise.allSettled(ve)}finally{$.isCurrent(K)&&$.end(K)}}E();const F=setInterval(E,tP);return()=>{k=!1,clearInterval(F),x.current.reset(),L.current&&L.current.abort()}},[t,e,n]),s}const T0=52,P0=14;function Gi({position:t,itemKey:e,label:n,onMove:s,onStep:i,canMove:a=()=>!0,scope:c="roster"}){const u=w.useRef(null),h=w.useRef(0),[f,g]=w.useState(!1),v=()=>{var R,S,j,E;const k=u.current;(S=(R=k==null?void 0:k.over)==null?void 0:R.classList)==null||S.remove("nc-roster-over"),(E=(j=k==null?void 0:k.source)==null?void 0:j.classList)==null||E.remove("nc-roster-dragging"),h.current&&cancelAnimationFrame(h.current),h.current=0},_=(k=!1)=>{const R=u.current;if(!R)return;const S=R.target;v(),u.current=null,g(!1);try{R.handle.releasePointerCapture(R.pointerId)}catch{}k&&S&&S!==e&&a(e,S)&&s(e,S)},b=(k,R)=>{var K,Y,te,q,D,I,O,M,z;const S=u.current;if(!S)return;S.x=k,S.y=R;const j=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",E=(Y=(K=document.elementFromPoint(k,R))==null?void 0:K.closest)==null?void 0:Y.call(K,j),F=c==="node"?(te=E==null?void 0:E.dataset)==null?void 0:te.nodeOrderKey:(q=E==null?void 0:E.dataset)==null?void 0:q.rosterKey,G=(c==="node"||((D=E==null?void 0:E.dataset)==null?void 0:D.position)===t)&&F&&F!==e&&a(e,F);S.over!==(G?E:null)&&((O=(I=S.over)==null?void 0:I.classList)==null||O.remove("nc-roster-over"),S.over=G?E:null,(z=(M=S.over)==null?void 0:M.classList)==null||z.add("nc-roster-over")),S.target=G?F:null},x=()=>{const k=u.current;if(!k){h.current=0;return}const R=k.container;if(R){const S=R.getBoundingClientRect(),j=k.y<S.top+T0?-P0:k.y>S.bottom-T0?P0:0;j&&(R.scrollTop+=j,b(k.x,k.y))}h.current=requestAnimationFrame(x)};w.useEffect(()=>{const k=S=>{S.key==="Escape"&&u.current&&(S.preventDefault(),_(!1))},R=()=>_(!1);return window.addEventListener("keydown",k),window.addEventListener("blur",R),()=>{window.removeEventListener("keydown",k),window.removeEventListener("blur",R),v(),u.current=null}},[e,t,c]);const L=k=>{var E;if(k.pointerType==="mouse"&&k.button!==0)return;k.preventDefault(),k.stopPropagation(),k.currentTarget.focus({preventScroll:!0});const R=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",S=k.currentTarget.closest(R),j=k.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");u.current={pointerId:k.pointerId,handle:k.currentTarget,source:S,container:j,target:null,over:null,x:k.clientX,y:k.clientY},(E=S==null?void 0:S.classList)==null||E.add("nc-roster-dragging");try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}g(!0),h.current=requestAnimationFrame(x)};return l.jsx("button",{type:"button",className:`nc-roster-handle${f?" active":""}`,"aria-label":`${p("reorder")} ${n}`,"aria-keyshortcuts":"ArrowUp ArrowDown",title:p("reorder-help"),onClick:k=>{k.preventDefault(),k.stopPropagation()},onDragStart:k=>k.preventDefault(),onKeyDown:k=>{k.key!=="ArrowUp"&&k.key!=="ArrowDown"||(k.preventDefault(),k.stopPropagation(),i(k.key==="ArrowUp"?-1:1))},onPointerDown:L,onPointerMove:k=>{!u.current||k.pointerId!==u.current.pointerId||(k.preventDefault(),k.stopPropagation(),b(k.clientX,k.clientY))},onPointerUp:k=>{!u.current||k.pointerId!==u.current.pointerId||(k.preventDefault(),k.stopPropagation(),_(!0))},onPointerCancel:()=>_(!1),onLostPointerCapture:()=>{u.current&&_(!1)},children:"↕"})}const Tk="nc_pins";function no(){return Lr(Tk,{fallback:()=>[],parse:t=>Array.isArray(t)?t:void 0})}function kv(t){return yi(Tk,t)}function iP(t,e){const n=t.includes(e)?t.filter(s=>s!==e):[...t,e];return{next:n,error:kv(n)}}function I0(t,e){if(!Array.isArray(t)||!t.includes(e))return{next:Array.isArray(t)?t:[],error:null};const n=t.filter(s=>s!==e);return{next:n,error:kv(n)}}function rP(t,e,n){if(!t.includes(e)||!t.includes(n)||e===n)return t;const s=[...t],i=s.indexOf(e),a=s.indexOf(n);s.splice(i,1);const c=s.indexOf(n);return s.splice(i<a?c+1:c,0,e),kv(s),s}function oP(t,e,n){const s=t.indexOf(e);return[s===-1?1e9:s,-(n||0)]}function aP(t,e){return t[0]-e[0]||t[1]-e[1]}const vg="nexuscrew-roster-preferences",lP=new Set(["nc_pins",Qo,Jo,gg]),Ma=()=>{try{window.dispatchEvent(new Event(vg))}catch{}},cP=(t,e)=>JSON.stringify(t)===JSON.stringify(e),kp=t=>e=>cP(e,t)?e:t;function Cv(){const[t,e]=w.useState(no),[n,s]=w.useState(yd),[i,a]=w.useState(dc),[c,u]=w.useState(null),[h,f]=w.useState(null);w.useEffect(()=>{if(!h)return;const j=setTimeout(()=>f(null),8e3);return()=>clearTimeout(j)},[h]),w.useEffect(()=>{const j=E=>{E&&E.type==="storage"&&E.key&&!lP.has(E.key)||(e(kp(no())),a(kp(dc())),s(kp(yd())))};return window.addEventListener("storage",j),window.addEventListener(vg,j),()=>{window.removeEventListener("storage",j),window.removeEventListener(vg,j)}},[]);const g=j=>{const E=no(),F=iP(E,j);e(F.next),Ji({reason:F.error?"pin-write-failed":"pin",key:j,before:E,after:F.next,note:F.error?String(F.error.message||F.error):void 0}),Ma()},v=j=>{const E=no(),F=I0(E,j);return e(F.next),u(F.error?{key:j,message:F.error.message||String(F.error)}:null),Ji({reason:F.error?"unpin-write-failed":"unpin",key:j,before:E,after:F.next}),Ma(),F.error},_=()=>{if(!c)return;const j=I0(no(),c.key);e(j.next),u(j.error?{...c,message:j.error.message||String(j.error)}:null),Ma()},b=()=>u(null),x=j=>S0(ja(n),j),L=(j,E)=>{const F=yd(),$=bp(j),G=WT({...F,[$]:{...S0(ja(F),j),...E}});s(G),Ma()},k=(j,E)=>t.includes(j)===t.includes(E);function R(j,E,F,$){var A,N;const G=(A=$.find(U=>U.partial))==null?void 0:A.partial;if(G){f({reason:G,position:j,at:Date.now()}),Ji({reason:"reorder-blocked",position:bp(j),source:E,target:F,note:G});return}f(null);const K=no(),Y=K.includes(E),te=K.includes(F);if(Y!==te)return;if(Y){const U=rP(K,E,F);e(U),Ji({reason:"move-pin",source:E,target:F,before:K,after:U}),Ma();return}const q=dc(),D=bp(j),I=ja(q),O=((N=$.find(U=>U.key===E))==null?void 0:N.technical)===!0,M=kr($,K,O?"technical":"all",wi(I,j)).map(U=>U.key),z=UT({...q,[D]:wi(I,j)},D,E,F,M),T={...q,[D]:z[D]};HT(T),Ji({reason:"move",position:D,source:E,target:F,before:wi(I,j),after:z[D],visible:M}),a(T),Ma()}function S(j,E,F,$){var O;if($.some(M=>M.partial)){R(j,E,E,$);return}const G=no(),K=ja(dc()),Y=((O=$.find(M=>M.key===E))==null?void 0:O.technical)===!0,te=G.includes(E),q=kr($,G,Y?"technical":"all",wi(K,j)).map(M=>M.key).filter(M=>G.includes(M)===te),D=q.indexOf(E),I=q[D+F];D>=0&&I&&R(j,E,I,$)}return{pins:t,views:ja(n),orders:ja(i),togglePin:g,removePin:v,pinError:c,retryPinPersist:_,clearPinError:b,reorderBlocked:h,viewFor:x,updateView:L,canMoveRoster:k,moveRoster:R,stepRoster:S}}const lh="nc_node_order_v1",uP=/^[a-f0-9]{16,64}$/;function ao(t){if(uP.test(String((t==null?void 0:t.instanceId)||"")))return`id:${t.instanceId}`;const e=Array.isArray(t==null?void 0:t.route)?t.route.filter(n=>typeof n=="string"&&n):[];return e.length?`route:${e.map(encodeURIComponent).join("/")}`:typeof(t==null?void 0:t.name)=="string"&&t.name?`name:${encodeURIComponent(t.name)}`:""}function _g(t=globalThis.localStorage){return Lr(lh,{storage:t,fallback:()=>[],parse:e=>Array.isArray(e)?[...new Set(e.filter(n=>typeof n=="string"&&n&&n.length<=192))].slice(0,128):void 0})}function dP(t,e=globalThis.localStorage){return yi(lh,t,{storage:e}),t}function D0(t=[],e=[]){const n=new Map(e.map((s,i)=>[s,i]));return t.map((s,i)=>({group:s,index:i})).sort((s,i)=>{const a=n.has(ao(s.group))?n.get(ao(s.group)):Number.MAX_SAFE_INTEGER,c=n.has(ao(i.group))?n.get(ao(i.group)):Number.MAX_SAFE_INTEGER;return a-c||s.index-i.index}).map(({group:s})=>s)}function hP(t,e,n,s=[]){if(!e||!n||e===n)return t;const i=s.map(ao).filter(Boolean);if(!i.includes(e)||!i.includes(n))return t;const a=[...t,...i.filter(f=>!t.includes(f))],c=a.indexOf(e),u=a.indexOf(n);a.splice(c,1);const h=a.indexOf(n);return a.splice(c<u?h+1:h,0,e),a}const yg="nexuscrew-node-preferences";function fP(){try{window.dispatchEvent(new Event(yg))}catch{}}function ch(){const[t,e]=w.useState(_g);w.useEffect(()=>{const a=()=>e(_g());return window.addEventListener("storage",a),window.addEventListener(yg,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(yg,a)}},[]);const n=a=>D0(a,t),s=(a,c,u)=>e(h=>{const f=hP(h,a,c,u);return dP(f),fP(),f});return{order:t,groupsFor:n,moveNode:s,stepNode:(a,c,u)=>{const h=D0(u,t).map(ao),f=h.indexOf(a),g=h[f+c];f>=0&&g&&s(a,g,u)},nodeKey:ao}}function Pk({pinError:t,onRetry:e,onDismiss:n}){return t?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:e,children:"riprova"}),l.jsx("button",{type:"button",className:"nc-pin-error-close",onClick:n,"aria-label":"chiudi avviso",children:"×"})]}):null}function uh({item:t,pins:e,hostByRoute:n,route:s}){const i=(n||{})[Cs(s)]||{},a=Nd({hostCell:i.hostCell??null,threadStatus:i.threadStatus,pins:e,item:t}),c=I5(a);return{state:a,live:!!c,favorite:a==="favorite",filled:a!=="none",titleKey:c||"pin",action:a===U1?"removePin":"addPin"}}async function Ev({view:t,itemKey:e,togglePin:n,removePin:s}){return t.action==="removePin"?(s(e),{ok:!0}):(n(e),{ok:!0})}function lo({item:t,cellName:e,route:n=[],pins:s=[],hostByRoute:i={}}={}){const a=uh({item:t,pins:s,hostByRoute:i,route:n}),c=(i||{})[Cs(n)]||{};return{pinned:a.favorite,isLive:!!c.hostCell&&c.hostCell===e}}function Nv({isLive:t,pinned:e,canBoot:n,boot:s,alive:i,handlers:a={}}={}){const c=[];return typeof a.onToggleLive=="function"&&c.push({id:"live",kind:"action",on:!!t,labelKey:t?"cell-actions-live-remove":"cell-actions-live-assign",run:a.onToggleLive}),typeof a.onTogglePin=="function"&&c.push({id:"pin",kind:"action",on:!!e,labelKey:e?"cell-actions-unpin":"cell-actions-pin",run:a.onTogglePin}),n&&typeof a.onToggleBoot=="function"&&c.push({id:"boot",kind:"switch",on:!!s,labelKey:"cell-actions-boot",run:()=>a.onToggleBoot(!s)}),i&&typeof a.onWatchLive=="function"&&c.push({id:"watch",kind:"action",on:!1,labelKey:"cell-actions-watch",run:a.onWatchLive}),c}function Ik({items:t=[],busy:e=!1,onRun:n}){return l.jsx("div",{className:"nc-cellactions",role:"menu","aria-busy":e||void 0,children:t.map(s=>{const i=s.descKey?p(s.descKey):s.descText;return l.jsxs("button",{type:"button",role:s.kind==="switch"?"menuitemcheckbox":"menuitem","aria-checked":s.kind==="switch"?s.on?"true":"false":void 0,className:`nc-cellactions-voce${s.on?" on":""}`,disabled:e,"data-cellaction":s.id,onClick:a=>{a.stopPropagation(),n?n(s):s.run()},children:[s.kind==="switch"?l.jsx("span",{className:`nc-cellactions-toggle${s.on?" on":""}`,"aria-hidden":"true"}):null,l.jsxs("span",{className:"nc-cellactions-testo",children:[p(s.labelKey),i?l.jsx("small",{className:"nc-cellactions-desc",children:i}):null]})]},s.id)})})}function Dk({aperto:t,refGuscio:e,onClose:n}){w.useEffect(()=>{const s=a=>{e.current&&!e.current.contains(a.target)&&n()},i=a=>{a.key==="Escape"&&n()};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",i),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",i)}},[t,e,n])}function Ok({anchorRect:t,items:e,busy:n,onClose:s}){const i=w.useRef(null);Dk({aperto:!0,refGuscio:i,onClose:s});const a=t?{top:Math.min(t.bottom+6,window.innerHeight-8),left:Math.max(8,Math.min(t.right-210,window.innerWidth-218))}:void 0;return l.jsx("div",{className:"nc-cellactions-popover",style:a,ref:i,"data-testid":"cell-actions-popover",children:l.jsx(Ik,{items:e,busy:n,onRun:c=>{c.run(),s()}})})}function Rv({cellName:t,items:e,busy:n,onClose:s}){const i=w.useRef(null);return Dk({aperto:!0,refGuscio:i,onClose:s}),l.jsx("div",{className:"nc-cellactions-velo","data-testid":"cell-actions-sheet",children:l.jsxs("div",{className:"nc-cellactions-foglio",role:"dialog","aria-modal":"true","aria-label":p("cell-actions-title").replace("{cell}",t||""),ref:i,children:[l.jsxs("div",{className:"nc-cellactions-testa",children:[l.jsx("span",{className:"nc-cellactions-titolo",children:p("cell-actions-title").replace("{cell}",t||"")}),l.jsx("button",{type:"button",className:"nc-cellactions-chiudi",onClick:s,title:p("close"),"aria-label":p("close"),children:"✕"})]}),l.jsx(Ik,{items:e,busy:n,onRun:a=>{a.run(),s()}})]})})}const pP="native",mP="tmux";function gP(t){return typeof t!="string"||!t?null:t.startsWith("codex-vl")?pP:mP}function Va({liveHost:t,cells:e=[],localNodeId:n="",ownerId:s=null}={}){const i=t&&typeof t.hostCell=="string"&&t.hostCell?t.hostCell:null,a=i&&(Array.isArray(e)?e:[]).find(u=>u&&u.cell===i)||null,c=a&&typeof a.engine=="string"&&a.engine?a.engine:null;return{hostCell:i,cell:i,known:!!a,engine:c,mode:gP(c),state:i?G1(t&&t.threadStatus):yc,remote:!!(s&&n&&s!==n),lease:t&&(t.hostLease||(t.host&&typeof t.host.lease=="string"?t.host.lease:null))||null}}function vP(t){const e=t&&t.state?t.state:yc;return{modeKey:t&&t.mode?`live-host-mode-${t.mode}`:null,stateKey:`live-host-state-${e}`}}function Lv(t){const e=t&&t.state?t.state:yc;return e==="thread-active"?"active":e==="thread-present"?"present":e===yc?"none":e==="thread-unknown"?"unknown":"designated"}function co(t,e=Math.floor(Date.now()/1e3)){if(!t)return"";const n=e-t;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 Bk(t){const e=t||{};return!(e.sessionsAvailable===!1||typeof e.status=="string"&&e.status!=="up")}function Qi(t){return t.status==="up"&&!Bk(t)?p("node-sessions-unverified"):t.status==="passive"?p("node-passive"):t.status==="down"?t.downSince?p("tunnel-down-since").replace("{t}",co(t.downSince)):p("tunnel-down"):t.status==="unreachable"?t.cause===Ak?p("peer-cause-nega"):t.cause===jk?p("peer-cause-rotta"):t.cause===Lk?p("peer-cause-assente"):p("node-unreachable"):t.status==="offline"?t.lastSeen?p("node-offline-seen").replace("{t}",co(t.lastSeen)):p("node-offline"):t.status==="needs-repair"?p("node-needs-repair"):""}function $k(t,{passive:e=null}={}){return t?t.status==="passive"?e:t.status==="healthy"?"on":"warn":null}function Dd(t){return t&&(t.detail||t.status)||""}const _P="restrict,port-forwarding,permitopen=";function yP(t){const e=t&&typeof t.hint=="string"&&t.hint.trim()||"",n=t&&typeof t.authorizedKeys=="string"&&t.authorizedKeys.trim()||"";if(n){const i=e.indexOf(n);return{note:i>=0?e.slice(0,i).replace(/[:\s]+$/,""):e,line:n}}if(!e)return null;const s=e.indexOf(_P);return s<0?{note:e,line:""}:{note:e.slice(0,s).replace(/[:\s]+$/,""),line:e.slice(s).trim()}}function Od(t,e,n=globalThis.localStorage){if(!(t!=null&&t.outbox)||t.outbox.count<1)return!1;const s=Number(n.getItem(k1(e))||0);return t.outbox.latest>s}function dh(t,e={},{autorevole:n=!0}={}){const s=t||{},i=`${s.engine||""}${s.key?`·${s.key}`:""}`,a=[i,s.model&&s.model!==i?s.model:""].filter(Boolean).join(" · ");if(!s.tmux)return{working:!1,subtitle:String(a||p("cell-off")).trim()};const c=e.attivita&&typeof e.attivita=="object"?e.attivita.stato:null;if(c==="lavora"||c==="attesa"){const u=p(c==="attesa"?"cell-permission":"cell-working"),h=String(e.status||"").trim(),f=!h||/^working(?:\.{3}|…)?$/i.test(h);return{working:!0,stato:c,subtitle:c==="lavora"&&!f?`${u} · ${h}`:u}}if(c==="ferma")return{working:!1,stato:"ferma",subtitle:p("cell-stopped")};if(!n)return{working:!1,stato:"ignoto",subtitle:[p("cell-unknown"),a].filter(Boolean).join(" · ")};if(e.working===!0){const u=String(e.status||"").trim();return{working:!0,stato:"ignoto",subtitle:!u||/^working(?:\.{3}|…)?$/i.test(u)?p("cell-unknown"):`${p("cell-unknown")} · ${u}`}}return e.working===!1?{working:!1,stato:"ignoto",subtitle:p("cell-unknown")}:{working:!1,stato:"ignoto",subtitle:String(e.preview||s.preview||p("cell-on")).trim()}}function zk(t,e){return[...new Set([t.engine,t.model,t.key,e.preview,t.preview,e.status].filter(Boolean).map(String))].join(" ")}function Fk({sessionsOk:t=!0,fleetStale:e=!1,cellCount:n=0}={}){return t?e&&!n?"fleet":null:"sessions"}function Av(t,e,n,s=globalThis.localStorage,{autorevole:i=!0,fleetStale:a=!1}={}){const c=Fk({sessionsOk:i,fleetStale:a,cellCount:Array.isArray(t)?t.length:0});return Hk([...(Array.isArray(t)?t:[]).map(u=>{const h=n.get(u.tmuxSession)||{},f=qa([],u.tmuxSession),g=dh(u,h,{autorevole:i});return{type:"cell",value:u,key:f,label:u.cell,live:!!u.tmux,fresh:Od(h,f,s),activity:h.activity||0,working:g.working,stato:g.stato,subtitle:g.subtitle,searchText:zk(u,h)}}),...(Array.isArray(e)?e:[]).map(u=>{const h=qa([],u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:Od(u,h,s),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})],c)}const Hk=(t,e)=>e?t.map(n=>({...n,partial:e})):t;function gc(t,e=globalThis.localStorage){const n=t||{},s=Array.isArray(n.route)?n.route:[],i=Bk(n),a=new Map((n.sessions||[]).map(h=>[h.name,h])),c=[...(n.cells||[]).map(h=>{const f=a.get(h.tmuxSession)||{},g=qa(s,h.tmuxSession||h.cell),v=dh(h,f,{autorevole:i});return{type:"cell",value:h,key:g,label:h.cell,live:!!h.tmux&&!h.preserved,fresh:Od(f,g,e),activity:f.activity||h.activity||0,working:v.working,stato:v.stato,subtitle:v.subtitle,searchText:zk(h,f)}}),...(n.unmanaged||[]).map(h=>{const f=qa(s,h.name);return{type:"session",value:h,key:f,label:h.name,live:!0,technical:h.technical===!0,fresh:Od(h,f,e),activity:h.activity||0,searchText:`${h.preview||""} ${h.cmd||""}`}})],u=Fk({sessionsOk:n.sessionsAvailable!==!1,fleetStale:n.fleetState==="stale",cellCount:(n.cells||[]).length});return{route:s,rawItems:Hk(c,u)}}const hh=9,wg=.2,wP=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Ya=/^[a-f0-9]{16,64}$/,bg=t=>wP.test(t)&&new Set(t.split("/")).size===t.split("/").length;function Er(t){if(typeof t=="string"&&t){const e=t.indexOf(":");if(e<0)return{session:t};const n=t.slice(0,e),s=t.slice(e+1);return!bg(n)||!s?null:{session:s,node:n}}if(t&&typeof t=="object"&&typeof t.session=="string"&&t.session){const e=t.ownerId===void 0?void 0:typeof t.ownerId=="string"&&Ya.test(t.ownerId)?t.ownerId:null;return e===null?null:t.node===void 0||t.node===null||t.node===""?{session:t.session,...e?{ownerId:e}:{}}:typeof t.node=="string"&&bg(t.node)?{session:t.session,node:t.node,...e?{ownerId:e}:{}}:null}return null}function Bt(t){const e=Er(t);return e?e.node?`${e.node}:${e.session}`:e.session:""}const Uk=9,Wk=24,_i=11,qk=t=>{const e=Number(t);return e>=Uk&&e<=Wk?e:_i};function ho(){return{columns:[]}}function _s(t){return t.columns.flatMap(e=>e.tiles.map(n=>Bt(n)))}function bP(t){const e=[],n=Math.max(0,...t.columns.map(s=>s.tiles.length));for(let s=0;s<n;s+=1)for(const i of t.columns)i.tiles[s]&&e.push(Bt(i.tiles[s]));return e}const Oi=t=>({columns:t.columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))});function Nc(t,e,n,s){const i=Er(e);if(!i||_s(t).includes(Bt(i))||_s(t).length>=hh)return t;const a=Oi(t),c={session:i.session,height:1,fontSize:_i,...s||{}};if(i.node&&(c.node=i.node),i.ownerId&&(c.ownerId=i.ownerId),n==="end")return a.columns.push({width:1,tiles:[c]}),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,c),a;if(n&&typeof n.col=="number"){const u=Math.max(0,Math.min(a.columns.length,n.col));return a.columns.splice(u,0,{width:1,tiles:[c]}),a}return a.columns.push({width:1,tiles:[c]}),a}function Kk(t,e){const n=Bt(e);if(!n||_s(t).includes(n)||_s(t).length>=hh)return t;const s=_s(t).length+1,i=Math.ceil(Math.sqrt(s));if(t.columns.length>=i){let g=0;for(let v=1;v<t.columns.length;v+=1)t.columns[v].tiles.length<t.columns[g].tiles.length&&(g=v);return Nc(t,e,{col:g,row:t.columns[g].tiles.length})}const a=[...bP(t),n],c=new Map(t.columns.flatMap(g=>g.tiles.map(v=>[Bt(v),v]))),u=Er(e),h=t.columns.length?t.columns.reduce((g,v)=>g+(Number(v.width)||1),0)/t.columns.length:1,f=Array.from({length:i},(g,v)=>{var _;return{width:((_=t.columns[v])==null?void 0:_.width)||h,tiles:[]}});return a.forEach((g,v)=>{const _=Er(g);if(!_)return;const b=c.get(g)||(g===n?u:{})||{},x={session:_.session,height:b.height||1,fontSize:b.fontSize||_i};_.node&&(x.node=_.node),b.ownerId&&(x.ownerId=b.ownerId),b.unavailable===!0&&(x.unavailable=!0),b.stale===!0&&(x.stale=!0),f[v%i].tiles.push(x)}),{columns:f.filter(g=>g.tiles.length)}}function Vk(t,e){const n=Er(e);if(!n)return t;const s=Bt(n);if(!s||_s(t).includes(s)||_s(t).length>=hh)return t;const i=e&&typeof e=="object"?e:{},a={height:Math.max(wg,Number(i.height)||1),fontSize:qk(i.fontSize),...n.ownerId?{ownerId:n.ownerId}:{}};if(!t.columns.length)return Nc(t,n,null,a);let c=0;for(let u=1;u<t.columns.length;u+=1)t.columns[u].tiles.length<t.columns[c].tiles.length&&(c=u);return Nc(t,n,{col:c,row:t.columns[c].tiles.length},a)}function Rc(t,e){const n=Bt(e),s=Oi(t);for(const i of s.columns)i.tiles=i.tiles.filter(a=>Bt(a)!==n);return s.columns=s.columns.filter(i=>i.tiles.length>0),s}function SP(t,e,n){const s=Bt(e);if(!_s(t).includes(s))return t;const i=t.columns.flatMap(a=>a.tiles).find(a=>Bt(a)===s);return Nc(Rc(t,s),s,n,{fontSize:i.fontSize,height:i.height,...i.ownerId?{ownerId:i.ownerId}:{},...i.unavailable===!0?{unavailable:!0}:{},...i.stale===!0?{stale:!0}:{}})}function xP(t,e){if(!(e instanceof Map)||e.size===0)return t;let n=!1;const s=Oi(t);for(const i of s.columns)for(const a of i.tiles){const c=e.get(Bt(a));if(!c)continue;const u=Er(c);u&&(a.session=u.session,u.node?a.node=u.node:delete a.node,u.ownerId&&(a.ownerId=u.ownerId),n=!0)}return n?Ii(s):t}const Yk=120,Gk=60,fc=[1/3,.5,2/3],Sg=16;function Xk(t,e,n,s){if(!(e>0))return .5;const i=Math.max(0,Math.min(.5,n/e));let a=t/e;if(a=Math.max(i,Math.min(1-i,a)),s){for(const c of fc)if(Math.abs(a-c)*e<=Sg){a=c;break}}return a}function O0(t,e,n,s,i={}){const a=Oi(t),c=a.columns[e],u=a.columns[e+1];if(!c||!u)return t;const h=a.columns.reduce((_,b)=>_+(Number(b.width)||1),0),f=(Number(c.width)||1)+(Number(u.width)||1),g=(Number(n)||0)*(f/(h||1)),v=i.half===!0?.5:Xk(s,g,i.minPx??Yk,i.snap!==!1);return c.width=f*v,u.width=f*(1-v),a}function B0(t,e,n,s,i,a={}){const c=Oi(t),u=c.columns[e],h=u&&u.tiles[n],f=u&&u.tiles[n+1];if(!h||!f)return t;const g=u.tiles.reduce((x,L)=>x+(Number(L.height)||1),0),v=(Number(h.height)||1)+(Number(f.height)||1),_=(Number(s)||0)*(v/(g||1)),b=a.half===!0?.5:Xk(i,_,a.minPx??Gk,a.snap!==!1);return h.height=v*b,f.height=v*(1-b),c}function kP(t,e,n){if(!e||!n||e===n)return t;const s=Oi(t);let i=null,a=null;for(const f of s.columns)for(let g=0;g<f.tiles.length;g+=1){const v=Bt(f.tiles[g]);v===e&&!i?i={col:f,i:g}:v===n&&!a&&(a={col:f,i:g})}if(!i||!a)return t;const c=i.col.tiles[i.i],u=a.col.tiles[a.i],h=f=>{const g={...f};return delete g.height,g};return i.col.tiles[i.i]={...h(u),height:c.height},a.col.tiles[a.i]={...h(c),height:u.height},s}const zc=6,Fc=t=>{let{x:e,y:n,w:s,h:i}=t;return s=Math.max(.05,Math.min(1,Number(s)||.3)),i=Math.max(.05,Math.min(1,Number(i)||.3)),e=Math.max(0,Math.min(1-s,Number(e)||0)),n=Math.max(0,Math.min(1-i,Number(n)||0)),{x:e,y:n,w:s,h:i}};function jv(t,e){for(const n of t.columns)for(let s=0;s<n.tiles.length;s+=1)if(Bt(n.tiles[s])===e)return{tile:n.tiles[s]};return null}function CP(t,e,n){const s=Oi(t),i=Bt(e);if(NP(s).length>=zc)return t;const a=jv(s,i);return!a||a.tile.float?t:(a.tile.float=Fc(n||{}),s)}function EP(t,e){const n=Oi(t),s=jv(n,Bt(e));return!s||!s.tile.float?t:(delete s.tile.float,n)}function $0(t,e,n){const s=Oi(t),i=jv(s,Bt(e));return!i||!i.tile.float?t:(i.tile.float=Fc(n),s)}function NP(t){return t.columns.flatMap(e=>e.tiles).filter(e=>e.float).map(e=>Bt(e))}function Bd(t){const e=[],n=[];for(const s of t.columns){const i=[];for(const a of s.tiles)if(a.float){const c={session:a.session,...a.float,fontSize:a.fontSize};a.node&&(c.node=a.node),a.ownerId&&(c.ownerId=a.ownerId),e.push(c)}else i.push(a);i.length&&n.push({width:s.width,tiles:i})}return{grid:{columns:n},floating:e}}const Jk=["x","y","w","h","fontSize"],xg=(t,e)=>Math.abs((Number(t)||0)-(Number(e)||0))<1e-9,Qk=(t,e)=>Jk.every(n=>xg(t[n],e[n]));function RP(t,e,n){if(!t)return n;const s={...n};for(const i of Jk)xg(n[i],t[i])&&!xg(e[i],t[i])&&(s[i]=e[i]);return{...s,...Fc(s)}}function LP(t,e,n){const s=h=>new Map((Array.isArray(h)?h:[]).map(f=>[Bt(f),f]).filter(([f])=>f)),i=s(t),a=s(e),c=s(n),u=[];for(const[h,f]of c)!a.has(h)&&i.has(h)&&Qk(f,i.get(h))||u.push(a.has(h)?RP(i.get(h),a.get(h),f):f);for(const[h,f]of a)c.has(h)||i.has(h)||u.push(f);return u.slice(0,zc)}function AP(t,e,n,s,i){const a=_=>Array.isArray(_.floating)?_.floating:[],c=(_,b)=>a(_).some(x=>Bt(x)===b)?"float":_s(_.grid).includes(b)?"grid":"",u=(_,b)=>_.columns.flatMap(x=>x.tiles).find(x=>Bt(x)===b),h=new Set([...a(n),...a(s),...a(i)].map(_=>Bt(_)).filter(Boolean));let f=t,g=Array.isArray(e)?e:[];const v=(_,b)=>a(_).find(x=>Bt(x)===b);for(const _ of h){const b=c(i,_),x=c(n,_),k=b!==x||b==="float"&&!Qk(v(i,_),v(n,_))?b:c(s,_);if(k!=="grid"&&_s(f).includes(_)&&(f=Rc(f,_)),k!=="float"&&(g=g.filter(R=>Bt(R)!==_)),k==="grid"&&!_s(f).includes(_)){const R=u(s.grid,_)||u(i.grid,_)||u(n.grid,_);R&&(f=Vk(f,R))}if(k==="float"&&!g.some(R=>Bt(R)===_)){const R=[s,i,n].map(S=>a(S).find(j=>Bt(j)===_)).find(Boolean);R&&(g=[...g,R])}}return{grid:f,floating:g.slice(0,zc)}}function jP(t,e){const n=s=>{const{grid:i,floating:a}=Bd(s||ho());return JSON.stringify({g:i.columns.map(c=>[c.width,c.tiles.map(u=>[Bt(u),u.ownerId||"",u.height,u.fontSize])]),f:a.map(c=>[Bt(c),c.ownerId||"",c.x,c.y,c.w,c.h,c.fontSize])})};return n(t)===n(e)}function kg(t,e){let n=t;for(const s of Array.isArray(e)?e:[]){const i={session:s.session};s.node&&(i.node=s.node),s.ownerId&&(i.ownerId=s.ownerId);const a=Bt(i);if(!a||_s(n).includes(a))continue;const c=Oi(n);c.columns.length||c.columns.push({width:1,tiles:[]});let u=0;for(let f=1;f<c.columns.length;f+=1)c.columns[f].tiles.length<c.columns[u].tiles.length&&(u=f);const h={session:i.session,height:1,fontSize:s.fontSize||_i,float:Fc(s)};i.node&&(h.node=i.node),i.ownerId&&(h.ownerId=i.ownerId),c.columns[u].tiles.push(h),n=c}return n}function MP(t,e,n,s){if(!(t.columns[e]&&t.columns[e].tiles[n]))return t;const a=Oi(t),c=a.columns[e].tiles[n],u=Number(c.fontSize)||_i;return c.fontSize=Math.max(Uk,Math.min(Wk,u+(Number(s)||0))),a}function TP(t,e,n,s){const i=t.columns[e];if(!i||!i.tiles[n])return null;switch(s){case"left":return{col:e};case"right":return{col:e+1};case"top":return{col:e,row:n};case"bottom":return{col:e,row:n+1};default:return null}}function Ii(t){if(!t||!Array.isArray(t.columns))return ho();const e=t.columns.map(a=>({width:Math.max(wg,Number(a&&a.width)||1),tiles:(Array.isArray(a&&a.tiles)?a.tiles:[]).filter(c=>c&&typeof c.session=="string"&&c.session).filter(c=>c.node==null||typeof c.node=="string"&&bg(c.node)).filter(c=>c.ownerId==null||typeof c.ownerId=="string"&&Ya.test(c.ownerId)).map(c=>{const u={session:c.session,height:Math.max(wg,Number(c.height)||1),fontSize:qk(c.fontSize)};return c.node!=null&&(u.node=c.node),c.ownerId!=null&&(u.ownerId=c.ownerId),c.float&&(u.float=Fc(c.float)),u})})).filter(a=>a.tiles.length>0),n=new Set;let s=0,i=0;for(const a of e)a.tiles=a.tiles.filter(c=>{const u=Bt(c);return n.has(u)||(c.float?i>=zc:s>=hh)?!1:(n.add(u),c.float?i+=1:s+=1,!0)});return{columns:e.filter(a=>a.tiles.length>0)}}function PP(t,e){let n=Ii(t);const s=Ii(e),i=new Map;for(const c of s.columns)for(const u of c.tiles)i.set(Bt(u),u);for(const c of n.columns)for(let u=0;u<c.tiles.length;u+=1){const h=Bt(c.tiles[u]);i.has(h)&&(c.tiles[u]=i.get(h))}const a=new Map;for(const c of s.columns){const u=c.tiles.map(h=>Bt(h)).sort().join("|");a.has(u)||a.set(u,c.width)}for(const c of n.columns){const u=c.tiles.map(f=>Bt(f)).sort().join("|"),h=a.get(u);h!=null&&(c.width=h)}for(const[c,u]of i)_s(n).includes(c)||(n=Vk(n,u));return n}const Zk=/^[a-z0-9-]{1,32}$/,IP=/^[A-Za-z0-9._-]{1,32}$/,DP=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,OP=320;function Cg(t){return typeof t=="string"&&Zk.test(t)}const BP=64;function Ga(t){if(typeof t!="string")return!1;const e=t.trim();return e.length>0&&e.length<=BP&&!/[\x00-\x1f\x7f]/.test(e)}function fo(t){return String(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function eC(t){if(typeof t!="string"||!t||t.length>OP||t.startsWith("-")||/[\0-\x20\x7f]/.test(t))return!1;if(!t.includes("@"))return/^[A-Za-z0-9][A-Za-z0-9._:-]{0,254}$/.test(t);const e=t.indexOf("@");return e<=0||e!==t.lastIndexOf("@")?!1:IP.test(t.slice(0,e))&&DP.test(t.slice(e+1))}function z0(t){if(t===""||t===null||t===void 0)return null;const e=String(t).trim();if(!/^[0-9]{1,5}$/.test(e))return;const n=Number(e);return Number.isInteger(n)&&n>=1&&n<=65535?n:void 0}function $P({name:t,ssh:e,sshPort:n,remotePort:s}={}){const i=typeof t=="string"?t.trim():t,a=typeof e=="string"?e.trim():e;if(!Cg(i))return{ok:!1,error:"err-node-name"};if(!eC(a))return{ok:!1,error:"err-ssh"};const c=z0(n);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const u=z0(s);if(u===void 0)return{ok:!1,error:"err-node-port"};const h={name:i,ssh:a};return c!==null&&(h.sshPort=c),u!==null&&(h.remotePort=u),{ok:!0,value:h}}function zP(t,e){if(!t||!e||e<t)return null;const n=Math.floor((e-t)/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 Eg(t,e){const n=!!(t&&t.status==="up"),s=!!(t&&t.status==="passive");return{up:n,...s?{passive:!0}:{},label:n?"tunnel-up":s?"node-passive":"tunnel-down",since:n?zP(t.since,e):null}}const FP=new Set(["v","instanceId","port","label","invite"]),HP=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function UP(t){const e=String(t).replace(/-/g,"+").replace(/_/g,"/"),n=e+"=".repeat((4-e.length%4)%4),s=typeof atob=="function"?atob(n):Buffer.from(n,"base64").toString("binary"),i=Uint8Array.from(s,a=>a.charCodeAt(0));return typeof TextDecoder<"u"?new TextDecoder().decode(i):Buffer.from(i).toString("utf8")}function WP(t){let e="";try{const c=new URL(String(t));e=new URLSearchParams(c.hash.replace(/^#/,"")).get("pair")||""}catch{return{ok:!1}}if(!e)return{ok:!1};let n;try{n=JSON.parse(UP(e))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?FP:n.v===2?HP:null;if(!s)return{ok:!1};for(const c of Object.keys(n))if(!s.has(c))return{ok:!1};if(!/^[a-f0-9]{16,64}$/.test(String(n.instanceId)))return{ok:!1};const i=Number(n.port);if(!Number.isInteger(i)||i<1||i>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:i};if(n.v===2){if(n.name!==void 0){if(typeof n.name!="string"||!Zk.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!eC(n.ssh))return{ok:!1};a.ssh=String(n.ssh).trim()}if(n.sshPort!==void 0){const c=Number(n.sshPort);if(!Number.isInteger(c)||c<1||c>65535)return{ok:!1};a.sshPort=c}}return a}function qP(t,e,n=new Set){if(!e||!e.ok)return t;const s={...t},i=(a,c)=>{c==null||c===""||n.has(a)||(s[a]=c)};return i("label",e.label),e.version===2&&(i("name",e.name||(e.ssh?fo(e.label):"")),i("ssh",e.ssh),e.sshPort!==void 0&&i("sshPort",String(e.sshPort))),s}const KP=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],VP=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function YP(t){const e=t&&typeof t=="object"?t.actionRequired:null;if(e&&typeof e=="object"&&KP.includes(e.code)&&VP.includes(e.recovery))return{code:e.code,recovery:e.recovery,text:p(`fleet-recovery-${e.recovery}`)};if(t&&typeof t=="object"&&t.vlPromptDegraded===!0)return{code:"VL_PROMPT_DEGRADED",recovery:null,text:p("fleet-vl-prompt-degraded")};if(t&&typeof t=="object"&&t.readinessDegraded===!0){if(t.mcpDegraded&&typeof t.mcpDegraded=="object"){const n=[...Array.isArray(t.mcpDegraded.failed)?t.mcpDegraded.failed:[],...Array.isArray(t.mcpDegraded.pending)?t.mcpDegraded.pending:[]].filter(s=>typeof s=="string"&&s).slice(0,16);if(n.length)return{code:"READINESS_DEGRADED",recovery:null,text:p("fleet-mcp-degraded")+" "+n.join(", ")}}return{code:"READINESS_DEGRADED",recovery:null,text:p("fleet-readiness-degraded")}}return null}function GP(t,e){if(!t)return null;const n=t.status===502&&t.data&&t.data.cause==="upstream-timeout";return t.name==="TimeoutError"||n?{code:"FLEET_ACTION_TIMEOUT",recovery:null,text:p(e==="down"?"fleet-down-slow":"fleet-up-slow")}:t.status===409&&e==="up"&&t.data&&t.data.code==="SESSION_DUPLICATE"?{code:"FLEET_SESSION_DUPLICATE",recovery:null,text:p("fleet-up-duplicate")}:null}async function Mv({token:t,powerCell:e,payload:n,onNotice:s,fleetApi:i}){const a=i||{fleetUp:kN,fleetDown:E1},{cell:c}=e,u=Array.isArray(e.route)?e.route:[];try{if(n.action==="up"){const h=await a.fleetUp(t,{cell:c,boot:!!n.boot,...n.engine?{engine:n.engine}:{},...n.model!==void 0?{model:n.model}:{},...n.permissionPolicy?{permissionPolicy:n.permissionPolicy}:{}},u),f=YP(h);f&&s(f.text)}else await a.fleetDown(t,{cell:c,boot:!!n.boot},u);return}catch(h){const f=GP(h,n.action);if(f)return s(f.text),{benign:f.code};throw h}}const XP=1e4;function tC(){const[t,e]=w.useState(null),n=w.useRef(null),s=w.useCallback(i=>{typeof i!="string"||!i||(n.current&&clearTimeout(n.current),e(i),n.current=setTimeout(()=>e(null),XP))},[]);return w.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]),{notice:t,showActionNotice:s}}let Ng={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function F0(){return Ng}function nC(t={}){return Ng={sessions:Array.isArray(t.sessions)?t.sessions:[],cells:Array.isArray(t.cells)?t.cells:[],nodeGroups:Array.isArray(t.nodeGroups)?t.nodeGroups:[],localNodeId:typeof t.localNodeId=="string"?t.localNodeId:"",localFresh:t.localFresh===!0,refreshedAt:Number.isFinite(t.refreshedAt)?t.refreshedAt:0},Ng}const Ta=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function JP({onPick:t,token:e,onSettings:n,onOpenVlSession:s,hostByRoute:i={},onDesignateCell:a,onClearHostCell:c,panelPort:u=0,nodePanelPorts:h=null}){const[f,g]=zn(),v=xv(e),[_,b]=w.useState(null),[x,L]=w.useState(null),[k,R]=w.useState(!0),[S,j]=w.useState(""),[E,F]=w.useState(""),[$,G]=w.useState({bind:"127.0.0.1",port:""}),[K,Y]=w.useState(""),[te,q]=w.useState([]),[D,I]=w.useState([]),[O,M]=w.useState(!1),[z,T]=w.useState(null),[A,N]=w.useState({}),[U,P]=w.useState(new Set),[H,ie]=w.useState(null),{notice:J,showActionNotice:Q}=tC(),[ve,de]=w.useState(null),[ne,xe]=w.useState(null),[$e,rt]=w.useState(!1),[je,Ie]=w.useState(null),[oe,Ne]=w.useState(null),[me,Ce]=w.useState("preview"),[V,ge]=w.useState(!1),{pins:Le,orders:ke,togglePin:We,removePin:Re,pinError:_e,reorderBlocked:st,retryPinPersist:Xe,clearPinError:De,viewFor:He,updateView:Ke,canMoveRoster:wt,moveRoster:fe,stepRoster:he}=Cv(),Z=le=>i[Cs(le)]||{},{groupsFor:X,moveNode:ue,stepNode:Ze,nodeKey:se}=ch(),Be=X(v);w.useEffect(()=>{nC({sessions:_||[],cells:te,nodeGroups:v,localNodeId:K})},[_,te,v,K]),w.useEffect(()=>{const le=new Map;for(const re of te)le.set(Ta(re.cell),!!re.boot);for(const re of v){const Te=re.route||[re.name];for(const Ge of re.cells||[])le.set(Ta(Ge.cell,Te),!!Ge.boot)}N(re=>{let Te=!1;const Ge={...re};for(const[gt,W]of Object.entries(re))le.has(gt)&&le.get(gt)===W&&(delete Ge[gt],Te=!0);return Te?Ge:re})},[te,v]);function ht(){sc([],e)}w.useEffect(()=>{const re=Cd(e,[],Te=>{if(!Te)return;const Ge=Te.sessionsError?null:Te.sessionsJson;Ge&&!Ge.error?(L(null),b(Ge.sessions||[]),R(!0)):Ge?(L(Ge.error),b([]),R(!1)):(L(String(Te.sessionsError)),b([]),R(!1));const gt=bv({fs:Te.fs,error:Te.fleetError});gt.kind==="data"?(Ka("local",gt.cells),q(gt.cells),I(gt.capabilities),M(!1),T(null)):gt.kind==="stale"?(q(W=>W.length?W:wv("local")),M(!0),T(null)):(q([]),Ka("local",[]),I([]),M(!1),T(gt.reason||""))});return qn("/api/config",e).then(Te=>Te.json()).then(Te=>{F(Te.version||""),G({bind:Te.bind||"127.0.0.1",port:Te.port||""}),Y(Ya.test(String(Te.instanceId||""))?Te.instanceId:"")}).catch(()=>{}),re},[e]);async function Pt(){if(!$.port)return;const le=`http://${$.bind}:${$.port}/#token=${e}`;try{await navigator.clipboard.writeText(le)}catch{}}function St(le,re,Te){const Ge=Ta(le,re);N(gt=>({...gt,[Ge]:!!Te}))}function Nt(le,re=[]){const Te=Ta(le.cell,re);return Object.prototype.hasOwnProperty.call(A,Te)?A[Te]:!!le.boot}async function ut(le,re,Te=[],Ge){const gt=Ta(re.cell,Te),W=typeof Ge=="boolean"?Ge:!Nt(re,Te);St(re.cell,Te,W),P(ae=>new Set(ae).add(gt));try{await N1(e,{cell:re.cell,enabled:W},Te),Te.length||q(ae=>ae.map(Ae=>Ae.cell===re.cell?{...Ae,boot:W}:Ae))}catch(ae){N(Ae=>{const Je={...Ae};return delete Je[gt],Je}),L(String((ae==null?void 0:ae.message)||ae))}finally{P(ae=>{const Ae=new Set(ae);return Ae.delete(gt),Ae})}}const zt=(le,re,Te)=>({onToggleLive:async()=>{const Ge=lo({item:le,cellName:re.cell,route:Te,pins:Le,hostByRoute:i});rt(!0);const gt=await th({action:Ge.isLive?"remove":"use",cellId:re.cell,route:Te,token:e});rt(!1),Ie({messageKey:gt.messageKey,ok:gt.ok,cell:gt.hostCell||re.cell})},onTogglePin:()=>Ev({view:uh({item:le,pins:Le,hostByRoute:i,route:Te}),itemKey:le.key,togglePin:We,removePin:Re}),onToggleBoot:Ge=>ut(null,re,Te,Ge),onWatchLive:()=>{Ce("stream"),Ne(le.key)}});async function Yt(le){if(!H)return;let re=null;try{re=await Mv({token:e,powerCell:H,payload:le,onNotice:Q})}catch(Te){throw Q(String(Te&&Te.message||Te)),Te}if(!re){const{cell:Te}=H,Ge=Array.isArray(H.route)?H.route:[];le.action==="up"?St(Te,Ge,!!le.boot):le.boot&&St(Te,Ge,!1)}ht()}const Ut=w.useMemo(()=>{if(!H)return null;const le=(Array.isArray(H.route)?H.route:[]).join("/"),Te=[...te,...v.flatMap(Ge=>(Ge.cells||[]).map(gt=>({...gt,route:Ge.route||[Ge.name]})))].find(Ge=>Ge.cell===H.cell&&(Array.isArray(Ge.route)?Ge.route.join("/"):"")===le);return Te?{...H,active:!!Te.active}:H},[H,te,v]);async function dt(le,re=[]){try{await Xg(e,le,re)}catch{return}ht()}async function qt(le,re,Te=[]){try{await A1(e,le,re,Te)}catch{return}ht()}async function In(le){if(!(!(le!=null&&le.direct)||ve)){de(le.name);try{await Zg(e,le.name,le.tunnelStatus==="up"?"down":"up")}catch{}de(null)}}async function Kt(le){if(!(le!=null&&le.direct))return;const re=window.prompt(p("rename-node-prompt"),le.label||le.name);if(re===null)return;const Te=String(re).trim();if(!Ga(Te)){window.alert(p("rename-node-invalid"));return}try{await I1(e,le.name,Te)}catch(Ge){window.alert(String((Ge==null?void 0:Ge.message)||Ge))}}const wn=w.useMemo(()=>new Map((_||[]).map(le=>[le.name,le])),[_]),tn=w.useMemo(()=>new Set(te.map(le=>le.tmuxSession)),[te]),bn=w.useMemo(()=>(_||[]).filter(le=>!tn.has(le.name)),[_,tn]),Ft=w.useMemo(()=>Av(te,bn,wn,void 0,{autorevole:k,fleetStale:O}),[te,bn,wn,k,O]),Jt=w.useMemo(()=>{const le=new Map;for(const re of Ft)re.type==="cell"&&le.set(re.key,{item:re,route:[],nodeLabel:"",sessions:_||[],cells:te});for(const re of Be){const Te=Array.isArray(re.route)?re.route:[];if(!Te.length||re.kind==="vl")continue;const{rawItems:Ge}=gc(re);for(const gt of Ge)gt.type==="cell"&&le.set(gt.key,{item:gt,route:Te,nodeLabel:re.label||re.name||"",sessions:re.sessions||[],cells:re.cells||[]})}return le},[Ft,Be,_,te]),Qt=w.useMemo(()=>{if(!oe)return null;const le=Jt.get(oe);if(!le)return null;const re=le.item.value,Te=(le.sessions||[]).find(Ge=>Ge.name===re.tmuxSession)||{};return{row:{key:le.item.key,cellName:re.cell,subtitle:le.item.subtitle||"",nodeLabel:le.nodeLabel,node:le.route.length?le.route.join("/"):"",session:re.tmuxSession,route:le.route,panelUrl:re.panelUrl||"",telemetry:Te.telemetry||null,preview:Te.preview||re.preview||"",activity:Te.activity||re.activity||0},cells:le.cells||[]}},[oe,Jt]),Zt=He("local"),ls=w.useMemo(()=>kr(Ft,Le,Zt.filter,wi(ke,"local")).filter(le=>x0(le,S)),[Ft,Le,Zt.filter,S,ke]),cs=Be.reduce((le,re)=>le+(re.cells||[]).length+(re.unmanaged||[]).filter(Te=>!Te.technical).length,0),mn=kr(Ft,Le,"all",wi(ke,"local")).length+cs,gn=Ft.filter(le=>le.live).length+Be.reduce((le,re)=>le+gc(re).rawItems.filter(Te=>Te.live).length,0),qs=(_||[]).filter(le=>le.attached).length+Be.reduce((le,re)=>le+(re.sessions||[]).filter(Te=>Te.attached).length,0),Vn=Math.min(qs,gn),bt=$.port?`${$.bind}:${$.port}`:$.bind;function us(le,re=null,Te=Ft){var xt,vt;const Ge=Array.isArray(re==null?void 0:re.route)?re.route:[],gt=Ge.join("/"),W=gt||"local",ae=Ge.length?re==null?void 0:re.instanceId:K,Ae=(Qe,Rt)=>t({session:Qe,...gt?{node:gt}:{},...Ya.test(String(ae||""))?{ownerId:ae}:{},...typeof Rt=="string"&&Rt?{cellName:Rt}:{}}),Je=wt;if(le.type==="cell"){const Qe=le.value,Rt=Z(Ge),ot=Nd({hostCell:Rt.hostCell??null,threadStatus:Rt.threadStatus,pins:Le,item:le}),ze=Ge.length?((re==null?void 0:re.sessions)||[]).find(en=>en.name===Qe.tmuxSession):wn.get(Qe.tmuxSession),Wt=mm(ot,Rt.hostLease??null),Sn=Qe.degraded?p("cell-degraded"):le.subtitle||(Qe.tmux?p("cell-idle"):p("cell-off")),Se=Wt?`${Sn} · ${p(Wt)}`:Sn,Me=Ge.length===0||((re==null?void 0:re.capabilities)||[]).includes(Qe.active?"down":"up"),qe=Ge.length===0?D.includes("boot"):((re==null?void 0:re.capabilities)||[]).includes("boot"),ct=Nt(Qe,Ge),Lt=lo({item:le,cellName:Qe.cell,route:Ge,pins:Le,hostByRoute:i}),Ks=!!ne&&ne.itemKey===le.key,Vs=`${p("cell-actions-open")}: ${Qe.cell}`;return l.jsxs("div",{className:"nc-mcard","data-roster-key":le.key,"data-position":W,children:[V&&l.jsx(Gi,{position:W,itemKey:le.key,label:Qe.cell,canMove:Je,onMove:(en,nn)=>fe(W,en,nn,Te),onStep:en=>he(W,le.key,en,Te)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Qe.tmux&&Ae(Qe.tmuxSession,Qe.cell),title:Se,"aria-label":`${Qe.cell}, ${Se}`,children:[l.jsx("span",{className:`dot ${Qe.degraded?"warn":Qe.tmux?`on${le.working?" working":""}`:""}`}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsxs("span",{className:"nc-mcard-nome",children:[l.jsx("b",{children:Qe.cell}),Lt.isLive&&l.jsx("span",{className:"nc-m-live",children:"LIVE"})]}),l.jsx("small",{title:le.subtitle,children:le.subtitle})]})]}),le.activity?l.jsx("span",{className:"nc-rel",children:co(le.activity)}):null,le.fresh&&((xt=ze==null?void 0:ze.outbox)==null?void 0:xt.count)>0&&l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:ze.outbox.count}),l.jsx("button",{type:"button",className:`nc-act cellmenu${Ks?" on":""}`,title:Vs,"aria-label":Vs,"aria-haspopup":"menu","aria-expanded":Ks?"true":"false",onClick:()=>xe({itemKey:le.key,item:le,cell:Qe,route:Ge,canBoot:qe}),children:"⋯"}),Me&&l.jsx("button",{className:`nc-act power${Qe.tmux?" on":""}${Qe.degraded?" warn":""}`,onClick:()=>ie(Ge.length?{...Qe,boot:ct,route:Ge,availableEngines:(re==null?void 0:re.engines)||[]}:{...Qe,boot:ct}),title:Qe.active?p("power-off"):p("power-on"),"aria-label":`${Qe.active?p("power-off"):p("power-on")} ${Qe.cell}`,children:l.jsx(Tt,{name:"power",size:16})})]},le.key)}const Pe=le.value;return l.jsxs("div",{className:"nc-mcard","data-roster-key":le.key,"data-position":W,children:[l.jsx(Gi,{position:W,itemKey:le.key,label:Pe.name,canMove:Je,onMove:(Qe,Rt)=>fe(W,Qe,Rt,Te),onStep:Qe=>he(W,le.key,Qe,Te)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Ae(Pe.name),children:[l.jsx("span",{className:Pe.attached?"dot on":"dot"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Pe.name}),l.jsx("small",{children:Pe.preview?Pe.preview:Pe.cmd?Pe.cmd:p("windows").replace("{n}",String(Pe.windows||0))})]})]}),le.activity?l.jsx("span",{className:"nc-rel",children:co(le.activity)}):null,le.fresh&&((vt=Pe.outbox)==null?void 0:vt.count)>0&&l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Pe.outbox.count}),l.jsx("button",{className:`nc-act pin${Le.includes(le.key)?" on":""}`,"aria-label":`${p("pin")} ${Pe.name}`,title:p("pin"),onClick:()=>We(le.key),children:Le.includes(le.key)?"★":"☆"}),l.jsx("button",{className:`nc-act technical${Pe.technical?" on":""}`,title:Pe.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${Pe.technical?p("mark-normal"):p("mark-technical")} ${Pe.name}`,onClick:()=>qt(Pe.name,!Pe.technical,Ge),children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),"aria-label":`${p("terminate")} ${Pe.name}`,onClick:()=>{window.confirm(p("terminate-confirm").replace("{name}",Pe.name))&&dt(Pe.name,Ge)},children:"⋯"})]},le.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:[p("fleet-tmux")," · ",gn," ",p("sessions"),Vn>0&&` · ${Vn} attached`]}),l.jsxs("span",{className:"nc-head-actions",children:[l.jsx("button",{className:`nc-refresh${V?" on":""}`,onClick:()=>ge(le=>!le),"aria-pressed":V,title:p("reorder-help"),"aria-label":p("reorder"),children:"↕"}),l.jsx("button",{className:"nc-refresh",onClick:()=>n("nodes",!1),title:p("settings"),children:l.jsx(Tt,{name:"gear",size:18})}),l.jsx("button",{className:"nc-refresh",onClick:ht,title:p("refresh"),children:l.jsx(Tt,{name:"refresh",size:18})})]})]}),l.jsxs("main",{className:"nc-home-scroll",children:[l.jsx(QP,{view:Va({liveHost:i[Cs([])],cells:te}),notice:je}),l.jsx(Pk,{pinError:_e,onRetry:Xe,onDismiss:De}),mn>8&&l.jsx("input",{className:"nc-filter",type:"search",placeholder:p("filter-placeholder"),"aria-label":p("filter-placeholder"),value:S,onChange:le=>j(le.target.value)}),x&&l.jsx("div",{className:"nc-err",children:x}),J&&l.jsx("div",{className:"nc-notice",role:"status",children:J}),O&&l.jsx("div",{className:"nc-set-hint nc-fleet-stale",role:"status",children:p("fleet-stale")}),st&&l.jsxs("div",{className:"nc-set-hint nc-reorder-blocked",role:"status",children:[p("reorder-blocked")," (",st.reason,")"]}),z!==null&&l.jsxs("div",{className:"nc-set-hint nc-fleet-off",role:"status",children:[p("fleet-off"),z?` (${z})`:""]}),l.jsxs("section",{className:"nc-group","data-position":"local",children:[l.jsx(Cp,{label:p("position-local"),count:ls.length,state:Zt,dotClass:"on",onToggle:()=>Ke("local",{open:!Zt.open}),onFilter:le=>Ke("local",{filter:le})}),Zt.open&&ls.map(le=>us(le,null,Ft)),Zt.open&&_===null&&l.jsx("div",{className:"nc-empty",children:p("loading-fleet")}),Zt.open&&_!==null&&ls.length===0&&!x&&l.jsx("div",{className:"nc-empty",children:S?p("no-match").replace("{q}",S):p("no-sessions-short")})]}),Be.map(le=>{const re=$k(le.health,{passive:"warn"}),Te=le.fleetState==="stale"?p("fleet-stale"):le.fleetState==="disabled"?p("fleet-off"):"",Ge=le.fleetState==="stale"?"warn":re||(le.status==="up"?"on":le.status==="passive"?"":"warn"),gt=[le.health?Dd(le.health):Qi(le),Te].filter(Boolean).join(" · "),ae=(le.route&&le.route.length?le.route:[le.name]).join("/"),Ae=He(ae);if(le.kind==="vl")return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":ae,"data-node-order-key":se(le),children:[l.jsx(Cp,{label:le.label||le.name,count:le.sessions.length,state:Ae,dotClass:Ge,dotTitle:gt,detail:Qi(le),onToggle:()=>Ke(ae,{open:!Ae.open}),onFilter:Qe=>Ke(ae,{filter:Qe})}),le.status==="up"&&Ae.open&&le.sessions.map(Qe=>l.jsx("div",{className:"nc-mcard nc-vl-session-row",children:l.jsxs("button",{className:"nc-mcard-main",onClick:()=>s&&s(le.peer),"aria-label":`${le.label||le.name}: ${Qe.name}`,children:[l.jsx("span",{className:"dot on"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Qe.name}),l.jsx("small",{children:p("vl-events-title")})]})]})},Qe.key)),le.status==="up"&&Ae.open&&le.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]},`nodo-vl-${ae}-${le.name}`);const{rawItems:Je}=gc(le),Pe=kr(Je,Le,Ae.filter,wi(ke,ae)).filter(Qe=>x0(Qe,S)),xt=le.direct&&le.health&&le.health.managed!==!1?l.jsx("button",{type:"button",className:`nc-act power${le.tunnelStatus==="up"?" on":""}`,disabled:ve===le.name,title:le.tunnelStatus==="up"?p("power-off"):p("power-on"),"aria-label":`${le.tunnelStatus==="up"?p("power-off"):p("power-on")} ${le.label||le.name}`,onClick:()=>In(le),children:l.jsx(Tt,{name:"power",size:15})}):null,vt=l.jsxs("span",{className:"nc-node-actions",children:[l.jsx(Gi,{scope:"node",position:"nodes",itemKey:se(le),label:le.label||le.name,onMove:(Qe,Rt)=>ue(Qe,Rt,v),onStep:Qe=>Ze(se(le),Qe,v)}),le.direct&&l.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${le.label||le.name}`,onClick:()=>Kt(le),children:"✎"}),xt]});return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":ae,"data-node-order-key":se(le),children:[l.jsx(Cp,{label:le.label||le.name,count:Pe.length,state:Ae,dotClass:Ge,dotTitle:gt,detail:le.status==="up"?[Qi(le),Te].filter(Boolean).join(" · "):le.health&&Dd(le.health)||Qi(le),onToggle:()=>Ke(ae,{open:!Ae.open}),onFilter:Qe=>Ke(ae,{filter:Qe}),onRename:le.direct?()=>Kt(le):null,action:vt}),le.status==="up"&&Ae.open&&Pe.map(Qe=>us(Qe,le,Je)),le.status==="up"&&Ae.open&&Pe.length===0&&l.jsx("div",{className:"nc-empty",children:S?p("no-match").replace("{q}",S):p("no-sessions-short")})]},`nodo-${ae}`)}),l.jsxs("footer",{className:"nc-home-foot",onClick:Pt,title:p("copy-url"),children:[l.jsxs("span",{className:"nc-home-meta",children:[E&&l.jsxs("span",{className:"nc-home-version",children:["v",E]}),l.jsxs("span",{className:"nc-home-endpoint",children:[bt," · ",p("ssh-only")]})]}),l.jsx("span",{className:"nc-lang",onClick:le=>le.stopPropagation(),children:z1.map((le,re)=>l.jsxs("span",{children:[re>0&&" · ",l.jsx("button",{className:`nc-lang-btn${f===le?" on":""}`,onClick:()=>g(le),title:le,children:le.toUpperCase()})]},le))})]})]}),Ut&&l.jsx(Id,{cell:Ut,token:e,route:Array.isArray(Ut.route)?Ut.route:[],onConfirm:Yt,onClose:()=>ie(null)}),Qt&&l.jsx(bk,{row:Qt.row,token:e,initialSource:me,panelPort:Cc(Qt.row.route||[],h,u),liveHost:Va({liveHost:i[Cs(Qt.row.route||[])],cells:Qt.cells}),onClose:()=>{Ne(null),Ce("preview")}}),ne&&(()=>{const{item:le,cell:re,route:Te=[],canBoot:Ge}=ne,gt=lo({item:le,cellName:re.cell,route:Te,pins:Le,hostByRoute:i}),W=Nv({...gt,canBoot:Ge,boot:Nt(re,Te),alive:!!re.tmux,handlers:zt(le,re,Te)});return l.jsx(Rv,{cellName:re.cell,items:W,busy:$e||U.has(Ta(re.cell,Te)),onClose:()=>xe(null)})})()]})}function QP({view:t,notice:e}){const n=!!(t&&t.cell),s=n?p("live-host-indicator").replace("{cell}",t.cell).replace("{mode}",p(t.mode?`live-host-mode-${t.mode}`:"live-host-mode-unknown")).replace("{state}",p(`live-host-state-${t.state||"none"}`)):p("live-host-indicator-none");return l.jsxs("div",{className:"nc-m-live-strip","data-state":t&&t.state?t.state:"none",title:e?`${s} · ${p(e.messageKey)}`:s,children:[l.jsx("span",{className:`nc-m-live-dot ${Lv(t||{})}`,"aria-hidden":"true"}),l.jsx("span",{className:"nc-m-live-testo",children:n?t.cell:s}),e&&l.jsx("span",{className:`nc-m-live-notice${e.ok?" ok":" ko"}`,role:"status",children:p(e.messageKey).replace("{cell}",e.cell||t.cell||"")})]})}function Cp({label:t,count:e,state:n,dotClass:s="",dotTitle:i="",detail:a="",onToggle:c,onFilter:u,onRename:h=null,action:f=null}){return l.jsxs("div",{className:"nc-mobile-position-head",onContextMenu:h?g=>{g.preventDefault(),h()}:void 0,children:[l.jsxs("button",{type:"button",className:"nc-mobile-position-toggle",onClick:c,"aria-expanded":n.open,"aria-label":`${t} · ${p("node-sessions").replace("{n}",String(e))}`,children:[l.jsx("span",{className:"nc-mobile-chevron","aria-hidden":"true",children:n.open?"⌄":"›"}),l.jsx("span",{className:`dot ${s}`,title:i}),l.jsxs("span",{className:"nc-mobile-position-copy",children:[l.jsx("b",{children:t}),l.jsx("small",{children:a||p("node-sessions").replace("{n}",String(e))})]})]}),l.jsxs("select",{className:"nc-mobile-position-filter",value:n.filter,"aria-label":`${t} · ${p("filter-placeholder")}`,title:p(`view-${n.filter}`),onChange:g=>u(g.target.value),children:[l.jsx("option",{value:"all",children:p("view-all")}),l.jsx("option",{value:"pinned",children:p("view-pinned")}),l.jsx("option",{value:"active",children:p("view-active")}),l.jsx("option",{value:"off",children:p("view-off")}),l.jsx("option",{value:"technical",children:p("view-technical")})]}),f]})}const H0="",ln="\x1B",ZP=[{label:"↑",seq:ln+"[A"},{label:"↓",seq:ln+"[B"},{label:"PGUP",seq:ln+"[5~"},{label:"PGDN",seq:ln+"[6~"}],eI=new Set([ln+"[A",ln+"[B",ln+"[C",ln+"[D",ln+"[5~",ln+"[6~"]),tI=350,nI=55;function sI({send:t,action:e,ctrlArmed:n=!1,onCtrl:s,altArmed:i=!1,onAlt:a,onAltConsume:c,onKeyboard:u,selectionMode:h=!1,onSelectionMode:f,onCellSwitcher:g,cellSwitcherOpen:v=!1,keepKeyboardClosed:_=!0,showEnter:b=!0,keybarLayout:x="full",onKeyboardKeep:L}){const[k,R]=w.useState(!1),[S,j]=w.useState(!1),[E,F]=w.useState(!1),$=x==="compact"&&!E,G=w.useRef({delay:null,interval:null}),K=w.useRef(()=>{}),Y=()=>{const P=G.current;P.delay!==null&&clearTimeout(P.delay),P.interval!==null&&clearInterval(P.interval),P.delay=null,P.interval=null};K.current=Y,w.useEffect(()=>{const P=()=>{document.visibilityState==="hidden"&&K.current()},H=()=>K.current();return window.addEventListener("blur",H),document.addEventListener("visibilitychange",P),()=>{window.removeEventListener("blur",H),document.removeEventListener("visibilitychange",P),K.current()}},[]),w.useEffect(()=>{x!=="compact"&&F(!1)},[x]);const te=P=>{i?(t(ln+P),c&&c()):t(P)},q=(P,{keepOpen:H}={})=>{_&&!H&&ug(),H&&L&&L(),P()},D=(P,H={})=>({onPointerDown:ie=>{ie.preventDefault(),q(P,H)},onClick:ie=>{ie.detail===0&&q(P,H)}}),I=(P,H={})=>({onPointerDown:ie=>{ie.preventDefault(),Y(),q(P,H),!i&&(G.current.delay=setTimeout(()=>{G.current.delay=null,P(),G.current.interval=setInterval(P,nI)},tI))},onPointerUp:Y,onPointerLeave:Y,onPointerCancel:Y,onLostPointerCapture:Y,onTouchCancel:Y,onClick:ie=>{ie.detail===0&&q(P,H)}}),O=(P,H,ie)=>l.jsx("button",{type:"button",...eI.has(H)&&!ie?I(()=>te(H)):D(()=>{te(H),ie&&ie()}),children:P},P),M=(P,H)=>l.jsx("button",{type:"button",...D(()=>{e(H),j(!1)}),children:P},P),z=g?l.jsx("button",{type:"button","aria-label":p("fleet-cells"),title:p("fleet-cells"),"aria-expanded":v,...D(g),children:"◫"},"cells"):l.jsx("button",{type:"button",...D(()=>{u&&u()}),children:"⌨"},"kbd"),T=b&&l.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...D(()=>te("\r")),children:l.jsx(Tt,{name:"enter",size:24})}),A=S&&l.jsxs("div",{className:"nc-keymenu",children:[M("←WIN","prev-window"),M("WIN→","next-window"),M("⬅PANE","pane-left"),M("PANE➡","pane-right"),O("SCROLL",H0+"[",()=>{R(!0),j(!1)}),l.jsx("button",{type:"button",className:h?"armed":"",...D(()=>{f==null||f(!h),j(!1)}),children:"SELECT"}),O("⌃C","",()=>j(!1)),O("DETACH",H0+"d",()=>j(!1))]});if(k)return l.jsxs("div",{className:"nc-keybar copy",children:[l.jsx("span",{className:"tag",children:"copy-mode"}),ZP.map(P=>O(P.label,P.seq)),O("ESCI (q)","q",()=>R(!1))]});if($)return l.jsxs("div",{className:"nc-keybar termux",children:[A,l.jsxs("div",{className:`nc-keygrid compact${b?"":" no-enter"}`,children:[l.jsx("div",{className:"nc-keyrows",children:l.jsxs("div",{className:"row",children:[l.jsx("button",{type:"button","aria-label":p("keybar-expand"),title:p("expand"),...D(()=>F(!0)),children:l.jsx(Tt,{name:"chevronUp",size:20})},"expand"),z,l.jsx("button",{type:"button",className:S?"armed":"",...D(()=>j(P=>!P)),children:"☰"},"menu"),O("↑",ln+"[A"),O("↓",ln+"[B"),O("←",ln+"[D"),O("→",ln+"[C"),O("PGUP",ln+"[5~"),O("PGDN",ln+"[6~")]})}),T]})]});const N=x==="compact"&&E,U=N&&l.jsx("button",{type:"button",className:"nc-retract-key","aria-label":p("keybar-retract"),title:p("retract"),...D(()=>F(!1)),children:l.jsx(Tt,{name:"chevronDown",size:20})});return l.jsxs("div",{className:`nc-keybar termux${N?" expanded":""}`,children:[A,l.jsxs("div",{className:`nc-keygrid${b?"":" no-enter"}${N?" expanded":""}`,children:[U,l.jsxs("div",{className:"nc-keyrows",children:[l.jsxs("div",{className:"row",children:[O("ESC",ln),l.jsx("button",{type:"button",className:S?"armed":"",...D(()=>j(P=>!P)),children:"☰"},"menu"),O("/","/"),O("—","-"),O("HOME",ln+"[H"),O("↑",ln+"[A"),O("END",ln+"[F"),O("PGUP",ln+"[5~")]}),l.jsxs("div",{className:"row",children:[O("⇥"," "),z,l.jsx("button",{type:"button",className:n?"armed":"",...D(()=>{s&&s()},{keepOpen:!0}),children:"CTRL"},"ctrl"),l.jsx("button",{type:"button",className:i?"armed":"",...D(()=>{a&&a()},{keepOpen:!0}),children:"ALT"},"alt"),O("←",ln+"[D"),O("↓",ln+"[B"),O("→",ln+"[C"),O("PGDN",ln+"[6~")]})]}),T]})]})}const iI=t=>t>1048576?`${(t/1048576).toFixed(1)}M`:t>1024?`${(t/1024).toFixed(0)}K`:`${t}B`;function Rg({session:t,node:e,token:n,filesEvent:s,onClose:i}){zn();const a=e?`/api/route/${String(e).split("/").map(encodeURIComponent).join("/")}/_`:"/api",c=e?`${e}:${t}`:t,[u,h]=w.useState("outbox"),[f,g]=w.useState({inbox:[],outbox:[]}),[v,_]=w.useState("");async function b(){try{const R=await(await qn(`${a}/files?session=${encodeURIComponent(t)}`,n)).json();if(R.error){_(R.error);return}g(R);const S=R.outbox[0]?R.outbox[0].mtime:0;localStorage.setItem(k1(c),String(S))}catch(k){_(String(k))}}w.useEffect(()=>{b()},[t,e]),w.useEffect(()=>{s&&s.session===t&&b()},[s]);async function x(k){const R=await qn(`${a}/files/download?session=${encodeURIComponent(t)}&box=${u}&name=${encodeURIComponent(k)}`,n);if(!R.ok){const F=await R.json().catch(()=>({}));_(F.error?`errore: ${F.error}`:"errore download");return}const S=await R.blob(),j=URL.createObjectURL(S),E=document.createElement("a");E.href=j,E.download=k,E.click(),URL.revokeObjectURL(j)}async function L(k){const R=await qn(`${a}/files?session=${encodeURIComponent(t)}&box=${u}&name=${encodeURIComponent(k)}`,n,{method:"DELETE"});if(!R.ok){const S=await R.json().catch(()=>({}));_(S.error?`errore: ${S.error}`:"errore delete");return}b()}return l.jsxs("div",{className:"nc-files",children:[l.jsxs("header",{children:[l.jsx("b",{children:e?`${e}:${t}`:t}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:i,title:p("close"),"aria-label":p("close"),children:l.jsx(Tt,{name:"x",size:16})})]}),l.jsxs("nav",{children:[l.jsx("button",{className:u==="outbox"?"on":"",onClick:()=>h("outbox"),children:"outbox"}),l.jsx("button",{className:u==="inbox"?"on":"",onClick:()=>h("inbox"),children:"inbox"})]}),v&&l.jsx("div",{className:"nc-busy",children:v}),l.jsxs("ul",{children:[f[u].map(k=>l.jsxs("li",{children:[l.jsx("span",{className:"name",children:k.name}),l.jsx("small",{children:iI(k.size)}),l.jsx("button",{type:"button",onClick:()=>x(k.name),title:p("files-download"),"aria-label":`${p("files-download")} ${k.name}`,children:l.jsx(Tt,{name:"download",size:18})}),l.jsx("button",{onClick:()=>L(k.name),title:p("delete"),"aria-label":`${p("delete")} ${k.name}`,children:l.jsx(Tt,{name:"trash",size:18})})]},k.name)),f[u].length===0&&l.jsx("li",{className:"empty",children:p("empty-files")})]})]})}const fh="nc_composer_v1",Lg="nc-composer-reset",rI=50,sC=256*1024,iC=512*1024,oI=768*1024,U0=2*1024*1024,rC=720*60*60*1e3,Ag=1;function oC(t){const e=Number(t);return Number.isFinite(e)&&e>0?e:0}function Tv(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function $d(){return{version:Ag,cells:{}}}function aC(t){const e=[];for(const s of Array.isArray(t)?t:[]){const i=typeof s=="string"?s:s&&s.text,a=oC(typeof s=="string"?0:s&&s.at);if(!(typeof i!="string"||!i||i.length>sC)&&!(e.length&&e[e.length-1].text===i)&&(e.push({text:i,at:a}),e.length>=rI))break}let n=0;return e.filter(s=>n+s.text.length>oI?!1:(n+=s.text.length,!0))}function zd(t){if(!t||typeof t!="object")return null;const e=typeof t.draft=="string"&&t.draft.length<=iC?t.draft:"",n=aC(t.history),s=oC(t.updatedAt),i=t.expanded===!0;return!e&&!n.length&&!i?null:{draft:e,history:n,expanded:i,updatedAt:s}}function aI(t){let e;try{e=typeof t=="string"?JSON.parse(t):t}catch{return $d()}if(!e||typeof e!="object"||e.version!==Ag||!e.cells||typeof e.cells!="object")return $d();const n=Object.create(null);for(const[s,i]of Object.entries(e.cells)){if(!s||typeof s!="string"||s.length>512||s==="__proto__"||s==="constructor"||s==="prototype")continue;const a=zd(i);a&&(n[s]=a)}return{version:Ag,cells:n}}function lC(t){const e=Tv(t);if(!e)return $d();try{return aI(e.getItem(fh))}catch{return $d()}}function W0(t){try{return JSON.stringify(t).length}catch{return 1/0}}function lI(t,e,n){for(const[s,i]of Object.entries(t.cells))s!==n&&i.updatedAt>0&&e-i.updatedAt>rC&&delete t.cells[s]}function cC(t,e){return Object.entries(t.cells).filter(([n])=>n!==e).sort((n,s)=>n[1].updatedAt-s[1].updatedAt).map(([n])=>n)}function cI(t,e){for(;W0(t)>U0;){const n=Object.entries(t.cells).filter(([,s])=>s.history.length).sort((s,i)=>s[1].updatedAt-i[1].updatedAt);if(!n.length)break;n[0][1].history.pop()}for(const n of cC(t,e)){if(W0(t)<=U0)break;delete t.cells[n]}}function uC(t,e,n){const s=Tv(t);if(!s)return!1;cI(e,n);const i=()=>(s.setItem(fh,JSON.stringify(e)),!0);try{return i()}catch{for(const c of cC(e,n)){delete e.cells[c];try{return i()}catch{}}return!1}}function Hc(t,e,n,s){const i=lC(e);lI(i,n,t);const a=zd(i.cells[t])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...a,history:[...a.history]}),u=zd(c);return u?i.cells[t]={...u,updatedAt:n}:delete i.cells[t],{ok:uC(e,i,t),cell:i.cells[t]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function uI({ownerId:t,node:e,session:n}){const s=String(n||"");if(!s)return"";const i=Ya.test(String(t||""))?String(t):e?`route:${String(e)}`:"local";return`${encodeURIComponent(i)}:${encodeURIComponent(s)}`}function Yl(t,e,n=Date.now()){if(!t)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=lC(e),i=zd(s.cells[t]);return!i||i.updatedAt>0&&n-i.updatedAt>rC?(s.cells[t]&&(delete s.cells[t],uC(e,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...i,history:[...i.history]}}function q0(t,e,n,s=Date.now()){const i=String(e||"");return!t||i.length>iC?!1:Hc(t,n,s,a=>({...a,draft:i})).ok}function K0(t,e,n=Date.now()){return t?Hc(t,e,n,s=>({...s,draft:""})).ok:!1}function dI(t,e,n,s=Date.now()){return t?Hc(t,n,s,i=>({...i,expanded:!!e})).ok:!1}function hI(t,e,n,s=Date.now()){const i=String(e||"");return!t||!i||i.length>sC?!1:Hc(t,n,s,a=>{const c=a.history.filter(u=>u.text!==i);return c.unshift({text:i,at:s}),{...a,history:aC(c)}}).ok}function fI(t,e,n=Date.now()){return t?Hc(t,e,n,s=>({...s,history:[]})).ok:!1}function pI(t){const e=Tv(t);if(!e)return!1;try{return e.removeItem(fh),!0}catch{return!1}}const mI=300;function gI(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function vI({ownerId:t,node:e,session:n,storage:s=gI()}){const i=w.useMemo(()=>uI({ownerId:t,node:e,session:n}),[t,e,n]),a=w.useMemo(()=>Yl(i,s),[]),[c,u]=w.useState(a.draft),[h,f]=w.useState(a.expanded),[g,v]=w.useState(a.history),[_,b]=w.useState(-1),x=w.useRef(i),L=w.useRef(a.draft),k=w.useRef(null),R=w.useRef(a.updatedAt||0),S=w.useRef(a.draft),j=w.useCallback(()=>{k.current&&clearTimeout(k.current),k.current=null},[]),E=w.useCallback(()=>{j(),q0(x.current,L.current,s)},[j,s]),F=w.useCallback(()=>{j(),k.current=setTimeout(()=>{k.current=null,q0(x.current,L.current,s)},mI)},[j,s]),$=w.useCallback(O=>{const M=String(typeof O=="function"?O(L.current):O||"");L.current=M,R.current=Date.now(),S.current=M,b(-1),u(M),F()},[F]),G=w.useCallback((O,M)=>{j(),L.current=O,R.current=Date.now(),u(O),b(M),F()},[j,F]),K=w.useCallback(()=>{if(!g.length)return!1;const O=Math.min(_+1,g.length-1);return _<0&&(S.current=L.current),G(g[O].text,O),!0},[G,g,_]),Y=w.useCallback(()=>{if(_<0)return!1;const O=_-1;return G(O<0?S.current:g[O].text,O),!0},[G,g,_]),te=w.useCallback(O=>{S.current=L.current;const M=g.findIndex(z=>z.text===O);G(String(O||""),M)},[G,g]),q=w.useCallback(()=>{f(O=>{const M=!O;return dI(x.current,M,s),M})},[s]),D=w.useCallback((O,M,z)=>{if(!O)return;if(hI(O,z,s),!(x.current===O)){Yl(O,s).draft===M&&K0(O,s);return}v(Yl(O,s).history),S.current="",b(-1),L.current===M?(j(),L.current="",R.current=Date.now(),u(""),K0(O,s)):F()},[j,F,s]),I=w.useCallback(()=>{fI(x.current,s),v([]),b(-1),S.current=L.current},[s]);return w.useEffect(()=>{if(x.current===i)return;E(),x.current=i;const O=Yl(i,s);L.current=O.draft,R.current=O.updatedAt||0,S.current=O.draft,u(O.draft),f(O.expanded),v(O.history),b(-1)},[i,E,s]),w.useEffect(()=>{const O=()=>E(),M=()=>{document.visibilityState==="hidden"&&E()};return window.addEventListener("pagehide",O),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("pagehide",O),document.removeEventListener("visibilitychange",M),E()}},[E]),w.useEffect(()=>{const O=()=>{j(),L.current="",R.current=0,S.current="",u(""),f(!1),v([]),b(-1)},M=T=>{if(T.key!==fh)return;if(T.newValue==null){O();return}const A=Yl(x.current,s);A.updatedAt<R.current||(j(),L.current=A.draft,R.current=A.updatedAt,S.current=A.draft,u(A.draft),f(A.expanded),v(A.history),b(-1))},z=()=>O();return window.addEventListener("storage",M),window.addEventListener(Lg,z),()=>{window.removeEventListener("storage",M),window.removeEventListener(Lg,z)}},[j,s]),{cellKey:i,text:c,setText:$,expanded:h,toggleExpanded:q,history:g,historyCursor:_,recallPrevious:K,recallNext:Y,selectHistory:te,confirmSubmitted:D,clearHistory:I,flush:E}}function dC({submitText:t,token:e,session:n,node:s,ownerId:i,readonly:a=!1,keepKeyboardClosedOnVoice:c=!0}){zn();const u=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:f,setText:g,expanded:v,toggleExpanded:_,history:b,historyCursor:x,recallPrevious:L,recallNext:k,selectHistory:R,confirmSubmitted:S,clearHistory:j,flush:E}=vI({ownerId:i,node:s,session:n}),[F,$]=w.useState(!1),[G,K]=w.useState(""),[Y,te]=w.useState(""),[q,D]=w.useState(!1),I=w.useRef(null),O=w.useRef(null),M=w.useRef(null),[z,T]=w.useState(!1),[A,N]=w.useState({left:0,bottom:0}),[U,P]=w.useState(!1),[H,ie]=w.useState(!1),J=w.useRef(null),Q=w.useRef(null),ve=w.useRef(null),de=w.useRef(null),ne=w.useRef(null),xe=w.useRef(null),$e=w.useRef(null),rt=w.useRef(null),je=w.useRef(!1),[Ie,oe]=w.useState(!1),[Ne,me]=w.useState({left:0,bottom:0,width:320}),Ce=w.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);w.useEffect(()=>{let he=!1;if(s){D(!1);return}return qn(`${u}/voice/status`,e).then(Z=>Z.json()).then(Z=>{he||D(!!Z.serverSttConfigured)}).catch(()=>{he||D(!1)}),()=>{he=!0}},[e,u]);const ge=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||q);async function Le(){const he=M.current&&typeof M.current.value=="string"?M.current.value:f;ug(),he!==f&&g(he);const Z=he,X=XM(Z);if(!X||H)return;if(a){K(p("settings-readonly"));return}ie(!0),K("");let ue=!1;try{ue=!!await t(X)}catch{ue=!1}ue?S(h,Z,X):K(p("composer-send-failed")),ie(!1)}function ke(){const he=J.current&&J.current.getBoundingClientRect();he&&N({left:Math.max(6,Math.min(he.left,window.innerWidth-186)),bottom:window.innerHeight-he.top+6}),T(!0)}function We(he){T(!1),he&&J.current&&J.current.focus()}function Re(){const he=ve.current&&ve.current.getBoundingClientRect();if(he){const Z=Math.max(220,Math.min(360,window.innerWidth-12));me({left:Math.max(6,Math.min(he.right-Z,window.innerWidth-Z-6)),bottom:window.innerHeight-he.top+6,width:Z})}oe(!0)}function _e(he){oe(!1),he&&ve.current&&ve.current.focus()}w.useEffect(()=>{if(!z)return;const he=X=>{X.key==="Escape"&&We(!0)},Z=X=>{const ue=Q.current&&Q.current.contains(X.target),Ze=J.current&&J.current.contains(X.target);!ue&&!Ze&&We(!1)};return document.addEventListener("keydown",he),document.addEventListener("pointerdown",Z),()=>{document.removeEventListener("keydown",he),document.removeEventListener("pointerdown",Z)}},[z]),w.useEffect(()=>{if(!Ie)return;const he=X=>{X.key==="Escape"&&_e(!0)},Z=X=>{const ue=de.current&&de.current.contains(X.target),Ze=ve.current&&ve.current.contains(X.target);!ue&&!Ze&&_e(!1)};return document.addEventListener("keydown",he),document.addEventListener("pointerdown",Z),()=>{document.removeEventListener("keydown",he),document.removeEventListener("pointerdown",Z)}},[Ie]);function st(he){if(!(he.isComposing||je.current||he.altKey||he.ctrlKey||he.metaKey)){if(he.key==="ArrowUp"&&he.currentTarget.selectionStart===0&&he.currentTarget.selectionEnd===0){L()&&he.preventDefault();return}he.key==="ArrowDown"&&x>=0&&he.currentTarget.selectionStart===f.length&&he.currentTarget.selectionEnd===f.length&&k()&&he.preventDefault()}}function Xe(he){We(!1),he.current&&he.current.click()}async function De(he){if(!he.length||!n)return;P(!0),K("");const{paths:Z,errors:X}=await cg({files:he,token:e,session:n,node:s,paste:!1});X.length&&K(X.map(ue=>`${ue.name}: ${ue.message}`).join(" · ")),Z.length&&g(ue=>ue+(ue&&!ue.endsWith(" ")?" ":"")+Z.join(" ")),P(!1)}async function He(he){var ue;if(!he.length||!n)return;P(!0),K(""),te("");const{paths:Z,errors:X}=await cg({files:he,token:e,session:n,node:s,paste:!1});if(X.length&&K(X.map(Ze=>`${Ze.name}: ${Ze.message}`).join(" · ")),Z.length){te(p("attach-inbox-done").replace("{n}",String(Z.length)));try{(ue=navigator.vibrate)==null||ue.call(navigator,10)}catch{}setTimeout(()=>te(""),2500)}P(!1)}function Ke(){I.current&&I.current.stop(),O.current&&O.current.stop(),$(!1)}async function wt(){K("");const he=window.SpeechRecognition||window.webkitSpeechRecognition;if(he){const Z=new he;Z.lang="it-IT",Z.continuous=!1,Z.interimResults=!0;const X=f?`${f} `:"";Z.onresult=ue=>{const Ze=Array.from(ue.results).map(se=>se[0].transcript).join("");g(X+Ze)},Z.onend=()=>$(!1),Z.onerror=ue=>{K(`voice: ${ue.error||"errore"}`),$(!1)},I.current=Z,Z.start(),$(!0);return}try{const Z=await navigator.mediaDevices.getUserMedia({audio:!0}),X=new MediaRecorder(Z),ue=[];X.ondataavailable=Ze=>ue.push(Ze.data),X.onstop=async()=>{Z.getTracks().forEach(Ze=>Ze.stop()),$(!1),K("trascrivo…");try{const Ze=new Blob(ue,{type:X.mimeType||"audio/webm"}),Be=await(await qn(`${u}/voice/transcribe`,e,{method:"POST",headers:{"content-type":"application/octet-stream"},body:Ze})).json();Be.error?K(Be.error):(K(""),g(ht=>ht+(ht?" ":"")+(Be.text||"")))}catch(Ze){K(String(Ze))}},O.current={stop:()=>X.state!=="inactive"&&X.stop()},X.start(),$(!0)}catch{K("microfono non disponibile"),$(!1)}}function fe(){c&&ug(),F?Ke():wt()}return l.jsxs("div",{className:"nc-composer",children:[G&&l.jsx("div",{className:"nc-composer-err",children:G}),Y&&l.jsx("div",{className:"nc-composer-info",children:Y}),l.jsxs("div",{className:"nc-composer-row",children:[n&&l.jsx("button",{ref:J,className:U?"attach busy":"attach",disabled:U,onClick:()=>z?We(!1):ke(),title:p(U?"attach-uploading":"attach"),"aria-label":p("attach"),"aria-haspopup":"menu","aria-expanded":z,"aria-controls":Ce.current,children:l.jsx(Tt,{name:"attach",size:22})}),z&&l.jsxs("div",{ref:Q,id:Ce.current,role:"menu",className:"nc-attach-menu",style:{left:A.left,bottom:A.bottom},children:[l.jsxs("button",{role:"menuitem",onClick:()=>Xe(ne),children:[l.jsx(Tt,{name:"file",size:18})," ",p("attach-file")]}),l.jsxs("button",{role:"menuitem",onClick:()=>Xe(xe),children:[l.jsx(Tt,{name:"camera",size:18})," ",p("attach-camera")]}),l.jsxs("button",{role:"menuitem",onClick:()=>Xe($e),children:[l.jsx(Tt,{name:"image",size:18})," ",p("attach-gallery")]}),l.jsxs("button",{role:"menuitem",onClick:()=>Xe(rt),children:[l.jsx(Tt,{name:"folder",size:18})," ",p("attach-inbox")]})]}),l.jsx("button",{ref:ve,type:"button",className:"history",onPointerDown:he=>he.preventDefault(),onClick:()=>Ie?_e(!1):Re(),title:p("composer-history-tools"),"aria-label":p("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":Ie,children:l.jsx(Tt,{name:"history",size:21})}),Ie&&l.jsxs("div",{ref:de,role:"menu",className:"nc-composer-history-menu",style:{left:Ne.left,bottom:Ne.bottom,width:Ne.width},children:[l.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:he=>he.preventDefault(),onClick:()=>{_(),_e(!1)},children:[l.jsx(Tt,{name:v?"chevronDown":"chevronUp",size:18}),p(v?"composer-collapse":"composer-expand")]}),l.jsx("div",{className:"nc-composer-history-title",children:p("composer-history")}),b.length===0&&l.jsx("div",{className:"nc-composer-history-empty",children:p("composer-history-empty")}),b.map((he,Z)=>l.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:X=>X.preventDefault(),onClick:()=>{R(he.text),_e(!1)},children:[l.jsx("span",{children:he.text.replace(/\s+/g," ").slice(0,180)}),he.at>0&&l.jsx("small",{children:new Date(he.at).toLocaleString()})]},`${he.at}:${Z}`)),b.length>0&&l.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:he=>he.preventDefault(),onClick:()=>{j(),_e(!1)},children:p("composer-history-clear")})]}),l.jsx("input",{ref:ne,type:"file",multiple:!0,hidden:!0,onChange:he=>{De(Array.from(he.target.files||[])),he.target.value=""}}),l.jsx("input",{ref:xe,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:he=>{De(Array.from(he.target.files||[])),he.target.value=""}}),l.jsx("input",{ref:$e,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:he=>{De(Array.from(he.target.files||[])),he.target.value=""}}),l.jsx("input",{ref:rt,type:"file",multiple:!0,hidden:!0,onChange:he=>{He(Array.from(he.target.files||[])),he.target.value=""}}),l.jsx("textarea",{ref:M,className:v?"expanded":"",rows:v?8:2,value:f,placeholder:p("composer-placeholder"),onChange:he=>g(he.target.value),onKeyDown:st,onCompositionStart:()=>{je.current=!0},onCompositionEnd:()=>{je.current=!1},onBlur:E}),ge&&l.jsx("button",{type:"button",className:F?"mic on":"mic",title:p("voice"),"aria-label":p("voice"),onPointerDown:he=>{he.preventDefault(),fe()},onClick:he=>{he.detail===0&&fe()},children:l.jsx(Tt,{name:"mic",size:22})}),l.jsx("button",{type:"button",className:"go",disabled:H,onPointerDown:he=>he.preventDefault(),onClick:Le,title:p("send"),children:l.jsx(Tt,{name:"enter",size:22})})]})]})}const V0=460,_I=320;function yI({row:t,token:e,panelPort:n=0,anchorRect:s,liveHost:i=null,onLiveHostApplied:a,source:c,onSourceChange:u,onExpand:h,onClose:f,onMouseEnter:g,onMouseLeave:v}){w.useEffect(()=>{const x=L=>{L.key==="Escape"&&f()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[f]);const _=s?Math.max(8,Math.min(s.right+10,window.innerWidth-V0-8)):void 0,b=s?Math.max(8,Math.min(s.top-6,window.innerHeight-_I-8)):void 0;return l.jsxs("div",{className:"nc-peekcloud",style:{left:_,top:b,width:V0},"data-testid":"peek-cloud",onMouseEnter:g,onMouseLeave:v,children:[l.jsxs("div",{className:"nc-peekcloud-testa",children:[l.jsx("b",{className:"nc-peekcloud-nome",children:t.cellName}),[t.nodeLabel,t.subtitle].filter(Boolean).length>0&&l.jsx("span",{className:"nc-peekcloud-sub",children:[t.nodeLabel,t.subtitle].filter(Boolean).join(" · ")}),l.jsx("button",{type:"button",className:"nc-peekcloud-espandi",title:p("cell-peek-expand"),"aria-label":`${p("cell-peek-expand")}: ${t.cellName}`,onClick:()=>h(c),children:"⤢"})]}),l.jsx(vv,{row:t,token:e,panelPort:n,liveHost:i,onLiveHostApplied:a,source:c,onSourceChange:u})]})}function Ep(t){return String(t||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const wI=180,bI=480,Gl=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function SI({sessions:t=[],cells:e=[],activeSessions:n=[],nodeGroups:s=[],onPick:i,onAddTile:a,onPower:c,onBoot:u,onNodePower:h,onKill:f,onVisibility:g,onNew:v,onNodeRename:_,onSettings:b,onBootError:x,localNodeId:L,fleetCapabilities:k=[],fleetStale:R=!1,fleetOff:S=null,bootSettlement:j=null,localVerified:E=!0,hostByRoute:F={},onDesignateCell:$,onClearHostCell:G,onBootSettlementApplied:K,onOpenVlSession:Y,token:te="",onPeekOpen:q,overlayOpen:D=!1,width:I=240,collapsed:O=!1,onResize:M,onToggleCollapse:z}){const[T,A]=zn(),{pins:N,orders:U,togglePin:P,removePin:H,pinError:ie,reorderBlocked:J,retryPinPersist:Q,clearPinError:ve,viewFor:de,updateView:ne,canMoveRoster:xe,moveRoster:$e,stepRoster:rt}=Cv(),{groupsFor:je,moveNode:Ie,stepNode:oe,nodeKey:Ne}=ch(),me=W=>F[Cs(W)]||{},Ce=new Set((e||[]).map(W=>W.tmuxSession)),V=new Map((t||[]).map(W=>[W.name,W])),ge=(W,ae)=>oP(N,W,ae),Le=aP,ke=[...e||[]].sort((W,ae)=>Le(ge(W.tmuxSession,(V.get(W.tmuxSession)||{}).activity),ge(ae.tmuxSession,(V.get(ae.tmuxSession)||{}).activity))),We=(t||[]).filter(W=>!Ce.has(W.name)).sort((W,ae)=>Le(ge(W.name,W.activity),ge(ae.name,ae.activity))||W.name.localeCompare(ae.name)),Re=new Set(n||[]),[_e,st]=w.useState(null),[Xe,De]=w.useState("preview"),[He,Ke]=w.useState(null),wt=w.useRef(null),fe=w.useRef(null),he=w.useRef(null);w.useEffect(()=>{he.current=_e},[_e]),w.useEffect(()=>()=>{clearTimeout(wt.current),clearTimeout(fe.current)},[]);const[Z,X]=w.useState(null),[ue,Ze]=w.useState(null),[se,Be]=w.useState(!1),[ht,Pt]=w.useState(null),St=(W,ae,Ae=[],Je="",Pe=null)=>{const vt=(Ae.length===0?V.get(ae.tmuxSession):(Pe||[]).find(Qe=>Qe&&Qe.name===ae.tmuxSession))||{};return{key:W.key,cellName:ae.cell,subtitle:W.subtitle||"",nodeLabel:Je,node:Ae.length?Ae.join("/"):"",session:ae.tmuxSession,route:Ae,panelUrl:ae.panelUrl||"",telemetry:vt.telemetry||null,preview:vt.preview||ae.preview||"",activity:vt.activity||ae.activity||0}},Nt=(W,ae,Ae=[],Je="",Pe="preview")=>xt=>{xt&&xt.stopPropagation(),Ke(null),De(Pe),st(W.key),typeof q=="function"&&q()},ut=(W,ae,Ae)=>{Ae&&(clearTimeout(fe.current),clearTimeout(wt.current),wt.current=setTimeout(()=>{he.current||Ke({itemKey:W.key,routeKey:ae||"",anchorRect:Ae.getBoundingClientRect(),source:"stream"})},300))},zt=()=>{clearTimeout(wt.current),clearTimeout(fe.current),fe.current=setTimeout(()=>Ke(null),150)},Yt=()=>clearTimeout(fe.current),Ut=()=>Ke(null),dt=(W,ae,Ae,Je,Pe)=>{if(Z&&Z.itemKey===W){X(null);return}X({itemKey:W,routeKey:ae||"",canBoot:!!Je,preserved:!!Pe}),Ze(Ae?Ae.getBoundingClientRect():null)};w.useEffect(()=>{D&&(st(null),De("preview"))},[D]);const qt=Av(ke,We,V,void 0,{autorevole:E,fleetStale:R}),In=kr(qt,N,de("local").filter,wi(U,"local")),wn=je(s||[]).map(W=>{const ae=(W.route&&W.route.length?W.route:[W.name]).join("/"),Ae=de(ae);if(W.kind==="vl")return{g:W,nodeRoute:ae,groupView:Ae,rawItems:[],items:[]};const{rawItems:Je}=gc(W),Pe=kr(Je,N,Ae.filter,wi(U,ae));return{g:W,nodeRoute:ae,groupView:Ae,rawItems:Je,items:Pe}}),tn=[...In,...wn.flatMap(({items:W,nodeRoute:ae,g:Ae})=>(W||[]).map(Je=>({...Je,nodeRoute:ae,nodeLabel:Ae.label||Ae.name})))].filter(W=>W.type==="cell"),bn=_e?tn.find(W=>W.key===_e):null,Ft=()=>{if(!He)return null;const W=tn.find(Pe=>Pe.key===He.itemKey);if(!W)return null;const ae=W.value,Ae=W.nodeRoute?s.find(Pe=>(Pe.route||[Pe.name]).join("/")===W.nodeRoute)||{}:null,Je=W.nodeRoute?Ae.route||[W.nodeRoute]:[];return l.jsx(yI,{row:St(W,ae,Je,W.nodeLabel||"",Ae&&Ae.sessions),token:te,anchorRect:He.anchorRect,source:He.source,onSourceChange:Pe=>Ke(xt=>xt&&{...xt,source:Pe}),onExpand:Pe=>{Ke(null),De(Pe),st(W.key),typeof q=="function"&&q()},onClose:Ut,onMouseEnter:Yt,onMouseLeave:zt})},Jt=(W,ae,Ae)=>i&&i({session:W,...ae?{node:ae}:{},...Ya.test(String(Ae||""))?{ownerId:Ae}:{}}),Qt=async W=>{if(!(W!=null&&W.direct)||!_)return;const ae=window.prompt(p("rename-node-prompt"),W.label||W.name);if(ae!==null)try{await _(W,ae)||window.alert(p("rename-node-invalid"))}catch(Ae){window.alert(String((Ae==null?void 0:Ae.message)||Ae))}},[Zt,ls]=w.useState({}),[cs,mn]=w.useState(new Set);w.useEffect(()=>{const W=new Map;for(const ae of e||[])W.set(Gl(ae.cell),!!ae.boot);for(const ae of s||[]){const Ae=ae.route||[ae.name];for(const Je of ae.cells||[])W.set(Gl(Je.cell,Ae),!!Je.boot)}ls(ae=>{let Ae=!1;const Je={...ae};for(const[Pe,xt]of Object.entries(ae))W.has(Pe)&&W.get(Pe)===xt&&(delete Je[Pe],Ae=!0);return Ae?Je:ae})},[e,s]),w.useEffect(()=>{if(!(j!=null&&j.cell))return;const W=Array.isArray(j.route)?j.route:[],ae=Gl(j.cell,W);ls(Ae=>({...Ae,[ae]:!!j.enabled})),K&&K(j.id)},[j,K]);const gn=(W,ae=[])=>{const Ae=Gl(W.cell,ae);return Object.prototype.hasOwnProperty.call(Zt,Ae)?Zt[Ae]:!!W.boot},qs=async(W,ae,Ae=[],Je)=>{if(!u)return;const Pe=Gl(ae.cell,Ae),xt=typeof Je=="boolean"?Je:!gn(ae,Ae);ls(vt=>({...vt,[Pe]:xt})),mn(vt=>new Set(vt).add(Pe));try{await u(ae.cell,xt,Ae)}catch(vt){ls(Qe=>{const Rt={...Qe};return delete Rt[Pe],Rt}),x&&x(vt)}finally{mn(vt=>{const Qe=new Set(vt);return Qe.delete(Pe),Qe})}},Vn=(W,ae,Ae)=>({onToggleLive:async()=>{const Je=lo({item:W,cellName:ae.cell,route:Ae,pins:N,hostByRoute:F});Be(!0);const Pe=await th({action:Je.isLive?"remove":"use",cellId:ae.cell,route:Ae,token:te});Be(!1),Pt({messageKey:Pe.messageKey,ok:Pe.ok,cell:Pe.hostCell||ae.cell})},onTogglePin:()=>Ev({view:uh({item:W,pins:N,hostByRoute:F,route:Ae}),itemKey:W.key,togglePin:P,removePin:H}),onToggleBoot:Je=>qs(null,ae,Ae,Je),onWatchLive:()=>{Ke(null),De("stream"),st(W.key),typeof q=="function"&&q()}}),[bt,us]=w.useState(null),le=(W,ae)=>{const Ae=W.currentTarget.getBoundingClientRect();us({text:ae,y:Ae.top+Ae.height/2})},re=()=>us(null),Te=w.useRef(null);w.useEffect(()=>()=>{Te.current&&Te.current()},[]);function Ge(W){W.preventDefault(),W.stopPropagation();const ae=W.clientX,Ae=I,Je=xt=>{const vt=Math.max(wI,Math.min(bI,Ae+(xt.clientX-ae)));M&&M(vt)},Pe=()=>{window.removeEventListener("pointermove",Je),window.removeEventListener("pointerup",Pe),window.removeEventListener("pointercancel",Pe),window.removeEventListener("blur",Pe),Te.current=null};window.addEventListener("pointermove",Je),window.addEventListener("pointerup",Pe),window.addEventListener("pointercancel",Pe),window.addEventListener("blur",Pe),Te.current=Pe}const gt=O?{width:48,flex:"0 0 48px"}:{width:I,flex:`0 0 ${I}px`};return O?l.jsxs("aside",{className:"nc-sidebar mini",style:gt,children:[l.jsx("div",{className:"nc-side-head mini",children:l.jsx("button",{className:"nc-collapse-btn",onClick:z,title:p("expand"),children:"⟩"})}),l.jsx("button",{className:"nc-side-gear mini",onClick:()=>b&&b("nodes",!1),title:p("settings"),onMouseEnter:W=>le(W,p("settings")),onMouseLeave:re,children:l.jsx(Tt,{name:"gear",size:16})}),l.jsx("div",{className:"nc-side-scroll mini",children:l.jsxs("div",{className:"nc-side-group mini",children:[de("local").open&&In.map(W=>W.type==="cell"?(()=>{const ae=W.value,Ae=ae.degraded?"warn":ae.tmux?"on":"",Je=!!ae.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${Re.has(ae.tmuxSession)?" active":""}`,onMouseEnter:Pe=>{Je?ut(W,"",Pe.currentTarget):le(Pe,`${ae.cell}: ${W.subtitle}`)},onMouseLeave:()=>{Je?zt():re()},draggable:Je,onDragStart:Je?Pe=>Pe.dataTransfer.setData("text/nc-session",ae.tmuxSession):void 0,onClick:Je?()=>{Ke(null),a&&a(ae.tmuxSession)}:()=>c&&c(ae),onDoubleClick:Je?()=>Jt(ae.tmuxSession,"",L):void 0,children:l.jsx("span",{className:`nc-dot ${Ae}${W.working?" working":""}`})},W.key)})():(()=>{const ae=W.value;return l.jsx("button",{type:"button",className:`nc-mini-init${Re.has(ae.name)?" active":""}`,onMouseEnter:Ae=>le(Ae,ae.name),onMouseLeave:re,draggable:!0,onDragStart:Ae=>Ae.dataTransfer.setData("text/nc-session",ae.name),onClick:()=>a&&a(ae.name),onDoubleClick:()=>Jt(ae.name,"",L),children:Ep(ae.name)},W.key)})()),wn.flatMap(({g:W,nodeRoute:ae,groupView:Ae,items:Je})=>W.kind==="vl"?W.status==="up"&&W.sessions.length?W.sessions.map(Pe=>l.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:xt=>le(xt,`${W.label||ae}: ${Pe.name}`),onMouseLeave:re,onClick:()=>Y&&Y(W.peer),children:Ep(Pe.name)},Pe.key)):[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Pe=>le(Pe,`${W.label||W.name}: ${Qi(W)||p("no-sessions-short")}`),onMouseLeave:re,children:l.jsx("span",{className:`nc-dot${W.status==="up"?" on":" warn"}`})},`nodo-vl-${ae}-${W.name}`)]:W.status==="up"?Ae.open?Je.map(Pe=>Pe.type==="cell"?(()=>{const xt=Pe.value,vt=!!xt.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${Re.has(Pe.key)?" active":""}`,onMouseEnter:Qe=>{vt?ut(Pe,ae,Qe.currentTarget):le(Qe,`${W.label||ae}: ${xt.cell} · ${Pe.subtitle}`)},onMouseLeave:()=>{vt?zt():re()},draggable:vt,onDragStart:vt?Qe=>Qe.dataTransfer.setData("text/nc-session",Pe.key):void 0,onClick:vt?()=>{Ke(null),a&&a(Pe.key)}:()=>c&&c({...xt,route:W.route,availableEngines:W.engines||[]}),onDoubleClick:vt?()=>Jt(xt.tmuxSession,ae,W.instanceId):void 0,children:l.jsx("span",{className:`nc-dot ${xt.degraded?"warn":vt?`on${Pe.working?" working":""}`:""}`})},Pe.key)})():(()=>{const xt=Pe.value;return l.jsx("button",{type:"button",className:`nc-mini-init${Re.has(Pe.key)?" active":""}`,onMouseEnter:vt=>le(vt,`${W.label||ae}: ${xt.name}`),onMouseLeave:re,draggable:!0,onDragStart:vt=>vt.dataTransfer.setData("text/nc-session",Pe.key),onClick:()=>a&&a(Pe.key),onDoubleClick:()=>Jt(xt.name,ae,W.instanceId),children:Ep(xt.name)},Pe.key)})()):[]:[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Pe=>le(Pe,`${W.label||(W.route||[W.name]).join(" › ")}: ${Qi(W)}`),onMouseLeave:re,children:l.jsx("span",{className:`nc-dot${W.status==="passive"?"":" warn"}`})},`nodo-${(W.route||[W.name]).join("/")}`)])]})}),Ft(),bt&&l.jsx("div",{className:"nc-mini-tip",style:{top:bt.y},children:bt.text})]}):l.jsxs("aside",{className:"nc-sidebar",style:gt,children:[l.jsx("div",{className:"nc-side-live-host",children:l.jsx(xI,{view:Va({liveHost:F[Cs([])],cells:e}),notice:ht})}),l.jsxs("div",{className:"nc-side-head",children:[l.jsx("button",{className:"nc-collapse-btn",onClick:z,title:p("collapse"),children:"⟨"}),l.jsx("span",{className:"nc-side-title",children:p("fleet")}),J&&l.jsx("span",{className:"nc-side-fleet-stale",role:"status",title:p("reorder-blocked"),"aria-label":p("reorder-blocked"),children:"⇅"}),R&&l.jsx("span",{className:"nc-side-fleet-stale",role:"status",title:p("fleet-stale"),"aria-label":p("fleet-stale"),children:"●"}),S!==null&&l.jsx("span",{className:"nc-side-fleet-off",role:"status",title:`${p("fleet-off")}${S?` (${S})`:""}`,"aria-label":`${p("fleet-off")}${S?` (${S})`:""}`,children:"○"}),l.jsxs("button",{className:"nc-new-btn",onClick:v,title:p("fleet-new-cell"),children:["+ ",p("new")]})]}),l.jsxs("button",{className:"nc-side-gear",onClick:()=>b&&b("nodes",!1),title:p("settings"),children:[l.jsx(Tt,{name:"gear",size:15})," ",p("settings")]}),l.jsx(Pk,{pinError:ie,onRetry:Q,onDismiss:ve}),l.jsxs("div",{className:"nc-side-scroll",children:[l.jsx(kI,{label:p("position-local"),count:In.length,state:de("local"),onToggle:()=>ne("local",{open:!de("local").open}),onFilter:W=>ne("local",{filter:W})}),de("local").open&&l.jsxs("div",{className:"nc-side-group",children:[In.map(W=>W.type==="cell"?(()=>{var ot;const ae=W.value,Ae=me([]),Je=Nd({hostCell:Ae.hostCell??null,threadStatus:Ae.threadStatus,pins:N,item:W}),Pe=ae.degraded?"warn":ae.tmux?"on":"",xt=mm(Je,Ae.hostLease??null),vt=ae.degraded?p("cell-degraded"):W.subtitle||(ae.tmux?p("cell-idle"):p("cell-off")),Qe=xt?`${vt} · ${p(xt)}`:vt,Rt=!!ae.tmux;return l.jsxs("div",{"data-roster-key":W.key,"data-position":"local",className:`nc-cell${Rt?" live":""}${Re.has(ae.tmuxSession)?" active":""}`,title:`${ae.cell} · ${W.subtitle}${Qe===W.subtitle?"":` · ${Qe}`}`,"aria-label":`${ae.cell}, ${W.subtitle}${Qe===W.subtitle?"":`, ${Qe}`}`,draggable:Rt,onDragStart:Rt?ze=>ze.dataTransfer.setData("text/nc-session",ae.tmuxSession):void 0,onClick:Rt?()=>a&&a(ae.tmuxSession):void 0,onDoubleClick:Rt?()=>Jt(ae.tmuxSession,"",L):void 0,children:[l.jsx(Gi,{position:"local",itemKey:W.key,label:ae.cell,canMove:xe,onMove:(ze,Wt)=>$e("local",ze,Wt,qt),onStep:ze=>rt("local",W.key,ze,qt)}),Rt?l.jsx("button",{type:"button",className:"nc-side-peek",title:p("cell-peek"),"aria-label":`${p("cell-peek")}: ${ae.cell}`,onClick:Nt(W,ae,[],""),onMouseEnter:ze=>ut(W,"",ze.currentTarget),onMouseLeave:zt,children:l.jsx("span",{className:`nc-dot ${Pe}${W.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${Pe}${W.working?" working":""}`}),l.jsxs("span",{className:"nc-cell-main",children:[l.jsxs("b",{title:ae.cell,children:[ae.cell,lo({item:W,cellName:ae.cell,route:[],pins:N,hostByRoute:F}).isLive&&l.jsx("span",{className:"nc-live-bollino",children:"LIVE"})]}),l.jsx("small",{title:W.subtitle,children:W.subtitle})]}),W.activity?l.jsx("span",{className:"nc-rel",children:co(W.activity)}):null,W.fresh&&((ot=(V.get(ae.tmuxSession)||{}).outbox)==null?void 0:ot.count)>0?l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:V.get(ae.tmuxSession).outbox.count}):null,l.jsx("button",{type:"button",className:"nc-cellmenu",title:`${p("cell-actions-open")}: ${ae.cell}`,"aria-label":`${p("cell-actions-open")}: ${ae.cell}`,"aria-haspopup":"menu","aria-expanded":Z&&Z.itemKey===W.key?"true":"false",onClick:ze=>{ze.stopPropagation(),dt(W.key,"",ze.currentTarget,k.includes("boot")&&!!u,!1)},children:l.jsx("span",{"aria-hidden":"true",children:"⋯"})}),l.jsx("button",{className:`nc-power${ae.tmux?" on":""}${ae.degraded?" warn":""}`,onClick:ze=>{ze.stopPropagation(),c&&c({...ae,boot:gn(ae)})},title:ae.active?p("power-off"):p("power-on"),children:l.jsx(Tt,{name:"power",size:14})})]},W.key)})():(()=>{var Ae;const ae=W.value;return l.jsxs("div",{"data-roster-key":W.key,"data-position":"local",className:`nc-side-card${Re.has(ae.name)?" active":""}`,draggable:!0,onDragStart:Je=>Je.dataTransfer.setData("text/nc-session",ae.name),onClick:()=>a&&a(ae.name),onDoubleClick:()=>Jt(ae.name,"",L),children:[l.jsx(Gi,{position:"local",itemKey:W.key,label:ae.name,canMove:xe,onMove:(Je,Pe)=>$e("local",Je,Pe,qt),onStep:Je=>rt("local",W.key,Je,qt)}),l.jsx("span",{className:ae.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:ae.name}),l.jsxs("small",{children:[ae.preview||ae.cmd||p("windows").replace("{n}",String(ae.windows||0)),((Ae=ae.outbox)==null?void 0:Ae.count)>0?` · 📦${ae.outbox.count}`:""]})]}),ae.activity?l.jsx("span",{className:"nc-rel",children:co(ae.activity)}):null,l.jsx("button",{className:`nc-pin${N.includes(W.key)?" on":""}`,title:p("pin"),onClick:Je=>{Je.stopPropagation(),P(W.key)},children:N.includes(W.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${ae.technical?" on":""}`,title:ae.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${ae.technical?p("mark-normal"):p("mark-technical")} ${ae.name}`,onClick:Je=>{Je.stopPropagation(),g&&g(ae.name,!ae.technical,[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:Je=>{Je.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",ae.name))&&f&&f(ae.name)},children:"⋯"})]},W.key)})()),In.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]}),wn.map(({g:W,nodeRoute:ae,groupView:Ae,rawItems:Je,items:Pe})=>{const xt=$k(W.health),vt=W.fleetState==="stale"?p("fleet-stale"):W.fleetState==="disabled"?p("fleet-off"):"",Qe=W.fleetState==="stale"?"warn":xt||(W.status==="up"?"on":W.status==="passive"?"":"warn"),Rt=[W.health?Dd(W.health):"",vt].filter(Boolean).join(" · ");return W.kind==="vl"?l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":Ne(W),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>ne(ae,{open:!Ae.open}),onKeyDown:ot=>{(ot.key==="Enter"||ot.key===" ")&&(ot.preventDefault(),ne(ae,{open:!Ae.open}))},children:[l.jsx(Gi,{scope:"node",position:"nodes",itemKey:Ne(W),label:W.label||W.name,onMove:(ot,ze)=>Ie(ot,ze,s||[]),onStep:ot=>oe(Ne(W),ot,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:Ae.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${Qe}`,title:Rt}),l.jsx("b",{children:W.label||W.name}),l.jsxs("small",{children:[" · ",Qi(W)||[p("node-sessions").replace("{n}",String(W.sessions.length)),vt].filter(Boolean).join(" · ")]})]}),W.status==="up"&&Ae.open&&l.jsxs("div",{className:"nc-side-group",children:[W.sessions.map(ot=>l.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>Y&&Y(W.peer),onKeyDown:ze=>{(ze.key==="Enter"||ze.key===" ")&&(ze.preventDefault(),Y&&Y(W.peer))},children:[l.jsx("span",{className:"nc-dot on"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:ot.name}),l.jsx("small",{children:p("vl-events-title")})]})]},ot.key)),W.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-vl-${ae}-${W.name}`):l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":Ne(W),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:W.direct&&_?ot=>{ot.preventDefault(),Qt(W)}:void 0,onClick:()=>ne(ae,{open:!Ae.open}),onKeyDown:ot=>{(ot.key==="Enter"||ot.key===" ")&&(ot.preventDefault(),ne(ae,{open:!Ae.open}))},children:[l.jsx(Gi,{scope:"node",position:"nodes",itemKey:Ne(W),label:W.label||W.name,onMove:(ot,ze)=>Ie(ot,ze,s||[]),onStep:ot=>oe(Ne(W),ot,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:Ae.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${Qe}`,title:Rt}),l.jsx("b",{children:W.label||W.name}),l.jsxs("small",{children:[" · ",W.status==="up"?[p("node-sessions").replace("{n}",String(Pe.length)),vt].filter(Boolean).join(" · "):W.health&&Dd(W.health)||Qi(W)]}),l.jsxs("select",{className:"nc-node-filter",value:Ae.filter,title:p(`view-${Ae.filter}`),onClick:ot=>ot.stopPropagation(),onChange:ot=>ne(ae,{filter:ot.target.value}),children:[l.jsx("option",{value:"all",children:p("view-all")}),l.jsx("option",{value:"pinned",children:p("view-pinned")}),l.jsx("option",{value:"active",children:p("view-active")}),l.jsx("option",{value:"off",children:p("view-off")}),l.jsx("option",{value:"technical",children:p("view-technical")})]}),W.direct&&_&&l.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${W.label||W.name}`,onClick:ot=>{ot.stopPropagation(),Qt(W)},children:"✎"}),W.direct&&W.health&&W.health.managed!==!1&&l.jsx("button",{type:"button",className:`nc-power${W.tunnelStatus==="up"?" on":""}`,title:W.tunnelStatus==="up"?p("power-off"):p("power-on"),onClick:ot=>{ot.stopPropagation(),h&&h(W)},children:l.jsx(Tt,{name:"power",size:14})})]}),(W.status==="up"||W.cellsPreserved)&&Ae.open&&l.jsxs("div",{className:"nc-side-group",children:[Pe.map(ot=>ot.type==="cell"?(()=>{var en;const ze=ot.value,Wt=W.route||[W.name],Sn=me(Wt),Se=Nd({hostCell:Sn.hostCell??null,threadStatus:Sn.threadStatus,pins:N,item:ot}),Me=mm(Se,Sn.hostLease??null),qe=!!ze.tmux&&!W.cellsPreserved,ct=ze.degraded?"warn":ze.tmux&&!W.cellsPreserved?"on":"",Lt=(W.sessions||[]).find(nn=>nn&&nn.name===ze.tmuxSession)||null,Ks=W.cellsPreserved?`${p("fleet-stale")}`:ot.subtitle||(ze.tmux?p("cell-idle"):p("cell-off")),Vs=Me?`${Ks} · ${p(Me)}`:Ks;return l.jsxs("div",{"data-roster-key":ot.key,"data-position":ae,className:`nc-side-card nc-cell${qe?" live":""}${W.cellsPreserved?" preserved":""}${Re.has(ze.key)?" active":""}`,title:Vs,draggable:qe,onDragStart:qe?nn=>nn.dataTransfer.setData("text/nc-session",ze.key):void 0,onClick:qe?()=>a&&a(ze.key):void 0,onDoubleClick:qe?()=>Jt(ze.tmuxSession,ae,W.instanceId):void 0,children:[l.jsx(Gi,{position:ae,itemKey:ot.key,label:ze.cell,canMove:xe,onMove:(nn,on)=>$e(ae,nn,on,Je),onStep:nn=>rt(ae,ot.key,nn,Je)}),qe?l.jsx("button",{type:"button",className:"nc-side-peek",title:p("cell-peek"),"aria-label":`${p("cell-peek")}: ${ze.cell}`,onClick:Nt(ot,ze,W.route||[W.name],W.label||W.name),onMouseEnter:nn=>ut(ot,ae,nn.currentTarget),onMouseLeave:zt,children:l.jsx("span",{className:`nc-dot ${ct}${ot.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${ct}${ot.working?" working":""}`}),l.jsxs("span",{className:"nc-card-main",children:[l.jsxs("b",{children:[ze.cell,lo({item:ot,cellName:ze.cell,route:Wt,pins:N,hostByRoute:F}).isLive&&l.jsx("span",{className:"nc-live-bollino",children:"LIVE"})]}),l.jsx("small",{title:ot.subtitle,children:ot.subtitle})]}),ot.activity?l.jsx("span",{className:"nc-rel",children:co(ot.activity)}):null,ot.fresh&&((en=(Lt||{}).outbox)==null?void 0:en.count)>0?l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Lt.outbox.count}):null,l.jsx("button",{type:"button",className:"nc-cellmenu",title:`${p("cell-actions-open")}: ${ze.cell}`,"aria-label":`${p("cell-actions-open")}: ${ze.cell}`,"aria-haspopup":"menu","aria-expanded":Z&&Z.itemKey===ot.key?"true":"false",onClick:nn=>{nn.stopPropagation(),dt(ot.key,ae,nn.currentTarget,u&&(W.capabilities||[]).includes("boot"),!!W.cellsPreserved)},children:l.jsx("span",{"aria-hidden":"true",children:"⋯"})}),(W.capabilities||[]).includes(ze.active?"down":"up")&&l.jsx("button",{className:`nc-power${ze.active?" on":""}${ze.degraded?" warn":""}`,onClick:nn=>{nn.stopPropagation(),c&&c({...ze,boot:gn(ze,W.route||[]),route:W.route,availableEngines:W.engines||[]})},title:ze.active?p("power-off"):p("power-on"),children:l.jsx(Tt,{name:"power",size:14})})]},ot.key)})():(()=>{const ze=ot.value;return l.jsxs("div",{"data-roster-key":ot.key,"data-position":ae,className:`nc-side-card${Re.has(ze.key)?" active":""}`,draggable:!0,onDragStart:Wt=>Wt.dataTransfer.setData("text/nc-session",ze.key),onClick:()=>a&&a(ze.key),onDoubleClick:()=>Jt(ze.name,ze.node||ae,W.instanceId),children:[l.jsx(Gi,{position:ae,itemKey:ot.key,label:ze.name,canMove:xe,onMove:(Wt,Sn)=>$e(ae,Wt,Sn,Je),onStep:Wt=>rt(ae,ot.key,Wt,Je)}),l.jsx("span",{className:ze.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:ze.name}),l.jsx("small",{children:ze.preview?ze.preview:ze.cmd?ze.cmd:p("windows").replace("{n}",String(ze.windows||0))})]}),ze.activity?l.jsx("span",{className:"nc-rel",children:co(ze.activity)}):null,l.jsx("button",{className:`nc-pin${N.includes(ot.key)?" on":""}`,title:p("pin"),onClick:Wt=>{Wt.stopPropagation(),P(ot.key)},children:N.includes(ot.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${ze.technical?" on":""}`,title:ze.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${ze.technical?p("mark-normal"):p("mark-technical")} ${ze.name}`,onClick:Wt=>{Wt.stopPropagation(),g&&g(ze.name,!ze.technical,W.route||[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:Wt=>{Wt.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",ze.name))&&f&&f(ze.name,W.route)},children:"⋯"})]},ot.key)})()),Pe.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-${(W.route||[W.name]).join("/")}`)})]}),l.jsx("div",{className:"nc-side-lang",children:z1.map((W,ae)=>l.jsxs("span",{children:[ae>0&&" · ",l.jsx("button",{className:`nc-lang-btn${T===W?" on":""}`,onClick:()=>A(W),title:W,children:W.toUpperCase()})]},W))}),l.jsx("div",{className:"nc-side-resize",onPointerDown:Ge,title:""}),bn&&(()=>{const W=bn.value,ae=bn.nodeRoute?s.find(Je=>(Je.route||[Je.name]).join("/")===bn.nodeRoute)||{}:null,Ae=bn.nodeRoute?ae.route||[bn.nodeRoute]:[];return l.jsx(bk,{row:St(bn,W,Ae,bn.nodeLabel||"",ae&&ae.sessions),token:te,initialSource:Xe,onClose:()=>{st(null),De("preview")}})})(),Ft(),Z&&(()=>{const W=tn.find(Qe=>Qe.key===Z.itemKey);if(!W)return null;const ae=W.value,Ae=Z.routeKey?s.find(Qe=>(Qe.route||[Qe.name]).join("/")===Z.routeKey)||{}:null,Je=Z.routeKey?Ae.route||[Z.routeKey]:[],Pe=Z.preserved?!1:!!ae.tmux,xt=lo({item:W,cellName:ae.cell,route:Je,pins:N,hostByRoute:F}),vt=Nv({...xt,canBoot:Z.canBoot,boot:gn(ae,Je),alive:Pe,handlers:Vn(W,ae,Je)});return l.jsx(Ok,{anchorRect:ue,items:vt,busy:se,onClose:()=>X(null)})})()]})}function xI({view:t,notice:e}){const n=!!(t&&t.cell),s=n?p("live-host-indicator").replace("{cell}",t.cell).replace("{mode}",p(t.mode?`live-host-mode-${t.mode}`:"live-host-mode-unknown")).replace("{state}",p(`live-host-state-${t.state||"none"}`)):p("live-host-indicator-none");return l.jsxs("div",{className:"nc-live-strip","data-state":t&&t.state?t.state:"none",title:e?`${s} · ${p(e.messageKey)}`:s,children:[l.jsx("span",{className:`nc-live-strip-dot ${Lv(t||{})}`,"aria-hidden":"true"}),l.jsx("span",{className:"nc-live-strip-testo",children:n?t.cell:s}),e&&l.jsx("span",{className:`nc-live-strip-notice${e.ok?" ok":" ko"}`,role:"status",children:p(e.messageKey).replace("{cell}",e.cell||t.cell||"")})]})}function kI({label:t,count:e,state:n,onToggle:s,onFilter:i}){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:t}),l.jsxs("small",{children:[" · ",p("node-sessions").replace("{n}",String(e))]}),l.jsxs("select",{className:"nc-node-filter",value:n.filter,title:p(`view-${n.filter}`),onClick:a=>a.stopPropagation(),onChange:a=>i(a.target.value),children:[l.jsx("option",{value:"all",children:p("view-all")}),l.jsx("option",{value:"pinned",children:p("view-pinned")}),l.jsx("option",{value:"active",children:p("view-active")}),l.jsx("option",{value:"off",children:p("view-off")}),l.jsx("option",{value:"technical",children:p("view-technical")})]})]})}const ps={PRESENTE:"presente-verificata",ASSENTE:"assente-verificata",IGNOTA:"ignota"},Np={OK:"ok",NON_DISPONIBILE:"non-disponibile",RIMOSSO:"rimosso"},td={LETTURA_NON_VERIFICABILE:"lettura-non-verificabile",OWNER_NON_DISPONIBILE:"owner-non-disponibile",OWNER_RIMOSSO:"owner-rimosso",LOCALE_NON_VERIFICATO:"lettura-locale-non-verificata"},Y0={RITORNO:"ritorno-dopo-assenza",IDENTITA:"identita-cambiata"},CI=6e4;function EI(t,e){return!t||!Array.isArray(e)?null:e.find(n=>Array.isArray(n==null?void 0:n.route)&&n.route.join("/")===t)||null}function G0(t){const e=t&&t.created;return Number.isFinite(e)&&e>0?e:null}function NI({tileKey:t,node:e,nodeGroups:n,sessionsAlive:s,localVerified:i=!0,localIdentita:a=null,lastVerifiedAt:c=null,nowMs:u=0}={}){const h=EI(e,n);let f,g=Np.OK,v=null,_=null;if(!e)i?!s||s.has(t)?(f=ps.PRESENTE,_=G0({created:a})):f=ps.ASSENTE:(f=ps.IGNOTA,v=td.LOCALE_NON_VERIFICATO);else if(!h)f=ps.IGNOTA,g=Np.RIMOSSO,v=td.OWNER_RIMOSSO;else if(h.status!=="up")f=ps.IGNOTA,g=Np.NON_DISPONIBILE,v=h.cause||td.OWNER_NON_DISPONIBILE;else if(h.inventoryPartial===!0)f=ps.IGNOTA,v=td.LETTURA_NON_VERIFICABILE;else if(!s||s.has(t)){f=ps.PRESENTE;const x=Array.isArray(h.sessions)?h.sessions.find(L=>L&&L.key===t):null;_=G0(x)}else f=ps.ASSENTE;const b=f===ps.IGNOTA&&Number.isFinite(c)&&Number.isFinite(u)&&u-c>CI;return{presenza:f,owner:g,causa:v,identita:f===ps.PRESENTE?_:null,verificata:f!==ps.IGNOTA,oltreIlTetto:b}}function hC(){return{presenza:null,identita:null}}function RI(t,e){const n=t&&typeof t=="object"?t:hC();if(!e||e.presenza===ps.IGNOTA)return{runtime:{presenza:n.presenza,identita:n.identita},generazione:0,motivo:null};const s=e.presenza===ps.PRESENTE;let i=null;return s&&(n.presenza===ps.ASSENTE?i=Y0.RITORNO:n.presenza===ps.PRESENTE&&n.identita!==null&&e.identita!==null&&n.identita!==e.identita&&(i=Y0.IDENTITA)),{runtime:{presenza:e.presenza,identita:s?e.identita===void 0?null:e.identita:null},generazione:i?1:0,motivo:i}}const Pv="nc_input_preferences_v1",Rp="nc-input-preferences",fC=Object.freeze(["double-tap","single-tap","never"]),pC=Object.freeze(["full","compact"]);function LI(){try{return typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches:!1}catch{return!1}}const wr=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full",showComposer:LI()});function Iv(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{terminalKeyboardGesture:fC.includes(e.terminalKeyboardGesture)?e.terminalKeyboardGesture:wr.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof e.keybarKeepsKeyboardClosed=="boolean"?e.keybarKeepsKeyboardClosed:wr.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof e.voiceKeepsKeyboardClosed=="boolean"?e.voiceKeepsKeyboardClosed:wr.voiceKeepsKeyboardClosed,showKeybarEnter:typeof e.showKeybarEnter=="boolean"?e.showKeybarEnter:wr.showKeybarEnter,keybarLayout:pC.includes(e.keybarLayout)?e.keybarLayout:wr.keybarLayout,showComposer:typeof e.showComposer=="boolean"?e.showComposer:wr.showComposer}}function mC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function X0(t=mC()){if(!t)return{...wr};try{return Iv(JSON.parse(t.getItem(Pv)||"null"))}catch{return{...wr}}}function AI(t,e=mC()){const n=Iv(t);if(e)try{e.setItem(Pv,JSON.stringify(n))}catch{}return n}function Dv(){const[t,e]=w.useState(X0);w.useEffect(()=>{const s=i=>{if((i==null?void 0:i.type)==="storage"&&i.key!==Pv&&i.key!==null)return;const a=i!=null&&i.detail?Iv(i.detail):X0();e(a)};return window.addEventListener(Rp,s),window.addEventListener("storage",s),()=>{window.removeEventListener(Rp,s),window.removeEventListener("storage",s)}},[]);const n=w.useCallback(s=>{e(i=>{const a=AI({...i,...s||{}});return window.dispatchEvent(new CustomEvent(Rp,{detail:a})),a})},[]);return[t,n]}function jI({session:t,node:e,ownerId:n,cellName:s,token:i,readonly:a=!1,focused:c,onFocus:u,onClose:h,onOpenSingle:f,onDragTileStart:g,floating:v=!1,minimized:_=!1,takeSize:b=!1,onDetach:x,onReattach:L,onToggleMinimize:k,onFloatDragStart:R,alive:S=!0,sessionAlive:j=S,available:E=!0,stale:F=!1,presence:$=null,fontSize:G=_i,onZoom:K,decks:Y=[],currentDeck:te,onSendToDeck:q,panelUrl:D="",panelCellId:I="",panelPort:O=0}){const[M]=Dv(),z=s||t,T=w.useRef(()=>{}),A=w.useRef(()=>!1),N=w.useRef(()=>{}),U=w.useRef(!1),[P,H]=w.useState(!1),[ie,J]=w.useState(!1),[Q,ve]=w.useState(!1),[de,ne]=w.useState(!1),[xe,$e]=w.useState(null),[rt,je]=w.useState(0),Ie=w.useRef(hC()),oe=e?`${e}:${t}`:t,Ne=Y.filter(V=>V.id!==te&&V.available!==!1),me=$?$.presenza:j?ps.PRESENTE:ps.ASSENTE,Ce=$?$.identita??null:null;return w.useEffect(()=>{const V=RI(Ie.current,{presenza:me,identita:Ce});Ie.current=V.runtime,V.generazione&&je(ge=>ge+V.generazione)},[me,Ce]),l.jsxs("div",{className:`nc-tile${c?" focused":""}`,onMouseDown:()=>u&&u(oe),children:[l.jsxs("div",{className:`nc-tile-head${v?" nc-float-head":""}`,draggable:!v,onPointerDown:v&&R?V=>{V.target&&V.target.closest&&V.target.closest(".nc-tile-actions")||R(V)}:void 0,onDragStart:V=>{v||(V.dataTransfer.setData("text/nc-session",oe),V.dataTransfer.effectAllowed="move",g&&g(oe))},children:[l.jsxs("button",{className:"nc-tile-name",onClick:()=>u&&u(oe),title:e?`${z} · ${e}`:z,children:[l.jsx("span",{className:S?"nc-dot on":"nc-dot"}),l.jsx("b",{children:z})]}),l.jsxs("span",{className:"nc-tile-actions",children:[v?l.jsxs(l.Fragment,{children:[L&&l.jsx("button",{className:"nc-tile-float-btn",onClick:()=>L(oe),title:p("tile-reattach"),"aria-label":p("tile-reattach"),children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("rect",{x:"9",y:"3",width:"12",height:"12",rx:"1"}),l.jsx("path",{d:"M11 21H3v-8M3 21l9-9"})]})}),k&&l.jsx("button",{onClick:()=>k(oe),title:p(_?"tile-restore":"tile-minimize"),"aria-label":p(_?"tile-restore":"tile-minimize"),children:"–"})]}):l.jsxs(l.Fragment,{children:[K&&l.jsx("button",{onClick:()=>K(-1),title:p("zoom-out"),"aria-label":p("zoom-out"),children:l.jsx(Tt,{name:"zoomOut",size:14})}),K&&l.jsx("button",{onClick:()=>K(1),title:p("zoom-in"),"aria-label":p("zoom-in"),children:l.jsx(Tt,{name:"zoomIn",size:14})}),q&&Ne.length>0&&l.jsxs("select",{className:"nc-tile-deck",title:p("send-to-deck"),value:"",onMouseDown:V=>V.stopPropagation(),onChange:V=>{const ge=V.target.value;ge&&q(oe,ge),V.target.value=""},children:[l.jsx("option",{value:"",children:p("send-to-deck")}),Ne.map(V=>l.jsxs("option",{value:V.id,children:[V.ownerLabel," · ",V.name]},V.id))]}),l.jsx("button",{onClick:()=>J(V=>!V),title:p("composer"),children:"⌨"}),l.jsx("button",{onClick:()=>ve(V=>!V),title:p("files"),children:"📁"}),D&&l.jsx("button",{onClick:()=>ne(V=>!V),title:p("panel"),"aria-pressed":de,children:l.jsx(Tt,{name:"monitor",size:14})}),f&&l.jsx("button",{onClick:()=>f({session:t,node:e,ownerId:n}),title:p("single-view"),children:"↗"})]}),!v&&x&&l.jsx("button",{className:"nc-tile-float-btn",onClick:()=>x(oe),title:p("tile-detach"),"aria-label":p("tile-detach"),children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("rect",{x:"3",y:"9",width:"12",height:"12",rx:"1"}),l.jsx("path",{d:"M13 3h8v8M21 3l-9 9"})]})}),h&&l.jsx("button",{className:"nc-tile-close",onClick:()=>h(oe),title:p("close"),"aria-label":p("close"),children:"✕"})]})]}),l.jsxs("div",{className:"nc-tile-body",children:[$&&$.oltreIlTetto===!0&&l.jsx("div",{className:"nc-tile-unverified",role:"status","data-causa":$.causa||"",children:p("tile-unverified")}),l.jsx(mc,{session:t,node:e,token:i,readonly:a,takeSize:b,focused:c,sendRef:T,composerRef:A,actionRef:N,ctrlRef:U,setCtrlArmed:H,onFiles:$e,fontSize:G,keyboardGesture:M.terminalKeyboardGesture},`${oe}:${rt}`),!E&&l.jsx("div",{className:"nc-tile-unavailable",title:p("deck-owner-unavailable"),children:p("deck-owner-reconnecting")}),E&&F&&l.jsx("div",{className:"nc-tile-stale",title:p("deck-owner-stale"),children:p("deck-owner-stale")}),E&&Q&&l.jsx("div",{className:"nc-tile-files",onMouseDown:V=>V.stopPropagation(),children:l.jsx(Rg,{session:t,node:e,token:i,filesEvent:xe,onClose:()=>ve(!1)})})]}),E&&ie&&l.jsx("div",{className:"nc-tile-composer",onMouseDown:V=>V.stopPropagation(),children:l.jsx(dC,{submitText:V=>A.current(V),token:i,session:t,node:e,ownerId:n,readonly:a,keepKeyboardClosedOnVoice:M.voiceKeepsKeyboardClosed})}),E&&de&&D&&I&&l.jsx(H1,{title:z,onClose:()=>ne(!1),children:l.jsx(gv,{cellId:I,panelUrl:D,route:e?e.split("/"):[],panelPort:O,token:i,title:z})})]})}function jg({session:t,node:e,ownerId:n,cells:s,nodeGroups:i}={}){const a=typeof t=="string"?t:"";if(!a)return null;if(e){const u=Array.isArray(i)?i:[];for(const h of u){if(!h||(Array.isArray(h.route)?h.route:[]).join("/")!==e||n&&h.instanceId&&String(n)!==String(h.instanceId))continue;const g=(Array.isArray(h.cells)?h.cells:[]).find(v=>v&&v.tmuxSession===a);if(g)return g}return null}return(Array.isArray(s)?s:[]).find(u=>u&&u.tmuxSession===a)||null}function Lc({session:t,cell:e,node:n,ownerId:s,cells:i,nodeGroups:a}={}){const c=typeof t=="string"?t:"";if(e&&typeof e.cell=="string"&&e.cell)return e.cell;const u=jg({session:c,node:n,ownerId:s,cells:i,nodeGroups:a});return u&&u.cell?u.cell:c}const J0=.22,Q0=.3,gC=(t,e)=>Array.from((t==null?void 0:t.types)||[]).includes(e),Lp=t=>gC(t,"text/nc-session"),Z0=t=>{var e;return gC(t,"Files")||(((e=t==null?void 0:t.files)==null?void 0:e.length)||0)>0};function MI(t,e){return t&&Array.isArray(e)?e.find(n=>Array.isArray(n==null?void 0:n.route)&&n.route.join("/")===t):null}function TI(t,e,n){const s=(t-n.left)/(n.width||1),i=(e-n.top)/(n.height||1);return s<J0?"left":s>1-J0?"right":i>=Q0&&i<=1-Q0?"center":i<.5?"top":"bottom"}const PI=[["left","M15 6l-6 6 6 6",22],["top","M6 15l6-6 6 6",22],["center","M4 8h16M20 8l-3-3M20 8l-3 3M20 16H4M4 16l3-3M4 16l3 3",34],["bottom","M6 9l6 6 6-6",22],["right","M9 6l6 6-6 6",22]];function II({active:t}){return l.jsx("div",{className:"nc-drop-zones","data-testid":"nc-drop-zones","aria-hidden":"true",children:PI.map(([e,n,s])=>l.jsx("div",{className:`nc-drop-zone ${e}${t===e?" on":""}`,"data-zone":e,children:l.jsx("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("path",{d:n})})},e))})}function Ap(t,e){for(const n of t.columns)for(const s of n.tiles)if(Bt(s)===e)return s.float||null;return null}function eS(t,e){for(const n of t.columns)for(const s of n.tiles)if(Bt(s)===e)return s.fontSize||null;return null}function DI({layout:t,onLayoutChange:e,token:n,readonly:s=!1,sessionsAlive:i,focusSession:a,onFocus:c,onOpenSingle:u,localVerified:h=!0,localIdentities:f=null,localVerifiedAt:g=null,decks:v=[],currentDeck:_,onSendToDeck:b,onResizeEnd:x,cells:L=[],nodeGroups:k=[],panelPort:R=0,nodePanelPorts:S={}}){zn();const j=Date.now(),[E,F]=w.useState(null),[$,G]=w.useState(null),K=w.useRef(null);K.current=$;const[Y,te]=w.useState({z:{},next:1,focus:null,mini:{}}),[q,D]=w.useState(null),I=w.useRef(null);I.current=q;const O=w.useRef(null),M=w.useRef([]),z=w.useRef(null);function T(V,ge,Le){const ke=()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",We),window.removeEventListener("pointercancel",Re),window.removeEventListener("blur",Re)},We=()=>{ke(),z.current=null,ge&&ge()},Re=()=>{ke(),z.current=null,Le&&Le()};window.addEventListener("pointermove",V),window.addEventListener("pointerup",We),window.addEventListener("pointercancel",Re),window.addEventListener("blur",Re),z.current=Re}w.useEffect(()=>()=>{z.current&&z.current()},[]),w.useEffect(()=>{if(!E&&!q)return;const V=ge=>{ge.key==="Escape"&&(F(null),q&&z.current&&z.current())};return window.addEventListener("keydown",V),()=>{window.removeEventListener("keydown",V)}},[E,q]),w.useEffect(()=>{const V=()=>F(null);return window.addEventListener("dragend",V),window.addEventListener("drop",V),()=>{window.removeEventListener("dragend",V),window.removeEventListener("drop",V)}},[]);const A=t.columns.length,N=t.columns.flatMap(V=>V.tiles).filter(V=>V.float).map(V=>Bt(V)),U=V=>!!V&&V.tiles.length>0&&V.tiles.every(ge=>ge.float),P=V=>E&&E.col===V&&E.row===void 0,H=!!E&&E.col===A,ie=(V,ge)=>E&&E.col===V&&E.row===ge&&E.quadrant?` drop-${E.quadrant}`:"";function J(V){var We;if(V.preventDefault(),Z0(V.dataTransfer)){F(null);return}const ge=V.dataTransfer.getData("text/nc-session"),Le=E;if(F(null),!ge||!Le)return;if(Le.quadrant==="center"){const Re=Bt(((We=t.columns[Le.col])==null?void 0:We.tiles[Le.row])||{});Re&&Re!==ge&&e(kP(t,ge,Re));return}let ke;if(Le.quadrant){if(ke=TP(t,Le.col,Le.row,Le.quadrant),!ke)return}else ke={col:Le.col};e(_s(t).includes(ge)?SP(t,ge,ke):Nc(t,ge,ke))}function Q(V,ge){var he,Z,X;V.preventDefault(),V.stopPropagation();try{V.currentTarget.setPointerCapture&&V.pointerId!=null&&V.currentTarget.setPointerCapture(V.pointerId)}catch{}const Le=O.current&&O.current.clientWidth||0,ke=O.current?O.current.getBoundingClientRect():null,We=ke?ke.left:0,Re=M.current[ge]?M.current[ge].getBoundingClientRect():null,_e=M.current[ge+1]?M.current[ge+1].getBoundingClientRect():null,st=Re&&_e&&_e.right>Re.left?Re.left-(ke?ke.left:0):0,Xe=Number.isFinite(V.clientX)?V.clientX:0,De=t.columns[ge].width+(((he=t.columns[ge+1])==null?void 0:he.width)||0),He=t.columns.reduce((ue,Ze)=>ue+Ze.width,0),Ke=Re&&_e&&_e.right>Re.left?_e.right-Re.left:Le*(De/(He||1)),wt=Math.min(Yk,Ke/2),fe=ue=>{const Ze=(Number.isFinite(ue.clientX)?ue.clientX:Xe)-We;let se=Math.max(wt,Math.min(Ke-wt,Ze-st)),Be=!1;if(!ue.altKey){for(const ht of fc)if(Math.abs(se-ht*Ke)<=Sg){se=ht*Ke,Be=!0;break}}return{border:se,snapped:Be,alt:ue.altKey===!0}};G({kind:"col",ci:ge,coupleLeft:st,couplePx:Ke,live:fe(V),pxOther:O.current&&O.current.clientHeight||0,fsA:((Z=t.columns[ge].tiles[0])==null?void 0:Z.fontSize)||_i,fsB:((X=t.columns[ge+1].tiles[0])==null?void 0:X.fontSize)||_i}),T(ue=>G(Ze=>Ze&&{...Ze,live:fe(ue)}),()=>{var se,Be;const ue=K.current,Ze=((se=ue==null?void 0:ue.live)==null?void 0:se.border)??Ke/2;G(null),e(O0(t,ge,Le,Ze,{snap:!((Be=ue==null?void 0:ue.live)!=null&&Be.alt)})),x&&x()},()=>G(null))}function ve(V){const ge=O.current&&O.current.clientWidth||0;e(O0(t,V,ge,Number.NaN,{snap:!0,half:!0})),x&&x()}function de(V,ge,Le){var se;V.preventDefault(),V.stopPropagation();try{V.currentTarget.setPointerCapture&&V.pointerId!=null&&V.currentTarget.setPointerCapture(V.pointerId)}catch{}const ke=M.current[ge],We=ke&&ke.clientHeight||O.current&&O.current.clientHeight||0,Re=O.current?O.current.getBoundingClientRect():null,_e=Re?Re.top:0,st=ke?ke.getBoundingClientRect():null,Xe=st?st.left-(Re?Re.left:0):0,De=st&&st.width>0?st.width:ke&&ke.clientWidth||0,He=Number.isFinite(V.clientY)?V.clientY:0,Ke=t.columns[ge].tiles,wt=Ke[Le].height+(((se=Ke[Le+1])==null?void 0:se.height)||0),fe=Ke.reduce((Be,ht)=>Be+ht.height,0),he=Ke.slice(0,Le).reduce((Be,ht)=>Be+ht.height,0),Z=(st&&st.height>0?st.top-_e:0)+We*(he/(fe||1)),X=(st&&st.height>0,We*(wt/(fe||1))),ue=Math.min(Gk,X/2),Ze=Be=>{const ht=(Number.isFinite(Be.clientY)?Be.clientY:He)-_e;let Pt=Math.max(ue,Math.min(X-ue,ht-Z)),St=!1;if(!Be.altKey){for(const Nt of fc)if(Math.abs(Pt-Nt*X)<=Sg){Pt=Nt*X,St=!0;break}}return{border:Pt,snapped:St,alt:Be.altKey===!0}};G({kind:"row",ci:ge,ri:Le,coupleTop:Z,couplePx:X,colLeft:Xe,colWidth:De,live:Ze(V),pxOther:ke&&ke.clientWidth||O.current&&O.current.clientWidth||0,fsA:Ke[Le].fontSize||_i,fsB:Ke[Le+1].fontSize||_i}),T(Be=>G(ht=>ht&&{...ht,live:Ze(Be)}),()=>{var Pt,St;const Be=K.current,ht=((Pt=Be==null?void 0:Be.live)==null?void 0:Pt.border)??X/2;G(null),e(B0(t,ge,Le,We,ht,{snap:!((St=Be==null?void 0:Be.live)!=null&&St.alt)})),x&&x()},()=>G(null))}function ne(V,ge){const Le=M.current[V],ke=Le&&Le.clientHeight||O.current&&O.current.clientHeight||0;e(B0(t,V,ge,ke,Number.NaN,{snap:!0,half:!0})),x&&x()}function xe(V){e(Rc(t,V))}const $e={x:.45,y:.12,w:.42,h:.6},rt=8;function je(V){te(ge=>({...ge,z:{...ge.z,[V]:ge.next},next:ge.next+1,focus:V})),c&&c(V)}function Ie(V){te(ge=>({...ge,mini:{...ge.mini,[V]:!ge.mini[V]}}))}function oe(V){N.length>=zc||e(CP(t,V,$e))}function Ne(V,ge){const Le=[0,1];let ke=!1,We=V;for(const Re of[...Le,...ge])if(Math.abs(V-Re)<=rt/window.innerWidth){We=Re,ke=!0;break}return{v:Math.max(0,Math.min(1,We)),snapped:ke}}function me(V,ge){V.preventDefault(),V.stopPropagation();try{V.currentTarget.setPointerCapture&&V.pointerId!=null&&V.currentTarget.setPointerCapture(V.pointerId)}catch{}const Le=Ap(t,ge);if(!Le)return;const ke=Number.isFinite(V.clientX)?V.clientX:0,We=Number.isFinite(V.clientY)?V.clientY:0,Re=N.filter(De=>De!==ge).map(De=>Ap(t,De)).filter(Boolean),_e=Re.flatMap(De=>[De.x,De.x+De.w]),st=Re.flatMap(De=>[De.y,De.y+De.h]),Xe=De=>{const He=(Number.isFinite(De.clientX)?De.clientX:ke)-ke,Ke=(Number.isFinite(De.clientY)?De.clientY:We)-We,wt=Ne(Le.x+He/Math.max(1,window.innerWidth),_e),fe=Ne(Le.y+Ke/Math.max(1,window.innerHeight),st);return{x:wt.v,y:fe.v,w:Le.w,h:Le.h,snappedX:wt.snapped,snappedY:fe.snapped}};D({key:ge,kind:"move",live:Xe(V)}),T(De=>D(He=>He&&{...He,live:Xe(De)}),()=>{var He;const De=(He=I.current)==null?void 0:He.live;D(null),De&&e($0(t,ge,De))},()=>D(null))}function Ce(V,ge,Le){V.preventDefault(),V.stopPropagation();try{V.currentTarget.setPointerCapture&&V.pointerId!=null&&V.currentTarget.setPointerCapture(V.pointerId)}catch{}const ke=Ap(t,ge);if(!ke)return;const We=Number.isFinite(V.clientX)?V.clientX:0,Re=Number.isFinite(V.clientY)?V.clientY:0,_e=Math.max(1,window.innerWidth),st=Math.max(1,window.innerHeight);eS(t,ge);const Xe=De=>{const He=((Number.isFinite(De.clientX)?De.clientX:We)-We)/_e,Ke=((Number.isFinite(De.clientY)?De.clientY:Re)-Re)/st;let{x:wt,y:fe,w:he,h:Z}=ke;return Le.includes("e")&&(he=ke.w+He),Le.includes("s")&&(Z=ke.h+Ke),Le.includes("w")&&(wt=ke.x+He,he=ke.w-He),Le.includes("n")&&(fe=ke.y+Ke,Z=ke.h-Ke),he=Math.max(.05,Math.min(1-wt,he)),Z=Math.max(.05,Math.min(1-fe,Z)),{x:wt,y:fe,w:he,h:Z}};D({key:ge,kind:"resize",dir:Le,live:Xe(V),badge:!0}),T(De=>D(He=>He&&{...He,live:Xe(De)}),()=>{var He;const De=(He=I.current)==null?void 0:He.live;D(null),De&&e($0(t,ge,De)),x&&x()},()=>D(null))}return l.jsxs("div",{className:`nc-grid${$||q?" gesturing":""}`,ref:O,onDragOver:V=>{if(Z0(V.dataTransfer)){V.preventDefault(),F(null);return}Lp(V.dataTransfer)&&(V.preventDefault(),E&&E.col===A||F({col:A}))},onDrop:J,onDragLeave:V=>{const ge=V.relatedTarget;(!ge||!(O.current&&O.current.contains(ge)))&&F(null)},children:[t.columns.flatMap((V,ge)=>{const Le=[];return Le.push(l.jsx("div",{className:`nc-col${P(ge)?" drop-newcol":""}${U(V)?" nc-col-emptyfloat":""}`,ref:ke=>{M.current[ge]=ke},style:{flexGrow:U(V)?0:V.width,flexBasis:0},onDragOver:ke=>{Lp(ke.dataTransfer)&&(ke.preventDefault(),ke.stopPropagation(),E&&E.col===ge&&E.row===void 0||F({col:ge}))},children:V.tiles.flatMap((ke,We)=>{const Re=[],_e=Bt(ke),st=MI(ke.node,k),Xe=NI({tileKey:_e,node:ke.node,nodeGroups:k,sessionsAlive:i,localVerified:h,localIdentita:f?f.get(_e):null,lastVerifiedAt:ke.node?(st==null?void 0:st.verifiedAt)??null:g,nowMs:j}),De=ke.unavailable!==!0&&(ke.node?(st==null?void 0:st.status)==="up":Xe.owner==="ok"),He=ke.unavailable!==!0&&Xe.presenza!=="assente-verificata",Ke=jg({session:ke.session,node:ke.node,ownerId:ke.ownerId,cells:L,nodeGroups:k}),wt=Lc({session:ke.session,cell:Ke,node:ke.node,ownerId:ke.ownerId,cells:L,nodeGroups:k}),fe=typeof(Ke==null?void 0:Ke.panelUrl)=="string"?Ke.panelUrl.trim():"",he=typeof(Ke==null?void 0:Ke.cell)=="string"?Ke.cell:"",Z=ke.float||null,X=!!(Z&&Y.mini[_e]);return Re.push(l.jsxs("div",{className:`nc-tile-slot${ie(ge,We)}${E&&E.from===_e?" nc-tile-source":""}${Z?" nc-float":""}${X?" nc-float-mini":""}`,style:Z?{position:"fixed",left:`${Z.x*100}%`,top:`${Z.y*100}%`,width:`${Z.w*100}%`,height:X?"auto":`${Z.h*100}%`,zIndex:20+(Y.z[_e]||0)}:{flexGrow:ke.height,flexBasis:0},onPointerDown:Z?()=>je(_e):void 0,onDragOver:ue=>{if(!Lp(ue.dataTransfer))return;if(Z){ue.stopPropagation();return}ue.preventDefault(),ue.stopPropagation();const Ze=TI(ue.clientX,ue.clientY,ue.currentTarget.getBoundingClientRect());E&&E.col===ge&&E.row===We&&E.quadrant===Ze||F({col:ge,row:We,quadrant:Ze,from:E==null?void 0:E.from,ghost:{x:ue.clientX,y:ue.clientY}})},children:[l.jsx(jI,{session:ke.session,node:ke.node,ownerId:ke.ownerId,cellName:wt,token:n,readonly:s,focused:a===_e,onFocus:c,onClose:xe,onOpenSingle:u,floating:!!Z,minimized:X,takeSize:!!Z,onDetach:Z?void 0:oe,onReattach:Z?ue=>e(EP(t,ue)):void 0,onToggleMinimize:Z?Ie:void 0,onFloatDragStart:Z?ue=>me(ue,_e):void 0,onDragTileStart:Z?void 0:ue=>F(Ze=>Ze?{...Ze,from:ue}:{from:ue}),available:ke.unavailable!==!0,stale:ke.stale===!0,alive:De,sessionAlive:He,presence:Xe,fontSize:ke.fontSize,onZoom:ue=>e(MP(t,ge,We,ue)),decks:v,currentDeck:_,onSendToDeck:b,panelUrl:fe,panelCellId:he,panelPort:Cc(ke.node?ke.node.split("/"):[],S,R)}),!Z&&E&&E.col===ge&&E.row===We&&E.quadrant&&l.jsx(II,{active:E.quadrant}),Z&&!X&&["n","s","e","w","se"].map(ue=>l.jsx("div",{className:`nc-float-rz ${ue}`,"data-testid":`float-resize-${ue}`,onPointerDown:Ze=>Ce(Ze,_e,ue)},`rz-${ue}`))]},_e)),We<V.tiles.length-1&&Re.push(l.jsx("div",{className:`nc-divider-h${$&&$.kind==="row"&&$.ci===ge&&$.ri===We?" dragging":""}`,title:p("grid-resize-rows"),onPointerDown:ue=>de(ue,ge,We),onDoubleClick:()=>ne(ge,We)},`h${We}`)),Re})},`c${ge}`)),ge<A-1&&!U(V)&&!U(t.columns[ge+1])&&Le.push(l.jsx("div",{className:`nc-divider-v${$&&$.kind==="col"&&$.ci===ge?" dragging":""}`,title:p("grid-resize-cols"),onPointerDown:ke=>Q(ke,ge),onDoubleClick:()=>ve(ge)},`v${ge}`)),Le}),$&&l.jsx("div",{className:`nc-gesture-shield ${$.kind==="col"?"col":"row"}`,"data-testid":"nc-gesture-shield"}),$&&$.kind==="col"&&fc.map(V=>l.jsx("div",{className:"nc-gesture-ghost v",style:{left:$.coupleLeft+V*$.couplePx}},`ghost-v-${V}`)),$&&$.kind==="row"&&fc.map(V=>l.jsx("div",{className:"nc-gesture-ghost h",style:{top:$.coupleTop+V*$.couplePx,left:$.colLeft,width:$.colWidth}},`ghost-h-${V}`)),$&&$.kind==="col"&&l.jsx("div",{className:`nc-gesture-guide v${$.live.snapped?" snap":""}`,"data-testid":"nc-gesture-guide",style:{left:$.coupleLeft+$.live.border}}),$&&$.kind==="row"&&l.jsx("div",{className:`nc-gesture-guide h${$.live.snapped?" snap":""}`,"data-testid":"nc-gesture-guide",style:{top:$.coupleTop+$.live.border,left:$.colLeft,width:$.colWidth}}),$&&l.jsx("div",{className:"nc-gesture-badge","data-testid":"nc-gesture-badge",style:$.kind==="col"?{left:$.coupleLeft+$.live.border,top:"50%"}:{top:$.coupleTop+$.live.border,left:"50%"},children:[$.fsA,$.fsB].map((V,ge)=>{const Le=ge===0?$.live.border:$.couplePx-$.live.border,ke=Math.max(1,V*.6),We=Math.max(1,V*1.2),Re=$.kind==="col"?`${Math.round(Le/ke)}×${Math.round($.pxOther/We)}`:`${Math.round($.pxOther/ke)}×${Math.round(Le/We)}`;return l.jsx("span",{className:"nc-gesture-chip",children:Re},ge)})}),q&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`nc-gesture-shield ${q.kind==="resize"?"row":"col"}`,"data-testid":"nc-gesture-shield"}),q.live.snappedX&&l.jsx("div",{className:"nc-float-snap v",style:{left:`${q.live.x*100}%`}}),q.live.snappedY&&l.jsx("div",{className:"nc-float-snap h",style:{top:`${q.live.y*100}%`}}),q.kind==="resize"&&(()=>{const V=eS(t,q.key)||_i,ge=Math.max(1,V*.6),Le=Math.max(1,V*1.2);return l.jsx("div",{className:"nc-gesture-badge","data-testid":"nc-gesture-badge",style:{left:`${(q.live.x+q.live.w/2)*100}%`,top:`${(q.live.y+q.live.h)*100}%`},children:l.jsx("span",{className:"nc-gesture-chip",children:`${Math.round(q.live.w*window.innerWidth/ge)}×${Math.round(q.live.h*window.innerHeight/Le)}`})})})()]}),E&&E.from&&E.ghost&&(()=>{const V=t.columns.flatMap(Le=>Le.tiles).find(Le=>Bt(Le)===E.from),ge=V?Lc({session:V.session,node:V.node,ownerId:V.ownerId,cells:L,nodeGroups:k,cell:jg({session:V.session,node:V.node,ownerId:V.ownerId,cells:L,nodeGroups:k})}):E.from;return l.jsxs("div",{className:"nc-drag-ghost","data-testid":"nc-drag-ghost",style:{left:E.ghost.x,top:E.ghost.y},children:[l.jsxs("div",{className:"nc-drag-ghost-head",children:[l.jsx("span",{className:"nc-dot on"}),l.jsx("b",{children:ge})]}),l.jsx("div",{className:"nc-drag-ghost-body"})]})})(),H&&l.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),A===0&&l.jsx("div",{className:"nc-grid-empty",children:p("grid-empty")})]})}const Xi="local",Ws=/^[a-f0-9]{16,64}$/,vC=3,Da=new Map,so=new Map,tS=128;function OI(t){const e=new Set;for(const n of Array.isArray(t)?t:[])!n||!Ws.test(String(n.instanceId||""))||!Array.isArray(n.route)||(e.add(n.instanceId),so.set(n.instanceId,[...n.route]),Da.set(n.instanceId,0));for(const n of[...so.keys()]){if(e.has(n))continue;const s=(Da.get(n)||0)+1;Da.set(n,s),s>vC+32&&(Da.delete(n),so.delete(n))}if(so.size>tS)for(const n of[...so.keys()].slice(0,so.size-tS))Da.delete(n),so.delete(n)}function Vo(t,e){return`${t&&Ws.test(t)?t:Xi}:${e}`}function Uc(t){const e=String(t||""),n=e.indexOf(":");if(n<1)return null;const s=e.slice(0,n),i=e.slice(n+1);return s!==Xi&&!Ws.test(s)||!/^[a-z0-9-]{1,32}$/.test(i)?null:{ownerId:s===Xi?null:s,name:i}}function Ac(t){return Array.isArray(t)&&t.length?t.join("/"):""}function Ov(t){return{columns:Ii(t).columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))}}function BI(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&Ws.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(Ac(n.route),n.instanceId);return e}function $I(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&Ws.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(n.instanceId,[...n.route]);return e}function Mg(t,e,n=[]){const s=Ov(t),i=BI(n);for(const a of s.columns)for(const c of a.tiles)c.ownerId||(!c.node&&Ws.test(String(e||""))?c.ownerId=e:c.node&&i.has(c.node)&&(c.ownerId=i.get(c.node)));return s}function Xl(t,e){const n=Uc(t);return!n||!n.ownerId||!e||n.ownerId!==e?t:Vo(null,n.name)}function Ha(t,e,n=[]){const s=Ov(t),i=new Map,a=new Set;for(const c of n)c&&Ws.test(String(c.instanceId||""))&&Array.isArray(c.route)&&(i.set(c.instanceId,[...c.route]),c.stale===!0&&a.add(c.instanceId));for(const c of s.columns)for(const u of c.tiles)if(u.ownerId)if(u.ownerId===e)delete u.node,delete u.unavailable,delete u.stale;else if(i.has(u.ownerId))u.node=Ac(i.get(u.ownerId)),delete u.unavailable,a.has(u.ownerId)?u.stale=!0:delete u.stale;else{const h=Da.get(u.ownerId),f=so.get(u.ownerId);f&&h!==void 0&&h<vC?(u.node=Ac(f),delete u.unavailable,u.stale=!0):(u.unavailable=!0,delete u.stale)}return s}function Jl(t,e,n=[]){const s=Ov(t),i=$I(n);for(const a of s.columns)for(const c of a.tiles)delete c.unavailable,delete c.stale,c.ownerId&&(c.ownerId===e?delete c.node:i.has(c.ownerId)&&(c.node=Ac(i.get(c.ownerId))));return s}function _C(t,e,n=[]){const s=Er(t);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Ws.test(String(e||""))?{ownerId:e}:{}};const i=n.find(a=>Ac(a&&a.route)===s.node);return{...s,...i&&Ws.test(String(i.instanceId||""))?{ownerId:i.instanceId}:{}}}const zI=/^[a-z0-9-]{1,32}$/,ti="main",yC="nc_decks",wC="nc_deck_order_v1",bC=24;function nS(t){return typeof t!="string"?"":t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Xa(t){return typeof t=="string"&&zI.test(t)}function FI(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/?$/);if(e){let n;try{n=decodeURIComponent(e[1])}catch{n=e[1]}return Xa(n)?n:ti}return ti}function HI(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(e){let s,i;try{s=decodeURIComponent(e[1]),i=decodeURIComponent(e[2])}catch{return{id:Vo(null,ti),ownerId:null,name:ti}}if(Ws.test(s)&&Xa(i))return{id:Vo(s,i),ownerId:s,name:i}}const n=FI(t);return{id:Vo(null,n),ownerId:null,name:n}}function jp(t,e){const n=typeof t=="object"&&t?{ownerId:t.ownerId||null,name:t.name}:Uc(t)||{ownerId:null,name:t},s=Xa(n.name)?n.name:ti,i=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===ti?"/":`/deck/${encodeURIComponent(s)}`;return e?`${i}#token=${encodeURIComponent(e)}`:i}function SC(t){return t===ti?"nc_grid_v1":`nc_grid_v1__${t}`}function xC(t){const e=[ti];if(Array.isArray(t)){for(const n of t)if(Xa(n)&&n!==ti&&!e.includes(n)&&e.push(n),e.length>=bC)break}return e}function nl(){return typeof localStorage<"u"?localStorage:null}function UI(){const t=nl();if(!t)return[ti];try{return xC(JSON.parse(t.getItem(yC)||"null"))}catch{return[ti]}}function WI(t){const e=nl();if(e)try{e.setItem(yC,JSON.stringify(xC(t)))}catch{}}function Wc(t){return t==="local"||Ws.test(String(t||""))}function ph(t,e){const n=Uc(t);return!!n&&(n.ownerId||"local")===e}function tr(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,s]of Object.entries(t).slice(0,64)){if(!Wc(n)||!Array.isArray(s))continue;const i=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&ph(a,n)))].slice(0,bC);i.length&&(e[n]=i)}return e}function Ql(t=nl()){if(!t)return{};try{return tr(JSON.parse(t.getItem(wC)||"null"))}catch{return{}}}function Mp(t,e=nl()){const n=tr(t);if(e)try{e.setItem(wC,JSON.stringify(n))}catch{}return n}function mh(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function qI(t,e,n,s,i=[]){if(!Wc(e)||n===s)return tr(t);const a=[...new Set(i.filter(v=>ph(v,e)))];if(!a.includes(n)||!a.includes(s))return tr(t);const c=mh(t,e).filter(v=>a.includes(v)),u=[...c,...a.filter(v=>!c.includes(v))],h=u.indexOf(n),f=u.indexOf(s);u.splice(h,1);const g=u.indexOf(s);return u.splice(h<f?g+1:g,0,n),tr({...t,[e]:u})}function KI(t,e,n,s){if(!Wc(e)||!ph(s,e))return tr(t);const i=mh(t,e);return i.includes(n)?tr({...t,[e]:i.map(a=>a===n?s:a)}):tr(t)}function VI(t,e,n){return Wc(e)?tr({...t,[e]:mh(t,e).filter(s=>s!==n)}):tr(t)}function Tp(t,e={},n=[]){const s=new Map,i=new Map;for(const h of Array.isArray(t)?t:[]){const f=h!=null&&h.local?"local":String((h==null?void 0:h.ownerId)||"");!Wc(f)||!ph(h==null?void 0:h.id,f)||(s.has(f)||s.set(f,[]),i.has(f)||i.set(f,i.size),s.get(f).push(h))}const a=new Map;(Array.isArray(n)?n:[]).forEach((h,f)=>{typeof h=="string"&&!a.has(h)&&a.set(h,f)});const c=h=>{if(h==="local")return-1;const f=a.get(`id:${h}`);return f===void 0?Number.MAX_SAFE_INTEGER:f},u=[];for(const h of[...s.keys()].sort((f,g)=>c(f)-c(g)||i.get(f)-i.get(g))){const f=s.get(h),g=mh(e,h),v=new Map(g.map((_,b)=>[_,b]));f.sort((_,b)=>{const x=v.has(_.id)?v.get(_.id):Number.MAX_SAFE_INTEGER,L=v.has(b.id)?v.get(b.id):Number.MAX_SAFE_INTEGER;return x-L}),u.push(...f)}return u}function Tg(t){const e=nl();if(!e)return null;try{return JSON.parse(e.getItem(SC(t))||"null")}catch{return null}}function YI(t,e){const n=nl();if(n)try{n.setItem(SC(t),JSON.stringify(e))}catch{}}const Bv="nc_deckbar_collapsed_v1",kC=64;function $v(t){return t===Xi||Ws.test(String(t||""))}function zv(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};let n=0;for(const[s,i]of Object.entries(t)){if(n>=kC)break;if($v(s)){if(i===!0)e[s]=!0;else if(i===!1)e[s]=!1;else continue;n+=1}}return e}function CC(t,e){return $v(e)&&Object.prototype.hasOwnProperty.call(t||{},e)?t[e]===!0:!0}function GI(t,e){const n=zv(t);return $v(e)&&(!Object.prototype.hasOwnProperty.call(n,e)&&Object.keys(n).length>=kC&&delete n[Object.keys(n)[0]],n[e]=!CC(n,e)),n}function EC(){return typeof localStorage<"u"?localStorage:null}function sS(t=EC()){if(!t)return{};try{return zv(JSON.parse(t.getItem(Bv)||"null"))}catch{return{}}}function XI(t,e=EC()){const n=zv(t);if(e)try{e.setItem(Bv,JSON.stringify(n))}catch{}return n}function JI(){const[t,e]=w.useState(sS);w.useEffect(()=>{const i=a=>{(a.key===Bv||a.key===null)&&e(sS())};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]);const n=w.useCallback(i=>CC(t,i),[t]),s=w.useCallback(i=>{e(a=>XI(GI(a,i)))},[]);return{collapsed:t,isCollapsed:n,toggle:s}}const Fv="nc_deck_presence_v1",iS=3e4,QI=18e4,NC=1e4,RC=32,ZI=/^[A-Za-z0-9_-]{1,64}$/,eD=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),rS="working",tD="on",nD="neutral",sD="warn";function Hv(t){return typeof t=="string"&&ZI.test(t)&&!eD.has(t)}function LC(t){return typeof t=="string"&&Uc(t)!==null}function Uv(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}function Ja(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};let n=0;for(const[s,i]of Object.entries(t)){if(n>=RC)break;Hv(s)&&(!i||typeof i!="object"||LC(i.deckId)&&Uv(i.ts)&&(e[s]={deckId:i.deckId,ts:i.ts,focus:i.focus===!0,visible:i.visible===!0},n+=1))}return e}function AC(t,e){const n=Ja(t);if(!Uv(e))return n;const s={};for(const[i,a]of Object.entries(n)){const c=a.visible?iS:QI,u=e-c;a.ts>=u&&a.ts<=e+iS&&(s[i]=a)}return s}function oS(t,e,n,s){if(!Hv(e)||!Uv(s))return Ja(t);const i=AC(t,s);if(!LC(n==null?void 0:n.deckId))return i;if(!Object.prototype.hasOwnProperty.call(i,e)&&Object.keys(i).length>=RC){let a="",c=1/0;for(const[u,h]of Object.entries(i))h.ts<c&&(a=u,c=h.ts);a&&delete i[a]}return i[e]={deckId:n.deckId,ts:s,focus:(n==null?void 0:n.focus)===!0,visible:(n==null?void 0:n.visible)===!0},Ja(i)}function iD(t,e){const n=Ja(t);if(!Hv(e))return n;const s={...n};return delete s[e],s}function rD(t,e){const n=AC(t,e),s={};for(const i of Object.values(n)){const a=i.focus&&i.visible?rS:tD;s[i.deckId]!==rS&&(s[i.deckId]=a)}return s}function jC(){return typeof localStorage<"u"?localStorage:null}function nd(t=jC()){if(!t)return{};try{return Ja(JSON.parse(t.getItem(Fv)||"null"))}catch{return{}}}function Pp(t,e=jC()){const n=Ja(t);if(e)try{e.setItem(Fv,JSON.stringify(n))}catch{}return n}const oD=Math.min(NC,5e3);function aD(){var t,e;try{const n=(e=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:e.call(t);if(n)return`w${n.replaceAll("-","")}`}catch{}return`w${Date.now().toString(36)}${Math.random().toString(36).slice(2,14)}`}const lD=aD();function aS(){const t=typeof document<"u"&&typeof document.hasFocus=="function"?document.hasFocus():!0,e=typeof document<"u"&&typeof document.visibilityState=="string"?document.visibilityState!=="hidden":!0;return{focus:t,visible:e}}function cD(t,e=!0){const s=w.useRef(lD).current,i=w.useRef(t);i.current=t;const[a,c]=w.useState(()=>({map:{},now:Date.now()})),u=w.useCallback(()=>{c({map:nd(),now:Date.now()})},[]);w.useEffect(()=>{if(!e)return;const g=()=>{const k=Date.now(),R=oS(nd(),s,{deckId:i.current,...aS()},k);return Pp(R),{map:R,now:k}},v=()=>c(g());v();const _=setInterval(g,NC),b=setInterval(u,oD),x=v,L=k=>{(k.key===Fv||k.key===null)&&u()};return window.addEventListener("focus",x),window.addEventListener("blur",x),typeof document<"u"&&document.addEventListener("visibilitychange",x),window.addEventListener("storage",L),()=>{clearInterval(_),clearInterval(b),window.removeEventListener("focus",x),window.removeEventListener("blur",x),typeof document<"u"&&document.removeEventListener("visibilitychange",x),window.removeEventListener("storage",L);try{Pp(iD(nd(),s))}catch{}}},[e,s,u]),w.useEffect(()=>{if(!e)return;const g=Date.now(),v=oS(nd(),s,{deckId:t,...aS()},g);Pp(v),c({map:v,now:g})},[t,e,s]);const h=w.useMemo(()=>e?rD(a.map,a.now):{},[e,a]);return{dotFor:w.useCallback((g,v=!1)=>e?v?sD:h[g]||nD:null,[h,e]),windowId:s}}const lS=52,cS=18;function uD({ownerKey:t,deckId:e,label:n,onMove:s,onStep:i}){const a=w.useRef(null),c=w.useRef(0),[u,h]=w.useState(!1),f=()=>{var L,k,R,S;const x=a.current;(k=(L=x==null?void 0:x.over)==null?void 0:L.classList)==null||k.remove("nc-deck-over"),(S=(R=x==null?void 0:x.source)==null?void 0:R.classList)==null||S.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},g=(x=!1)=>{const L=a.current;if(!L)return;const k=L.target;f(),a.current=null,h(!1);try{L.handle.releasePointerCapture(L.pointerId)}catch{}x&&k&&k!==e&&s(e,k)},v=(x,L)=>{var E,F,$,G,K,Y,te,q;const k=a.current;if(!k)return;k.x=x,k.y=L;const R=(F=(E=document.elementFromPoint(x,L))==null?void 0:E.closest)==null?void 0:F.call(E,"[data-deck-id][data-owner-key]"),S=($=R==null?void 0:R.dataset)==null?void 0:$.deckId,j=((G=R==null?void 0:R.dataset)==null?void 0:G.ownerKey)===t&&S&&S!==e;k.over!==(j?R:null)&&((Y=(K=k.over)==null?void 0:K.classList)==null||Y.remove("nc-deck-over"),k.over=j?R:null,(q=(te=k.over)==null?void 0:te.classList)==null||q.add("nc-deck-over")),k.target=j?S:null},_=()=>{var k,R;const x=a.current;if(!x){c.current=0;return}const L=(R=(k=x.container)==null?void 0:k.getBoundingClientRect)==null?void 0:R.call(k);if(L){const S=x.x<L.left+lS?-cS:x.x>L.right-lS?cS:0;S&&(x.container.scrollLeft+=S,v(x.x,x.y))}c.current=requestAnimationFrame(_)};w.useEffect(()=>{const x=k=>{k.key==="Escape"&&a.current&&(k.preventDefault(),g(!1))},L=()=>g(!1);return window.addEventListener("keydown",x),window.addEventListener("blur",L),()=>{window.removeEventListener("keydown",x),window.removeEventListener("blur",L),f(),a.current=null}},[e,t]);const b=x=>{var R;if(x.pointerType==="mouse"&&x.button!==0)return;x.preventDefault(),x.stopPropagation(),x.currentTarget.focus({preventScroll:!0});const L=x.currentTarget.closest("[data-deck-id][data-owner-key]"),k=x.currentTarget.closest(".nc-deckbar");a.current={pointerId:x.pointerId,handle:x.currentTarget,source:L,container:k,target:null,over:null,x:x.clientX,y:x.clientY},(R=L==null?void 0:L.classList)==null||R.add("nc-deck-dragging");try{x.currentTarget.setPointerCapture(x.pointerId)}catch{}h(!0),c.current=requestAnimationFrame(_)};return l.jsx("button",{type:"button",className:`nc-deck-handle${u?" active":""}`,"aria-label":`${p("reorder")} ${n}`,"aria-keyshortcuts":"ArrowLeft ArrowRight",title:p("reorder-deck-help"),onClick:x=>{x.preventDefault(),x.stopPropagation()},onDragStart:x=>x.preventDefault(),onKeyDown:x=>{x.key!=="ArrowLeft"&&x.key!=="ArrowRight"||(x.preventDefault(),x.stopPropagation(),i(x.key==="ArrowLeft"?-1:1))},onPointerDown:b,onPointerMove:x=>{!a.current||x.pointerId!==a.current.pointerId||(x.preventDefault(),x.stopPropagation(),v(x.clientX,x.clientY))},onPointerUp:x=>{!a.current||x.pointerId!==a.current.pointerId||(x.preventDefault(),x.stopPropagation(),g(!0))},onPointerCancel:()=>g(!1),onLostPointerCapture:()=>{a.current&&g(!1)},children:"↔"})}function dD({decks:t=[],currentDeck:e="local:main",onCreate:n,onRename:s,onDelete:i,onReorder:a,onOpenWindow:c,onNavigate:u,saveState:h="idle",error:f="",sidebarVisible:g,onToggleSidebar:v,conflict:_=!1,onReloadDeck:b=null}){zn();const{isCollapsed:x,toggle:L}=JI(),{dotFor:k}=cD(e),[R,S]=w.useState(null),[j,E]=w.useState(""),[F,$]=w.useState(!1),[G,K]=w.useState(""),[Y,te]=w.useState(""),q=nS(j),D=Xa(q),I=[];for(const A of t){const N=A.local?"local":A.ownerId;let U=I.find(P=>P.key===N);U||(U={key:N,label:A.ownerLabel||(A.local?"Local":N),local:!!A.local,decks:[]},I.push(U)),U.decks.push(A)}const O=async()=>{if(D){$(!0),K("");try{n&&await n(q,R),E(""),S(null)}catch(A){K(String(A.message||A))}$(!1)}},M=A=>{te(""),c&&c(A.id)||te(A.id)},z=async A=>{if(!(A.id===e||!u||F||A.available===!1)){$(!0),K("");try{await u(A.id)}catch(N){K(String((N==null?void 0:N.message)||N))}$(!1)}},T=(A,N,U)=>{const P=A.decks.findIndex(ie=>ie.id===N.id),H=A.decks[P+U];P>=0&&H&&a&&!F&&a(N.id,H.id)};return l.jsxs("div",{className:"nc-deckbar",children:[v&&l.jsx("button",{className:"nc-deck-sidebar-toggle",title:p("toggle-sidebar"),onClick:v,children:g?"◀":"☰"}),l.jsx("span",{className:"nc-deckbar-label",children:p("decks")}),l.jsx("div",{className:"nc-deck-chips",children:I.map(A=>{const N=x(A.key),U=`nc-deck-content-${A.key}`,P=A.local?"Local":A.label,H=A.decks.some(Q=>Q.id===e),ie=(A.decks.find(Q=>Q.id===e)||{}).name,J=p(A.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",A.decks.length);return l.jsxs("span",{className:`nc-deck-owner-group${N?" collapsed":""}`,"data-owner-key":A.key,"data-collapsed":N?"1":"0",children:[l.jsxs("button",{type:"button",className:"nc-deck-owner-toggle","aria-expanded":!N,"aria-controls":U,title:p(N?"expand-owner":"collapse-owner").replace("{owner}",P),onClick:()=>{!N&&R===A.key&&(E(""),S(null)),L(A.key)},children:[l.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:N?"▸":"▾"}),l.jsx("span",{className:"nc-deck-owner",children:P})]}),N&&l.jsxs("span",{className:"nc-deck-summary",title:J,children:[l.jsx("span",{className:"nc-deck-summary-count",children:A.decks.length}),H&&l.jsxs("span",{className:"nc-deck-summary-current",children:["• ",ie]})]}),l.jsxs("span",{id:U,className:"nc-deck-owner-content",hidden:N,children:[A.decks.map(Q=>{const ve=k(Q.id,Q.available===!1);return l.jsxs("span",{"data-deck-id":Q.id,"data-owner-key":A.key,className:`nc-deck-chip${Q.id===e?" current":""}${Q.available===!1?" offline":""}`,children:[ve&&l.jsx(hD,{state:ve}),l.jsx(uD,{ownerKey:A.key,deckId:Q.id,label:`${A.label} · ${Q.name}`,onMove:(de,ne)=>{a&&!F&&a(de,ne)},onStep:de=>T(A,Q,de)}),l.jsxs("button",{className:"nc-deck-open",title:Q.available===!1?`${Q.ownerLabel} offline${Q.refreshFailedAt?" · aggiornamento in ritardo":""}`:Q.id===e?p("deck-current"):`${Q.ownerLabel} · ${Q.name}`,disabled:F||Q.available===!1,onClick:()=>z(Q),children:[Q.name,Q.id===e?" •":""]}),Q.available!==!1&&Q.stale===!0&&Q.refreshFailedAt?l.jsx("span",{className:"nc-deck-stale",title:`${Q.ownerLabel} · ${p("deck-stale")}`,children:p("deck-stale-badge")}):null,l.jsx("button",{className:"nc-deck-mini",disabled:Q.available===!1,title:p("detach-deck"),onClick:()=>M(Q),children:"↗"}),Q.name!==ti&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"nc-deck-mini",disabled:Q.available===!1,title:p("rename-deck"),onClick:()=>{const de=(typeof window<"u"?window.prompt(p("rename-deck"),Q.name):"")||"",ne=nS(de);Xa(ne)&&ne!==Q.name&&s&&s(Q.id,ne).catch(xe=>K(String(xe.message||xe)))},children:"✎"}),l.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:Q.available===!1,title:p("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(p("delete-deck-confirm").replace("{name}",`${Q.ownerLabel} · ${Q.name}`)))&&i&&i(Q.id).catch(de=>K(String(de.message||de)))},children:"✕"})]})]},Q.id)}),R===A.key?l.jsxs("span",{className:"nc-deck-add",children:[l.jsx("input",{autoFocus:!0,className:D||!j?"":"invalid",placeholder:p("deck-name"),value:j,onChange:Q=>E(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&O(),Q.key==="Escape"&&(E(""),S(null))}}),j&&D&&q!==j&&l.jsxs("span",{className:"nc-deck-slug",children:["→ ",q]}),l.jsx("button",{className:"nc-deck-ok",disabled:!D||F,onClick:O,children:p("create")}),l.jsx("button",{className:"nc-deck-cancel",onClick:()=>{E(""),S(null)},children:p("cancel")})]}):l.jsxs("button",{className:"nc-deck-newbtn",disabled:F||A.decks.every(Q=>Q.available===!1),title:`${p("new-deck")} · ${A.label}`,onClick:()=>{E(""),S(A.key)},children:["+ ",p("new")]})]})]},A.key)})}),l.jsx("span",{className:`nc-deck-state ${h}`,title:p("deck-autosave"),children:p(h==="saving"?"saving":h==="saved"?"saved":"deck-autosave")}),(G||f)&&l.jsx("span",{className:"nc-deck-error",children:G||f}),_&&b&&l.jsx("button",{className:"nc-deck-reload",onClick:b,children:p("reload")}),Y&&l.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(Y),children:p("popup-blocked")})]})}function hD({state:t}){if(!t)return null;const e=p(`dot-${t}`);return l.jsx("span",{className:`nc-deck-dot ${t}`,role:"img","aria-label":e,title:e})}var Pa={},Ip,uS;function fD(){return uS||(uS=1,Ip=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Ip}var Dp={},Qr={},dS;function ea(){if(dS)return Qr;dS=1;let t;const e=[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 Qr.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},Qr.getSymbolTotalCodewords=function(s){return e[s]},Qr.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},Qr.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');t=s},Qr.isKanjiModeEnabled=function(){return typeof t<"u"},Qr.toSJIS=function(s){return t(s)},Qr}var Op={},hS;function Wv(){return hS||(hS=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},t.from=function(s,i){if(t.isValid(s))return s;try{return e(s)}catch{return i}}})(Op)),Op}var Bp,fS;function pD(){if(fS)return Bp;fS=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(e){const n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)===1},put:function(e,n){for(let s=0;s<n;s++)this.putBit((e>>>n-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}},Bp=t,Bp}var $p,pS;function mD(){if(pS)return $p;pS=1;function t(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return t.prototype.set=function(e,n,s,i){const a=e*this.size+n;this.data[a]=s,i&&(this.reservedBit[a]=!0)},t.prototype.get=function(e,n){return this.data[e*this.size+n]},t.prototype.xor=function(e,n,s){this.data[e*this.size+n]^=s},t.prototype.isReserved=function(e,n){return this.reservedBit[e*this.size+n]},$p=t,$p}var zp={},mS;function gD(){return mS||(mS=1,(function(t){const e=ea().getSymbolSize;t.getRowColCoords=function(s){if(s===1)return[];const i=Math.floor(s/7)+2,a=e(s),c=a===145?26:Math.ceil((a-13)/(2*i-2))*2,u=[a-7];for(let h=1;h<i-1;h++)u[h]=u[h-1]-c;return u.push(6),u.reverse()},t.getPositions=function(s){const i=[],a=t.getRowColCoords(s),c=a.length;for(let u=0;u<c;u++)for(let h=0;h<c;h++)u===0&&h===0||u===0&&h===c-1||u===c-1&&h===0||i.push([a[u],a[h]]);return i}})(zp)),zp}var Fp={},gS;function vD(){if(gS)return Fp;gS=1;const t=ea().getSymbolSize,e=7;return Fp.getPositions=function(s){const i=t(s);return[[0,0],[i-e,0],[0,i-e]]},Fp}var Hp={},vS;function _D(){return vS||(vS=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},t.from=function(i){return t.isValid(i)?parseInt(i,10):void 0},t.getPenaltyN1=function(i){const a=i.size;let c=0,u=0,h=0,f=null,g=null;for(let v=0;v<a;v++){u=h=0,f=g=null;for(let _=0;_<a;_++){let b=i.get(v,_);b===f?u++:(u>=5&&(c+=e.N1+(u-5)),f=b,u=1),b=i.get(_,v),b===g?h++:(h>=5&&(c+=e.N1+(h-5)),g=b,h=1)}u>=5&&(c+=e.N1+(u-5)),h>=5&&(c+=e.N1+(h-5))}return c},t.getPenaltyN2=function(i){const a=i.size;let c=0;for(let u=0;u<a-1;u++)for(let h=0;h<a-1;h++){const f=i.get(u,h)+i.get(u,h+1)+i.get(u+1,h)+i.get(u+1,h+1);(f===4||f===0)&&c++}return c*e.N2},t.getPenaltyN3=function(i){const a=i.size;let c=0,u=0,h=0;for(let f=0;f<a;f++){u=h=0;for(let g=0;g<a;g++)u=u<<1&2047|i.get(f,g),g>=10&&(u===1488||u===93)&&c++,h=h<<1&2047|i.get(g,f),g>=10&&(h===1488||h===93)&&c++}return c*e.N3},t.getPenaltyN4=function(i){let a=0;const c=i.data.length;for(let h=0;h<c;h++)a+=i.data[h];return Math.abs(Math.ceil(a*100/c/5)-10)*e.N4};function n(s,i,a){switch(s){case t.Patterns.PATTERN000:return(i+a)%2===0;case t.Patterns.PATTERN001:return i%2===0;case t.Patterns.PATTERN010:return a%3===0;case t.Patterns.PATTERN011:return(i+a)%3===0;case t.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(a/3))%2===0;case t.Patterns.PATTERN101:return i*a%2+i*a%3===0;case t.Patterns.PATTERN110:return(i*a%2+i*a%3)%2===0;case t.Patterns.PATTERN111:return(i*a%3+(i+a)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}t.applyMask=function(i,a){const c=a.size;for(let u=0;u<c;u++)for(let h=0;h<c;h++)a.isReserved(h,u)||a.xor(h,u,n(i,h,u))},t.getBestMask=function(i,a){const c=Object.keys(t.Patterns).length;let u=0,h=1/0;for(let f=0;f<c;f++){a(f),t.applyMask(f,i);const g=t.getPenaltyN1(i)+t.getPenaltyN2(i)+t.getPenaltyN3(i)+t.getPenaltyN4(i);t.applyMask(f,i),g<h&&(h=g,u=f)}return u}})(Hp)),Hp}var sd={},_S;function MC(){if(_S)return sd;_S=1;const t=Wv(),e=[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 sd.getBlocksCount=function(i,a){switch(a){case t.L:return e[(i-1)*4+0];case t.M:return e[(i-1)*4+1];case t.Q:return e[(i-1)*4+2];case t.H:return e[(i-1)*4+3];default:return}},sd.getTotalCodewordsCount=function(i,a){switch(a){case t.L:return n[(i-1)*4+0];case t.M:return n[(i-1)*4+1];case t.Q:return n[(i-1)*4+2];case t.H:return n[(i-1)*4+3];default:return}},sd}var Up={},Zl={},yS;function yD(){if(yS)return Zl;yS=1;const t=new Uint8Array(512),e=new Uint8Array(256);return(function(){let s=1;for(let i=0;i<255;i++)t[i]=s,e[s]=i,s<<=1,s&256&&(s^=285);for(let i=255;i<512;i++)t[i]=t[i-255]})(),Zl.log=function(s){if(s<1)throw new Error("log("+s+")");return e[s]},Zl.exp=function(s){return t[s]},Zl.mul=function(s,i){return s===0||i===0?0:t[e[s]+e[i]]},Zl}var wS;function wD(){return wS||(wS=1,(function(t){const e=yD();t.mul=function(s,i){const a=new Uint8Array(s.length+i.length-1);for(let c=0;c<s.length;c++)for(let u=0;u<i.length;u++)a[c+u]^=e.mul(s[c],i[u]);return a},t.mod=function(s,i){let a=new Uint8Array(s);for(;a.length-i.length>=0;){const c=a[0];for(let h=0;h<i.length;h++)a[h]^=e.mul(i[h],c);let u=0;for(;u<a.length&&a[u]===0;)u++;a=a.slice(u)}return a},t.generateECPolynomial=function(s){let i=new Uint8Array([1]);for(let a=0;a<s;a++)i=t.mul(i,new Uint8Array([1,e.exp(a)]));return i}})(Up)),Up}var Wp,bS;function bD(){if(bS)return Wp;bS=1;const t=wD();function e(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(s){this.degree=s,this.genPoly=t.generateECPolynomial(this.degree)},e.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const i=new Uint8Array(s.length+this.degree);i.set(s);const a=t.mod(i,this.genPoly),c=this.degree-a.length;if(c>0){const u=new Uint8Array(this.degree);return u.set(a,c),u}return a},Wp=e,Wp}var qp={},Kp={},Vp={},SS;function TC(){return SS||(SS=1,Vp.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),Vp}var Ki={},xS;function PC(){if(xS)return Ki;xS=1;const t="[0-9]+",e="[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
|
|
158
|
-
]))+`;Ki.KANJI=new RegExp(n,"g"),Ki.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Ki.BYTE=new RegExp(s,"g"),Ki.NUMERIC=new RegExp(t,"g"),Ki.ALPHANUMERIC=new RegExp(e,"g");const i=new RegExp("^"+n+"$"),a=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Ki.testKanji=function(h){return i.test(h)},Ki.testNumeric=function(h){return a.test(h)},Ki.testAlphanumeric=function(h){return c.test(h)},Ki}var kS;function ta(){return kS||(kS=1,(function(t){const e=TC(),n=PC();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(a,c){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!e.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?a.ccBits[0]:c<27?a.ccBits[1]:a.ccBits[2]},t.getBestModeForData=function(a){return n.testNumeric(a)?t.NUMERIC:n.testAlphanumeric(a)?t.ALPHANUMERIC:n.testKanji(a)?t.KANJI:t.BYTE},t.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},t.isValid=function(a){return a&&a.bit&&a.ccBits};function s(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+i)}}t.from=function(a,c){if(t.isValid(a))return a;try{return s(a)}catch{return c}}})(Kp)),Kp}var CS;function SD(){return CS||(CS=1,(function(t){const e=ea(),n=MC(),s=Wv(),i=ta(),a=TC(),c=7973,u=e.getBCHDigit(c);function h(_,b,x){for(let L=1;L<=40;L++)if(b<=t.getCapacity(L,x,_))return L}function f(_,b){return i.getCharCountIndicator(_,b)+4}function g(_,b){let x=0;return _.forEach(function(L){const k=f(L.mode,b);x+=k+L.getBitsLength()}),x}function v(_,b){for(let x=1;x<=40;x++)if(g(_,x)<=t.getCapacity(x,b,i.MIXED))return x}t.from=function(b,x){return a.isValid(b)?parseInt(b,10):x},t.getCapacity=function(b,x,L){if(!a.isValid(b))throw new Error("Invalid QR Code version");typeof L>"u"&&(L=i.BYTE);const k=e.getSymbolTotalCodewords(b),R=n.getTotalCodewordsCount(b,x),S=(k-R)*8;if(L===i.MIXED)return S;const j=S-f(L,b);switch(L){case i.NUMERIC:return Math.floor(j/10*3);case i.ALPHANUMERIC:return Math.floor(j/11*2);case i.KANJI:return Math.floor(j/13);case i.BYTE:default:return Math.floor(j/8)}},t.getBestVersionForData=function(b,x){let L;const k=s.from(x,s.M);if(Array.isArray(b)){if(b.length>1)return v(b,k);if(b.length===0)return 1;L=b[0]}else L=b;return h(L.mode,L.getLength(),k)},t.getEncodedBits=function(b){if(!a.isValid(b)||b<7)throw new Error("Invalid QR Code version");let x=b<<12;for(;e.getBCHDigit(x)-u>=0;)x^=c<<e.getBCHDigit(x)-u;return b<<12|x}})(qp)),qp}var Yp={},ES;function xD(){if(ES)return Yp;ES=1;const t=ea(),e=1335,n=21522,s=t.getBCHDigit(e);return Yp.getEncodedBits=function(a,c){const u=a.bit<<3|c;let h=u<<10;for(;t.getBCHDigit(h)-s>=0;)h^=e<<t.getBCHDigit(h)-s;return(u<<10|h)^n},Yp}var Gp={},Xp,NS;function kD(){if(NS)return Xp;NS=1;const t=ta();function e(n){this.mode=t.NUMERIC,this.data=n.toString()}return e.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(s){let i,a,c;for(i=0;i+3<=this.data.length;i+=3)a=this.data.substr(i,3),c=parseInt(a,10),s.put(c,10);const u=this.data.length-i;u>0&&(a=this.data.substr(i),c=parseInt(a,10),s.put(c,u*3+1))},Xp=e,Xp}var Jp,RS;function CD(){if(RS)return Jp;RS=1;const t=ta(),e=["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=t.ALPHANUMERIC,this.data=s}return n.getBitsLength=function(i){return 11*Math.floor(i/2)+6*(i%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(i){let a;for(a=0;a+2<=this.data.length;a+=2){let c=e.indexOf(this.data[a])*45;c+=e.indexOf(this.data[a+1]),i.put(c,11)}this.data.length%2&&i.put(e.indexOf(this.data[a]),6)},Jp=n,Jp}var Qp,LS;function ED(){if(LS)return Qp;LS=1;const t=ta();function e(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return e.getBitsLength=function(s){return s*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(n){for(let s=0,i=this.data.length;s<i;s++)n.put(this.data[s],8)},Qp=e,Qp}var Zp,AS;function ND(){if(AS)return Zp;AS=1;const t=ta(),e=ea();function n(s){this.mode=t.KANJI,this.data=s}return n.getBitsLength=function(i){return i*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 i;for(i=0;i<this.data.length;i++){let a=e.toSJIS(this.data[i]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[i]+`
|
|
159
|
-
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),s.put(a,13)}},Zp=n,Zp}var em={exports:{}},jS;function RD(){return jS||(jS=1,(function(t){var e={single_source_shortest_paths:function(n,s,i){var a={},c={};c[s]=0;var u=e.PriorityQueue.make();u.push(s,0);for(var h,f,g,v,_,b,x,L,k;!u.empty();){h=u.pop(),f=h.value,v=h.cost,_=n[f]||{};for(g in _)_.hasOwnProperty(g)&&(b=_[g],x=v+b,L=c[g],k=typeof c[g]>"u",(k||L>x)&&(c[g]=x,u.push(g,x),a[g]=f))}if(typeof i<"u"&&typeof c[i]>"u"){var R=["Could not find a path from ",s," to ",i,"."].join("");throw new Error(R)}return a},extract_shortest_path_from_predecessor_list:function(n,s){for(var i=[],a=s;a;)i.push(a),n[a],a=n[a];return i.reverse(),i},find_path:function(n,s,i){var a=e.single_source_shortest_paths(n,s,i);return e.extract_shortest_path_from_predecessor_list(a,i)},PriorityQueue:{make:function(n){var s=e.PriorityQueue,i={},a;n=n||{};for(a in s)s.hasOwnProperty(a)&&(i[a]=s[a]);return i.queue=[],i.sorter=n.sorter||s.default_sorter,i},default_sorter:function(n,s){return n.cost-s.cost},push:function(n,s){var i={value:n,cost:s};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(em)),em.exports}var MS;function LD(){return MS||(MS=1,(function(t){const e=ta(),n=kD(),s=CD(),i=ED(),a=ND(),c=PC(),u=ea(),h=RD();function f(R){return unescape(encodeURIComponent(R)).length}function g(R,S,j){const E=[];let F;for(;(F=R.exec(j))!==null;)E.push({data:F[0],index:F.index,mode:S,length:F[0].length});return E}function v(R){const S=g(c.NUMERIC,e.NUMERIC,R),j=g(c.ALPHANUMERIC,e.ALPHANUMERIC,R);let E,F;return u.isKanjiModeEnabled()?(E=g(c.BYTE,e.BYTE,R),F=g(c.KANJI,e.KANJI,R)):(E=g(c.BYTE_KANJI,e.BYTE,R),F=[]),S.concat(j,E,F).sort(function(G,K){return G.index-K.index}).map(function(G){return{data:G.data,mode:G.mode,length:G.length}})}function _(R,S){switch(S){case e.NUMERIC:return n.getBitsLength(R);case e.ALPHANUMERIC:return s.getBitsLength(R);case e.KANJI:return a.getBitsLength(R);case e.BYTE:return i.getBitsLength(R)}}function b(R){return R.reduce(function(S,j){const E=S.length-1>=0?S[S.length-1]:null;return E&&E.mode===j.mode?(S[S.length-1].data+=j.data,S):(S.push(j),S)},[])}function x(R){const S=[];for(let j=0;j<R.length;j++){const E=R[j];switch(E.mode){case e.NUMERIC:S.push([E,{data:E.data,mode:e.ALPHANUMERIC,length:E.length},{data:E.data,mode:e.BYTE,length:E.length}]);break;case e.ALPHANUMERIC:S.push([E,{data:E.data,mode:e.BYTE,length:E.length}]);break;case e.KANJI:S.push([E,{data:E.data,mode:e.BYTE,length:f(E.data)}]);break;case e.BYTE:S.push([{data:E.data,mode:e.BYTE,length:f(E.data)}])}}return S}function L(R,S){const j={},E={start:{}};let F=["start"];for(let $=0;$<R.length;$++){const G=R[$],K=[];for(let Y=0;Y<G.length;Y++){const te=G[Y],q=""+$+Y;K.push(q),j[q]={node:te,lastCount:0},E[q]={};for(let D=0;D<F.length;D++){const I=F[D];j[I]&&j[I].node.mode===te.mode?(E[I][q]=_(j[I].lastCount+te.length,te.mode)-_(j[I].lastCount,te.mode),j[I].lastCount+=te.length):(j[I]&&(j[I].lastCount=te.length),E[I][q]=_(te.length,te.mode)+4+e.getCharCountIndicator(te.mode,S))}}F=K}for(let $=0;$<F.length;$++)E[F[$]].end=0;return{map:E,table:j}}function k(R,S){let j;const E=e.getBestModeForData(R);if(j=e.from(S,E),j!==e.BYTE&&j.bit<E.bit)throw new Error('"'+R+'" cannot be encoded with mode '+e.toString(j)+`.
|
|
160
|
-
Suggested mode is: `+e.toString(E));switch(j===e.KANJI&&!u.isKanjiModeEnabled()&&(j=e.BYTE),j){case e.NUMERIC:return new n(R);case e.ALPHANUMERIC:return new s(R);case e.KANJI:return new a(R);case e.BYTE:return new i(R)}}t.fromArray=function(S){return S.reduce(function(j,E){return typeof E=="string"?j.push(k(E,null)):E.data&&j.push(k(E.data,E.mode)),j},[])},t.fromString=function(S,j){const E=v(S,u.isKanjiModeEnabled()),F=x(E),$=L(F,j),G=h.find_path($.map,"start","end"),K=[];for(let Y=1;Y<G.length-1;Y++)K.push($.table[G[Y]].node);return t.fromArray(b(K))},t.rawSplit=function(S){return t.fromArray(v(S,u.isKanjiModeEnabled()))}})(Gp)),Gp}var TS;function AD(){if(TS)return Dp;TS=1;const t=ea(),e=Wv(),n=pD(),s=mD(),i=gD(),a=vD(),c=_D(),u=MC(),h=bD(),f=SD(),g=xD(),v=ta(),_=LD();function b($,G){const K=$.size,Y=a.getPositions(G);for(let te=0;te<Y.length;te++){const q=Y[te][0],D=Y[te][1];for(let I=-1;I<=7;I++)if(!(q+I<=-1||K<=q+I))for(let O=-1;O<=7;O++)D+O<=-1||K<=D+O||(I>=0&&I<=6&&(O===0||O===6)||O>=0&&O<=6&&(I===0||I===6)||I>=2&&I<=4&&O>=2&&O<=4?$.set(q+I,D+O,!0,!0):$.set(q+I,D+O,!1,!0))}}function x($){const G=$.size;for(let K=8;K<G-8;K++){const Y=K%2===0;$.set(K,6,Y,!0),$.set(6,K,Y,!0)}}function L($,G){const K=i.getPositions(G);for(let Y=0;Y<K.length;Y++){const te=K[Y][0],q=K[Y][1];for(let D=-2;D<=2;D++)for(let I=-2;I<=2;I++)D===-2||D===2||I===-2||I===2||D===0&&I===0?$.set(te+D,q+I,!0,!0):$.set(te+D,q+I,!1,!0)}}function k($,G){const K=$.size,Y=f.getEncodedBits(G);let te,q,D;for(let I=0;I<18;I++)te=Math.floor(I/3),q=I%3+K-8-3,D=(Y>>I&1)===1,$.set(te,q,D,!0),$.set(q,te,D,!0)}function R($,G,K){const Y=$.size,te=g.getEncodedBits(G,K);let q,D;for(q=0;q<15;q++)D=(te>>q&1)===1,q<6?$.set(q,8,D,!0):q<8?$.set(q+1,8,D,!0):$.set(Y-15+q,8,D,!0),q<8?$.set(8,Y-q-1,D,!0):q<9?$.set(8,15-q-1+1,D,!0):$.set(8,15-q-1,D,!0);$.set(Y-8,8,1,!0)}function S($,G){const K=$.size;let Y=-1,te=K-1,q=7,D=0;for(let I=K-1;I>0;I-=2)for(I===6&&I--;;){for(let O=0;O<2;O++)if(!$.isReserved(te,I-O)){let M=!1;D<G.length&&(M=(G[D]>>>q&1)===1),$.set(te,I-O,M),q--,q===-1&&(D++,q=7)}if(te+=Y,te<0||K<=te){te-=Y,Y=-Y;break}}}function j($,G,K){const Y=new n;K.forEach(function(O){Y.put(O.mode.bit,4),Y.put(O.getLength(),v.getCharCountIndicator(O.mode,$)),O.write(Y)});const te=t.getSymbolTotalCodewords($),q=u.getTotalCodewordsCount($,G),D=(te-q)*8;for(Y.getLengthInBits()+4<=D&&Y.put(0,4);Y.getLengthInBits()%8!==0;)Y.putBit(0);const I=(D-Y.getLengthInBits())/8;for(let O=0;O<I;O++)Y.put(O%2?17:236,8);return E(Y,$,G)}function E($,G,K){const Y=t.getSymbolTotalCodewords(G),te=u.getTotalCodewordsCount(G,K),q=Y-te,D=u.getBlocksCount(G,K),I=Y%D,O=D-I,M=Math.floor(Y/D),z=Math.floor(q/D),T=z+1,A=M-z,N=new h(A);let U=0;const P=new Array(D),H=new Array(D);let ie=0;const J=new Uint8Array($.buffer);for(let xe=0;xe<D;xe++){const $e=xe<O?z:T;P[xe]=J.slice(U,U+$e),H[xe]=N.encode(P[xe]),U+=$e,ie=Math.max(ie,$e)}const Q=new Uint8Array(Y);let ve=0,de,ne;for(de=0;de<ie;de++)for(ne=0;ne<D;ne++)de<P[ne].length&&(Q[ve++]=P[ne][de]);for(de=0;de<A;de++)for(ne=0;ne<D;ne++)Q[ve++]=H[ne][de];return Q}function F($,G,K,Y){let te;if(Array.isArray($))te=_.fromArray($);else if(typeof $=="string"){let M=G;if(!M){const z=_.rawSplit($);M=f.getBestVersionForData(z,K)}te=_.fromString($,M||40)}else throw new Error("Invalid data");const q=f.getBestVersionForData(te,K);if(!q)throw new Error("The amount of data is too big to be stored in a QR Code");if(!G)G=q;else if(G<q)throw new Error(`
|
|
161
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
162
|
-
Minimum version required to store current data is: `+q+`.
|
|
163
|
-
`);const D=j(G,K,te),I=t.getSymbolSize(G),O=new s(I);return b(O,G),x(O),L(O,G),R(O,K,0),G>=7&&k(O,G),S(O,D),isNaN(Y)&&(Y=c.getBestMask(O,R.bind(null,O,K))),c.applyMask(Y,O),R(O,K,Y),{modules:O,version:G,errorCorrectionLevel:K,maskPattern:Y,segments:te}}return Dp.create=function(G,K){if(typeof G>"u"||G==="")throw new Error("No input text");let Y=e.M,te,q;return typeof K<"u"&&(Y=e.from(K.errorCorrectionLevel,e.M),te=f.from(K.version),q=c.from(K.maskPattern),K.toSJISFunc&&t.setToSJISFunction(K.toSJISFunc)),F(G,te,Y,q)},Dp}var tm={},nm={},PS;function IC(){return PS||(PS=1,(function(t){function e(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 i=parseInt(s.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+s.slice(0,6).join("")}}t.getOptions=function(s){s||(s={}),s.color||(s.color={});const i=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,a=s.width&&s.width>=21?s.width:void 0,c=s.scale||4;return{width:a,scale:a?4:c,margin:i,color:{dark:e(s.color.dark||"#000000ff"),light:e(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},t.getScale=function(s,i){return i.width&&i.width>=s+i.margin*2?i.width/(s+i.margin*2):i.scale},t.getImageWidth=function(s,i){const a=t.getScale(s,i);return Math.floor((s+i.margin*2)*a)},t.qrToImageData=function(s,i,a){const c=i.modules.size,u=i.modules.data,h=t.getScale(c,a),f=Math.floor((c+a.margin*2)*h),g=a.margin*h,v=[a.color.light,a.color.dark];for(let _=0;_<f;_++)for(let b=0;b<f;b++){let x=(_*f+b)*4,L=a.color.light;if(_>=g&&b>=g&&_<f-g&&b<f-g){const k=Math.floor((_-g)/h),R=Math.floor((b-g)/h);L=v[u[k*c+R]?1:0]}s[x++]=L.r,s[x++]=L.g,s[x++]=L.b,s[x]=L.a}}})(nm)),nm}var IS;function jD(){return IS||(IS=1,(function(t){const e=IC();function n(i,a,c){i.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=c,a.width=c,a.style.height=c+"px",a.style.width=c+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(a,c,u){let h=u,f=c;typeof h>"u"&&(!c||!c.getContext)&&(h=c,c=void 0),c||(f=s()),h=e.getOptions(h);const g=e.getImageWidth(a.modules.size,h),v=f.getContext("2d"),_=v.createImageData(g,g);return e.qrToImageData(_.data,a,h),n(v,f,g),v.putImageData(_,0,0),f},t.renderToDataURL=function(a,c,u){let h=u;typeof h>"u"&&(!c||!c.getContext)&&(h=c,c=void 0),h||(h={});const f=t.render(a,c,h),g=h.type||"image/png",v=h.rendererOpts||{};return f.toDataURL(g,v.quality)}})(tm)),tm}var sm={},DS;function MD(){if(DS)return sm;DS=1;const t=IC();function e(i,a){const c=i.a/255,u=a+'="'+i.hex+'"';return c<1?u+" "+a+'-opacity="'+c.toFixed(2).slice(1)+'"':u}function n(i,a,c){let u=i+a;return typeof c<"u"&&(u+=" "+c),u}function s(i,a,c){let u="",h=0,f=!1,g=0;for(let v=0;v<i.length;v++){const _=Math.floor(v%a),b=Math.floor(v/a);!_&&!f&&(f=!0),i[v]?(g++,v>0&&_>0&&i[v-1]||(u+=f?n("M",_+c,.5+b+c):n("m",h,0),h=0,f=!1),_+1<a&&i[v+1]||(u+=n("h",g),g=0)):h++}return u}return sm.render=function(a,c,u){const h=t.getOptions(c),f=a.modules.size,g=a.modules.data,v=f+h.margin*2,_=h.color.light.a?"<path "+e(h.color.light,"fill")+' d="M0 0h'+v+"v"+v+'H0z"/>':"",b="<path "+e(h.color.dark,"stroke")+' d="'+s(g,f,h.margin)+'"/>',x='viewBox="0 0 '+v+" "+v+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(h.width?'width="'+h.width+'" height="'+h.width+'" ':"")+x+' shape-rendering="crispEdges">'+_+b+`</svg>
|
|
164
|
-
`;return typeof u=="function"&&u(null,k),k},sm}var OS;function TD(){if(OS)return Pa;OS=1;const t=fD(),e=AD(),n=jD(),s=MD();function i(a,c,u,h,f){const g=[].slice.call(arguments,1),v=g.length,_=typeof g[v-1]=="function";if(!_&&!t())throw new Error("Callback required as last argument");if(_){if(v<2)throw new Error("Too few arguments provided");v===2?(f=u,u=c,c=h=void 0):v===3&&(c.getContext&&typeof f>"u"?(f=h,h=void 0):(f=h,h=u,u=c,c=void 0))}else{if(v<1)throw new Error("Too few arguments provided");return v===1?(u=c,c=h=void 0):v===2&&!c.getContext&&(h=u,u=c,c=void 0),new Promise(function(b,x){try{const L=e.create(u,h);b(a(L,c,h))}catch(L){x(L)}})}try{const b=e.create(u,h);f(null,a(b,c,h))}catch(b){f(b)}}return Pa.create=e.create,Pa.toCanvas=i.bind(null,n.render),Pa.toDataURL=i.bind(null,n.renderToDataURL),Pa.toString=i.bind(null,function(a,c,u){return s.render(a,u)}),Pa}var PD=TD();const ID=Yg(PD);function BS(t){return typeof t=="string"?t.trim():t&&typeof t=="object"&&typeof t.data=="string"?t.data.trim():""}function DD(t){const e=String(t||"").trim();if(!e)return{kind:"empty"};const n=WP(e);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 OD(t,e,n=new Set,s=!1){if(!e||!e.ok)return t;const i=qP(t,e,n);return e.version===2&&e.name&&!n.has("name")&&!s&&(i.name=e.name),!n.has("label")&&!i.label&&e.label&&(i.label=e.label),i}function $S(t,e,n=new Set,s=!1){const i=String(e||"").trim(),a=DD(i);let c={...t,pairingUrl:i};return(a.kind==="complete"||a.kind==="partial")&&(c={...OD(c,a.decoded,n,s),pairingUrl:i}),{classification:a,form:c}}function wd(t,e){const n=String(e||"").toLowerCase();if(!/^[a-f0-9]{16,64}$/.test(n))return"";const s=String(t||"NexusCrew").replace(/([a-z0-9])([A-Z])/g,"$1 $2");let i=fo(s);(i==="localhost"||i==="node")&&(i="nexuscrew");const a=n.slice(0,4),c=Math.max(1,32-a.length-1);return`${i.slice(0,c).replace(/-+$/g,"")||"n"}-${a}`}function BD(t,{deviceDefault:e="",localNodeId:n="",localNameDefault:s=""}={}){const i={name:t.name,ssh:t.ssh,pairingUrl:t.pairingUrl,...t.label?{label:t.label}:{},...t.sshPort?{sshPort:Number(t.sshPort)}:{}},a=t.localLabel||e;a&&(i.localLabel=a);const c=String(t.localName||wd(a,n)||s||"").trim();return c&&(i.localName=c),i}function $D(){const t=new Set;let e=!1;return{canAuto(n){return!e&&!t.has(String(n||""))},start(n){return e?!1:(e=!0,t.add(String(n||"")),!0)},finish(){e=!1},reset(n){t.delete(String(n||""))},isBusy(){return e}}}const zD=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function FD(t){const e=t&&t.data||{},n=typeof e.stage=="string"&&e.stage?e.stage:"",s=typeof e.detail=="string"&&e.detail?e.detail:"";return{stage:n,code:typeof e.code=="string"?e.code:"",detail:s,hint:typeof e.hint=="string"?e.hint:"",suggestedName:typeof e.suggestedName=="string"?e.suggestedName:"",retryable:typeof e.retryable=="boolean"?e.retryable:!n,message:s||String(t&&t.message||t)}}const HD="modulepreload",UD=function(t){return"/"+t},zS={},WD=function(e,n,s){let i=Promise.resolve();if(n&&n.length>0){let c=function(f){return Promise.all(f.map(g=>Promise.resolve(g).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),h=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));i=c(n.map(f=>{if(f=UD(f),f in zS)return;zS[f]=!0;const g=f.endsWith(".css"),v=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${v}`))return;const _=document.createElement("link");if(_.rel=g?"stylesheet":HD,g||(_.as="script"),_.crossOrigin="",_.href=f,h&&_.setAttribute("nonce",h),document.head.appendChild(_),g)return new Promise((b,x)=>{_.addEventListener("load",b),_.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${f}`)))})}))}function a(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return i.then(c=>{for(const u of c||[])u.status==="rejected"&&a(u.reason);return e().catch(a)})};class Dt{constructor(e,n,s,i,a){this._legacyCanvasSize=Dt.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=e,this.$canvas=document.createElement("canvas"),s&&typeof s=="object"?this._onDecode=n:(console.warn(s||i||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 i=="function"?i:this._calculateScanRegion),this._preferredCamera=n.preferredCamera||a||this._preferredCamera,this._legacyCanvasSize=typeof s=="number"?s:typeof i=="number"?i: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),e.disablePictureInPicture=!0,e.playsInline=!0,e.muted=!0;let c=!1;if(e.hidden&&(e.hidden=!1,c=!0),document.body.contains(e)||(document.body.appendChild(e),c=!0),s=e.parentElement,n.highlightScanRegion||n.highlightCodeOutline){if(i=!!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"),!i&&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(e),requestAnimationFrame(()=>{let u=window.getComputedStyle(e);u.display==="none"&&(e.style.setProperty("display","block","important"),c=!0),u.visibility!=="visible"&&(e.style.setProperty("visibility","visible","important"),c=!0),c&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),e.style.opacity="0",e.style.width="0",e.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),e.addEventListener("play",this._onPlay),e.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=Dt.createQrEngine()}static set WORKER_PATH(e){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 Dt.listCameras(!1)).length}catch{return!1}}static async listCameras(e=!1){if(!navigator.mediaDevices)return[];let n=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(i=>i.kind==="videoinput"),s;try{e&&(await n()).every(i=>!i.label)&&(s=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await n()).map((i,a)=>({id:i.deviceId,label:i.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"),Dt._stopVideoStream(s))}}async hasFlash(){let e;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;e=this.$video.srcObject}else e=(await this._getCameraStream()).stream;return"torch"in e.getVideoTracks()[0].getSettings()}catch{return!1}finally{e&&e!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),Dt._stopVideoStream(e))}}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(e){throw this._flashOn=!1,e}}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(),Dt._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:e,facingMode:n}=await this._getCameraStream();!this._active||this._paused?Dt._stopVideoStream(e):(this._setVideoMirror(n),this.$video.srcObject=e,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(e){if(!this._paused)throw this._active=!1,e}}stop(){this.pause(),this._active=!1}async pause(e=!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&&(Dt._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return e?(n(),!0):(await new Promise(s=>setTimeout(s,300)),this._paused?(n(),!0):!1)}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(e,n,s,i,a=!1,c=!1){let u,h=!1;n&&("scanRegion"in n||"qrEngine"in n||"canvas"in n||"disallowCanvasResizing"in n||"alsoTryWithoutScanRegion"in n||"returnDetailedScanResult"in n)?(u=n.scanRegion,s=n.qrEngine,i=n.canvas,a=n.disallowCanvasResizing||!1,c=n.alsoTryWithoutScanRegion||!1,h=!0):console.warn(n||s||i||a||c?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),n=!!s;try{let f,g;[s,f]=await Promise.all([s||Dt.createQrEngine(),Dt._loadImage(e)]),[i,g]=Dt._drawToCanvas(f,u,i,a);let v;if(s instanceof Worker){let _=s;n||Dt._postWorkerMessageSync(_,"inversionMode","both"),v=await new Promise((b,x)=>{let L,k,R,S=-1;k=E=>{E.data.id===S&&(_.removeEventListener("message",k),_.removeEventListener("error",R),clearTimeout(L),E.data.data!==null?b({data:E.data.data,cornerPoints:Dt._convertPoints(E.data.cornerPoints,u)}):x(Dt.NO_QR_CODE_FOUND))},R=E=>{_.removeEventListener("message",k),_.removeEventListener("error",R),clearTimeout(L),x("Scanner error: "+(E?E.message||E:"Unknown Error"))},_.addEventListener("message",k),_.addEventListener("error",R),L=setTimeout(()=>R("timeout"),1e4);let j=g.getImageData(0,0,i.width,i.height);S=Dt._postWorkerMessageSync(_,"decode",j,[j.data.buffer])})}else v=await Promise.race([new Promise((_,b)=>window.setTimeout(()=>b("Scanner error: timeout"),1e4)),(async()=>{try{var[_]=await s.detect(i);if(!_)throw Dt.NO_QR_CODE_FOUND;return{data:_.rawValue,cornerPoints:Dt._convertPoints(_.cornerPoints,u)}}catch(b){if(_=b.message||b,/not implemented|service unavailable/.test(_))return Dt._disableBarcodeDetector=!0,Dt.scanImage(e,{scanRegion:u,canvas:i,disallowCanvasResizing:a,alsoTryWithoutScanRegion:c});throw`Scanner error: ${_}`}})()]);return h?v:v.data}catch(f){if(!u||!c)throw f;let g=await Dt.scanImage(e,{qrEngine:s,canvas:i,disallowCanvasResizing:a});return h?g:g.data}finally{n||Dt._postWorkerMessage(s,"close")}}setGrayscaleWeights(e,n,s,i=!0){Dt._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:n,blue:s,useIntegerApproximation:i})}setInversionMode(e){Dt._postWorkerMessage(this._qrEnginePromise,"inversionMode",e)}static async createQrEngine(e){if(e&&console.warn("Specifying a worker path is not required and not supported anymore."),e=()=>WD(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Dt._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return e();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:i})=>/arm/i.test(s||"arm")&&13<=parseInt(i||"13")).catch(()=>!0)?e():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(e){let n=Math.round(.6666666666666666*Math.min(e.videoWidth,e.videoHeight));return{x:Math.round((e.videoWidth-n)/2),y:Math.round((e.videoHeight-n)/2),width:n,height:n,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var e=this.$video,n=e.videoWidth,s=e.videoHeight,i=e.offsetWidth,a=e.offsetHeight,c=e.offsetLeft,u=e.offsetTop,h=window.getComputedStyle(e),f=h.objectFit,g=n/s,v=i/a;switch(f){case"none":var _=n,b=s;break;case"fill":_=i,b=a;break;default:(f==="cover"?g>v:g<v)?(b=a,_=b*g):(_=i,b=_/g),f==="scale-down"&&(_=Math.min(_,n),b=Math.min(b,s))}var[x,L]=h.objectPosition.split(" ").map((R,S)=>{const j=parseFloat(R);return R.endsWith("%")?(S?a-b:i-_)*j/100:j});h=this._scanRegion.width||n,v=this._scanRegion.height||s,f=this._scanRegion.x||0;var k=this._scanRegion.y||0;g=this.$overlay.style,g.width=`${h/n*_}px`,g.height=`${v/s*b}px`,g.top=`${u+L+k/s*b}px`,s=/scaleX\(-1\)/.test(e.style.transform),g.left=`${c+(s?i-x-_:x)+(s?n-f-h:f)/n*_}px`,g.transform=e.style.transform}})}static _convertPoints(e,n){if(!n)return e;let s=n.x||0,i=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 c of e)c.x=c.x*a+s,c.y=c.y*n+i;return e}_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 e=Date.now()-this._lastScanTimestamp,n=1e3/this._maxScansPerSecond;e<n&&await new Promise(i=>setTimeout(i,n-e)),this._lastScanTimestamp=Date.now();try{var s=await Dt.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(i){if(!this._active)return;this._onDecodeError(i)}!Dt._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Dt.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:i,y:a})=>`${i},${a}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(e){e!==Dt.NO_QR_CODE_FOUND&&console.log(e)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let e=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",n=[{width:{min:1024}},{width:{min:768}},{}],s=n.map(i=>Object.assign({},i,{[e]:{exact:this._preferredCamera}}));for(let i of[...s,...n])try{let a=await navigator.mediaDevices.getUserMedia({video:i,audio:!1}),c=this._getFacingMode(a)||(i.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:a,facingMode:c}}catch{}throw"Camera not found."}async _restartVideoStream(){let e=this._paused;await this.pause(!0)&&!e&&this._active&&await this.start()}static _stopVideoStream(e){for(let n of e.getTracks())n.stop(),e.removeTrack(n)}_setVideoMirror(e){this.$video.style.transform="scaleX("+(e==="user"?-1:1)+")"}_getFacingMode(e){return(e=e.getVideoTracks()[0])?/rear|back|environment/i.test(e.label)?"environment":/front|user|face/i.test(e.label)?"user":null:null}static _drawToCanvas(e,n,s,i=!1){s=s||document.createElement("canvas");let a=n&&n.x?n.x:0,c=n&&n.y?n.y:0,u=n&&n.width?n.width:e.videoWidth||e.width,h=n&&n.height?n.height:e.videoHeight||e.height;return i||(i=n&&n.downScaledWidth?n.downScaledWidth:u,n=n&&n.downScaledHeight?n.downScaledHeight:h,s.width!==i&&(s.width=i),s.height!==n&&(s.height=n)),n=s.getContext("2d",{alpha:!1}),n.imageSmoothingEnabled=!1,n.drawImage(e,a,c,u,h,0,0,s.width,s.height),[s,n]}static async _loadImage(e){if(e instanceof Image)return await Dt._awaitImageLoad(e),e;if(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof SVGImageElement||"OffscreenCanvas"in window&&e instanceof OffscreenCanvas||"ImageBitmap"in window&&e instanceof ImageBitmap)return e;if(e instanceof File||e instanceof Blob||e instanceof URL||typeof e=="string"){let n=new Image;n.src=e instanceof File||e instanceof Blob?URL.createObjectURL(e):e.toString();try{return await Dt._awaitImageLoad(n),n}finally{(e instanceof File||e instanceof Blob)&&URL.revokeObjectURL(n.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(e){e.complete&&e.naturalWidth!==0||await new Promise((n,s)=>{let i=a=>{e.removeEventListener("load",i),e.removeEventListener("error",i),a instanceof ErrorEvent?s("Image load error"):n()};e.addEventListener("load",i),e.addEventListener("error",i)})}static async _postWorkerMessage(e,n,s,i){return Dt._postWorkerMessageSync(await e,n,s,i)}static _postWorkerMessageSync(e,n,s,i){if(!(e instanceof Worker))return-1;let a=Dt._workerMessageId++;return e.postMessage({id:a,type:n,data:s},i),a}}Dt.DEFAULT_CANVAS_SIZE=400;Dt.NO_QR_CODE_FOUND="No QR code found";Dt._disableBarcodeDetector=!1;Dt._workerMessageId=0;function qD({onResult:t,onClose:e}){const n=w.useRef(null),s=w.useRef(null),i=w.useRef(!1),[a,c]=w.useState("");w.useEffect(()=>{let h=!1;const f=n.current,g=v=>{h||i.current||(i.current=!0,t(v))};return(async()=>{if(typeof navigator>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!="function"){c(p("qr-unsupported"));return}let v=!1;try{v=await Dt.hasCamera()}catch{v=!1}if(!v){c(p("qr-no-camera"));return}if(h||!f)return;const _=new Dt(f,b=>{const x=BS(b);x&&g(x)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:b=>{const x=b.videoWidth||640,L=b.videoHeight||480,k=Math.max(1,Math.round(Math.min(x,L)*.92));return{x:Math.round((x-k)/2),y:Math.round((L-k)/2),width:k,height:k,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=_;try{await _.start()}catch(b){if(h)return;const x=b&&b.name||"";c(p(x==="NotAllowedError"||x==="SecurityError"?"qr-permission":x==="NotFoundError"||x==="OverconstrainedError"||x==="NotReadableError"?"qr-no-camera":"qr-unsupported"))}})(),()=>{h=!0;const v=s.current;if(v){try{v.stop()}catch{}try{v.destroy()}catch{}s.current=null}const _=f,b=_&&_.srcObject;if(b&&typeof b.getTracks=="function"){for(const x of b.getTracks())try{x.stop()}catch{}try{_.srcObject=null}catch{}}}},[]);const u=async h=>{const f=h.target.files&&h.target.files[0];if(h.target.value="",!!f)try{const g=await Dt.scanImage(f,{returnDetailedScanResult:!0}),v=BS(g);if(!v)throw new Error("empty");i.current||(i.current=!0,t(v))}catch{c(p("pairing-qr-invalid"))}};return l.jsx("div",{className:"nc-sheet-overlay nc-qr-overlay",onClick:e,children:l.jsxs("div",{className:"nc-sheet nc-qr-modal",onClick:h=>h.stopPropagation(),children:[l.jsx("div",{className:"nc-sheet-head",children:l.jsx("b",{children:p("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:[p("qr-upload"),l.jsx("input",{type:"file",accept:"image/*",hidden:!0,onChange:u})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:e,children:p("cancel")})]})]})})}function qv({line:t,note:e}){const[n,s]=w.useState(!1);return t?l.jsxs("div",{className:"nc-authkeys",role:"group",children:[l.jsx("div",{className:"nc-sheet-label",children:p("pair-authkeys-title")}),l.jsx("small",{className:"nc-set-hint",children:e||p("pair-authkeys-hint")}),l.jsx("textarea",{className:"nc-authkeys-line",readOnly:!0,rows:3,value:t,"aria-label":p("pair-authkeys-title"),onFocus:i=>i.target.select()}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:async()=>{s(await ag(t))},children:p(n?"pair-authkeys-copied":"pair-authkeys-copy")})]}):null}const FS=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function DC({token:t,initial:e="",autoStart:n=!1,deviceDefault:s="",localNodeId:i="",localNameDefault:a="",readonly:c=!1,onSuccess:u,onBusyChange:h}){const[f,g]=w.useState(FS),[v,_]=w.useState(!1),[b,x]=w.useState(!1),[L,k]=w.useState("idle"),[R,S]=w.useState(null),[j,E]=w.useState(""),[F,$]=w.useState(null),[G,K]=w.useState(!1),[Y,te]=w.useState(!1),q=w.useRef($D()),D=w.useRef(new Set),I=L==="busy",O=wd(f.localLabel||s,i)||a,M=Y?f.localName:O;w.useEffect(()=>(h&&h(I),()=>{h&&h(!1)}),[I,h]);const z=async H=>{const ie=String(H.pairingUrl||"").trim();if(q.current.start(ie)){k("busy"),S(null),E("");try{const J=await HN(t,BD({...H,localName:Y?H.localName:wd(H.localLabel||s,i)||a},{deviceDefault:s,localNodeId:i,localNameDefault:a}));k("ok"),_(!1),g(FS()),$(J&&J.authorizedKeys?{line:J.authorizedKeys,note:J.authorizedKeysNote||""}:null),D.current=new Set,K(!1),te(!1),q.current.finish(),u&&await u(J)}catch(J){const Q=FD(J);S(Q),k("idle"),q.current.finish(),Q.code==="peer-name-conflict"&&Cg(Q.suggestedName)&&(te(!0),D.current.add("localName"),g(ve=>({...ve,localName:Q.suggestedName}))),(Q.stage==="validation"||Q.stage==="conflict"||Q.stage==="ssh-start"||Q.stage==="ssh-ready"||String(Q.code||"").startsWith("ssh-"))&&_(!0)}}},T=(H,ie=!0)=>{const{classification:J,form:Q}=$S(f,H,D.current,G),ve=Q.pairingUrl;if(S(null),E(""),L==="ok"&&k("idle"),g(Q),J.kind==="invalid"){S({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(J.kind==="partial"){_(!0),E(J.missing.includes("ssh")?p("pair-missing-ssh"):p("pair-missing-name"));return}J.kind==="complete"&&ie&&!c&&q.current.canAuto(ve)&&z(Q)};w.useEffect(()=>{e&&T(e,n)},[]);const A=()=>{const H=String(f.pairingUrl||"").trim(),{classification:ie,form:J}=$S(f,H,D.current,G);if(g(J),E(""),S(null),ie.kind==="empty"){S({stage:"validation",message:p("pairing-required"),retryable:!0});return}if(ie.kind==="invalid"){S({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(!J.ssh||!J.name){_(!0),E(J.ssh?p("pair-missing-name"):p("pair-missing-ssh"));return}if(J.label&&!Ga(J.label)){S({stage:"validation",message:p("err-label"),retryable:!0});return}if(J.localLabel&&!Ga(J.localLabel)){S({stage:"validation",message:p("err-label"),retryable:!0});return}const Q=Y?J.localName:wd(J.localLabel||s,i)||a;if(!Cg(Q)||Q==="localhost"){_(!0),S({stage:"validation",code:"bad-local-name",message:p("err-local-name"),retryable:!0});return}q.current.reset(H),z(J)},N=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const H=await navigator.clipboard.readText();H&&H.trim()?T(H):E(p("pair-clipboard-empty"))}catch{E(p("pair-clipboard-denied"))}},U=(H,ie)=>{D.current.add(H),g(J=>({...J,[H]:ie}))},P=R&&R.stage&&(zD.includes(R.stage)||R.stage==="internal")?p(`pair-stage-${R.stage}`):p("pair-stage-generic");return l.jsxs("div",{className:"nc-set-form nc-pair-card",children:[l.jsx("div",{className:"nc-sheet-label",children:p("pair-card-title")}),l.jsx("div",{className:"nc-set-info",children:p("pair-card-help")}),l.jsx("input",{className:"nc-pair-input",placeholder:p("pair-paste-ph"),value:f.pairingUrl,disabled:c||I,onChange:H=>{g({...f,pairingUrl:H.target.value}),S(null),E("")},onPaste:H=>{const ie=H.clipboardData&&H.clipboardData.getData("text")||"";ie.trim()&&(H.preventDefault(),T(ie))},onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),A())}}),l.jsxs("div",{className:"nc-pair-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:N,children:p("pair-paste-btn")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:()=>x(!0),children:p("scan-qr")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:c||I,title:c?p("settings-readonly"):"",onClick:A,children:p("test-and-connect")})]}),l.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[I&&l.jsx("div",{className:"nc-pair-progress",children:p("pair-progress")}),L==="ok"&&l.jsx("div",{className:"nc-set-test ok",children:p("node-connected")}),L==="ok"&&F&&l.jsx(qv,{line:F.line,note:F.note}),j&&l.jsx("div",{className:"nc-set-hint nc-pair-notice",children:j}),R&&l.jsxs("div",{className:"nc-err",role:"alert",children:[l.jsx("b",{children:P})," — ",R.message,R.hint&&l.jsx("div",{className:"nc-pair-hint",children:R.hint}),R.retryable&&l.jsx("div",{children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||I,onClick:A,children:p("pair-retry")})})]})]}),l.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:I,onClick:()=>_(H=>!H),children:[v?"▾":"▸"," ",p("pair-advanced")]}),v&&l.jsxs("div",{className:"nc-pair-advanced",children:[l.jsxs("label",{className:"nc-field",children:[p("node-display-label"),l.jsx("input",{placeholder:"Home Relay",value:f.label,disabled:c||I,onChange:H=>{D.current.add("label"),g(ie=>({...ie,label:H.target.value,name:G?ie.name:fo(H.target.value)}))}})]}),l.jsxs("label",{className:"nc-field",children:[p("node-name-label"),l.jsx("input",{placeholder:p("node-name-ph"),value:f.name,disabled:c||I,onChange:H=>{K(!0),D.current.add("name"),g(ie=>({...ie,name:H.target.value?fo(H.target.value):""}))}})]}),l.jsx("small",{className:"nc-set-hint",children:p("node-slug-hint").replace("{slug}",f.name||"home-relay")}),l.jsxs("label",{className:"nc-field",children:[p("pair-ssh-local-label"),l.jsx("input",{placeholder:"my-relay",value:f.ssh,disabled:c||I,onChange:H=>{D.current.add("ssh"),U("ssh",H.target.value)}}),l.jsx("small",{className:"nc-set-hint",children:p("node-ssh-local-help")})]}),l.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:p("node-ssh-port-help"),value:f.sshPort,disabled:c||I,onChange:H=>U("sshPort",H.target.value.replace(/[^0-9]/g,"").slice(0,5))})]}),l.jsxs("label",{className:"nc-field",children:[p("device-name-label"),l.jsx("input",{placeholder:s||"NexusCrew",value:f.localLabel,disabled:c||I,onChange:H=>U("localLabel",H.target.value)}),l.jsx("small",{className:"nc-set-hint",children:p("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[p("local-route-name-label"),l.jsx("input",{placeholder:O||"nexuscrew-5bd6",value:M,disabled:c||I,onChange:H=>{te(!0),D.current.add("localName"),g(ie=>({...ie,localName:H.target.value?fo(H.target.value):""}))}}),l.jsx("small",{className:"nc-set-hint",children:p("local-route-name-hint")})]})]}),b&&l.jsx(qD,{onResult:H=>{x(!1),T(H)},onClose:()=>x(!1)})]})}const Yi={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 Kv(t){if(!t||typeof t!="object")return{key:Yi.down,up:!1};if(t.kind==="vl")return t.online?{key:Yi.vlOnline,up:!0}:{key:Yi.vlOffline,up:!1};if(t.kind==="transitive"){const n=t.stale===!0;return{key:n?Yi.routedStale:Yi.routed,up:!n,routed:!0}}const e=t.tunnel&&t.tunnel.status;return e==="up"?{key:Yi.up,up:!0}:e==="passive"?{key:Yi.passive,up:!1,passive:!0}:{key:Yi.down,up:!1}}function OC(t){if(!t||typeof t!="object")return{key:"peer-private",shortKey:"row-private",shared:!1};if(t.kind==="vl")return{key:"peer-vl-federated",shortKey:"row-vl-federated",shared:!0};if(t.shared!==!0)return{key:"peer-private",shortKey:"row-private",shared:!1};const e=t.visibility||"network";if(e==="relay-only")return{key:"visibility-relay",shortKey:"visibility-relay",shared:!0,visibility:e};if(e==="selected"){const n=Array.isArray(t.selected)?t.selected.length:0;return{key:"visibility-selected",shortKey:"visibility-selected",shared:!0,visibility:e,count:n}}return{key:"visibility-network",shortKey:"visibility-network",shared:!0,visibility:e}}function KD(t){const n=t.health&&typeof t.health.detail=="string"&&t.health.detail.trim()||p(t.online?Yi.vlOnline:Yi.vlOffline);return t.ownerLabel?`${t.ownerLabel} · ${n}`:n}function VD(t){if(!t||typeof t!="object")return null;const e=typeof t.name=="string"?t.name:"";if(!e)return null;const n=t.kind==="transitive";return{name:e,title:typeof t.label=="string"&&t.label.trim()||e,subtitle:t.kind==="vl"?KD(t):e,reach:Kv(t),exposure:OC(t),routed:n,routeLabel:n&&Array.isArray(t.route)?t.route.join(" › "):null}}function YD(t){if(!t||typeof t!="object"||typeof t.name!="string"||!t.name)return null;const e=t.kind==="transitive";return{name:t.name,title:typeof t.label=="string"&&t.label.trim()||t.name,routed:e,route:e&&Array.isArray(t.route)?[...t.route]:null,ssh:!e&&t.direction==="outbound"&&t.ssh?String(t.ssh):null,inbound:!e&&t.direction==="inbound",transport:t.tunnel&&typeof t.tunnel.transport=="string"&&t.tunnel.transport||null}}function GD(t){return!t||typeof t!="object"?null:t.kind==="transitive"?{key:"authority-routed",ownerEquivalent:!1,grants:[],model:"none"}:{key:"authority-owner-equivalent",ownerEquivalent:!0,grants:[],model:"none"}}function XD(t,e){if(!t||t.visibility!=="selected")return[];const n=[...new Set(Array.isArray(t.selected)?t.selected:[])],s=new Map;for(const i of Array.isArray(e)?e:[])i&&i.nodeId&&!s.has(i.nodeId)&&s.set(i.nodeId,i);return n.map(i=>{const a=s.get(i);return{id:i,label:a?typeof a.label=="string"&&a.label.trim()||a.name:i,known:!!a}})}function JD(t,e,n=""){if(!t)return[];const s=new Set(Array.isArray(t.selected)?t.selected:[]),i=String(n||"").trim().toLowerCase(),a=new Set,c=[],u=h=>t.nodeId?h.nodeId===t.nodeId:h.name===t.name;for(const h of Array.isArray(e)?e:[]){if(!h||!h.nodeId||u(h)||s.has(h.nodeId)||a.has(h.nodeId))continue;const f=typeof h.label=="string"&&h.label.trim()||h.name;i&&!`${f} ${h.name}`.toLowerCase().includes(i)||(a.add(h.nodeId),c.push({id:h.nodeId,label:f,name:h.name}))}return c.sort((h,f)=>h.label.localeCompare(f.label))}function QD(t,{readonly:e=!1,busy:n=!1}={}){if(!t||typeof t!="object")return[];const s=t.actions&&typeof t.actions=="object"?t.actions:{},i=Kv(t).up,a=[],c=(u,h,{mutating:f=!0,danger:g=!1}={})=>{a.push({key:u,action:h,danger:g,disabled:n||f&&e})};return s.edit&&c("edit","edit"),s.test&&c("node-test","test",{mutating:!1}),s.disconnect&&i&&c("tunnel-stop","down"),s.connect&&!i&&c("tunnel-start","up"),s.restart&&c("tunnel-restart","restart"),s.remove&&c("delete","remove",{danger:!0}),a}function BC(t){const e=t&&typeof t.cellVisibility=="string"?t.cellVisibility:"all";return["all","none","selected"].includes(e)?e:"all"}function ZD(t,e){if(BC(t)!=="selected")return[];const n=[...new Set(Array.isArray(t.cells)?t.cells:[])];if(!Array.isArray(e))return n.map(i=>({id:i,label:i,known:!0}));const s=new Set(e.map(i=>typeof i=="string"?i:i&&(i.cell||i.id)).filter(Boolean));return n.map(i=>({id:i,label:i,known:s.has(i)}))}function e3(t,e,n=""){const s=new Set(Array.isArray(t&&t.cells)?t.cells:[]),i=String(n||"").trim().toLowerCase(),a=new Set,c=[];for(const u of Array.isArray(e)?e:[]){const h=typeof u=="string"?u:u&&(u.cell||u.id);!h||s.has(h)||a.has(h)||i&&!h.toLowerCase().includes(i)||(a.add(h),c.push({id:h,label:h}))}return c.sort((u,h)=>u.label.localeCompare(h.label))}function t3(t){if(!t||typeof t!="object"||t.kind!=="direct")return null;const e=t.access&&typeof t.access=="object"&&!Array.isArray(t.access)?t.access:null;return{label:typeof t.accessLabel=="string"?t.accessLabel:"unconfigured",configured:t.accessConfigured===!0,grants:e}}function n3(t,e,{readonly:n=!1,busy:s=!1}={}){const i=YD(t);return i?{identity:i,reach:Kv(t),authority:GD(t),exposure:OC(t),grants:XD(t,e),cellScope:BC(t),actions:QD(t,{readonly:n,busy:s}),canEditVisibility:!!(t.actions&&t.actions.visibility)&&t.shared===!0&&t.kind!=="transitive",canEditCellScope:!!(t.actions&&t.actions.edit)&&t.kind!=="transitive"}:null}const s3=Object.freeze(["cellVisibility","eventsAccess","nodeEventsAccess","askReplyAccess","filesReadAccess","liveHostAccess","panelAccess","peerOperatorAccess"]),i3=Object.freeze(["admin","user","nexushost"]),r3=Object.freeze({admin:Object.freeze({cellVisibility:"all",eventsAccess:!0,nodeEventsAccess:!0,askReplyAccess:!0,filesReadAccess:!0,liveHostAccess:!0,panelAccess:!0,peerOperatorAccess:!0}),user:Object.freeze({cellVisibility:"all",eventsAccess:!0,nodeEventsAccess:!0,askReplyAccess:!1,filesReadAccess:!0,liveHostAccess:!1,panelAccess:!1,peerOperatorAccess:!1}),nexushost:Object.freeze({cellVisibility:"none",eventsAccess:!1,nodeEventsAccess:!1,askReplyAccess:!1,filesReadAccess:!1,liveHostAccess:!1,panelAccess:!1,peerOperatorAccess:!1})});function o3(t,e,n=!1){const s=r3[e];if(!s)return[];const i=t&&typeof t=="object"?t:{},a=s3.map(c=>{const u=s[c],h=i[c];return{key:c,current:h,next:u,changed:h!==u}});return e==="admin"&&a.push({key:"eventsReceive",current:n===!0,next:!0,changed:n!==!0}),a}const $C="nc_push_local_v1",HS=Object.freeze({enabled:!0});function zC(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled!==!1}}function Vv(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function FC(t=Vv()){if(!t)return{...HS};try{return zC(JSON.parse(t.getItem($C)||"null"))}catch{return{...HS}}}function a3(t,e=Vv()){const n=zC(t);if(e)try{e.setItem($C,JSON.stringify(n))}catch{}return n}function l3(t=Vv()){return FC(t).enabled===!1}function Yv(){return typeof navigator<"u"&&"serviceWorker"in navigator&&typeof window<"u"&&"PushManager"in window&&typeof Notification<"u"}function c3(t){const e="=".repeat((4-t.length%4)%4),n=(t+e).replace(/-/g,"+").replace(/_/g,"/"),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}async function HC(){if(!Yv())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function UC(t){if(!Yv())throw new Error("push-unsupported");if(l3())throw new Error("push-disabled-local");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await qn("/api/push/vapid",t),{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:c3(s)}),c=await qn("/api/push/subscribe",t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({subscription:a.toJSON()})});if(!c.ok){try{await a.unsubscribe()}catch{}const u=await c.json().catch(()=>({}));throw new Error(u.error||`HTTP ${c.status}`)}return!0}async function US(t){if(!Yv())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 qn("/api/push/subscribe",t,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const u3=new Set(["update_candidate"]),WS=4096,d3=new Set(["prompt"]),qS={logs:{limit:50}};function h3(t){if(!t||t.kind!=="vl")return[];const e=Array.isArray(t.capabilities)?t.capabilities:[],n=new Set,s=[];for(const i of e)typeof i!="string"||!i||u3.has(i)||d3.has(i)||n.has(i)||(n.add(i),s.push(i));return s}function KS(t){return!!(t&&t.kind==="vl"&&Array.isArray(t.capabilities)&&t.capabilities.includes("prompt"))}function f3(t){return qS[t]?{...qS[t]}:{}}function p3(t,e){return t?t.inflight&&typeof t.inflight=="object"?{phase:"inflight",kind:t.inflight.kind}:e?t.lastAck&&t.lastAck.id===e.id?{phase:"done",kind:e.kind,status:t.lastAck.status,result:t.lastAck.result,at:t.lastAck.at}:{phase:"submitted",kind:e.kind}:t.lastAck&&typeof t.lastAck=="object"?{phase:"done",kind:null,status:t.lastAck.status,result:t.lastAck.result,at:t.lastAck.at}:null:null}function m3({title:t,subtitle:e,status:n,footer:s,onClose:i,plain:a=!1,children:c}){const u=w.useRef(null),h=w.useRef(null);return w.useEffect(()=>(h.current=document.activeElement,u.current&&u.current.focus(),()=>{const f=h.current;f&&typeof f.focus=="function"&&document.contains(f)&&f.focus()}),[]),w.useEffect(()=>{const f=g=>{g.key==="Escape"&&(g.stopPropagation(),i&&i())};return document.addEventListener("keydown",f,!0),()=>document.removeEventListener("keydown",f,!0)},[i]),l.jsx("div",{className:"nc-detail-overlay",onMouseDown:f=>{f.target===f.currentTarget&&i&&i()},children:l.jsxs("div",{className:"nc-detail-sheet",ref:u,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":typeof t=="string"?t:void 0,children:[l.jsxs("div",{className:"nc-detail-head",children:[l.jsxs("div",{className:"nc-detail-title",children:[l.jsx("b",{children:t}),e&&l.jsx("small",{children:e})]}),n,l.jsx("button",{type:"button",className:"nc-btn ghost nc-detail-close",onClick:i,"aria-label":p("close"),children:l.jsx(Tt,{name:"x",size:14})})]}),l.jsx("div",{className:`nc-detail-body${a?" plain":""}`,children:c}),s&&l.jsx("div",{className:"nc-detail-foot",children:s})]})})}function Do({title:t,hint:e,children:n}){return n==null||n===!1?null:l.jsxs("section",{className:"nc-detail-section",children:[t&&l.jsx("div",{className:"nc-sheet-label",children:t}),e&&l.jsx("small",{className:"nc-set-hint",children:e}),n]})}function g3({node:t,nodes:e,token:n,readonly:s,refresh:i,onClose:a,peerAccessRevision:c=null}){var fe,he;zn();const[u,h]=w.useState(null),[f,g]=w.useState(null),[v,_]=w.useState(null),[b,x]=w.useState(null),[L,k]=w.useState(!1),[R,S]=w.useState(""),[j,E]=w.useState(!1),[F,$]=w.useState(null),[G,K]=w.useState(!1),[Y,te]=w.useState(""),[q,D]=w.useState(!1),[I,O]=w.useState(null),[M,z]=w.useState(!1),[T,A]=w.useState(""),[N,U]=w.useState(null),P=w.useMemo(()=>n3(t,e,{readonly:s,busy:!!u}),[t,e,s,u]);if(!P)return null;const{identity:H,reach:ie,authority:J,exposure:Q,grants:ve,actions:de,canEditVisibility:ne,canEditCellScope:xe,cellScope:$e}=P,rt=t3(t),je=H.routed?{up:ie.up,since:null}:Eg(t.tunnel,Date.now()),Ie=async(Z,X)=>{g(null),h(Z);try{await X()}catch(ue){g(String(ue&&ue.message||ue))}h(null)},oe=Z=>{if(Z==="edit"){x({label:t.label||t.name,ssh:t.ssh||"",sshPort:t.sshPort?String(t.sshPort):"",autostart:t.autostart===!0,visibility:t.visibility||"network"});return}if(Z==="remove"){k(!0);return}Ie(`${t.name}:${Z}`,async()=>{const X=await Zg(n,t.name,Z);Z==="test"&&_(X),await i()})},Ne=(Z,X=f3(Z))=>Ie(`${t.nodeId}:${Z}`,async()=>{const ue=await Iw(n,t.nodeId,Z,X,t.route||[]);O({id:ue.id,kind:Z,submittedAt:Date.now()}),await i()}),me=()=>{const Z=T.trim().slice(0,WS);Z&&Ie(`${t.nodeId}:prompt`,async()=>{const X=await Iw(n,t.nodeId,"prompt",{text:Z},t.route||[]);O({id:X.id,kind:"prompt",submittedAt:Date.now()}),A(""),z(!1),await i()})},Ce=()=>{if(!Ga(b.label)){g(p("err-label"));return}const Z=H.inbound?{label:b.label,visibility:b.visibility,selected:b.visibility==="selected"?[...t.selected||[]]:[]}:{label:b.label,ssh:b.ssh,autostart:b.autostart,...b.sshPort?{sshPort:Number(b.sshPort)}:{}};return Ie(`${t.name}:edit`,async()=>{await Vf(n,t.name,Z),x(null),await i()})},V=(Z,X)=>Ie(`${t.name}:visibility`,async()=>{await YN(n,t.name,Z,X),await i()}),ge=ne&&t.visibility==="selected"?JD(t,e,R):[],Le=(Z,X)=>Ie(`${t.name}:cell-scope`,async()=>{await Vf(n,t.name,Z==="selected"?{cellVisibility:Z,cells:Array.isArray(X)?X:t.cells||[]}:{cellVisibility:Z}),await i()}),ke=Z=>Ie(`${t.name}:access`,async()=>{try{if(await Vf(n,t.name,{accessRole:Z,accessRevision:c}),Z==="admin"&&typeof Notification<"u"&&Notification.permission==="granted")try{await HC()==="idle"&&await UC(n)}catch{}U(null),await i()}catch(X){if(X&&X.status===409)g(p("peer-access-conflict")),await i();else throw X}}),We=async({retry:Z=!1}={})=>{if(Z&&G)K(!1);else if(F!==null||G)return;try{const X=await Gd(n);$(Array.isArray(X&&X.cells)?X.cells:[])}catch{K(!0)}};w.useEffect(()=>{xe&&$e==="selected"&&F===null&&We()},[xe,$e,F]);const Re=ZD(t,F),_e=$e==="selected"?e3(t,F,Y):[],st=l.jsxs("span",{className:`nc-set-tunnel${ie.up?" up":""}`,children:[p(ie.key),je.since?` · ${je.since}`:""]}),Xe=t.kind==="vl",De=Xe?h3(t):[],He=Xe?p3(t,I):null,Ke=Z=>{const X=`vl-cmd-${Z}`,ue=p(X);return ue===X?Z:ue},wt=Xe?[...De.map(Z=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u||s,title:s?p("settings-readonly"):void 0,onClick:()=>Ne(Z),children:Ke(Z)},Z)),...KS(t)?[l.jsx("button",{type:"button",className:`nc-btn ghost${M?" on":""}`,disabled:!!u||s,title:s?p("settings-readonly"):void 0,onClick:()=>z(Z=>!Z),children:Ke("prompt")},"prompt")]:[]]:de.map(Z=>l.jsx("button",{type:"button",className:`nc-btn ${Z.danger?"danger":"ghost"}`,disabled:Z.disabled,title:Z.disabled&&s?p("settings-readonly"):void 0,onClick:()=>oe(Z.action),children:Z.action==="remove"?l.jsxs(l.Fragment,{children:[l.jsx(Tt,{name:"trash",size:14})," ",p(Z.key)]}):p(Z.key)},Z.action));return l.jsxs(m3,{title:H.title,subtitle:H.name,status:st,footer:wt,onClose:a,children:[l.jsxs(Do,{title:p("node-detail-reach"),children:[l.jsxs("dl",{className:"nc-detail-facts",children:[H.route&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-route")}),l.jsx("dd",{children:H.route.join(" › ")})]}),H.ssh&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-ssh")}),l.jsxs("dd",{children:[H.ssh,t.sshPort?`:${t.sshPort}`:""]})]}),H.transport&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-transport")}),l.jsx("dd",{children:H.transport})]}),Xe&&t.ownerLabel&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-owner")}),l.jsx("dd",{children:t.ownerLabel})]})]}),((fe=t.health)==null?void 0:fe.detail)&&l.jsx("div",{className:`nc-set-test${Xe?t.health.state==="running"?" ok":t.health.state==="starting"?"":" ko":t.health.status==="healthy"?" ok":t.health.status==="passive"?"":" ko"}`,children:t.health.detail}),(()=>{const Z=yP(t.health);return Z?Z.line?l.jsx(qv,{line:Z.line,note:Z.note}):l.jsx("small",{className:"nc-set-hint",children:Z.note}):null})(),v&&l.jsxs("div",{className:`nc-set-test${v.ok?" ok":" ko"}`,children:[v.result,v.detail?` — ${v.detail}`:""]})]}),Xe&&l.jsxs(Do,{title:p("node-detail-command"),children:[De.length===0&&!KS(t)&&l.jsx("small",{className:"nc-set-hint",children:p("vl-no-commands")}),M&&l.jsxs("div",{className:"nc-vl-prompt",children:[l.jsx("textarea",{value:T,maxLength:WS,placeholder:p("vl-prompt-placeholder"),"aria-label":p("vl-prompt-placeholder"),disabled:!!u||s,onChange:Z=>A(Z.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u||s||!T.trim(),onClick:me,children:p("vl-prompt-send")})]}),He&&l.jsxs("div",{className:`nc-set-test${He.phase==="done"?He.status==="ok"?" ok":" ko":""}`,children:[He.kind&&`${Ke(He.kind)}: `,He.phase==="submitted"&&p("vl-cmd-phase-submitted"),He.phase==="inflight"&&p("vl-cmd-phase-inflight"),He.phase==="done"&&p(He.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),He.phase==="done"&&((he=He.result)!=null&&he.detail)?` — ${He.result.detail}`:""]})]}),l.jsxs(Do,{title:p("node-detail-authority"),children:[l.jsx("div",{className:"nc-set-info",children:p(J.key)}),J.grants.length===0&&l.jsx("small",{className:"nc-set-hint",children:p(xe?"authority-no-grants":"authority-no-grants-elsewhere")})]}),l.jsxs(Do,{title:p("node-detail-network-view"),children:[l.jsx("div",{className:"nc-set-info",children:p(Xe?Q.key:Q.shared?"peer-shared":"peer-private")}),ne&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),l.jsxs("select",{value:t.visibility||"network",disabled:s||!!u,onChange:Z=>V(Z.target.value),children:[l.jsx("option",{value:"network",children:p("visibility-network")}),l.jsx("option",{value:"relay-only",children:p("visibility-relay")}),l.jsx("option",{value:"selected",children:p("visibility-selected")})]})]}),t.visibility==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[ve.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("node-grant-none")}),ve.map(Z=>l.jsxs("div",{className:`nc-detail-grant${Z.known?"":" unknown"}`,children:[l.jsxs("span",{children:[Z.label,Z.known?"":` — ${p("node-grant-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>V("selected",(t.selected||[]).filter(X=>X!==Z.id)),children:p("node-grant-remove")})]},Z.id)),!j&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>{E(!0),S("")},children:p("node-grant-add")}),j&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:R,placeholder:p("node-grant-search"),disabled:s||!!u,onChange:Z=>S(Z.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[ge.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("node-grant-no-candidates")}),ge.map(Z=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await V("selected",[...t.selected||[],Z.id]),E(!1),S("")},children:Z.label},Z.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{E(!1),S("")},children:p("cancel")})]})]})]})]}),xe&&l.jsxs(Do,{title:p("cell-scope"),children:[l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-help")}),l.jsx("label",{className:"nc-field",children:l.jsxs("select",{value:$e,"aria-label":p("cell-scope"),disabled:s||!!u,onChange:Z=>{Z.target.value==="selected"&&We(),Le(Z.target.value)},children:[l.jsx("option",{value:"all",children:p("cell-scope-all")}),l.jsx("option",{value:"none",children:p("cell-scope-none")}),l.jsx("option",{value:"selected",children:p("cell-scope-selected")})]})}),$e==="selected"&&Re.length>0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-reset-warning")}),G&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-list-unavailable")}),$e==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[Re.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-none-granted")}),Re.map(Z=>l.jsxs("div",{className:`nc-detail-grant${Z.known?"":" unknown"}`,children:[l.jsxs("span",{children:[Z.label,Z.known?"":` — ${p("cell-scope-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>Le("selected",(t.cells||[]).filter(X=>X!==Z.id)),children:p("node-grant-remove")})]},Z.id)),!q&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await We({retry:!0}),D(!0),te("")},children:p("cell-scope-add")}),q&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:Y,placeholder:p("cell-scope-search"),disabled:s||!!u,onChange:Z=>te(Z.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[_e.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-no-candidates")}),_e.map(Z=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Le("selected",[...t.cells||[],Z.id]),D(!1),te("")},children:Z.label},Z.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{D(!1),te("")},children:p("cancel")})]})]})]}),rt&&c!=null&&!Xe&&l.jsxs(Do,{title:p("peer-access"),children:[l.jsx("small",{className:"nc-set-hint",children:p("peer-access-help")}),l.jsxs("div",{className:"nc-set-info",children:[p("peer-access-current"),": ",l.jsx("b",{children:p(`access-label-${rt.label}`)})]}),l.jsx("label",{className:"nc-field",children:l.jsxs("select",{value:N||"","aria-label":p("peer-access-preset"),disabled:s||!!u,title:s?p("settings-readonly"):void 0,onChange:Z=>U(Z.target.value||null),children:[l.jsx("option",{value:"",children:p("peer-access-preset-none")}),i3.map(Z=>l.jsx("option",{value:Z,children:p(`access-label-${Z}`)},Z))]})}),N&&(()=>{const Z=o3(rt.grants,N,t.eventsReceive),X=Z.filter(ue=>ue.changed).length;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-access-matrix",role:"table","aria-label":p("peer-access-matrix"),children:Z.map(ue=>l.jsxs("div",{role:"row",className:`nc-access-row${ue.changed?" changed":""}`,children:[l.jsx("span",{role:"rowheader",children:p(`access-grant-${ue.key}`)}),l.jsx("span",{children:p(`access-value-${ue.current===!0?"yes":ue.current===!1?"no":String(ue.current)}`)}),l.jsx("span",{"aria-hidden":"true",children:"→"}),l.jsx("span",{children:p(`access-value-${ue.next===!0?"yes":ue.next===!1?"no":String(ue.next)}`)})]},ue.key))}),l.jsx("small",{className:"nc-set-hint",children:p(X===0?"peer-access-unchanged":"peer-access-changed-hint")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!!u,title:s?p("settings-readonly"):void 0,onClick:()=>ke(N),children:p("peer-access-apply")})]})})()]}),b&&l.jsxs(Do,{title:p("edit"),children:[l.jsxs("label",{className:"nc-field",children:[p("node-display-label"),l.jsx("input",{value:b.label,disabled:!!u,onChange:Z=>x({...b,label:Z.target.value})})]}),H.inbound?l.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),l.jsxs("select",{value:b.visibility,disabled:!!u,onChange:Z=>x({...b,visibility:Z.target.value}),children:[l.jsx("option",{value:"network",children:p("visibility-network")}),l.jsx("option",{value:"relay-only",children:p("visibility-relay")}),l.jsx("option",{value:"selected",children:p("visibility-selected")})]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-field",children:[p("node-ssh-label"),l.jsx("input",{value:b.ssh,disabled:!!u,onChange:Z=>x({...b,ssh:Z.target.value})})]}),l.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",value:b.sshPort,disabled:!!u,onChange:Z=>x({...b,sshPort:Z.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:b.autostart,disabled:!!u,onChange:Z=>x({...b,autostart:Z.target.checked})})," ",p("boot-persist")]})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u,onClick:Ce,children:p("save")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>x(null),children:p("cancel")})]})]}),L&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("b",{children:p("node-remove-confirm").replace("{name}",H.title)}),l.jsx("small",{children:p("node-remove-warning")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn danger",disabled:!!u,onClick:()=>Ie(`${t.name}:remove`,async()=>{await KN(n,t.name),k(!1),await i(),a&&a()}),children:p("delete")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>k(!1),children:p("cancel")})]})]}),f&&l.jsx("div",{className:"nc-err",children:f})]})}function v3(t,e){w.useEffect(()=>{if(typeof document>"u"||!document.addEventListener){const u=setInterval(t,e);return()=>clearInterval(u)}let n=null;const s=()=>document.visibilityState!=="hidden",i=()=>{n!==null&&(clearInterval(n),n=null)},a=()=>{n===null&&s()&&(n=setInterval(t,e))},c=()=>{s()?(i(),t(),a()):i()};return a(),document.addEventListener("visibilitychange",c),()=>{i(),document.removeEventListener("visibilitychange",c)}},[t,e])}const Pg="nexuscrew.fleet",WC=3,_3="nexuscrew.cells",qC=/^[A-Za-z0-9._-]{1,32}$/,gh=/^[a-z0-9._-]{1,32}$/,KC=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,VC=new Set(["standard","unsafe"]),y3=4096,w3=4096,Fd=256,YC=8192,b3=4096,S3=32,x3=64,id=100,k3=128,C3=new Set(["format","version","exportedAt","cells","engines","models"]),E3=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label","mcp"]),N3=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function zo(t){if(typeof t!="string"||t.length>w3)return null;for(let n=0;n<t.length;n+=1){const s=t.charCodeAt(n);if(s<=31||s===127||s===92)return null}if(t==="")return"";if(t.charAt(0)==="/"||/^[A-Za-z]:/.test(t))return null;const e=[];for(const n of t.split("/"))if(!(n===""||n===".")){if(n==="..")return null;e.push(n)}return e.join("/")}const R3=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag","panelUrl"]),L3=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]),A3=new Set(["127.0.0.1","localhost","[::1]"]);function Gv(t){if(typeof t!="string"||!t||t.length>512||/[\x00-\x1f\x7f]|\s/.test(t))return!1;let e;try{e=new URL(t)}catch{return!1}return!(e.protocol!=="http:"&&e.protocol!=="https:"||!A3.has(e.hostname))}function br(t,e){return typeof t=="string"&&t.length<=e&&!/[\x00-\x1f\x7f]/.test(t)}function Xv(t){const e=String(t||"");return/(?:bearer\s+|authorization\s*[:=]|(?:api[_-]?key|secret|token)\s*[:=])/i.test(e)||/^-{1,2}(?:api[-_]?key|access[-_]?key|auth(?:orization)?[-_]?token|token|secret|password|credential)(?:$|=)/i.test(e)||/\b(?:sk|fw|fpk|hf|zai)[-_][A-Za-z0-9._-]{8,}\b/i.test(e)||/https?:\/\/[^\s/@:]+:[^\s/@]+@/i.test(e)}function vc(t,e){if(t===void 0)return{};if(!t||typeof t!="object"||Array.isArray(t))return null;const n=Object.entries(t);if(n.length>128)return null;const s={};for(const[i,a]of n){if(!gh.test(i)||!e(a))return null;s[i]=a}return s}function GC(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(u=>!E3.has(u))||!qC.test(String(t.id||""))||typeof t.cwdRel!="string")return null;const e=zo(t.cwdRel);if(e===null||!gh.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>Fd)||t.systemPrompt!==void 0&&t.prompt!==void 0&&t.systemPrompt!==t.prompt)return null;const n=t.systemPrompt===void 0?t.prompt===void 0?"":t.prompt:t.systemPrompt;if(typeof n!="string"||n.length>YC)return null;const s=vc(t.models,u=>typeof u=="string"&&!!u&&u.length<=Fd),i=vc(t.permissionPolicies,u=>VC.has(u)),a=vc(t.commands,u=>br(u,b3)&&!Xv(u));if(s===null||i===null||a===null)return null;const c={id:t.id,cwdRel:e,engine:t.engine,boot:t.boot===!0,systemPrompt:n};if(t.model&&(c.model=t.model),t.label!==void 0){if(!br(t.label,x3)||!String(t.label).trim())return null;c.label=String(t.label).trim()}return Object.keys(s).length&&(c.models=s),Object.keys(i).length&&(c.permissionPolicies=i),Object.keys(a).length&&(c.commands=a),c}function j3(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(a=>!N3.has(a))||!qC.test(String(t.id||""))||typeof t.cwd!="string"||!t.cwd||t.cwd.length>y3||!gh.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>Fd)||t.systemPrompt!==void 0&&t.prompt!==void 0&&t.systemPrompt!==t.prompt)return null;const e=t.systemPrompt===void 0?t.prompt===void 0?"":t.prompt:t.systemPrompt;if(typeof e!="string"||e.length>YC)return null;const n=vc(t.models,a=>typeof a=="string"&&!!a&&a.length<=Fd),s=vc(t.permissionPolicies,a=>VC.has(a));if(n===null||s===null)return null;const i={id:t.id,cwd:t.cwd,engine:t.engine,boot:t.boot===!0,systemPrompt:e};return t.model&&(i.model=t.model),Object.keys(n).length&&(i.models=n),Object.keys(s).length&&(i.permissionPolicies=s),i}function M3(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(n=>!L3.has(n)))return null;const e={};for(const[n,s]of Object.entries(t)){if(typeof s!="string"||!br(s,n==="baseUrl"?512:128)||Xv(s))return null;e[n]=s}return!e.client||!e.provider||e.envKey&&!KC.test(e.envKey)?null:e}function XC(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(s=>!R3.has(s))||!gh.test(String(t.id||""))||!br(t.label||t.id,64)||t.rc!==void 0&&typeof t.rc!="boolean"||t.panelUrl!==void 0&&!Gv(t.panelUrl))return null;const e={id:t.id,label:t.label||t.id,rc:t.rc===!0};if(t.panelUrl!==void 0&&(e.panelUrl=t.panelUrl),t.managed!==void 0){const s=M3(t.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(i=>t[i]!==void 0)?null:(e.managed=s,e)}if(!br(t.command,512)||!t.command.startsWith("/")||!Array.isArray(t.args)||t.args.length>32||t.args.some(s=>!br(s,1024)||Xv(s))||t.promptMode!=="flag"&&t.promptMode!=="send-keys"||t.promptMode==="flag"&&(!br(t.promptFlag,32)||/\s/.test(t.promptFlag)))return null;if(t.model!==void 0){if(!t.model||typeof t.model!="object"||Array.isArray(t.model)||Object.keys(t.model).some(s=>s!=="flag"&&s!=="value")||!br(t.model.flag,32)||/\s/.test(t.model.flag)||!br(t.model.value||"",128))return null;e.model={flag:t.model.flag,value:t.model.value||""}}const n=t.envKeys===void 0?[]:t.envKeys;return!Array.isArray(n)||n.length>32||n.some(s=>!KC.test(s))?null:(Object.assign(e,{command:t.command,args:[...t.args],envKeys:[...new Set(n)].sort(),promptMode:t.promptMode}),t.promptMode==="flag"&&(e.promptFlag=t.promptFlag),e)}function JC(t){if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t.managed?{id:t.id,label:t.label,rc:t.rc,managed:t.managed,...t.panelUrl!==void 0?{panelUrl:t.panelUrl}:{}}:{id:t.id,label:t.label,rc:t.rc,command:t.command,args:t.args,envKeys:t.envKeys,model:t.model,promptMode:t.promptMode,promptFlag:t.promptFlag,...t.panelUrl!==void 0?{panelUrl:t.panelUrl}:{}},n=XC(e);return n||null}function T3(t,e,n){const s=new Set;for(const i of Array.isArray(e)?e:[]){if(!n.has(i.id)||!i.managed)continue;const{client:a,provider:c,credentialProfile:u}=i.managed;s.add(u?`${a}.${c}-${u}`:`${a}.${c}`),s.add(`${a}.${c}`)}return(Array.isArray(t)?t:[]).filter(i=>i&&s.has(i.engine))}function P3(t,e,n=[],s=[],i=new Date,a=[]){n instanceof Date&&(i=n,n=[],s=[]);const c=e instanceof Set?e:new Set(e||[]),u=s instanceof Set?s:new Set(s||[]),h=[];for(const v of Array.isArray(t)?t:[]){if(!c.has(v.id))continue;const _=GC({id:v.id,cwdRel:v.cwdRel,engine:v.engine,boot:v.boot===!0,...v.label?{label:v.label}:{},...v.model?{model:v.model}:{},...v.models?{models:v.models}:{},...v.permissionPolicies?{permissionPolicies:v.permissionPolicies}:{},systemPrompt:v.prompt||"",...v.commands?{commands:v.commands}:{}});if(!_)return{ok:!1,error:"invalid-cell",invalidCellIds:[v.id]};h.push(_)}const f=[];for(const v of Array.isArray(n)?n:[]){if(!u.has(v.id))continue;const _=JC(v);_&&f.push(_)}const g=T3(a,n,u);return{format:Pg,version:WC,exportedAt:i.toISOString(),cells:h,engines:f,...g.length?{models:g}:{}}}function I3(t){let e;try{e=JSON.parse(String(t||""))}catch{return{ok:!1,error:"invalid-json",cells:[],engines:[]}}const n=(e==null?void 0:e.format)===_3&&(e==null?void 0:e.version)===1,s=(e==null?void 0:e.format)===Pg&&(e==null?void 0:e.version)===2,i=(e==null?void 0:e.format)===Pg&&(e==null?void 0:e.version)===WC,a=n||s,c=s||i;if(c&&Array.isArray(e.engines)&&e.engines.length>id)return{ok:!1,error:"invalid-format",detail:`${e.engines.length} engine dichiarati, cap ${id}; riduci gli engine a ${id} o meno`,cells:[],engines:[]};if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(_=>!C3.has(_))||!n&&!s&&!i||!Array.isArray(e.cells)||e.cells.length>S3||c&&(!Array.isArray(e.engines)||e.engines.length>id))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const u=[],h=new Set;for(const _ of e.cells){const b=a?j3(_):GC(_);if(!b)return{ok:!1,error:"invalid-cell",cells:[],engines:[]};if(h.has(b.id))return{ok:!1,error:"duplicate-cell",cells:[],engines:[]};h.add(b.id),u.push(b)}const f=[],g=new Set;for(const _ of c?e.engines:[]){const b=XC(_);if(!b)return{ok:!1,error:"invalid-engine",cells:[],engines:[]};if(g.has(b.id))return{ok:!1,error:"duplicate-engine",cells:[],engines:[]};g.add(b.id),f.push(b)}const v=[];if(e.models!==void 0){if(!Array.isArray(e.models)||e.models.length>k3)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const _=new Set;for(const b of e.models){if(!b||typeof b!="object"||Array.isArray(b))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const x=new Set(["id","engine","label","contextWindow","maxTokens","reasoning"]);if(Object.keys(b).some(S=>!x.has(S)))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const L=typeof b.id=="string"?b.id.trim():"",k=typeof b.engine=="string"?b.engine.trim():"";if(!L||!k)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const R=`${k}::${L}`;if(_.has(R))return{ok:!1,error:"duplicate-model",cells:[],engines:[]};_.add(R),v.push({...b,id:L,engine:k})}}return{ok:!0,cells:u,engines:f,models:v,legacy:a,exportedAt:typeof e.exportedAt=="string"?e.exportedAt:""}}function D3(t,e,n){const s=new Set(n||[]);if(!s.has(e))return null;const i=f=>Object.fromEntries(Object.entries(f||{}).filter(([g])=>s.has(g))),a={id:t.id,engine:e,boot:t.boot===!0,prompt:t.systemPrompt||""};typeof t.label=="string"&&t.label&&(a.label=t.label),typeof t.cwdRel=="string"?a.cwdRel=t.cwdRel:typeof t.cwd=="string"&&t.cwd&&(a.cwd=t.cwd),e===t.engine&&t.model?a.model=t.model:t.models&&t.models[e]&&(a.model=t.models[e]);const c=i(t.models),u=i(t.permissionPolicies),h=i(t.commands);return Object.keys(c).length&&(a.models=c),Object.keys(u).length&&(a.permissionPolicies=u),Object.keys(h).length&&(a.commands=h),a}const O3=()=>({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:""}),VS=(t="")=>({id:"",cwd:"",engine:t,boot:!1,label:"",model:"",prompt:"",commands:{},command:"",panelUrl:""}),QC=t=>t==="claude"?"unsafe":"standard",jc=(t,e)=>t.find(n=>n.client===e.client&&n.provider===e.provider&&(n.credentialProfile||"")===(e.credentialProfile||"")),B3=(t,e)=>{var n;return((n=jc(t,e))==null?void 0:n.label)||`${e.client} · ${e.provider}`};function $3(t){var e,n,s,i,a,c,u,h,f,g,v,_,b,x,L;return{kind:t.managed?"managed":"custom",id:t.id,label:t.label||"",command:t.command||"",argsText:(t.args||[]).join(`
|
|
165
|
-
`),rc:!!t.rc,client:((e=t.managed)==null?void 0:e.client)||"claude",provider:((n=t.managed)==null?void 0:n.provider)||"native",credentialProfile:((s=t.managed)==null?void 0:s.credentialProfile)||"",managedModel:((i=t.managed)==null?void 0:i.model)||"",permissionPolicy:((a=t.managed)==null?void 0:a.permissionPolicy)||QC((c=t.managed)==null?void 0:c.client),credentialSourcePolicy:((u=t.managed)==null?void 0:u.credentialSourcePolicy)||"auto",displayName:((h=t.managed)==null?void 0:h.displayName)||"",protocol:((f=t.managed)==null?void 0:f.protocol)||"",baseUrl:((g=t.managed)==null?void 0:g.baseUrl)||"",envKey:((v=t.managed)==null?void 0:v.envKey)||"",providerId:((_=t.managed)==null?void 0:_.providerId)||"nexuscrew-custom",modelOptions:t.availableModels||((b=t.managedInfo)==null?void 0:b.models)||[],promptMode:t.promptMode||"send-keys",promptFlag:t.promptFlag||"",modelFlag:((x=t.model)==null?void 0:x.flag)||"",modelValue:((L=t.model)==null?void 0:L.value)||"",envRows:(t.envKeys||[]).map(k=>({key:k,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,panelUrl:t.panelUrl||""}}function YS(t,e,n){const s=(e.panelUrl||"").trim();return n?s&&(t.panelUrl=s):t.panelUrl=s||null,t}function z3(t,e,n=[]){if(t.kind==="managed"){const i={client:t.client,provider:t.provider,model:t.client==="shell"?"":t.managedModel||"",permissionPolicy:t.client==="shell"?"standard":t.permissionPolicy||QC(t.client)};t.credentialProfile&&(i.credentialProfile=t.credentialProfile),t.credentialSourcePolicy&&t.credentialSourcePolicy!=="auto"&&(i.credentialSourcePolicy=t.credentialSourcePolicy);const a=jc(n,t);return(a==null?void 0:a.credentialEnv)===!0&&(i.envKey=t.envKey),t.provider==="custom"&&Object.assign(i,{displayName:t.displayName,protocol:t.protocol,baseUrl:t.baseUrl,envKey:t.envKey,providerId:t.providerId}),YS({...e?{id:t.id}:{},label:t.label||B3(n,t),rc:!!t.rc,managed:i},t,e)}const s={...e?{id:t.id}:{},label:t.label||t.id,rc:!!t.rc,command:t.command,args:t.argsText.split(`
|
|
166
|
-
`).filter(i=>i!==""),promptMode:t.promptMode};return t.modelFlag&&(s.model={flag:t.modelFlag,value:t.modelValue||""}),t.promptMode==="flag"&&(s.promptFlag=t.promptFlag),e&&(s.env=Object.fromEntries(t.envRows.filter(i=>!i.remove&&i.key).map(i=>[i.key,i.value]))),YS(s,t,e)}function Zr({children:t,onClose:e,label:n,error:s=""}){const i=w.useRef(null),a=w.useRef(null),c=w.useRef(e);return c.current=e,w.useEffect(()=>{const u=document.activeElement,h=i.current,f=()=>Array.from((h==null?void 0:h.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])'))||[]).filter(_=>_.offsetParent!==null),g=requestAnimationFrame(()=>{var _;return(_=f()[0]||h)==null?void 0:_.focus({preventScroll:!0})}),v=_=>{var k;if(_.key==="Escape"){_.preventDefault(),(k=c.current)==null||k.call(c);return}if(_.key!=="Tab")return;const b=f();if(!b.length){_.preventDefault(),h==null||h.focus();return}const x=b[0],L=b[b.length-1];_.shiftKey&&document.activeElement===x?(_.preventDefault(),L.focus()):!_.shiftKey&&document.activeElement===L&&(_.preventDefault(),x.focus())};return document.addEventListener("keydown",v),()=>{cancelAnimationFrame(g),document.removeEventListener("keydown",v),u&&u.isConnected&&typeof u.focus=="function"&&u.focus({preventScroll:!0})}},[]),w.useEffect(()=>{s&&requestAnimationFrame(()=>{var u;return(u=a.current)==null?void 0:u.scrollIntoView({block:"nearest"})})},[s]),l.jsx("div",{className:"nc-fleet-modal",role:"presentation",onMouseDown:u=>{u.target===u.currentTarget&&e()},children:l.jsxs("div",{ref:i,className:"nc-fleet-modal-dialog",role:"dialog","aria-modal":"true","aria-label":n||p("settings"),tabIndex:-1,children:[t,s&&l.jsx("div",{ref:a,className:"nc-err nc-fleet-modal-error",role:"alert","aria-live":"assertive",children:s})]})})}function im({token:t,targets:e=[],readonly:n=!1,onPower:s,onImport:i}){const[a,c]=w.useState([]),[u,h]=w.useState(0);w.useEffect(()=>{let k=!0;async function R(){const j=[{route:[],label:p("local")}].concat((e||[]).map(F=>({route:Array.isArray(F.route)?F.route:[],label:F.label||(F.route||[]).join(" › ")}))),E=await Promise.all(j.map(async F=>{const $={...F,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const G=await Qa(t,F.route);$.available=!!G.available,$.capabilities=G.capabilities||[],$.provider=G.provider||null,$.cells=(G.cells||[]).map(K=>({...K,route:F.route}));try{$.readonly=!!(await Ic(t,F.route)).readonlyDefault}catch{}try{const K=await Qg(t,F.route),Y=new Set($.cells.map(te=>te.tmuxSession).filter(Boolean));$.unmanaged=(K.sessions||[]).filter(te=>te&&!Y.has(te.name))}catch{}}catch(G){$.err=String(G&&G.message||G)}return $}));k&&c(E)}R();const S=setInterval(R,6e3);return()=>{k=!1,clearInterval(S)}},[t,e,u]);const f=(k,R)=>Array.isArray(k.capabilities)&&k.capabilities.includes(R)&&!n&&!k.readonly,g=()=>h(k=>k+1),v=(k,R)=>{s&&s({...k,route:R})},_=(k,R)=>{s&&s({...k,route:R})},b=async(k,R)=>{try{await tc(t,k.cell,R)}catch{}g()},x=async(k,R)=>{if(window.confirm(p("fleet-remove-cell").replace("{id}",k.cell))){try{await L1(t,k.cell,!0,R)}catch{}g()}},L=async(k,R)=>{if(window.confirm(p("terminate-confirm").replace("{name}",k.name))){try{await Xg(t,k.name,R)}catch{}g()}};return l.jsxs("div",{className:"nc-fleet-inventory",children:[l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:p("fleet-inventory")}),l.jsx("small",{children:p("fleet-inventory-help")})]}),a.map(k=>{const R=k.route.length?k.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 ${k.available?"on":"warn"}`}),l.jsx("b",{children:k.label}),l.jsx("small",{children:k.available?`${k.cells.length} ${p("fleet-cells")} · ${k.unmanaged.length} ${p("fleet-tmux")}`:k.err||p("fleet-not-available")})]}),k.cells.map(S=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-cell",children:[l.jsxs("span",{children:[l.jsx("b",{children:S.cell}),l.jsx("small",{children:`${S.engine||""}${S.key?`·${S.key}`:""}${S.active?"":` · ${p("cell-off")}`}`})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[S.active&&f(k,"down")&&l.jsx("button",{className:"nc-btn ghost",title:p("power-off"),onClick:()=>_(S,k.route),children:p("stop")}),!S.active&&f(k,"up")&&l.jsx("button",{className:"nc-btn ghost",title:p("power-on"),onClick:()=>v(S,k.route),children:p("start")}),f(k,"restart")&&S.active&&l.jsx("button",{className:"nc-btn ghost",title:p("restart"),onClick:()=>b(S,k.route),children:p("restart")}),f(k,"remove")&&l.jsx("button",{className:"nc-btn danger",title:p("delete"),onClick:()=>x(S,k.route),children:"×"})]})]},`${R}:${S.cell}`)),k.unmanaged.map(S=>l.jsxs("div",{className:"nc-fleet-item nc-fleet-unmanaged",children:[l.jsxs("span",{children:[l.jsx("b",{children:S.name}),l.jsx("small",{children:p("fleet-tmux")})]}),l.jsxs("span",{className:"nc-fleet-cell-actions",children:[f(k,"import")&&i&&l.jsx("button",{className:"nc-btn ghost",title:p("import-as-cell"),onClick:()=>i(S,k.route),children:p("import-as-cell")}),l.jsx("button",{className:"nc-btn danger",title:p("terminate"),onClick:()=>L(S,k.route),children:"×"})]})]},`${R}:u:${S.name}`)),k.available&&k.cells.length===0&&k.unmanaged.length===0&&l.jsx("div",{className:"nc-empty",children:p("fleet-inventory-empty")})]},R)})]})}function F3({cells:t=[],engines:e=[],models:n=[],busy:s,canRestore:i=!1,onRestore:a,onClose:c}){const[u,h]=w.useState("export"),[f,g]=w.useState([]),[v,_]=w.useState(()=>new Set(t.map(z=>z.id))),[b,x]=w.useState(()=>new Set(e.map(z=>z.id))),[L,k]=w.useState([]),[R,S]=w.useState([]),[j,E]=w.useState(""),F=new Set(e.map(z=>z.id)),$=new Set(t.map(z=>z.id)),G=(z,T)=>z(A=>{const N=new Set(A);return N.has(T)?N.delete(T):N.add(T),N}),K=()=>{const z=P3(t,v,e,b,new Date,n);if(z.ok===!1){E(p(`fleet-backup-${z.error}`));return}const T=t.filter(H=>v.has(H.id)).length,A=e.filter(H=>b.has(H.id)).length;if(z.cells.length!==T){E(p("fleet-backup-invalid-cell"));return}if(z.engines.length!==A){E(p("fleet-backup-invalid-engine"));return}if(!z.cells.length&&!z.engines.length){E(p("fleet-backup-select-one"));return}const N=new Blob([`${JSON.stringify(z,null,2)}
|
|
167
|
-
`],{type:"application/json"}),U=URL.createObjectURL(N),P=document.createElement("a");P.href=U,P.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(P),P.click(),P.remove(),setTimeout(()=>URL.revokeObjectURL(U),0),E("")},Y=async z=>{if(E(""),k([]),S([]),!!z){if(z.size>1024*1024){E(p("fleet-backup-too-large"));return}try{const T=I3(await z.text());if(!T.ok){E(p(`fleet-backup-${T.error}`));return}g(Array.isArray(T.models)?T.models:[]);const A=new Set(T.engines.map(N=>N.id));S(T.engines.map(N=>({engine:N,exists:F.has(N.id),selected:!F.has(N.id)}))),k(T.cells.map(N=>{const U=F.has(N.engine)||A.has(N.engine),P=$.has(N.id);return{cell:N,engine:U?N.engine:"",selected:U&&!P,exists:P}}))}catch(T){E(String(T.message||T))}}},te=(z,T)=>k(A=>A.map((N,U)=>U===z?{...N,...T}:N)),q=(z,T)=>S(A=>A.map((N,U)=>U===z?{...N,...T}:N)),D=new Set([...F,...R.filter(z=>z.selected).map(z=>z.engine.id)]),I=L.filter(z=>z.selected&&z.engine&&D.has(z.engine)),O=R.filter(z=>z.selected),M=[...new Map([...e.map(z=>[z.id,z.label||z.id]),...R.filter(z=>z.selected).map(z=>[z.engine.id,z.engine.label||z.engine.id])]).entries()];return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-backup-dialog",children:[l.jsx("b",{children:p("fleet-backup")}),l.jsx("small",{children:p("fleet-backup-help")}),l.jsxs("div",{className:"nc-set-tabs nc-backup-tabs",children:[l.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="export"?" on":""}`,onClick:()=>{h("export"),E("")},children:p("fleet-backup-export")}),l.jsx("button",{type:"button",className:`nc-set-tabbtn${u==="import"?" on":""}`,disabled:!i,title:i?"":p("fleet-backup-restore-unavailable"),onClick:()=>{h("import"),E("")},children:p("fleet-backup-import")})]}),u==="export"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{_(new Set(t.map(z=>z.id))),x(new Set(e.map(z=>z.id)))},children:p("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{_(new Set),x(new Set)},children:p("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[l.jsx("b",{children:p("fleet-engines")}),e.map(z=>{var T;return l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:b.has(z.id),onChange:()=>G(x,z.id)}),l.jsxs("span",{children:[l.jsx("b",{children:z.label||z.id}),l.jsxs("small",{children:[z.id,(T=z.envKeys)!=null&&T.length?` · ${z.envKeys.length} ${p("fleet-backup-env-names")}`:""]})]})]},z.id)}),l.jsx("b",{children:p("fleet-cells")}),t.map(z=>l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:v.has(z.id),onChange:()=>G(_,z.id)}),l.jsxs("span",{children:[l.jsx("b",{children:z.id}),l.jsxs("small",{children:[z.engine," · ",p("fleet-system-prompt")," ",(z.prompt||"").length," ",p("characters")]})]})]},z.id)),!t.length&&!e.length&&l.jsx("div",{className:"nc-empty",children:p("fleet-backup-empty")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!v.size&&!b.size,onClick:K,children:p("fleet-backup-download")})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",accept:"application/json,.json",disabled:s,onChange:z=>Y(z.target.files&&z.target.files[0])}),l.jsx("small",{children:p("fleet-backup-import-help")}),!!(L.length||R.length)&&l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{S(z=>z.map(T=>({...T,selected:!0}))),k(z=>z.map(T=>({...T,selected:!!T.engine})))},children:p("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{S(z=>z.map(T=>({...T,selected:!1}))),k(z=>z.map(T=>({...T,selected:!1})))},children:p("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[!!R.length&&l.jsx("b",{children:p("fleet-engines")}),R.map((z,T)=>{var A;return l.jsx("div",{className:"nc-backup-import-row",children:l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:z.selected,onChange:N=>q(T,{selected:N.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:z.engine.label||z.engine.id}),l.jsxs("small",{children:[z.engine.id," · ",z.exists?p("fleet-backup-overwrite"):p("fleet-backup-new"),(A=z.engine.envKeys)!=null&&A.length?` · ${p("fleet-backup-env-values-required")}`:""]})]})]})},z.engine.id)}),!!L.length&&l.jsx("b",{children:p("fleet-cells")}),L.map((z,T)=>l.jsxs("div",{className:"nc-backup-import-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:z.selected,disabled:!z.engine||!D.has(z.engine),onChange:A=>te(T,{selected:A.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:z.cell.id}),l.jsxs("small",{children:[z.exists?p("fleet-backup-overwrite"):p("fleet-backup-new")," · ",p("fleet-system-prompt")," ",z.cell.systemPrompt.length," ",p("characters")]})]})]}),l.jsxs("select",{value:z.engine,onChange:A=>te(T,{engine:A.target.value,selected:!!A.target.value}),children:[l.jsx("option",{value:"",children:p("fleet-backup-engine-missing")}),M.map(([A,N])=>l.jsx("option",{value:A,children:N},A))]})]},z.cell.id))]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:s||!I.length&&!O.length,onClick:()=>a({engineRows:R,cellRows:L,models:f}),children:p("fleet-backup-restore")})]})]}),j&&l.jsx("div",{className:"nc-err",children:j})]})}function H3({state:t,setState:e,busy:n,onSave:s,catalog:i}){var R;const a=t.form,c=S=>e({...t,form:{...a,...S}}),u=a.envRows||[],h=[...new Map(i.map(S=>[S.client,S.clientLabel||S.client])).entries()],f=i.filter(S=>S.client===a.client),g=jc(i,a),v=typeof(g==null?void 0:g.credentialEnv)=="string"?g.credentialEnv:"",_=Array.isArray(g==null?void 0:g.credentialUsedBy)?g.credentialUsedBy:[],b=(g==null?void 0:g.credentialSource)||"missing",x=!!(g!=null&&g.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",L=!!v&&t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,k=S=>{S&&c({client:S.client,provider:S.provider,credentialProfile:S.credentialProfile||"",managedModel:S.model||"",protocol:S.protocol||"",permissionPolicy:S.permissionPolicyDefault||"standard",credentialSourcePolicy:"auto",rc:!!S.rc,displayName:S.custom?p("fleet-custom-provider-default"):"",baseUrl:S.custom?"":S.endpoint||"",envKey:S.defaultEnvKey||"",providerId:"nexuscrew-custom",credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,...t.mode==="new"?{id:S.id,label:""}:{}})};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:t.mode==="new"?p("fleet-new-engine"):`${p("edit")} ${a.id}`}),l.jsx("input",{value:a.id,disabled:t.mode!=="new",placeholder:"id",onChange:S=>c({id:S.target.value})}),l.jsx("input",{value:a.label,placeholder:p("label"),onChange:S=>c({label:S.target.value})}),l.jsxs("select",{value:a.kind,disabled:t.mode!=="new",onChange:S=>c({kind:S.target.value}),children:[l.jsx("option",{value:"managed",children:p("fleet-managed")}),l.jsx("option",{value:"custom",children:p("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:t.mode!=="new",onChange:S=>k(i.find(j=>j.client===S.target.value&&j.default)||i.find(j=>j.client===S.target.value)),children:h.map(([S,j])=>l.jsx("option",{value:S,children:j},S))}),l.jsx("select",{value:((R=jc(i,a))==null?void 0:R.id)||"",disabled:t.mode!=="new",onChange:S=>k(i.find(j=>j.id===S.target.value)),children:f.map(S=>l.jsx("option",{value:S.id,children:S.label},S.id))})]}),a.client!=="shell"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.managedModel,list:"nc-managed-models",placeholder:p(g!=null&&g.requiresModel?"fleet-model-required":"fleet-model-default"),onChange:S=>c({managedModel:S.target.value})}),l.jsx("datalist",{id:"nc-managed-models",children:[...(g==null?void 0:g.models)||[],...a.modelOptions||[]].filter((S,j,E)=>S&&E.indexOf(S)===j).map(S=>l.jsx("option",{value:S},S))})]}),g!=null&&g.supportsUnsafe?l.jsxs("select",{value:a.permissionPolicy,onChange:S=>c({permissionPolicy:S.target.value}),children:[l.jsx("option",{value:"standard",children:p("fleet-standard-permissions")}),l.jsx("option",{value:"unsafe",children:p("fleet-unsafe-permissions")})]}):l.jsx("small",{children:p("fleet-standard-permissions")}),(g==null?void 0:g.supportsUnsafe)&&a.permissionPolicy==="unsafe"&&l.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),x&&l.jsxs("select",{"aria-label":p("fleet-credential-source-policy"),value:a.credentialSourcePolicy||"auto",onChange:S=>c({credentialSourcePolicy:S.target.value}),children:[l.jsx("option",{value:"auto",children:p("fleet-credential-source-policy-auto")}),l.jsx("option",{value:"nexuscrew-store",children:p("fleet-credential-source-policy-nexuscrew-store")}),l.jsx("option",{value:"environment",children:p("fleet-credential-source-policy-environment")})]}),(g==null?void 0:g.credentialEnv)===!0&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.envKey,placeholder:p("fleet-api-key-env"),onChange:S=>c({envKey:S.target.value})}),l.jsx("small",{children:p("fleet-custom-secret-help")})]}),v&&l.jsxs("section",{className:"nc-fleet-key","aria-label":p("fleet-key-section"),children:[l.jsxs("div",{className:"nc-fleet-key-head",children:[l.jsx("b",{children:p("fleet-key-section")}),l.jsx("span",{children:p(`fleet-credential-source-${b}`)})]}),l.jsxs("label",{className:"nc-field",children:[p("fleet-key-variable"),l.jsx("input",{value:v,readOnly:!0,"aria-label":p("fleet-key-variable")})]}),l.jsx("small",{children:_.length?p("fleet-key-used-by").replace("{engines}",_.join(", ")):p("fleet-key-used-by-none")}),_.length>0&&l.jsx("small",{children:p("fleet-key-shared-impact").replace("{key}",v).replace("{engines}",_.join(", "))}),l.jsxs("div",{className:"nc-fleet-key-input",children:[l.jsx("input",{type:a.credentialReveal?"text":"password",value:a.credentialValue||"","aria-label":p("fleet-key-value").replace("{key}",v),autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",placeholder:g!=null&&g.authConfigured||t.mode==="edit"?p("fleet-key-blank-keeps"):p("fleet-key-enter"),onChange:S=>c({credentialValue:S.target.value,allowMissingCredential:S.target.value?!1:a.allowMissingCredential})}),l.jsx("button",{type:"button",className:"nc-btn ghost","aria-label":p(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal"),onClick:()=>c({credentialReveal:!a.credentialReveal}),children:p(a.credentialReveal?"fleet-key-hide":"fleet-key-reveal")})]}),l.jsx("small",{children:p("fleet-key-local-help")}),t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!a.credentialValue&&l.jsxs("label",{className:"nc-check nc-fleet-key-missing",children:[l.jsx("input",{type:"checkbox",checked:!!a.allowMissingCredential,onChange:S=>c({allowMissingCredential:S.target.checked})}),p("fleet-key-create-missing")]}),(g==null?void 0:g.notice)&&l.jsx("small",{className:"nc-fleet-provider-notice",children:p(`fleet-provider-notice-${g.notice}`)})]}),(g==null?void 0:g.notice)&&!v&&l.jsx("small",{className:"nc-fleet-provider-notice",children:p(`fleet-provider-notice-${g.notice}`)}),a.provider==="custom"&&l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.displayName,placeholder:p("fleet-provider-display"),onChange:S=>c({displayName:S.target.value})}),l.jsx("input",{value:a.baseUrl,placeholder:"https://api.example.com/v1",onChange:S=>c({baseUrl:S.target.value})}),((g==null?void 0:g.protocols)||[]).length>1&&l.jsx("select",{value:a.protocol,onChange:S=>c({protocol:S.target.value}),children:g.protocols.map(S=>l.jsx("option",{value:S,children:S},S))}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.envKey,placeholder:p("fleet-api-key-env"),onChange:S=>c({envKey:S.target.value})}),l.jsx("input",{value:a.providerId,placeholder:p("fleet-provider-id"),onChange:S=>c({providerId:S.target.value})})]}),l.jsxs("small",{children:[a.protocol," · ",p("fleet-custom-secret-help")]})]}),l.jsx("small",{children:p(a.client==="shell"?"fleet-shell-engine-help":"fleet-managed-help")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:a.command,placeholder:p("command-path"),onChange:S=>c({command:S.target.value})}),l.jsx("textarea",{value:a.argsText,placeholder:p("args-lines"),onChange:S=>c({argsText:S.target.value})}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:a.rc,onChange:S=>c({rc:S.target.checked})})," ",p("fleet-remote-control")]}),l.jsxs("select",{value:a.promptMode,onChange:S=>c({promptMode:S.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:S=>c({promptFlag:S.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:a.modelFlag,placeholder:"model flag",onChange:S=>c({modelFlag:S.target.value})}),l.jsx("input",{value:a.modelValue,placeholder:"model default",onChange:S=>c({modelValue:S.target.value})})]}),l.jsx("small",{children:p("env-write-only")}),u.map((S,j)=>l.jsxs("div",{className:"nc-fleet-env",children:[l.jsx("input",{value:S.key,disabled:S.configured,placeholder:"ENV_KEY",onChange:E=>{const F=u.slice();F[j]={...S,key:E.target.value},c({envRows:F})}}),l.jsx("input",{type:"password",value:S.value,placeholder:S.configured?"•••••• (unchanged)":"value",onChange:E=>{const F=u.slice();F[j]={...S,value:E.target.value},c({envRows:F})}}),l.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:u.filter((E,F)=>F!==j)}),children:"×"})]},`${S.key}-${j}`)),l.jsx("button",{className:"nc-btn ghost",onClick:()=>c({envRows:[...u,{key:"",value:"",configured:!1}]}),children:"+ env"})]}),l.jsx("input",{value:a.panelUrl||"",maxLength:512,placeholder:p("fleet-panel-url"),onChange:S=>c({panelUrl:S.target.value})}),l.jsx("small",{children:p("fleet-panel-url-help")}),a.panelUrl&&!Gv(a.panelUrl)&&l.jsx("small",{className:"nc-err",children:p("fleet-panel-url-invalid")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>e(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:n||!a.id||L||a.kind==="custom"&&!a.command||a.kind==="managed"&&(g==null?void 0:g.requiresModel)&&!a.managedModel||a.kind==="managed"&&(g==null?void 0:g.credentialEnv)===!0&&!a.envKey||a.kind==="managed"&&a.provider==="custom"&&(!a.displayName||!a.baseUrl||!a.envKey||!a.providerId),onClick:s,children:p("save")})]})]})}function U3({state:t,setState:e,busy:n,onSave:s,onTest:i,profiles:a=[],canTest:c=!0}){const[u,h]=w.useState(null),[f,g]=w.useState(!1),v=t.form,_=k=>e({...t,form:{...v,...k}}),b=/^[^\x00-\x1f\x7f]{1,128}$/.test(v.id||""),x=!!(v.id||"").trim()&&!!(v.engine||"").trim()&&b,L=async()=>{h(null),g(!0);try{h(await i(v.engine,v.id))}catch(k){h({outcome:"unverified",detail:String(k&&k.message||k)})}g(!1)};return l.jsxs("div",{className:"nc-fleet-form",children:[l.jsxs("label",{className:"nc-field",children:[p("model-editor-engine"),l.jsxs("select",{value:v.engine||"",disabled:n||t.mode==="edit",onChange:k=>{h(null),_({engine:k.target.value})},children:[l.jsx("option",{value:"",children:"—"}),a.map(k=>l.jsx("option",{value:k.id,children:k.label?`${k.id} · ${k.label}`:k.id},k.id))]})]}),l.jsxs("label",{className:"nc-field",children:[p("model-editor-id"),l.jsx("input",{value:v.id||"",disabled:n||t.mode==="edit",placeholder:"qwen3.9-max",onChange:k=>{h(null),_({id:k.target.value})}})]}),l.jsx("small",{className:"nc-set-hint",children:p("model-editor-id-help")}),l.jsxs("label",{className:"nc-field",children:[p("model-editor-context"),l.jsx("input",{inputMode:"numeric",value:v.contextWindow||"",disabled:n,onChange:k=>_({contextWindow:k.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-field",children:[p("model-editor-max-tokens"),l.jsx("input",{inputMode:"numeric",value:v.maxTokens||"",disabled:n,onChange:k=>_({maxTokens:k.target.value.replace(/[^0-9]/g,"").slice(0,9)})})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:v.reasoning===!0,disabled:n,onChange:k=>_({reasoning:k.target.checked})})," ",p("model-editor-reasoning")]}),l.jsxs("div",{className:"nc-set-row",children:[c&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||f||!x,onClick:L,children:p(f?"model-test-running":"model-test")}),u&&l.jsxs("span",{className:`nc-model-test ${u.outcome}`,children:[p(`model-test-${u.outcome}`),u.outcome==="ok"&&Number.isInteger(u.latencyMs)?` · ${u.latencyMs}ms`:""]})]}),u&&u.detail&&l.jsx("small",{className:"nc-set-hint",children:u.detail}),u&&u.outcome==="unverified"&&l.jsx("small",{className:"nc-set-hint",children:p("model-test-unverified-help")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>e(null),children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||!x,onClick:()=>s(v),children:p("save")})]})]})}function W3({token:t,route:e,targets:n=[],location:s,setLocation:i,state:a,setState:c,engines:u,mcpServers:h=[],managedCatalog:f=[],busy:g,onSave:v}){var O,M,z;const[_,b]=w.useState(null),[x,L]=w.useState(""),k=a.form,R=T=>c({...a,form:{...k,...T}}),S=u.find(T=>T.id===k.engine),j=((O=S==null?void 0:S.managed)==null?void 0:O.client)==="shell",E=((M=S==null?void 0:S.managed)==null?void 0:M.client)||"",F=((z=f.find(T=>T.client===E))==null?void 0:z.mcpManaged)!==!1,$=T=>{var U,P,H,ie;const A=u.find(J=>J.id===T),N={...k.commands||{}};((U=S==null?void 0:S.managed)==null?void 0:U.client)==="shell"&&(k.command?N[k.engine]=k.command:delete N[k.engine]),R({engine:T,model:((P=k.models)==null?void 0:P[T])||((H=A==null?void 0:A.managed)==null?void 0:H.model)||((ie=A==null?void 0:A.model)==null?void 0:ie.value)||"",commands:N,command:N[T]||""})},G=T=>{const A={...k.commands||{}};T?A[k.engine]=T:delete A[k.engine],R({command:T,commands:A})},K=j&&/[|&;<>()`$*?{}\[\]~]/.test(k.command||""),Y=[...new Set([...h||[],...Array.isArray(k.mcp)?k.mcp:[]])].sort(),te=Array.isArray(k.mcp)?k.mcp.length?"some":"none":"all",q=T=>{var A;return R({mcp:T==="all"?void 0:T==="none"?[]:(A=k.mcp)!=null&&A.length?k.mcp:[...Y]})},D=T=>{const A=Array.isArray(k.mcp)?k.mcp:[];R({mcp:A.includes(T)?A.filter(N=>N!==T):[...A,T].sort()})},I=async T=>{try{const A=await Jg(t,T,e);b(A),R({cwd:A.path}),L("")}catch(A){L(String(A.message||A))}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsx("b",{children:a.mode==="new"?p("fleet-new-cell"):`${p("edit")} ${k.id}`}),a.mode==="new"&&l.jsxs("label",{className:"nc-field",children:[p("location"),l.jsx("span",{className:"nc-req",children:" *"}),l.jsxs("select",{value:s,onChange:T=>{i(T.target.value),R({engine:""})},children:[l.jsx("option",{value:"",children:p("local")}),n.map(T=>l.jsxs("option",{value:T.route.join("/"),disabled:T.status&&T.status!=="up",children:[T.label,T.status&&T.status!=="up"?` · ${p("node-offline")}`:""]},T.route.join("/")))]})]}),l.jsx("input",{value:k.id,disabled:a.mode!=="new",placeholder:"id",onChange:T=>R({id:T.target.value})}),l.jsx("input",{value:k.label||"",maxLength:64,placeholder:p("fleet-cell-label"),onChange:T=>R({label:T.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:k.cwd,placeholder:p("cwd"),onChange:T=>R({cwd:T.target.value})}),l.jsx("button",{className:"nc-btn ghost",onClick:()=>_?b(null):I(k.cwd),children:p("browse")})]}),_&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:_.path}),l.jsxs("div",{className:"nc-fs-list",children:[_.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>I(_.parent),children:["↑ ",p("fs-parent")]}),(_.dirs||[]).map(T=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>I(`${_.path.replace(/\/$/,"")}/${T}`),children:["📁 ",T]},T))]})]}),x&&l.jsx("div",{className:"nc-err",children:x}),l.jsx("select",{value:k.engine,onChange:T=>$(T.target.value),children:u.map(T=>l.jsx("option",{value:T.id,children:T.label},T.id))}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!k.boot,onChange:T=>R({boot:T.target.checked})})," ",p("fleet-boot")]}),l.jsx("input",{value:k.panelUrl||"",maxLength:512,placeholder:p("fleet-panel-url"),onChange:T=>R({panelUrl:T.target.value})}),l.jsx("small",{children:p("fleet-panel-url-help")}),k.panelUrl&&!Gv(k.panelUrl)&&l.jsx("small",{className:"nc-err",children:p("fleet-panel-url-invalid")}),j?l.jsxs(l.Fragment,{children:[l.jsx("input",{value:k.command||"",maxLength:4096,placeholder:p("fleet-shell-command-placeholder"),onChange:T=>G(T.target.value)}),l.jsx("small",{children:k.command?p("fleet-shell-command-help"):p("fleet-shell-interactive")}),K&&l.jsx("small",{className:"nc-note",children:p("fleet-shell-command-metachar")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:k.model||"",list:"nc-cell-models",placeholder:p("fleet-model-override"),onChange:T=>R({model:T.target.value})}),l.jsx("datalist",{id:"nc-cell-models",children:((S==null?void 0:S.availableModels)||[]).map(T=>l.jsx("option",{value:T},T))}),l.jsx("textarea",{value:k.prompt||"",placeholder:p("cell-prompt"),onChange:T=>R({prompt:T.target.value})}),l.jsx("small",{children:p("cell-prompt-help")}),l.jsxs("label",{className:"nc-field",children:[p("cell-mcp"),l.jsxs("select",{value:te,onChange:T=>q(T.target.value),children:[l.jsx("option",{value:"all",children:p("cell-mcp-all")}),l.jsx("option",{value:"none",children:p("cell-mcp-none")}),l.jsx("option",{value:"some",children:p("cell-mcp-some")})]})]}),!F&&l.jsx("small",{className:"nc-note",children:p("cell-mcp-inert")}),te==="some"&&l.jsx("div",{className:"nc-fleet-mcp-list",children:Y.map(T=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:(k.mcp||[]).includes(T),onChange:()=>D(T)})," ",T]},T))}),l.jsx("small",{children:p("cell-mcp-help")})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>c(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:g||!k.id||!k.cwd||!k.engine,onClick:v,children:p("save")})]})]})}function GS({token:t,route:e=[],state:n,setState:s,busy:i,onSave:a}){const[c,u]=w.useState(null),[h,f]=w.useState([]),[g,v]=w.useState(""),_=Array.isArray(e)?e.join("/"):"";w.useEffect(()=>{let R=!0;return Gd(t,_?_.split("/"):[]).then(S=>{R&&(f(S.engines||[]),v(""))}).catch(S=>{R&&(f([]),v(String(S.message||S)))}),()=>{R=!1}},[t,_]);const b=n.form,x=R=>s({...n,form:{...b,...R}}),L=async R=>{try{const S=await Jg(t,R,e);u(S),x({cwd:S.path})}catch{}},k=!b.id&&b.tmuxSession?b.tmuxSession.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32):b.id;return l.jsxs("div",{className:"nc-set-form nc-fleet-form",children:[l.jsxs("b",{children:[p("import-as-cell")," · ",b.tmuxSession]}),l.jsx("small",{children:p("import-help")}),l.jsx("input",{value:b.tmuxSession,disabled:!0,placeholder:"tmux session",readOnly:!0}),l.jsx("input",{value:b.id,placeholder:p("name"),onChange:R=>x({id:R.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:b.cwd,placeholder:p("cwd"),onChange:R=>x({cwd:R.target.value})}),l.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?u(null):L(b.cwd),children:p("browse")})]}),c&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:c.path}),l.jsxs("div",{className:"nc-fs-list",children:[c.parent&&l.jsxs("button",{className:"nc-fs-item nc-fs-nav",onClick:()=>L(c.parent),children:["↑ ",p("fs-parent")]}),(c.dirs||[]).map(R=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>L(`${c.path.replace(/\/$/,"")}/${R}`),children:["📁 ",R]},R))]})]}),l.jsxs("select",{value:b.engine,onChange:R=>x({engine:R.target.value}),children:[l.jsx("option",{value:"",children:p("import-engine-required")}),h.map(R=>l.jsx("option",{value:R.id,children:R.label},R.id))]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:R=>x({boot:R.target.checked})})," ",p("fleet-boot")]}),(n.err||g)&&l.jsx("div",{className:"nc-err",children:n.err||g}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>s(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:i||!b.tmuxSession||!b.engine||!h.length,onClick:a,children:p(k?"import-as-cell":"save")})]})]})}function rd(t){const e=zo(t);return e===null?`~/${t}`:e?`~/${e}`:"~"}function q3(t){if(!t||typeof t.path!="string"||typeof t.home!="string")return"";const{path:e,home:n}=t;return!n||e===n||!e.startsWith(n+"/")?"":e.slice(n.length+1).replace(/\/+$/,"")}function K3({token:t,route:e,cell:n,busy:s=!1,onSaved:i,onClose:a}){const[c,u]=w.useState(""),[h,f]=w.useState(null),[g,v]=w.useState(!1),[_,b]=w.useState(""),x=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&zo(n.cwdSuggestion)!==null?zo(n.cwdSuggestion):null,[L,k]=w.useState(x),R=n==null?void 0:n.id,S=s||g,j=async Y=>{const te=zo(Y);if(te===null){f({rel:"",dirs:[],loading:!1,err:p("fleet-cwd-repair-invalid")});return}f({rel:te,dirs:[],loading:!0,err:""});try{const q=await Jg(t,te,e),D=q3(q);f({rel:D,dirs:Array.isArray(q.dirs)?q.dirs:[],loading:!1,err:""})}catch(q){f({rel:te,dirs:[],loading:!1,err:String(q&&q.message||q)})}},E=Y=>{if(!h)return;const te=h.rel?`${h.rel}/${Y}`:Y;j(te)},F=()=>{h!=null&&h.rel&&j(h.rel.split("/").slice(0,-1).join("/"))},$=()=>{h&&(u(h.rel||""),f(null),b(""),k(null))},G=()=>{L!==null&&(u(L),k(null),b(""))},K=async()=>{if(S)return;const Y=zo(c);if(Y===null){b(p("fleet-cwd-repair-invalid"));return}const te=rd(Y);let q=!0;try{q=window.confirm(p("fleet-cwd-repair-confirm").replace("{id}",String(R||"")).replace("{path}",te))}catch{q=!1}if(q){v(!0),b(""),k(null);try{const D=await R1(t,R,{cwdRel:Y},e);i==null||i(D)}catch(D){const I=D&&D.data||{};if(I.code==="unportable-cwd"){b(p("fleet-cwd-repair-unportable"));const O=Array.isArray(I.cells)?I.cells.find(z=>z&&z.id===R):null,M=O&&typeof O.suggestion=="string"?O.suggestion:null;M!==null&&zo(M)!==null&&k(M)}else b(String(D&&D.message||D))}finally{v(!1)}}};return l.jsxs("div",{className:"nc-set-form nc-fleet-form nc-cwd-repair",children:[l.jsx("b",{children:p("fleet-cwd-repair-title").replace("{id}",String(R||""))}),l.jsx("small",{className:"nc-set-info",children:p("fleet-cwd-repair-help")}),l.jsx("small",{className:"nc-cwd-no-source",children:p("fleet-cwd-repair-no-source-path")}),l.jsxs("label",{className:"nc-field",children:[p("cwd"),l.jsxs("div",{className:"nc-cwd-rel-row",children:[l.jsx("span",{className:"nc-cwd-rel-prefix",children:"~/"}),l.jsx("input",{value:c,placeholder:p("fleet-cwd-repair-placeholder"),autoComplete:"off",spellCheck:"false",autoCapitalize:"none",onChange:Y=>u(Y.target.value)}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>h?f(null):j(""),children:p(h?"close":"fleet-cwd-repair-browse")})]})]}),l.jsx("div",{className:"nc-cwd-preview",children:p("fleet-cwd-repair-preview").replace("{path}",rd(c))}),h&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:rd(h.rel)}),l.jsxs("div",{className:"nc-fs-list",children:[h.rel&&l.jsxs("button",{type:"button",className:"nc-fs-item nc-fs-nav",onClick:F,children:["↑ ",p("fs-parent")]}),h.loading&&l.jsx("div",{className:"nc-fs-empty",children:"…"}),!h.loading&&h.dirs.length===0&&l.jsx("div",{className:"nc-fs-empty",children:p("fleet-cwd-repair-fs-empty")}),!h.loading&&h.dirs.map(Y=>l.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>E(Y),children:["📁 ",Y]},Y))]}),h.err&&l.jsx("div",{className:"nc-err",children:h.err}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{type:"button",className:"nc-btn primary",disabled:S||h.loading||!!h.err,onClick:$,children:p("fleet-cwd-repair-use-current")})})]}),_&&l.jsx("div",{className:"nc-err",role:"alert",children:_}),L!==null&&l.jsxs("div",{className:"nc-cwd-suggestion",role:"status",children:[l.jsx("span",{children:p("fleet-cwd-repair-suggestion")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:G,children:p("fleet-cwd-repair-use-suggestion").replace("{path}",rd(L))})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:g,onClick:a,children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:S,onClick:K,children:g?"…":p("save")})]})]})}function V3({token:t,readonly:e,targets:n=[],startNewCell:s=!1,initialLocation:i=""}){const[a,c]=w.useState({engines:[],cells:[],managedCatalog:[]}),[u,h]=w.useState({available:!1,capabilities:[]}),[f,g]=w.useState(!1),[v,_]=w.useState(null),[b,x]=w.useState(null),[L,k]=w.useState({}),[R,S]=w.useState(null),[j,E]=w.useState(!1),[F,$]=w.useState(""),[G,K]=w.useState(""),[Y,te]=w.useState(i),[q,D]=w.useState(!1),[I,O]=w.useState(null),[M,z]=w.useState(null),[T,A]=w.useState(null),[N,U]=w.useState(!1),[P,H]=w.useState([]),[ie,J]=w.useState(null),[Q,ve]=w.useState("manage"),de=w.useRef(!1),ne=Y?Y.split("/"):[],xe=w.useCallback(async()=>{try{const fe=await Qa(t,ne);h(fe);try{const he=await Ic(t,ne);D(!!he.readonlyDefault)}catch{D(!1)}if(fe.provider==="builtin"&&(fe.capabilities||[]).includes("definitions")){const he=await Gd(t,ne),Z=new Map((fe.engines||[]).map(X=>[X.id,X]));if(he.engines=(he.engines||[]).map(X=>{var ue;return{...X,availableModels:((ue=Z.get(X.id))==null?void 0:ue.models)||[]}}),c(he),(fe.capabilities||[]).includes("credentials"))try{H((await CN(t,ne)).credentials||[])}catch{H([])}else H([])}$("")}catch(fe){$(String(fe.message||fe))}finally{g(!0)}},[t,Y]);w.useEffect(()=>{document.visibilityState!=="hidden"&&xe()},[xe]),v3(xe,5e3);const $e=new Set((u.cells||[]).filter(fe=>fe.active).map(fe=>fe.cell)),rt=u.provider==="builtin"&&(u.capabilities||[]).includes("edit"),je=(u.capabilities||[]).includes("restore");w.useEffect(()=>{!s||de.current||!rt||!a.engines.length||(de.current=!0,S({mode:"new",form:VS(a.engines[0].id)}))},[s,rt,a.engines]);const Ie=async fe=>{E(!0),$(""),K("");try{await fe(),await xe()}catch(he){$(String(he.message||he))}E(!1)},oe=async(fe,he)=>{const Z=await MN(t,fe,he,ne);return k(X=>({...X,[`${fe}::${he}`]:Z})),Z},Ne=fe=>Ie(async()=>{const he={id:String(fe.id||"").trim(),engine:String(fe.engine||"").trim()};for(const Z of["contextWindow","maxTokens"]){const X=String(fe[Z]||"").trim();X&&(he[Z]=Number(X))}fe.reasoning===!0&&(he.reasoning=!0),await AN(t,he,ne),x(null),await xe()}),me=()=>Ie(async()=>{var Nt;const fe=v.mode==="new",he=v.form,Z=a.managedCatalog||[],X=he.kind==="managed"?jc(Z,he):null,ue=typeof(X==null?void 0:X.credentialEnv)=="string"?X.credentialEnv:"",Ze=ue&&he.credentialValue||"",se=z3(he,fe,Z);!fe&&v.form.kind==="custom"&&!v.form.modelFlag&&(se.model=null),!fe&&v.form.kind==="custom"&&v.form.promptMode!=="flag"&&(se.promptFlag=null);let Be;if(fe)Be=await NN(t,se,ne);else{const ut=v.original,zt=new Set(v.form.envRows.filter(dt=>!dt.remove).map(dt=>dt.key)),Yt=(ut.envKeys||[]).filter(dt=>!zt.has(dt)),Ut=Object.fromEntries(v.form.envRows.filter(dt=>!dt.remove&&dt.key&&(!dt.configured||dt.value!=="")).map(dt=>[dt.key,dt.value]));Be=await RN(t,ut.id,se,v.form.kind==="custom"?{set:Ut,remove:Yt}:void 0,ne)}let ht=null;if(ue&&Ze)try{ht=await Pw(t,ue,Ze,ne),H(ht.credentials||[])}catch{throw await xe(),fe&&_({mode:"edit",original:{...se,id:he.id},form:{...he,credentialReveal:!1}}),new Error(p(fe?"fleet-key-partial-create":"fleet-key-partial-edit"))}await xe(),_(null),K(p("fleet-saved"));const Pt=((Nt=((ht==null?void 0:ht.credentials)||[]).find(ut=>ut.envKey===ue))==null?void 0:Nt.activeCells)||[],St=[...new Set([...(Be==null?void 0:Be.activeCells)||[],...Pt])];if(St.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",St.join(", "))))for(const ut of St)await tc(t,ut,ne)}),Ce=()=>Ie(async()=>{var Pt,St,Nt,ut,zt,Yt;const fe=R.mode==="new",he=R.form,Z={...fe?{id:he.id}:{},cwd:he.cwd,engine:he.engine,boot:!!he.boot},X={...he.commands||{}},ue=a.engines.find(Ut=>Ut.id===he.engine);((Pt=ue==null?void 0:ue.managed)==null?void 0:Pt.client)==="shell"&&typeof he.command=="string"&&he.command.length?X[he.engine]=he.command:((St=ue==null?void 0:ue.managed)==null?void 0:St.client)==="shell"&&delete X[he.engine],(Object.keys(X).length||!fe)&&(Z.commands=X);const Ze=(he.label||"").trim();fe?Ze&&(Z.label=Ze):Z.label=Ze||null;const se=(he.panelUrl||"").trim();fe?se&&(Z.panelUrl=se):Z.panelUrl=se||null,fe?Array.isArray(he.mcp)&&(Z.mcp=he.mcp):Z.mcp=Array.isArray(he.mcp)?he.mcp:null,fe?(((Nt=ue==null?void 0:ue.managed)==null?void 0:Nt.client)!=="shell"&&he.model&&(Z.model=he.model),((ut=ue==null?void 0:ue.managed)==null?void 0:ut.client)!=="shell"&&he.prompt&&(Z.prompt=he.prompt)):(Z.model=((zt=ue==null?void 0:ue.managed)==null?void 0:zt.client)==="shell"?null:he.model||null,((Yt=ue==null?void 0:ue.managed)==null?void 0:Yt.client)!=="shell"&&(Z.prompt=he.prompt||null));const Be=fe?await TN(t,Z,ne):await R1(t,R.original.id,Z,ne),ht=fe?he.id:R.original.id;S(null),K(p("fleet-saved")),!fe&&(Be!=null&&Be.active)&&window.confirm(p("fleet-restart-confirm").replace("{cells}",ht))&&await tc(t,ht,ne)}),V=e||q,ge=u.capabilities||[],Le=ne.length>0&&V,ke=fe=>P.find(he=>{var Z;return(Z=he.engines)==null?void 0:Z.includes(fe.id)})||null,We=()=>Ie(async()=>{var Z;const fe=await Pw(t,ie.envKey,ie.value,ne);H(fe.credentials||[]),J(null),K(p("fleet-credential-saved"));const he=((Z=(fe.credentials||[]).find(X=>X.envKey===ie.envKey))==null?void 0:Z.activeCells)||[];if(he.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",he.join(", "))))for(const X of he)await tc(t,X,ne)}),Re=fe=>Ie(async()=>{if(!window.confirm(p("fleet-credential-remove-confirm").replace("{key}",fe.envKey)))return;const he=await EN(t,fe.envKey,ne);H(he.credentials||[]),K(p("fleet-credential-removed"))}),_e=fe=>O({...fe,route:Array.isArray(fe==null?void 0:fe.route)?fe.route:ne}),st=async fe=>{if(!I)return;const he={...I,cell:I.cell||I.id};try{await Mv({token:t,powerCell:he,payload:fe,onNotice:K})}catch(Z){throw $(String(Z&&Z.message||Z)),Z}},Xe=(fe,he)=>{$(""),z({mode:"new",route:Array.isArray(he)?he:ne,form:{tmuxSession:fe.name,id:"",engine:"",cwd:"",boot:!1},err:""})},De=()=>Ie(async()=>{const fe=M.form;if(!fe.engine){z({...M,err:p("import-engine-required")});return}await PN(t,{tmuxSession:fe.tmuxSession,id:fe.id||void 0,engine:fe.engine,cwd:fe.cwd||void 0,boot:!!fe.boot},fe.route||ne),z(null),K(p("fleet-saved"))}),He=({engineRows:fe=[],cellRows:he=[],models:Z=[]})=>Ie(async()=>{const X=fe.filter(ut=>ut.selected),ue=X.map(ut=>JC(ut.engine));if(ue.some(ut=>!ut))throw new Error(p("fleet-backup-invalid-engine"));const Ze=X.filter(ut=>ut.exists).map(ut=>ut.engine.id);if(Ze.length&&!window.confirm(p("fleet-backup-confirm-engine-overwrite").replace("{engines}",Ze.join(", "))))return;const se=[...new Set([...a.engines.map(ut=>ut.id),...ue.map(ut=>ut.id)])],Be=[];for(const ut of he.filter(zt=>zt.selected)){const zt=D3(ut.cell,ut.engine,se);if(!zt)throw new Error(`${ut.cell.id}: ${p("fleet-backup-engine-missing")}`);Be.push(zt)}const ht=he.filter(ut=>ut.selected&&ut.exists).map(ut=>ut.cell.id);if(ht.length&&!window.confirm(p("fleet-backup-confirm-overwrite").replace("{cells}",ht.join(", "))))return;const Pt=ue.length?await DN(t,ue,Ze.length>0,ne,Z):{needsRestart:[]},St=Be.length?await IN(t,Be,ne):{needsRestart:[]},Nt=[...new Set([...Pt.needsRestart||[],...St.needsRestart||[]])];U(!1),K(`${p("fleet-backup-restored").replace("{n}",String(Be.length))}${ue.length?` · ${ue.length} ${p("fleet-engines").toLowerCase()}`:""}${Nt.length?` · ${p("fleet-backup-needs-restart").replace("{cells}",Nt.join(", "))}`:""}`)}),Ke=l.jsxs("label",{className:"nc-field",children:[p("location"),l.jsxs("select",{value:Y,onChange:fe=>{te(fe.target.value),_(null),S(null),$(""),K(""),D(!1),g(!1),h({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),H([]),J(null)},children:[l.jsx("option",{value:"",children:p("local")}),n.map(fe=>l.jsxs("option",{value:fe.route.join("/"),disabled:fe.status&&fe.status!=="up",children:[fe.label,fe.status&&fe.status!=="up"?` · ${p("node-offline")}`:""]},fe.route.join("/")))]})]}),wt=l.jsxs("div",{className:"nc-fleet-view-tabs",role:"tablist","aria-label":p("tab-fleet"),children:[l.jsx("button",{type:"button",role:"tab","aria-selected":Q==="manage",className:`nc-set-tabbtn${Q==="manage"?" on":""}`,onClick:()=>ve("manage"),children:p("fleet-manage-location")}),l.jsx("button",{type:"button",role:"tab","aria-selected":Q==="overview",className:`nc-set-tabbtn${Q==="overview"?" on":""}`,onClick:()=>ve("overview"),children:p("fleet-network-overview")})]});return f?rt?l.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[wt,Q==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(im,{token:t,targets:n,readonly:e,onPower:_e,onImport:Xe})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-manage-help")}),Ke,l.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:V||j,onClick:()=>{$(""),U(!0)},children:p("fleet-backup")}),l.jsx("small",{children:p("fleet-backup-help")})]}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:p("fleet-cells")}),l.jsx("span",{className:"nc-fleet-head-actions",children:l.jsxs("button",{className:"nc-btn primary",disabled:V||j||!a.engines.length,onClick:()=>{var fe;$(""),S({mode:"new",form:VS((fe=a.engines[0])==null?void 0:fe.id)})},children:["+ ",p("add")]})})]}),a.cells.map(fe=>{const he=$e.has(fe.id),Z=fe.needsRepair===!0;return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:fe.id}),fe.label?l.jsxs("small",{className:"nc-fleet-label",children:[" ",fe.label]}):null,l.jsxs("small",{children:[fe.engine," · ",Z?l.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:p("fleet-cwd-needs-repair")}):fe.cwd,he?` · ${p("service-active")}`:` · ${p("cell-off")}`]})]}),l.jsxs("span",{children:[he&&ge.includes("down")&&l.jsx("button",{className:"nc-btn ghost",disabled:V||j,onClick:()=>Ie(()=>E1(t,{cell:fe.id},ne)),children:p("stop")}),!he&&ge.includes("up")&&l.jsx("button",{className:"nc-btn primary",disabled:V||j,onClick:()=>_e({cell:fe.id,id:fe.id,engine:fe.engine,model:fe.model,models:fe.models,permissionPolicies:fe.permissionPolicies,active:!1,boot:fe.boot}),children:p("start")}),he&&ge.includes("restart")&&l.jsx("button",{className:"nc-btn ghost",disabled:V||j,onClick:()=>Ie(()=>tc(t,fe.id,ne)),children:p("restart")}),Z?l.jsx("button",{className:"nc-btn ghost",disabled:V||j,onClick:()=>{$(""),A(fe)},children:p("fleet-cwd-repair")}):l.jsx("button",{className:"nc-btn ghost",disabled:V||j,onClick:()=>{var X;$(""),S({mode:"edit",original:fe,form:{...fe,commands:{...fe.commands||{}},command:((X=fe.commands)==null?void 0:X[fe.engine])||""}})},children:p("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:V||j,onClick:()=>Ie(async()=>{window.confirm(p("fleet-remove-cell").replace("{id}",fe.id))&&await L1(t,fe.id,!0,ne)}),children:"×"})]})]},fe.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:p("fleet-engines")}),l.jsxs("button",{className:"nc-btn primary",disabled:V||j,onClick:()=>{$(""),_({mode:"new",form:O3()})},children:["+ ",p("add")]})]}),a.engines.map(fe=>{var Z,X;const he=ke(fe);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:fe.label}),l.jsx("small",{children:fe.managed?`${fe.id} · ${fe.managed.client} / ${fe.managed.provider} · ${(Z=fe.managedInfo)!=null&&Z.configured?p("fleet-ready"):((X=fe.managedInfo)==null?void 0:X.reason)||p("fleet-not-ready")}`:`${fe.id} · ${fe.command}`}),he&&l.jsxs("small",{children:[he.envKey," · ",p(`fleet-credential-source-${he.source||"missing"}`)]})]}),l.jsxs("span",{children:[he&&l.jsx("button",{className:"nc-btn ghost",disabled:V||j,onClick:()=>{$(""),J({envKey:he.envKey,value:""})},children:he.configured?p("fleet-credential-change"):p("fleet-credential-set")}),(he==null?void 0:he.source)==="local"&&l.jsx("button",{className:"nc-btn danger",disabled:V||j,onClick:()=>Re(he),children:p("fleet-credential-forget")}),l.jsx("button",{className:"nc-btn ghost",disabled:V||j,onClick:()=>{$(""),_({mode:"edit",original:fe,form:$3(fe)})},children:p("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:V||j,onClick:()=>Ie(async()=>{window.confirm(p("fleet-remove-engine").replace("{id}",fe.id))&&await LN(t,fe.id,ne)}),children:"×"})]})]},fe.id)}),l.jsxs("div",{className:"nc-fleet-section-head",children:[l.jsx("b",{children:p("fleet-models")}),l.jsxs("button",{className:"nc-btn primary",disabled:V||j,onClick:()=>{$(""),x({mode:"new",form:{id:"",engine:""}})},children:["+ ",p("add")]})]}),!(a.models||[]).length&&l.jsx("small",{className:"nc-set-hint",children:p("fleet-no-models")}),(a.models||[]).map(fe=>{const he=`${fe.engine}::${fe.id}`,Z=L[he],X=(a.engines||[]).some(ue=>ue.managed&&ue.managed.model===fe.id);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:fe.id}),l.jsxs("small",{children:[fe.engine,fe.contextWindow?` · ${fe.contextWindow}`:"",X?` · ${p("model-in-use")}`:""]}),Z&&l.jsxs("small",{className:`nc-model-test ${Z.outcome}`,children:[p(`model-test-${Z.outcome}`),Z.outcome==="ok"&&Number.isInteger(Z.latencyMs)?` · ${Z.latencyMs}ms`:""]})]}),l.jsxs("span",{children:[ge.includes("model-test")&&l.jsx("button",{className:"nc-btn ghost",disabled:j||Le,onClick:()=>Ie(()=>oe(fe.engine,fe.id)),children:p("model-test")}),l.jsx("button",{className:"nc-btn danger",disabled:V||j,onClick:()=>Ie(()=>jN(t,fe.id,fe.engine,ne)),children:"×"})]})]},he)})]}),b&&l.jsx(Zr,{onClose:()=>x(null),label:p("fleet-models"),error:F,children:l.jsx(U3,{state:b,setState:x,busy:j,onSave:Ne,onTest:oe,profiles:a.managedCatalog||[],canTest:ge.includes("model-test")&&!Le})}),v&&l.jsx(Zr,{onClose:()=>_(null),label:p("fleet-new-engine"),error:F,children:l.jsx(H3,{state:v,setState:_,busy:j,onSave:me,catalog:a.managedCatalog||[]})}),R&&l.jsx(Zr,{onClose:()=>S(null),label:p("fleet-new-cell"),error:F,children:l.jsx(W3,{token:t,route:ne,targets:n,location:Y,setLocation:te,state:R,setState:S,engines:a.engines,mcpServers:a.mcpServers||[],managedCatalog:a.managedCatalog||[],busy:j,onSave:Ce})}),T&&l.jsx(Zr,{onClose:()=>A(null),label:p("fleet-cwd-repair-title").replace("{id}",T.id),error:"",children:l.jsx(K3,{token:t,route:ne,cell:T,busy:j,onSaved:async()=>{A(null),K(p("fleet-cwd-repaired")),await xe()},onClose:()=>A(null)})}),G&&l.jsx("div",{className:"nc-set-note",children:G}),F&&l.jsx("div",{className:"nc-err",children:F}),N&&l.jsx(Zr,{onClose:()=>U(!1),label:p("fleet-backup"),error:F,children:l.jsx(F3,{cells:a.cells,engines:a.engines,models:a.models||[],busy:j,canRestore:je,onRestore:He,onClose:()=>U(!1)})}),ie&&l.jsx(Zr,{onClose:()=>J(null),label:p("fleet-credential-title"),error:F,children:l.jsxs("div",{className:"nc-fleet-form nc-credential-form",children:[l.jsx("b",{children:p("fleet-credential-title")}),l.jsx("small",{children:p("fleet-credential-help")}),l.jsxs("label",{className:"nc-field",children:[ie.envKey,l.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:ie.value,onChange:fe=>J({...ie,value:fe.target.value})})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>J(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:j||!ie.value,onClick:We,children:p("save")})]})]})}),M&&l.jsx(Zr,{onClose:()=>z(null),label:p("import-as-cell"),error:F,children:l.jsx(GS,{token:t,route:M.route||ne,state:M,setState:z,busy:j,onSave:De})}),I&&l.jsx(Id,{cell:I,token:t,route:Array.isArray(I.route)?I.route:ne,onConfirm:async fe=>{try{await st(fe)}finally{xe()}},onClose:()=>O(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[wt,Q==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(im,{token:t,targets:n,readonly:e,onPower:_e,onImport:Xe})]}):l.jsxs(l.Fragment,{children:[Ke,l.jsxs("div",{className:"nc-set-info",children:[p(F?"fleet-editor-load-error":"fleet-editor-unavailable"),!F&&u.reason?` ${u.reason}`:""]})]}),F&&l.jsx("div",{className:"nc-err",children:F}),M&&l.jsx(Zr,{onClose:()=>z(null),label:p("import-as-cell"),error:F,children:l.jsx(GS,{token:t,route:M.route||ne,state:M,setState:z,busy:j,onSave:De})}),I&&l.jsx(Id,{cell:I,token:t,route:Array.isArray(I.route)?I.route:ne,onConfirm:async fe=>{try{await st(fe)}finally{xe()}},onClose:()=>O(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[wt,Q==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(im,{token:t,targets:n,readonly:e,onPower:_e,onImport:Xe})]}):l.jsxs(l.Fragment,{children:[Ke,l.jsx("div",{className:"nc-set-info",children:p("fleet-editor-loading")})]})]})}const ZC="nc_bar_files_button",eE="nc_bar_keyboard_button",tE="nc_bar_panel_button";function Jv(t,e){try{const n=localStorage.getItem(t);if(n==="on")return!0;if(n==="off")return!1}catch{}return e}function Qv(t,e){try{localStorage.setItem(t,e?"on":"off")}catch{}}function nE(){return Jv(ZC,!0)}function sE(t){Qv(ZC,t)}function iE(){return Jv(eE,!0)}function Y3(t){Qv(eE,t)}function rE(){return Jv(tE,!1)}function G3(t){Qv(tE,t)}const Zv="nc_notification_speech_v1",od="nc-notification-speech",Ig="nc-notification-speech-preview",X3=320,J3=2,Q3=3e4,Z3=1e4,e6=6e4,t6=64,XS=Object.freeze({enabled:!1}),n6=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),s6=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"])}),e_=new WeakSet;function t_(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled===!0}}function oE(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function JS(t=oE()){if(!t)return{...XS};try{return t_(JSON.parse(t.getItem(Zv)||"null"))}catch{return{...XS}}}function i6(t,e=oE()){const n=t_(t);if(e)try{e.setItem(Zv,JSON.stringify(n))}catch{}return n}function sl(){try{return typeof window<"u"?window:null}catch{return null}}function Mc(t=sl()){try{return!!(t&&t.speechSynthesis&&typeof t.speechSynthesis.speak=="function"&&typeof t.SpeechSynthesisUtterance=="function")}catch{return!1}}function aE(t=sl()){return!!(t&&(typeof t=="object"||typeof t=="function")&&e_.has(t))}function Dg(t=sl()){t&&(typeof t=="object"||typeof t=="function")&&e_.delete(t)}function Ua(t){const e=String(t||"").trim().toLowerCase().split("-")[0];return n6[e]||""}function vh(t){return String(t||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function r6(t){const e=vh(t).normalize("NFD").replace(new RegExp("\\p{M}+","gu"),"").toLowerCase(),n=new Set(e.match(new RegExp("\\p{L}+","gu"))||[]);if(n.size<4)return"";const s=Object.entries(s6).map(([i,a])=>({lang:i,score:[...n].reduce((c,u)=>c+(a.has(u)?1:0),0)})).sort((i,a)=>a.score-i.score);return s[0].score>=3&&s[0].score-s[1].score>=2?s[0].lang:""}function o6(t,e){const n=Ua(t&&t.lang);return n||Ua(r6(t&&t.body))||Ua(e)}function lE(t){try{const e=t&&t.speechSynthesis&&t.speechSynthesis.getVoices;return typeof e=="function"?Array.from(e.call(t.speechSynthesis)||[]).filter(Boolean):[]}catch{return[]}}function cE(t,e){const n=Ua(e);if(!n)return null;const s=Array.from(t||[]).filter(u=>u&&typeof u.lang=="string"&&u.lang.trim()),i=s.filter(u=>u.lang.trim().toLowerCase()===n.toLowerCase()),a=n.slice(0,2).toLowerCase(),c=s.filter(u=>u.lang.trim().toLowerCase().split("-")[0]===a);return i.find(u=>u.default===!0)||i[0]||c.find(u=>u.default===!0)||c[0]||null}function QS(t){return vh(t).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 a6(t,e=X3){const n=QS(t&&t.title),s=QS(t&&t.body),i=[n,s&&s!==n?s:""].filter(Boolean).join(". "),a=Array.from(i);return a.length<=e?i:`${a.slice(0,Math.max(0,e-1)).join("").trimEnd()}…`}function l6(t){try{return!!(t&&t.visibilityState==="visible"&&typeof t.hasFocus=="function"&&t.hasFocus())}catch{return!1}}function uE(t=sl()){if(!Mc(t))return!1;try{return t.speechSynthesis.cancel(),!0}catch{return!1}}function c6(t){try{t&&typeof t.dispatchEvent=="function"&&typeof t.Event=="function"&&t.dispatchEvent(new t.Event(Ig))}catch{}}function u6(t,e,n=sl(),s={}){var f;if(Dg(n),!Mc(n))return Promise.resolve(!1);const i=vh(t);if(!i||(f=s.signal)!=null&&f.aborted)return Promise.resolve(!1);const a=Number.isFinite(s.timeoutMs)&&s.timeoutMs>0?s.timeoutMs:Z3,c=s.setTimer||((g,v)=>setTimeout(g,v)),u=s.clearTimer||(g=>clearTimeout(g)),h=s.signal;return c6(n),new Promise(g=>{let v=!1,_=!1,b=null,x=null;const L=k=>{if(!v){if(v=!0,h&&x&&h.removeEventListener("abort",x),b!==null&&u(b),k!==!0)try{n.speechSynthesis.cancel()}catch{}else e_.add(n);g(k)}};x=()=>L("no-activation"),h&&h.addEventListener("abort",x,{once:!0});try{n.speechSynthesis.cancel();const k=new n.SpeechSynthesisUtterance(i);k.lang=Ua(e);const R=cE(lE(n),k.lang);R&&(k.voice=R),k.onstart=()=>{_=!0},k.onend=()=>L(_?!0:"no-activation"),k.onerror=()=>L("voice-error"),b=c(()=>L("timeout"),a),n.speechSynthesis.speak(k)}catch{L("no-activation")}})}function d6(t={}){const e=t.scope||sl(),n=t.document||e&&e.document,s=Number.isInteger(t.maxPending)&&t.maxPending>=0?t.maxPending:J3,i=Number.isFinite(t.watchdogMs)&&t.watchdogMs>0?t.watchdogMs:Q3,a=Number.isFinite(t.dedupWindowMs)&&t.dedupWindowMs>0?t.dedupWindowMs:e6,c=Number.isInteger(t.maxDedup)&&t.maxDedup>0?t.maxDedup:t6,u=t.now||Date.now,h=t.setTimer||((q,D)=>setTimeout(q,D)),f=t.clearTimer||(q=>clearTimeout(q)),g=t.isPrimed||(()=>aE(e)),v=e&&e.speechSynthesis;let _=null,b=null,x=[],L=[],k=()=>{};const R=new Map,S=()=>{L=lE(e)};if(S(),v&&typeof v.addEventListener=="function")v.addEventListener("voiceschanged",S),k=()=>v.removeEventListener("voiceschanged",S);else if(v&&"onvoiceschanged"in v){const q=v.onvoiceschanged,D=(...I)=>{S(),typeof q=="function"&&q.apply(v,I)};v.onvoiceschanged=D,k=()=>{v.onvoiceschanged===D&&(v.onvoiceschanged=q)}}const j=q=>{if(q&&typeof q.id=="string"&&q.id)return`id:${q.id}`;const D=Number(q&&q.ts),I=vh(q&&q.title);return Number.isFinite(D)&&I?`frame:${D}:${I}`:""},E=q=>{if(!q)return!0;const D=u();for(const[I,O]of R)D-O>=a&&R.delete(I);if(R.has(q))return!1;for(R.set(q,D);R.size>c;)R.delete(R.keys().next().value);return!0},F=()=>{b!==null&&f(b),b=null},$=()=>{F(),_&&(_.onend=null,_.onerror=null,_=null),uE(e)},G=q=>{if(!Mc(e))return x=[],"unsupported";let D;try{D=new e.SpeechSynthesisUtterance(q.text),D.lang=Ua(q.lang);const O=cE(L,D.lang);O&&(D.voice=O)}catch{return x=[],"error"}_=D;const I=()=>{if(_!==D)return;F(),_=null,D.onend=null,D.onerror=null;const O=x.shift();O&&G(O)};D.onend=I,D.onerror=I;try{return b=h(()=>{if(_!==D)return;_=null,D.onend=null,D.onerror=null;try{e.speechSynthesis.cancel()}catch{}F();const O=x.shift();O&&G(O)},i),e.speechSynthesis.speak(D),"speaking"}catch{return I(),"error"}},K=(q,D)=>{if(!Mc(e))return"unsupported";const I=a6(q);if(!I)return"empty";if(!E(j(q)))return"duplicate";if(!l6(n))return"inactive";if(!g())return"unprimed";const O={text:I,lang:D};return q&&q.urgency==="high"?(x=[],$(),G(O)):_?s===0?"dropped":(x.length>=s&&x.shift(),x.push(O),"queued"):G(O)},Y=()=>{x=[],$()};return{enqueue:K,stop:Y,dispose:()=>{Y(),k(),k=()=>{}}}}function dE(){const[t,e]=w.useState(JS);w.useEffect(()=>{const s=i=>{if((i==null?void 0:i.type)==="storage"&&i.key!==Zv&&i.key!==null)return;const a=(i==null?void 0:i.type)===od?t_(i.detail):JS();e(a)};return window.addEventListener(od,s),window.addEventListener("storage",s),()=>{window.removeEventListener(od,s),window.removeEventListener("storage",s)}},[]);const n=w.useCallback(s=>{const i=i6({enabled:s===!0});return e(i),window.dispatchEvent(new CustomEvent(od,{detail:i})),i.enabled},[]);return[t.enabled,n]}const n_="nc_storage_persist_v1",h6=1440*60*1e3;function Og(t=globalThis.localStorage){return Lr(n_,{storage:t,fallback:()=>null,parse:e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0})}async function f6({manager:t=(s=>(s=globalThis.navigator)==null?void 0:s.storage)(),ls:e=globalThis.localStorage,now:n=Date.now}={}){const i=Og(e),a=n();let c;try{if(!t||typeof t.persist!="function")c={at:a,status:"unsupported"};else if(typeof t.persisted=="function"&&await t.persisted())c={at:a,status:"persistent"};else{if(i&&i.status==="denied"&&a-i.at<h6)return i;c={at:a,status:await t.persist()?"persistent":"denied"}}}catch(u){c={at:a,status:"error",note:String((u==null?void 0:u.message)||u).slice(0,120)}}return(!i||i.status!==c.status)&&Ji({reason:"storage-persist",note:c.status}),yi(n_,c,{storage:e}),c}const p6=t=>{try{return new Date(t).toLocaleString()}catch{return String(t)}},rm=t=>Array.isArray(t)?t.join(", "):"";function m6(){zn();const[t,e]=w.useState(()=>fg()),[n,s]=w.useState(()=>Og()),[i,a]=w.useState(!1);w.useEffect(()=>{const f=()=>{e(fg()),s(Og())};return window.addEventListener("storage",f),window.addEventListener("nexuscrew-roster-preferences",f),()=>{window.removeEventListener("storage",f),window.removeEventListener("nexuscrew-roster-preferences",f)}},[]);const c=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),a(!0),setTimeout(()=>a(!1),1500)}catch{}},u=()=>{BT(),e([])},h=[...t].reverse();return l.jsxs("div",{className:"nc-set-form nc-prefs-journal",children:[l.jsx("div",{className:"nc-sheet-label",children:p("prefs-journal")}),l.jsxs("div",{"data-testid":"persist-status",className:"nc-set-hint","data-key":n_,children:[p("prefs-persist"),": ",n?n.status:p("prefs-persist-unknown")]}),!h.length&&l.jsx("div",{className:"nc-set-hint",children:p("prefs-journal-empty")}),l.jsx("div",{className:"nc-journal-list",style:{maxHeight:220,overflow:"auto"},children:h.map((f,g)=>l.jsxs("div",{"data-testid":"journal-row",className:"nc-set-hint",style:{overflowWrap:"anywhere"},children:[l.jsx("b",{children:f.reason})," · ",p6(f.t),f.position?` · ${f.position}`:"",f.key?` · ${f.key}`:"",f.note?` · ${f.note}`:"",f.before?l.jsxs("div",{children:[p("prefs-before"),": ",rm(f.before)]}):null,f.after?l.jsxs("div",{children:[p("prefs-after"),": ",rm(f.after)]}):null,f.visible?l.jsxs("div",{children:[p("prefs-visible"),": ",rm(f.visible)]}):null]},`${f.t}-${g}`))}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,disabled:!t.length,children:p(i?"copied":"prefs-journal-copy")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:u,disabled:!t.length,children:p("prefs-journal-clear")})]})]})}const s_="nc_device_id_v1",hE="nc_prefs_sync_v1",g6="nexuscrew-roster-preferences",i_=/^[a-f0-9]{32}$/,v6=192,_6=256,ZS=128,fE="nexuscrew-preferences",Uo=t=>t&&typeof t=="object"&&!Array.isArray(t),bd=(t,e)=>typeof t=="string"&&t.length>0&&t.length<=e&&!/[\u0000-\u001f\u007f]/.test(t),om=(t,e=_6)=>Array.isArray(t)&&t.length<=e&&t.every(n=>bd(n,v6));function il(t){if(!Uo(t)||Object.keys(t).some(n=>!["pins","orders","views","nodeOrder"].includes(n)))return null;const e={pins:[],orders:{},views:{},nodeOrder:[]};if(t.pins!==void 0){if(!om(t.pins))return null;e.pins=[...new Set(t.pins)]}if(t.nodeOrder!==void 0){if(!om(t.nodeOrder,128))return null;e.nodeOrder=[...new Set(t.nodeOrder)]}if(t.orders!==void 0){if(!Uo(t.orders)||Object.keys(t.orders).length>ZS)return null;for(const[n,s]of Object.entries(t.orders)){if(!bd(n,96)||!om(s))return null;e.orders[n]=[...new Set(s)]}}if(t.views!==void 0){if(!Uo(t.views)||Object.keys(t.views).length>ZS)return null;for(const[n,s]of Object.entries(t.views)){if(!bd(n,96)||!Uo(s))return null;const i={};if(s.open!==void 0){if(typeof s.open!="boolean")return null;i.open=s.open}if(s.filter!==void 0){if(!bd(s.filter,16))return null;i.filter=s.filter}e.views[n]=i}}return e}const Bg=t=>!t||!(t.pins||[]).length&&!(t.nodeOrder||[]).length&&!Object.keys(t.orders||{}).length&&!Object.keys(t.views||{}).length;function r_(t){const e={pins:no(),orders:dc(t),views:yd(t),nodeOrder:_g(t)};return il(e)||{pins:[],orders:{},views:{},nodeOrder:[]}}const $g=t=>Array.isArray(t)?`[${t.map($g).join(",")}]`:Uo(t)?`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${$g(t[e])}`).join(",")}}`:JSON.stringify(t),Sd=t=>{const e=$g(il(t)||{});let n=2166136261;for(let s=0;s<e.length;s+=1)n^=e.charCodeAt(s),n=Math.imul(n,16777619);return(n>>>0).toString(16)},am=["nc_pins",Qo,Jo,lh];function o_(t,{storage:e,note:n="restore"}={}){const s=il(t);if(!s)return new Error("preferenze non valide");let i=e;try{i=i||globalThis.localStorage}catch(u){return u}const a={};for(const u of am)try{a[u]=i.getItem(u)}catch{a[u]=null}const c={nc_pins:s.pins,[Qo]:s.orders,[Jo]:s.views,[lh]:s.nodeOrder};for(const u of am){const h=yi(u,c[u],{storage:e});if(h){for(const f of am)try{a[f]===null||a[f]===void 0?i.removeItem(f):i.setItem(f,a[f])}catch{}return Ji({reason:"prefs-restore-failed",key:u,note:String(h&&h.message||h).slice(0,120)}),h}}Ji({reason:"prefs-restore",note:n,after:s.pins});try{window.dispatchEvent(new Event(g6))}catch{}return null}const pE=t=>({status:"error",code:"storage-write-failed",note:String(t&&t.message||t).slice(0,120)}),a_=t=>{try{return t||globalThis.localStorage}catch{return null}},_h=t=>{var e;try{const n=(e=a_(t))==null?void 0:e.getItem(s_);return i_.test(n||"")?n:""}catch{return""}},mE=(t,e)=>{var n;try{(n=a_(e))==null||n.setItem(s_,t)}catch{}};function y6(t,e){i_.test(t||"")&&!_h(e)&&mE(t,e)}const w6=_h,b6=t=>Lr(hE,{storage:t,fallback:()=>null,parse:e=>Uo(e)?e:void 0}),Hd=(t,e,n)=>yi(hE,{revision:t,hash:Sd(e),at:Date.now()},{storage:n});function gE(t){return async(e,n,{headers:s={},body:i}={})=>qn(n,t,{method:e,headers:{...i?{"content-type":"application/json"}:{},...s},body:i,timeoutMs:8e3})}async function e1(t,e){let n=_h(e);if(!n){const s=await t("POST","/api/prefs/devices");if(s.status!==201)throw Object.assign(new Error(`device ${s.status}`),{status:s.status});if(n=(await s.json()).deviceId,!i_.test(n||""))throw new Error("device non valido");mE(n,e)}return n}async function zg(t,e,n,s,i){const a=await t("PUT","/api/prefs",{headers:{"x-nc-device":e,"if-match":`"${s}"`},body:JSON.stringify({data:n})});if(a.status===200){const u=await a.json();return Hd(u.revision,n,i),{status:"uploaded",revision:u.revision}}const c=await a.json().catch(()=>({}));return a.status===409&&c.current?{status:"conflict",revision:c.current.revision,conflict:{local:n,server:il(c.current.data)||null,revision:c.current.revision,deviceId:e}}:{status:"error",code:c.code||`http-${a.status}`}}async function S6({request:t,token:e,storage:n}={}){var i;const s=t||gE(e);try{let a=await e1(s,n),c=await s("GET","/api/prefs",{headers:{"x-nc-device":a}});if(c.status===404){try{(i=a_(n))==null||i.removeItem(s_)}catch{}a=await e1(s,n),c=await s("GET","/api/prefs",{headers:{"x-nc-device":a}})}if(c.status!==200)return{status:"error",code:`http-${c.status}`};const u=await c.json(),h=r_(n),f=il(u.data);if(!f)return Bg(h)?{status:"synced",revision:u.revision}:zg(s,a,h,u.revision,n);if(Bg(h)){const v=o_(f,{storage:n});return v?pE(v):(Hd(u.revision,f,n),{status:"restored",revision:u.revision})}if(Sd(h)===Sd(f))return Hd(u.revision,h,n),{status:"synced",revision:u.revision};const g=b6(n);return g&&g.revision===u.revision&&g.hash!==Sd(h)?zg(s,a,h,u.revision,n):{status:"conflict",revision:u.revision,conflict:{local:h,server:f,revision:u.revision,deviceId:a}}}catch(a){return{status:"offline",note:String((a==null?void 0:a.message)||a).slice(0,120)}}}async function x6(t,e,{request:n,token:s,storage:i}={}){if(!e)return{status:"error",code:"no-conflict"};const a=n||gE(s);try{if(t==="server"){if(!e.server)return{status:"error",code:"no-server-copy"};const c=o_(e.server,{storage:i,note:"restore-from-server"});return c?pE(c):(Hd(e.revision,e.server,i),{status:"restored",revision:e.revision})}return await zg(a,e.deviceId||_h(i),e.local,e.revision,i)}catch(c){return{status:"offline",note:String((c==null?void 0:c.message)||c).slice(0,120)}}}function k6(t){return JSON.stringify({kind:fE,version:1,exportedAt:new Date().toISOString(),data:r_(t)},null,2)}function C6(t,{storage:e}={}){let n;try{n=JSON.parse(t)}catch{return{ok:!1,reason:"not-json"}}if(!Uo(n)||n.kind!==fE||n.version!==1)return{ok:!1,reason:"wrong-kind"};const s=il(n.data);if(!s)return{ok:!1,reason:"bad-schema"};const i=o_(s,{storage:e,note:"import"});return i?{ok:!1,reason:"storage-write-failed",note:String(i&&i.message||i).slice(0,120)}:{ok:!0,data:s}}const Ud={status:"idle"};let Cr=Ud;const Fg=new Set,Wd=t=>{Cr=t,Fg.forEach(e=>e(t))};let Hg=null,Tc=0;const E6=t=>{const e=t||null;Hg!==e&&(Hg=e,Tc+=1,Cr!==Ud&&Wd(Ud))},vE=()=>{const[t,e]=w.useState(Cr);return w.useEffect(()=>(Fg.add(e),e(Cr),()=>{Fg.delete(e)}),[]),t};async function _E(t,e){var i;if(Cr.status!=="conflict")return;const n=Tc;if(Hg!==(t||null)||((i=Cr.conflict)==null?void 0:i.deviceId)!==w6()){Wd(Ud);try{window.dispatchEvent(new Event("nexuscrew-roster-preferences"))}catch{}return}const s=await x6(e,Cr.conflict,{token:t});n===Tc&&Wd({...s,at:Date.now()})}const N6=1500,R6=3e3,t1="nexuscrew-roster-preferences";function L6(t){w.useEffect(()=>{if(E6(t),!t)return;let n=null,s=!0;const i=async()=>{if(!s||Cr.status==="conflict")return;const u=Tc,h=await S6({token:t});s&&u===Tc&&Wd({...h,at:Date.now()})},a=u=>{clearTimeout(n),n=setTimeout(i,u)},c=()=>{Cr.status!=="conflict"&&a(R6)};return a(N6),window.addEventListener(t1,c),window.addEventListener("storage",c),()=>{s=!1,clearTimeout(n),window.removeEventListener(t1,c),window.removeEventListener("storage",c)}},[t]);const e=w.useCallback(n=>_E(t,n),[t]);return{state:vE(),resolve:e}}const A6=t=>typeof t.text=="function"?t.text():new Promise((e,n)=>{const s=new FileReader;s.onload=()=>e(String(s.result||"")),s.onerror=()=>n(s.error),s.readAsText(t)});function j6({token:t=""}){zn();const e=vE(),n=w.useRef(null),s=h=>_E(t,h),[i,a]=w.useState(null),c=()=>{try{const h=URL.createObjectURL(new Blob([k6()],{type:"application/json"})),f=document.createElement("a");f.href=h,f.download="nexuscrew-preferences.json",document.body.appendChild(f),f.click(),f.remove(),setTimeout(()=>URL.revokeObjectURL(h),1e3),a({ok:!0,text:p("prefs-export-done")})}catch(h){a({ok:!1,text:String((h==null?void 0:h.message)||h)})}},u=async h=>{const f=h.target.files&&h.target.files[0];if(h.target.value="",!f)return;let g="";try{g=await A6(f)}catch(_){a({ok:!1,text:String((_==null?void 0:_.message)||_)});return}if(!Bg(r_())&&!window.confirm(p("prefs-import-confirm")))return;const v=C6(g);a(v.ok?{ok:!0,text:p("prefs-import-done")}:{ok:!1,text:p(v.reason==="not-json"||v.reason==="wrong-kind"?"prefs-import-wrong":v.reason==="storage-write-failed"?"prefs-import-storage":"prefs-import-bad")})};return l.jsxs("div",{className:"nc-set-form nc-prefs-backup",children:[l.jsx("div",{className:"nc-sheet-label",children:p("prefs-backup")}),l.jsxs("div",{"data-testid":"sync-status",className:"nc-set-hint",children:[p("prefs-sync"),": ",e.status,e.revision!==void 0?` (r${e.revision})`:"",e.code?` · ${e.code}`:"",e.note?` · ${e.note}`:""]}),e.status==="conflict"&&l.jsxs("div",{className:"nc-set-confirm",role:"group","aria-label":p("prefs-conflict"),children:[l.jsx("div",{children:p("prefs-conflict")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>s("local"),children:p("prefs-keep-local")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>s("server"),children:p("prefs-use-server")})]})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:c,children:p("prefs-export")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>n.current&&n.current.click(),children:p("prefs-import")}),l.jsx("input",{ref:n,type:"file",accept:"application/json,.json","aria-label":p("prefs-import"),style:{display:"none"},onChange:u})]}),i&&l.jsx("div",{className:i.ok?"nc-set-note":"nc-err",role:i.ok?"status":"alert",children:i.text})]})}function M6({text:t}){const[e,n]=w.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return l.jsxs("div",{className:"nc-set-copyline",children:[l.jsx("code",{children:t}),l.jsxs("button",{type:"button",className:"nc-btn ghost",onClick:s,children:[l.jsx(Tt,{name:"copy",size:14})," ",p(e?"copied":"copy")]})]})}function T6({value:t}){const[e,n]=w.useState("");return w.useEffect(()=>{let s=!0;return ID.toDataURL(t,{margin:1,width:220}).then(i=>{s&&n(i)}).catch(()=>{}),()=>{s=!1}},[t]),e?l.jsx("img",{src:e,width:"220",height:"220",alt:"NexusCrew pairing QR"}):null}function P6({token:t,nodes:e,roster:n,settings:s,readonly:i,refresh:a,refreshAliases:c,vlUnavailable:u=[],accessRevision:h=null}){const[f,g]=w.useState(null),[v,_]=w.useState(null),[b,x]=w.useState(null),[L,k]=w.useState({ssh:"",sshPort:"",name:""}),[R,S]=w.useState(""),[j,E]=w.useState(""),[F,$]=w.useState(!1),[G,K]=w.useState(null),Y=Date.now(),te=s&&s.deviceName||"",q=(e||[]).filter(N=>N&&N.direction==="outbound"&&N.name&&N.ssh),D=q.find(N=>N.name===R)||q[0]||null,I=D?Eg(D.tunnel,Y):null,O=D!=null&&D.shared?I!=null&&I.up?"share-local-active":"share-local-pending":I!=null&&I.up?"share-local-private":"share-local-private-down",M=[{key:"peer-group-hubs",rows:(e||[]).filter(N=>N.kind!=="transitive"&&N.kind!=="vl"&&N.relation!=="client")},{key:"peer-group-clients",rows:(e||[]).filter(N=>N.kind!=="transitive"&&N.kind!=="vl"&&N.relation==="client")},{key:"peer-group-routed",rows:(e||[]).filter(N=>N.kind==="transitive")},{key:"peer-group-vl",rows:(e||[]).filter(N=>N.kind==="vl")}],z=G&&(e||[]).find(N=>`${N.kind||"direct"}:${N.nodeId||N.name}`===G)||null,T=async N=>{if(D){g(null),_(`${D.name}:share`);try{const U=await VN(t,D.name,N);await a(),U&&U.reversePoolPending===!0&&g(`${D.name}: ${p("share-reverse-pool-pending")}`)}catch(U){const P=U!=null&&U.data&&U.data.shared===!1?U.data:null;if(P)try{await a()}catch{}const H=U!=null&&U.data&&typeof U.data.hint=="string"?U.data.hint:"",ie=(P==null?void 0:P.revoked)===!0&&(P==null?void 0:P.localReconcilePending)===!0?p("share-off-local-reconcile-pending"):(P==null?void 0:P.revoked)===!1&&(P==null?void 0:P.reconcilePending)===!0?p("share-off-hub-reconcile-pending"):"",J=U!=null&&U.data&&U.data.reversePoolPending===!0?p("share-reverse-pool-pending"):"",Q=U!=null&&U.data&&typeof U.data.code=="string"?U.data.code:"",ve=U!=null&&U.data&&typeof U.data.detail=="string"?U.data.detail.trim():"",de=ve&&ve!==String(U.message||"")?ve:"";g(`${D.name}: ${String(U.message||U)}${Q?` [${Q}]`:""}${de?` — ${de}`:""}${H?` — ${H}`:""}${ie?` — ${ie}`:""}${J?` — ${J}`:""}`)}_(null)}},A=async()=>{g(null);const N=fo(L.name||j||te||"NexusCrew"),U=$P({name:N,ssh:L.ssh,sshPort:L.sshPort});if(!U.ok){g(p(U.error));return}_("invite");try{x(await UN(t,{...j||te?{label:j||te}:{},name:N,ssh:U.value.ssh,...U.value.sshPort?{sshPort:U.value.sshPort}:{}}))}catch(P){g(String(P.message||P))}_(null)};return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-sheet-label",children:p("peer-inventory-title")}),(e||[]).length===0&&l.jsx("div",{className:"nc-empty",children:p("no-nodes")}),M.map(N=>N.rows.length>0&&l.jsxs("div",{className:"nc-peer-group",children:[l.jsxs("div",{className:"nc-peer-group-title",children:[p(N.key)," ",l.jsx("span",{children:N.rows.length})]}),N.rows.map(U=>{const P=VD(U);if(!P)return null;const H=`${U.kind||"direct"}:${U.nodeId||U.name}`,ie=P.routed?{up:P.reach.up,since:null}:Eg(U.tunnel,Y);return l.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${P.routed?" routed":""}`,"aria-label":`${P.title} — ${p("node-detail-open")}`,onClick:()=>K(H),children:[l.jsx("span",{className:`nc-dot ${P.reach.up?"on":""}`}),l.jsxs("span",{className:"nc-node-row-text",children:[l.jsx("b",{children:P.title}),l.jsxs("small",{children:[P.routed?P.routeLabel:`${P.subtitle} · ${p(P.exposure.shortKey)}`,!P.routed&&P.exposure.shortKey==="visibility-selected"?` (${P.exposure.count})`:""]})]}),l.jsxs("span",{className:`nc-set-tunnel${P.reach.up?" up":""}`,children:[p(P.reach.key),ie.since?` · ${ie.since}`:""]}),l.jsx("span",{className:"nc-node-row-more",children:l.jsx(Tt,{name:"chevronDown",size:14})})]},H)})]},N.key)),u.length>0&&l.jsxs("div",{className:"nc-err",children:[p("vl-owners-unavailable"),": ",u.map(N=>N.label||N.route.join("/")).join(", ")]}),z&&l.jsx(g3,{node:z,nodes:e||[],token:t,readonly:i,refresh:a,onClose:()=>K(null),peerAccessRevision:h}),(n||[]).some(N=>!N.direct&&N.instanceId)&&l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("routed-node-aliases")}),l.jsx("small",{className:"nc-set-hint",children:p("routed-node-aliases-help")}),(n||[]).filter(N=>!N.direct&&N.instanceId).map(N=>l.jsxs("div",{className:"nc-set-node",children:[l.jsxs("div",{className:"nc-set-node-head",children:[l.jsx("span",{className:`nc-dot ${N.status==="up"?"on":""}`}),l.jsx("b",{children:N.label||N.name}),l.jsx("small",{children:(N.route||[]).join(" › ")})]}),l.jsxs("div",{className:"nc-set-node-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!v,onClick:async()=>{const U=window.prompt(p("node-local-alias"),N.alias||"");if(U!=null){if(U.trim()&&!Ga(U.normalize("NFC"))){g(p("err-label"));return}_(`${N.instanceId}:alias`),g(null);try{U.trim()?await qN(t,N.instanceId,U):await Ow(t,N.instanceId),c()}catch(P){g(String(P.message||P))}_(null)}},children:p("alias-on-device")}),N.alias&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!v,onClick:async()=>{_(`${N.instanceId}:alias-reset`),g(null);try{await Ow(t,N.instanceId),c()}catch(U){g(String(U.message||U))}_(null)},children:p("reset-alias")})]})]},N.instanceId))]}),D&&l.jsxs("div",{className:"nc-set-form nc-local-share",children:[l.jsx("div",{className:"nc-sheet-label",children:p("share-local-heading")}),q.length>1&&l.jsxs("label",{className:"nc-field",children:[p("share-local-hub"),l.jsx("select",{value:D.name,disabled:i||!!v,onChange:N=>S(N.target.value),children:q.map(N=>l.jsx("option",{value:N.name,children:N.label||N.name},N.name))})]}),l.jsxs("label",{className:"nc-check nc-node-share",children:[l.jsx("input",{type:"checkbox",checked:D.shared===!0,disabled:i||!!v,onChange:N=>T(N.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("share-local-through").replace("{device}",te||p("local")).replace("{hub}",D.label||D.name)}),l.jsx("small",{children:p(D.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),l.jsx("div",{className:`nc-set-test${D.shared&&(I!=null&&I.up)?" ok":I!=null&&I.up?"":" ko"}`,children:p(O)}),!(I!=null&&I.up)&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!v,onClick:()=>T(D.shared===!0),children:p("share-local-reconnect")})]}),l.jsx(DC,{token:t,deviceDefault:te,localNodeId:s&&s.nodeId||"",localNameDefault:s&&s.localName||"",readonly:i,onSuccess:a}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("invite-node")}),l.jsx("small",{className:"nc-set-hint",children:p("invite-v2-hint")}),l.jsxs("div",{className:"nc-set-info nc-invite-endpoint",children:[p("invite-target-local"),": ",l.jsx("b",{children:te||p("invite-target-this")})]}),l.jsxs("label",{className:"nc-field",children:[p("invite-endpoint-label"),l.jsx("input",{placeholder:"user@host",value:L.ssh,disabled:i,onChange:N=>k({...L,ssh:N.target.value})}),l.jsx("small",{className:"nc-set-hint",children:p("invite-endpoint-needed")})]}),q.length>0&&l.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:p("invite-hub-only")}),F&&l.jsxs("div",{className:"nc-invite-advanced",children:[l.jsxs("label",{className:"nc-field",children:[p("node-ssh-port-label"),l.jsx("input",{inputMode:"numeric",placeholder:"22",value:L.sshPort,disabled:i,onChange:N=>k({...L,sshPort:N.target.value.replace(/[^0-9]/g,"").slice(0,5)})})]}),l.jsxs("label",{className:"nc-field",children:[p("device-name-label"),l.jsx("input",{placeholder:te||"NexusCrew",value:j,disabled:i,onChange:N=>E(N.target.value)}),l.jsx("small",{className:"nc-set-hint",children:p("device-name-hint")})]}),l.jsxs("label",{className:"nc-field",children:[p("node-name-label"),l.jsx("input",{placeholder:fo(j||te||p("node-name-ph")),value:L.name,disabled:i,onChange:N=>k({...L,name:N.target.value?fo(N.target.value):""})})]})]}),l.jsxs("div",{className:"nc-set-row nc-invite-actions",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:i||!!v||!L.ssh.trim(),onClick:A,children:p("create-pairing-link")}),l.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!v,onClick:()=>$(N=>!N),children:[F?"▾":"▸"," ",p("pair-advanced")]})]}),b&&l.jsxs(l.Fragment,{children:[l.jsx(T6,{value:b.pairingUrl}),l.jsx(M6,{text:b.pairingUrl}),l.jsx("div",{className:"nc-set-info",children:p("invite-next-steps")})]})]}),f&&l.jsx("div",{className:"nc-err",children:f})]})}function I6({token:t,readonly:e}){const[n,s]=w.useState("idle"),[i,a]=w.useState(()=>FC()),[c,u]=w.useState(!1),[h,f]=w.useState(null);w.useEffect(()=>{let _=!1;return HC().then(b=>{_||s(b)}),()=>{_=!0}},[]);const g=async()=>{f(null),u(!0);try{n==="subscribed"?(await US(t),s("idle")):(await UC(t),s("subscribed"))}catch(_){const b=String(_.message||_);b==="push-denied"?(s("denied"),f(p("push-denied"))):b==="push-unsupported"?(s("unsupported"),f(p("push-unsupported"))):f(b==="push-disabled-local"?p("push-local-disabled"):b)}u(!1)},v=async()=>{const _=a3({enabled:i.enabled!==!1});if(a(_),f(null),_.enabled===!1&&n==="subscribed"){u(!0);try{await US(t),s("idle")}catch{}u(!1)}};return n==="unsupported"?l.jsx("div",{className:"nc-set-info",children:p("push-unsupported")}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:v,disabled:c,children:i.enabled===!1?p("push-local-on"):p("push-local-off")}),l.jsx("span",{className:"nc-set-info",children:i.enabled===!1?p("push-local-off-note"):p("push-local-help")})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||c||n==="denied",title:e?p("settings-readonly"):"",onClick:g,children:p(n==="subscribed"?"push-disable":"push-enable")}),l.jsx("span",{className:"nc-set-info",children:p(n==="subscribed"?"push-on":n==="denied"?"push-denied":"push-off")})]}),h&&l.jsx("div",{className:"nc-err",children:h})]})}function D6(){const[t,e]=dE(),[n,s]=w.useState(""),[i,a]=w.useState(""),[c,u]=w.useState(!1),[h,f]=w.useState(aE),g=w.useRef(0),v=w.useRef(!1),_=w.useRef(null),b=Mc();w.useEffect(()=>()=>{var k;g.current+=1,v.current&&((k=_.current)==null||k.abort(),_.current=null,v.current=!1,Dg())},[]);const x=async()=>{const k=g.current+=1,R=typeof AbortController=="function"?new AbortController:null;s(""),a(""),u(!0),f(!1),v.current=!0,_.current=R;const S=await u6(p("notification-speech-preview"),Ed(),void 0,R?{signal:R.signal}:{});return k!==g.current||(_.current=null,v.current=!1,u(!1),f(S===!0),S===!0?a(p("notification-speech-preview-ok")):s(p(S==="voice-error"?"notification-speech-preview-voice-error":S==="timeout"?"notification-speech-preview-timeout":"notification-speech-preview-failed"))),S},L=k=>{var R;if(e(k),s(""),a(""),k)x();else{g.current+=1;const S=v.current;(R=_.current)==null||R.abort(),_.current=null,v.current=!1,u(!1),f(!1),Dg(),S||uE()}};return l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":p("notification-speech-enable"),checked:t,disabled:!b,onChange:k=>L(k.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("notification-speech-enable")}),l.jsx("small",{children:p("notification-speech-help")})]})]}),b?l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!t||c,onClick:()=>{x()},children:p(c?"notification-speech-testing":"notification-speech-test")})}):l.jsx("div",{className:"nc-set-info",children:p("notification-speech-unsupported")}),t&&!h&&!c&&!n&&l.jsx("div",{className:"nc-set-info",children:p("notification-speech-needs-test")}),i&&l.jsx("div",{className:"nc-set-info",role:"status",children:i}),n&&l.jsx("div",{className:"nc-err",children:n})]})}function O6({token:t,readonly:e,nodes:n=[],settings:s=null}){const[i,a]=w.useState(null),[c,u]=w.useState([]),[h,f]=w.useState({name:"",mode:"primary-failover",targets:[]}),[g,v]=w.useState(null),[_,b]=w.useState(!1),[x,L]=w.useState(null),[k,R]=w.useState(""),S=w.useCallback(async()=>{try{const[T,A]=await Promise.all([GN(t),ZN(t)]);a(T),u(Array.isArray(A==null?void 0:A.groups)?A.groups:[]),R("")}catch(T){R(String(T.message||T))}},[t]);w.useEffect(()=>{S()},[S]);const j=async T=>{b(!0),L(null),R("");try{a(await XN(t,T))}catch(A){R(String(A.message||A))}b(!1)},E=async()=>{b(!0),L(null),R("");try{L({kind:"test",...await JN(t)})}catch(T){R(String(T.message||T))}b(!1)},F=async()=>{b(!0),L(null),R("");try{L({kind:"stop",...await QN(t)})}catch(T){R(String(T.message||T))}b(!1)},$=[],G=new Set,K=(T,A)=>{const N=typeof T=="string"?T.toLowerCase():"";!/^[a-f0-9]{32}$/.test(N)||G.has(N)||(G.add(N),$.push({id:N,label:A||N}))};K(s==null?void 0:s.nodeId,p("audio-group-local"));for(const T of n||[])K((T==null?void 0:T.nodeId)||(T==null?void 0:T.instanceId),(T==null?void 0:T.label)||(T==null?void 0:T.name)||(T==null?void 0:T.nodeId));for(const T of h.targets)K(T,`${T} (${p("audio-group-unavailable-target")})`);const Y=(T=null)=>{R(""),T?(v(T.name),f({name:T.name,mode:T.mode,targets:[...T.targets||[]]})):(v(null),f({name:"",mode:"primary-failover",targets:[]}))},te=(T,A)=>f(N=>({...N,targets:A?[...new Set([...N.targets,T])]:N.targets.filter(U=>U!==T)})),q=async()=>{const T=h.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(T)||h.targets.length<1){R(p("audio-group-invalid"));return}b(!0),R("");try{const A=await e5(t,T,{targets:h.targets,mode:h.mode}),N=A==null?void 0:A.group;if(!N||!N.name)throw new Error(p("audio-group-save-failed"));u(U=>[...U.filter(P=>P.name!==N.name),N].sort((P,H)=>P.name.localeCompare(H.name))),Y(null)}catch(A){R(String(A.message||A))}b(!1)},D=async T=>{b(!0),R("");try{await t5(t,T),u(A=>A.filter(N=>N.name!==T)),g===T&&Y(null)}catch(A){R(String(A.message||A))}b(!1)},I=(i==null?void 0:i.installed)===!0,O=(i==null?void 0:i.liveness)==="ready",M=(i==null?void 0:i.consent)===!0&&I&&O,z=x?x.kind==="stop"?p(x.stopped?"audio-stop-stopped":"audio-stop-idle"):x.status==="accepted"||x.status==="spoken"?p("audio-test-accepted"):x.status==="unknown"?p("audio-test-unknown"):`${p("audio-test-refused")}${x.reason?` (${x.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:p("audio-title")}),l.jsx("br",{}),p("audio-help")]}),i?l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":p("audio-consent"),checked:i.consent===!0,disabled:e||_,onChange:T=>{j(T.target.checked)}}),l.jsxs("span",{children:[l.jsx("b",{children:p("audio-consent")}),l.jsx("small",{children:p("audio-consent-help")})]})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("audio-capability")}),l.jsxs("div",{className:"nc-set-info",children:[p("audio-adapter"),": ",i.adapter||p("audio-adapter-none"),l.jsx("br",{}),p("audio-installed"),": ",p(I?"audio-installed-yes":"audio-installed-no"),l.jsx("br",{}),p("audio-liveness"),": ",p(O?"audio-liveness-ready":"audio-liveness-unavailable"),Array.isArray(i.languages)&&i.languages.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),p("audio-languages"),": ",i.languages.join(", ")]})]}),i.limits&&l.jsxs("small",{className:"nc-set-hint",children:[p("audio-limits"),": ",i.limits]})]}),!i.consent&&l.jsx("div",{className:"nc-set-info",children:p("audio-test-needs-consent")}),!I&&l.jsx("div",{className:"nc-set-info",children:p("audio-unavailable")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||_||!M,title:e?p("settings-readonly"):"",onClick:()=>{E()},children:p(_?"audio-testing":"audio-test")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>{F()},children:p(_?"audio-stopping":"audio-stop")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>{S()},children:p("refresh")})]}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("audio-groups-title")}),l.jsx("small",{className:"nc-set-hint",children:p("audio-groups-help")}),c.length===0&&l.jsx("div",{className:"nc-set-info",children:p("audio-groups-empty")}),c.map(T=>{var A;return l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("span",{children:[l.jsx("b",{children:T.name})," ",l.jsxs("small",{children:["· ",T.mode==="fanout"?p("audio-group-fanout"):p("audio-group-primary")," · ",((A=T.targets)==null?void 0:A.length)||0]})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>Y(T),children:p("audio-group-edit")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>{D(T.name)},children:p("audio-group-delete")})]},T.name)}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>Y(null),children:p("audio-group-new")})}),l.jsxs("label",{className:"nc-field",children:[p("audio-group-name"),l.jsx("input",{"aria-label":p("audio-group-name"),value:h.name,maxLength:"32",disabled:e||_,onChange:T=>f(A=>({...A,name:T.target.value}))})]}),l.jsxs("label",{className:"nc-field",children:[p("audio-group-mode"),l.jsxs("select",{"aria-label":p("audio-group-mode"),value:h.mode,disabled:e||_,onChange:T=>f(A=>({...A,mode:T.target.value})),children:[l.jsx("option",{value:"primary-failover",children:p("audio-group-primary")}),l.jsx("option",{value:"fanout",children:p("audio-group-fanout")})]})]}),l.jsx("div",{className:"nc-set-info",children:p("audio-group-targets")}),$.length===0?l.jsx("small",{className:"nc-set-hint",children:p("audio-group-no-targets")}):$.map(T=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:h.targets.includes(T.id),disabled:e||_,onChange:A=>te(T.id,A.target.checked)}),l.jsxs("span",{children:[T.label,l.jsx("small",{children:T.id})]})]},T.id)),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||_,onClick:()=>{q()},children:p("audio-group-save")}),g&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>Y(null),children:p("audio-group-cancel")})]})]})]}):l.jsx("div",{className:"nc-set-info",children:p("audio-loading")}),z&&l.jsx("div",{className:"nc-set-note",role:"status",children:z}),k&&l.jsx("div",{className:"nc-err",children:k})]})}function B6(){const[t,e]=Dv(),[n,s]=w.useState(nE),[i,a]=w.useState(iE),[c,u]=w.useState(rE);return l.jsxs("div",{className:"nc-set-tab nc-input-settings",children:[l.jsx("div",{className:"nc-set-info",children:p("input-settings-local")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-field",children:[p("terminal-keyboard-gesture"),l.jsx("select",{"aria-label":p("terminal-keyboard-gesture"),value:t.terminalKeyboardGesture,onChange:h=>e({terminalKeyboardGesture:h.target.value}),children:fC.map(h=>l.jsx("option",{value:h,children:p(`terminal-keyboard-${h}`)},h))}),l.jsx("small",{children:p("terminal-keyboard-gesture-help")})]}),l.jsxs("label",{className:"nc-field",children:[p("keybar-layout"),l.jsx("select",{"aria-label":p("keybar-layout"),value:t.keybarLayout,onChange:h=>e({keybarLayout:h.target.value}),children:pC.map(h=>l.jsx("option",{value:h,children:p(`keybar-layout-${h}`)},h))}),l.jsx("small",{children:p("keybar-layout-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:t.showComposer,onChange:h=>e({showComposer:h.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:p("bar-menu-keyboard")}),l.jsx("small",{children:p("bar-menu-keyboard-desc")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:n,onChange:h=>{s(h.target.checked),sE(h.target.checked)}}),l.jsxs("span",{children:[l.jsx("b",{children:p("bar-menu-files")}),l.jsx("small",{children:p("bar-menu-files-setting-desc")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:i,onChange:h=>{a(h.target.checked),Y3(h.target.checked)}}),l.jsxs("span",{children:[l.jsx("b",{children:p("bar-keyboard-button")}),l.jsx("small",{children:p("bar-keyboard-button-desc")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:c,onChange:h=>{u(h.target.checked),G3(h.target.checked)}}),l.jsxs("span",{children:[l.jsx("b",{children:p("bar-panel-button")}),l.jsx("small",{children:p("bar-panel-button-desc")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:t.keybarKeepsKeyboardClosed,onChange:h=>e({keybarKeepsKeyboardClosed:h.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:p("keybar-ime-lock")}),l.jsx("small",{children:p("keybar-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:t.voiceKeepsKeyboardClosed,onChange:h=>e({voiceKeepsKeyboardClosed:h.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:p("voice-ime-lock")}),l.jsx("small",{children:p("voice-ime-lock-help")})]})]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:t.showKeybarEnter,onChange:h=>e({showKeybarEnter:h.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:p("keybar-enter-show")}),l.jsx("small",{children:p("keybar-enter-show-help")})]})]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>e(wr),children:p("input-settings-reset")})})]})}function $6({token:t,roster:e=[],readonly:n}){const s=[{key:"local",route:[],label:p("diagnostics-local"),status:"up"},...e.filter(M=>Array.isArray(M.route)&&M.route.length).map(M=>({key:M.route.join("/"),route:M.route,label:M.label||M.name,status:M.status}))],[i,a]=w.useState("local"),c=s.find(M=>M.key===i)||s[0],[u,h]=w.useState(null),[f,g]=w.useState([]),[v,_]=w.useState(""),[b,x]=w.useState(!1),[L,k]=w.useState(!0),[R,S]=w.useState(900),[j,E]=w.useState("all"),[F,$]=w.useState(""),G=w.useRef(0),K=w.useRef(null),Y=w.useCallback(async()=>{try{const M=await r5(t,c.route);if(h(M),_(""),!b){const z=await o5(t,{after:G.current,limit:200},c.route);Array.isArray(z.records)&&z.records.length&&(G.current=z.cursor,g(T=>[...T,...z.records].slice(-500)))}}catch(M){_(M&&M.status===404?p("diagnostics-unsupported"):String(M.message||M))}},[t,c.key,b]);w.useEffect(()=>{G.current=0,g([]),h(null),_("")},[c.key]),w.useEffect(()=>{let M=null,z=!0;const T=()=>{!z||document.visibilityState==="hidden"||Y()},A=()=>{M&&clearInterval(M),M=document.visibilityState==="hidden"?null:setInterval(T,2e3),document.visibilityState!=="hidden"&&T()};return document.addEventListener("visibilitychange",A),A(),()=>{z=!1,M&&clearInterval(M),document.removeEventListener("visibilitychange",A)}},[Y]),w.useEffect(()=>{L&&K.current&&(K.current.scrollTop=K.current.scrollHeight)},[f,L]);const te=f.filter(M=>(j==="all"||M.level===j)&&(!F||String(M.component||"").toLowerCase().includes(F.toLowerCase()))),q=te.map(M=>`${M.ts} ${M.level.toUpperCase()} ${M.component} ${M.code} ${M.message}${Object.keys(M.meta||{}).length?` ${JSON.stringify(M.meta)}`:""}`).join(`
|
|
168
|
-
`),D=async M=>{_("");try{const z=await M();h(z),await Y()}catch(z){_(String(z.message||z))}},I=async()=>{try{await navigator.clipboard.writeText(q)}catch{_(p("copy-manual"))}},O=()=>{try{const M=new Blob([`${JSON.stringify(te,null,2)}
|
|
169
|
-
`],{type:"application/json"}),z=URL.createObjectURL(M),T=document.createElement("a");T.href=z,T.download="nexuscrew-diagnostics.json",T.click(),URL.revokeObjectURL(z)}catch{_(p("diagnostics-export-failed"))}};return l.jsxs("div",{className:"nc-set-tab nc-diagnostics",children:[l.jsxs("label",{className:"nc-field",children:[p("diagnostics-target"),l.jsx("select",{value:c.key,onChange:M=>a(M.target.value),children:s.map(M=>l.jsxs("option",{value:M.key,children:[M.label,M.status!=="up"?` · ${M.status}`:""]},M.key))})]}),l.jsxs("div",{className:"nc-set-form nc-diag-controls",children:[l.jsx("div",{className:"nc-sheet-label",children:p("diagnostics-verbose")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("select",{"aria-label":p("diagnostics-duration"),value:R,onChange:M=>S(Number(M.target.value)),disabled:n,children:[300,900,1800,3600].map(M=>l.jsxs("option",{value:M,children:[M/60," min"]},M))}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||(u==null?void 0:u.verbose)===!0,onClick:()=>D(()=>Bw(t,!0,R,c.route)),children:p("enable")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(u==null?void 0:u.verbose)!==!0,onClick:()=>D(()=>Bw(t,!1,R,c.route)),children:p("stop")})]}),l.jsx("small",{className:"nc-set-hint",children:u!=null&&u.verbose?p("diagnostics-expires").replace("{time}",new Date(u.expiresAt).toLocaleTimeString()):p("diagnostics-off")})]}),l.jsxs("div",{className:"nc-diag-filters",children:[l.jsxs("select",{"aria-label":p("diagnostics-level"),value:j,onChange:M=>E(M.target.value),children:[l.jsx("option",{value:"all",children:p("diagnostics-all-levels")}),["debug","info","warn","error"].map(M=>l.jsx("option",{value:M,children:M},M))]}),l.jsx("input",{"aria-label":p("diagnostics-component"),placeholder:p("diagnostics-component"),value:F,onChange:M=>$(M.target.value)})]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:b,onChange:M=>x(M.target.checked)})," ",p("diagnostics-pause")]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:L,onChange:M=>k(M.target.checked)})," ",p("diagnostics-autoscroll")]})]}),l.jsx("pre",{ref:K,className:"nc-diag-log","aria-label":p("diagnostics-log"),children:q||p("diagnostics-empty")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:I,children:p("copy")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:O,children:p("diagnostics-export")}),l.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(p("diagnostics-clear-confirm"))&&D(async()=>{const M=await a5(t,c.route);return G.current=0,g([]),M})},children:p("diagnostics-clear")})]}),v&&l.jsx("div",{className:"nc-err",children:v})]})}function z6(){typeof window<"u"&&window.location&&typeof window.location.reload=="function"&&window.location.reload()}function F6({token:t,settings:e,readonly:n,refresh:s,roster:i,section:a,setSection:c}){const[u,h]=w.useState(kc),[f,g]=w.useState(null),[v,_]=w.useState(null),[b,x]=w.useState(!1),[L,k]=w.useState(!1),[R,S]=w.useState(null),[j,E]=w.useState(!1),[F,$]=w.useState(!1),[G,K]=w.useState(null);w.useEffect(()=>{S(e&&e.update||null),E(!!(e&&e.autoUpdate===!0)),$(!!(e&&e.alternateScreen))},[e]);const Y=async()=>{g(null),_(null),k(!0);try{const N=await FN(t);_(N.note||"ok"),x(!1)}catch(N){g(String(N.message||N))}k(!1)},te=async()=>{g(null),_(null),k(!0);try{const N=await n5(t);_(`${N.note||"ok"}${N.target?` (${N.target})`:""}`)}catch(N){g(String(N.message||N))}k(!1)},q=async N=>{g(null),_(null),k(!0);try{await kd(t,{autoUpdate:N}),E(N),s&&await s()}catch(U){g(String(U.message||U))}k(!1)},D=async N=>{g(null),_(null),k(!0);try{await kd(t,{alternateScreen:N}),$(N),s&&await s()}catch(U){g(String(U.message||U))}k(!1)},I=w.useCallback(async()=>{if(t)try{K(await zN(t))}catch{K(null)}},[t]);w.useEffect(()=>{I()},[I]);const O=async N=>{g(null),_(null),k(!0);try{if(!N&&G&&G.running&&!window.confirm(p("ai-desktop-confirm-stop"))){k(!1);return}const U=await P1(t,N);U&&U.ok===!1&&g(U.error||"comando fallito"),await I(),s&&await s()}catch(U){g(String(U.message||U))}k(!1)},M=async()=>{g(null),_(null),k(!0);try{S(await s5(t))}catch(N){g(String(N.message||N))}k(!1)},z=async()=>{g(null),_(null),k(!0);try{const N=await i5(t);S(N),_(p("npm-update-restarting"))}catch(N){g(String(N.message||N))}k(!1)},T=()=>{window.confirm(p("composer-clear-confirm"))&&(g(null),pI()?(window.dispatchEvent(new Event(Lg)),_(p("composer-clear-done"))):g(p("composer-clear-failed")))},A=e&&e.service;return l.jsxs("div",{className:"nc-set-tab",children:[l.jsx("div",{className:"nc-system-tabs",role:"tablist","aria-label":p("tab-system"),children:["general","diagnostics"].map(N=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===N,className:`nc-set-tabbtn${a===N?" on":""}`,onClick:()=>c(N),children:p(`system-${N}`)},N))}),a==="general"&&l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"nc-system-group",children:[l.jsx("div",{className:"nc-set-info",children:p("input-settings-local")}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:u===po,onChange:N=>{const U=pk(N.target.checked?po:mo);h(U),z6()}}),l.jsxs("span",{children:[l.jsx("b",{children:p("bar-menu-renderer")}),l.jsx("small",{children:p("bar-menu-renderer-desc")})]})]})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("system-this-node")}),e&&l.jsxs("div",{className:"nc-set-info",children:["v",e.version," · ",e.platform," · :",e.port,l.jsx("br",{}),A&&A.installed?p("service-installed"):p("service-missing"),A&&A.installed?` · ${A.active?p("service-active"):p("service-inactive")}`:"",A?` · boot ${A.boot?"on":"off"}`:""]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||L,title:n?p("settings-readonly"):"",onClick:te,children:p("service-regenerate")})}),l.jsx(I6,{token:t,readonly:n}),l.jsx(D6,{})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("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||L||R&&!R.supported,onChange:N=>q(N.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("npm-auto-update")}),l.jsx("small",{children:p("npm-auto-update-help")})]})]}),R&&l.jsxs("div",{className:"nc-set-info",children:[p("npm-update-current")," v",R.current,R.latest?` · ${p("npm-update-latest")} v${R.latest}`:""," · ",p(R.supported?R.phase==="idle"&&R.checked!==!0?"npm-update-never":`npm-update-${R.phase}`:"unsupported")]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||L||!R||!R.supported,onClick:M,children:p("npm-update-check")}),R&&R.available&&l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||L||R.phase==="installing",onClick:z,children:p("npm-update-install")})]}),R&&R.lastError&&l.jsx("div",{className:"nc-err",children:R.lastError})]})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("ai-desktop-title")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":p("ai-desktop"),disabled:n||L,checked:!!(G&&G.desired),onChange:N=>O(N.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("ai-desktop")}),l.jsx("small",{children:p("ai-desktop-help")})]})]}),G&&!G.desired&&G.running&&l.jsx("div",{className:"nc-set-info",children:p("ai-desktop-stop-pending")})]})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("system-security")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||L,title:n?p("settings-readonly"):"",onClick:()=>{g(null),_(null),x(!0)},children:p("token-rotate")})})]}),l.jsxs("section",{className:"nc-system-group",children:[l.jsx("h3",{children:p("system-local-data")}),l.jsxs("div",{className:"nc-set-form",children:[l.jsx("div",{className:"nc-sheet-label",children:p("composer-clear-data")}),l.jsx("small",{className:"nc-set-hint",children:p("composer-clear-data-help")}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:T,children:p("composer-clear-data")})})]})]})]}),a==="diagnostics"&&l.jsxs("section",{className:"nc-system-group nc-system-diagnostics",children:[l.jsx("h3",{children:p("system-diagnostics")}),l.jsxs("div",{className:"nc-set-form nc-alternate-screen-settings",children:[l.jsx("div",{className:"nc-sheet-label",children:p("system-terminal")}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox","aria-label":p("alternate-screen"),checked:F,disabled:n||L,onChange:N=>D(N.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("alternate-screen")}),l.jsx("small",{children:p("alternate-screen-help")})]})]})]}),l.jsx(j6,{token:t}),l.jsx(m6,{}),l.jsx($6,{token:t,roster:i,readonly:n})]}),b&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("div",{children:p("token-rotate-explain")}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:L,onClick:()=>x(!1),children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:L,onClick:Y,children:p("confirm")})]})]}),v&&l.jsx("div",{className:"nc-set-note",children:v}),f&&l.jsx("div",{className:"nc-err",children:f})]})}function H6({token:t,onClose:e,initialTab:n="nodes",initialLocation:s="",startNewCell:i=!1}){zn();const a=n==="diagnostics"?"diagnostics":"general",[c,u]=w.useState(n==="diagnostics"?"system":n),h=w.useRef(null),f=w.useRef(null),[g,v]=w.useState({start:!1,end:!1}),[_,b]=w.useState(a),[x,L]=w.useState(null),[k,R]=w.useState([]),[S,j]=w.useState(null),[E,F]=w.useState([]),[$,G]=w.useState(!1),[K,Y]=w.useState(null),[te,q]=w.useState(0),D=xv(t,!0,te),I=w.useCallback(()=>{const P=h.current;if(!P)return;const H=P.scrollWidth>P.clientWidth+1,ie={start:H&&P.scrollLeft>1,end:H&&P.scrollLeft+P.clientWidth<P.scrollWidth-1};v(J=>J.start===ie.start&&J.end===ie.end?J:ie)},[]);w.useEffect(()=>{const P=h.current;if(!P)return;const H=typeof ResizeObserver=="function"?new ResizeObserver(I):null;return H==null||H.observe(P),window.addEventListener("resize",I),I(),()=>{H==null||H.disconnect(),window.removeEventListener("resize",I)}},[I]),w.useEffect(()=>{var H,ie;(ie=(H=f.current)==null?void 0:H.scrollIntoView)==null||ie.call(H,{behavior:"smooth",block:"nearest",inline:"nearest"});const P=window.requestAnimationFrame?window.requestAnimationFrame(I):setTimeout(I,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(P):clearTimeout(P)}},[c,I]);const O=w.useRef(eh()),M=w.useRef(null),z=w.useRef([]),T=w.useRef(new Map),A=w.useRef({token:null,instanceId:null}),N=w.useCallback((P,H)=>{if(!P.isCurrent(H))return;const ie=z.current,J=[],Q=new Set;for(const ve of T.current.values())for(const de of ve){const ne=Array.isArray(de.route)&&de.route.length?de.route.join("/"):"local",xe=`${de.ownerInstanceId}:${ne}:${de.nodeId||de.name||de.label||""}`;Q.has(xe)||(Q.add(xe),J.push(de))}R([...ie,...J])},[]),U=w.useCallback(async()=>{const P=O.current,H=P.begin();if(H===null)return;const ie=new AbortController;M.current=ie;const J={timeoutMs:x1,signal:ie.signal};try{const Q=j1(t,J).then(ne=>{P.isCurrent(H)&&(L(ne),Y(null))}).catch(ne=>{P.isCurrent(H)&&Y(String((ne==null?void 0:ne.message)||ne))}),ve=BN(t,J).then(ne=>{if(!P.isCurrent(H))return;const xe=ne.peers||[];z.current=xe,j(Number.isInteger(ne.accessRevision)?ne.accessRevision:null),N(P,H)}).catch(ne=>{P.isCurrent(H)&&Y(String((ne==null?void 0:ne.message)||ne))}),de=(async()=>{const[ne,xe]=await Promise.all([Ic(t,[],J).then(oe=>oe).catch(()=>null),T1(t,J).then(oe=>oe).catch(()=>null)]);if(!P.isCurrent(H))return;const $e=ne&&typeof ne.instanceId=="string"?ne.instanceId:"";if(!$e)return;A.current.instanceId!==$e&&(T.current.clear(),A.current.instanceId=$e);const rt=[{instanceId:$e||null,route:[],label:null},...Nk(xe,$e)],je=oe=>`${oe.instanceId}:${oe.route.join("/")}`;if(xe){const oe=new Set(rt.map(je));for(const Ne of T.current.keys())oe.has(Ne)||T.current.delete(Ne)}if(!xe)for(const[oe,Ne]of T.current)Ne.some(me=>me.route.length)&&T.current.set(oe,Ne.map(me=>({...me,stale:!0,online:!1,canManage:!1,capabilities:[]})));const Ie=new Map;F([]),N(P,H),await Promise.allSettled(rt.map(async oe=>{const Ne=je(oe);try{const me=await M1(t,oe.route,{signal:ie.signal});if(!P.isCurrent(H))return;const Ce=(me.nodes||[]).map(V=>Ek(V,oe)).filter(Boolean);T.current.set(Ne,Ce),Ie.delete(Ne)}catch(me){if(!P.isCurrent(H))return;if((me==null?void 0:me.status)===403||(me==null?void 0:me.status)===404)T.current.delete(Ne);else{const V=T.current.get(Ne);V&&T.current.set(Ne,V.map(ge=>({...ge,stale:!0,online:!1,canManage:!1,capabilities:[]})))}oe.route.length>0&&Ie.set(Ne,{instanceId:oe.instanceId,label:oe.label,route:oe.route,failure:/timeout/i.test(String((me==null?void 0:me.message)||me))?"timeout":"unreachable"})}P.isCurrent(H)&&(F([...Ie.values()]),N(P,H))}))})();await Promise.allSettled([Q,ve,de])}finally{M.current===ie&&(M.current=null),P.end(H)}},[t,N]);return w.useEffect(()=>{A.current.token!==t&&(A.current={token:t,instanceId:null},z.current=[],T.current.clear(),R([]),F([]),j(null)),U();const P=setInterval(U,5e3);return()=>{clearInterval(P),O.current.reset(),M.current&&M.current.abort()}},[U]),w.useEffect(()=>{let P=!1;return qn("/api/config",t).then(H=>H.json()).then(H=>{P||G(!!H.readonlyDefault)}).catch(()=>{}),()=>{P=!0}},[t]),l.jsx("div",{className:"nc-set-overlay",onClick:e,children:l.jsxs("div",{className:"nc-set-panel",onClick:P=>P.stopPropagation(),children:[l.jsxs("div",{className:"nc-set-head",children:[l.jsx(Tt,{name:"gear",size:18}),l.jsx("b",{children:p("settings")}),l.jsx("button",{type:"button",className:"nc-set-close",onClick:e,title:p("close"),children:l.jsx(Tt,{name:"x",size:18})})]}),$&&l.jsx("div",{className:"nc-set-readonly",children:p("settings-readonly")}),K&&l.jsx("div",{className:"nc-err",children:K}),l.jsx("div",{className:`nc-set-tabs-wrap${g.start?" has-start-overflow":""}${g.end?" has-end-overflow":""}`,children:l.jsx("div",{className:"nc-set-tabs",ref:h,onScroll:I,children:["nodes","fleet","audio","input","system"].map(P=>l.jsx("button",{ref:c===P?f:null,type:"button",className:`nc-set-tabbtn${c===P?" on":""}`,onClick:()=>u(P),children:p(`tab-${P}`)},P))})}),l.jsxs("div",{className:"nc-set-body",children:[c==="nodes"&&l.jsx(P6,{token:t,nodes:k,roster:D,settings:x,readonly:$,vlUnavailable:E,accessRevision:S,refresh:U,refreshAliases:()=>q(P=>P+1)}),c==="fleet"&&l.jsx(V3,{token:t,readonly:$,startNewCell:i,initialLocation:s,targets:D.map(P=>({route:P.route,label:P.label||P.name,status:P.status}))}),c==="audio"&&l.jsx(O6,{token:t,readonly:$,nodes:k,settings:x}),c==="input"&&l.jsx(B6,{}),c==="system"&&l.jsx(F6,{token:t,settings:x,readonly:$,refresh:U,roster:D,section:_,setSection:b})]})]})})}function U6({token:t,initialPair:e,deviceDefault:n="",localNodeId:s="",localNameDefault:i="",deviceNameNeeded:a=!1,deviceNameSuggestion:c="",onPairDone:u,onDone:h}){zn();const[f,g]=w.useState(e?"pair":"welcome"),[v,_]=w.useState(!1),[b,x]=w.useState(null),[L,k]=w.useState(c||""),[R,S]=w.useState(null),j=async()=>{_(!0),x(null);try{const E={wizardDone:!0};a&&L.trim()&&(E.deviceName=L.trim()),await kd(t,E),u&&u(),h()}catch(E){x(String(E.message||E)),_(!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:p("wizard-title")}),l.jsx("small",{children:p("hydra-simple")})]}),f==="welcome"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:p("local-ready")}),a&&l.jsx("div",{className:"nc-wiz-done",children:p("wizard-device-name")}),a&&l.jsxs("label",{className:"nc-field",children:[l.jsx("span",{children:p("device-name-label")}),l.jsx("input",{value:L,onChange:E=>k(E.target.value),maxLength:64,"data-testid":"wizard-device-name-input"})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:v,onClick:j,children:p("local-only")}),l.jsx("button",{className:"nc-btn primary",disabled:v,onClick:()=>g("pair"),children:p("add-node")})]})]}),f==="pair"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx(DC,{token:t,initial:e||"",autoStart:!!e,deviceDefault:a&&L.trim()?L.trim():n,localNodeId:s,localNameDefault:i,onBusyChange:_,onSuccess:async E=>{S(E&&E.authorizedKeys?{line:E.authorizedKeys,note:E.authorizedKeysNote||""}:null),u&&u(),g("done")}}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn ghost",disabled:v,onClick:()=>{u&&u(),g("welcome")},children:p("back")})})]}),f==="done"&&l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("div",{className:"nc-wiz-done",children:p("node-connected")}),R&&l.jsx(qv,{line:R.line,note:R.note}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn primary",disabled:v,onClick:j,children:p("finish")})})]}),b&&l.jsx("div",{className:"nc-err",children:b})]})})}function W6({token:t,suggestion:e="",onSaved:n,onLater:s}){zn();const[i,a]=w.useState(e||""),[c,u]=w.useState(!1),[h,f]=w.useState(null),g=async()=>{const v=i.trim();if(v){u(!0),f(null);try{await kd(t,{deviceName:v}),n&&n(v)}catch(_){f(String(_.message||_)),u(!1)}}};return l.jsx("div",{className:"nc-wiz-overlay",role:"dialog","aria-label":p("device-name-ask-title"),"data-testid":"device-name-ask",children:l.jsxs("div",{className:"nc-wiz",children:[l.jsx("div",{className:"nc-wiz-head",children:l.jsx("b",{children:p("device-name-ask-title")})}),l.jsxs("div",{className:"nc-wiz-body",children:[l.jsx("p",{className:"nc-wiz-done",children:p("device-name-ask-text")}),l.jsxs("label",{className:"nc-field",children:[l.jsx("span",{children:p("device-name-label")}),l.jsx("input",{value:i,onChange:v=>a(v.target.value),maxLength:64,"data-testid":"device-name-input"})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c,onClick:s,children:p("device-name-later")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:c||!i.trim(),onClick:g,children:p("device-name-save")})]})]}),h&&l.jsx("div",{className:"nc-err",children:h})]})})}const q6=50;function K6(t){if(Number.isFinite(t))return t;const e=typeof t=="string"?Date.parse(t):NaN;return Number.isFinite(e)?e:0}function V6(t,e){return`${String(t)}|${String(e)}`}function n1(t,e){if(!t||typeof t!="object")return null;const n=t.frame&&typeof t.frame=="object"?t.frame:t;if(n.type!=="notify"||!t.eventId||typeof n.askId=="string"&&n.askId)return null;const s=typeof n.title=="string"?n.title:"",i=typeof n.body=="string"?n.body:"";return!s&&!i?null:{key:V6(e,t.eventId),ownerId:String(e),eventId:String(t.eventId),title:s,body:i,urgency:n.urgency==="high"?"high":"normal",ts:K6(t.ts)}}function s1(t){return[...t].sort((e,n)=>n.ts-e.ts).slice(0,q6)}function Y6(t,e,n){const s=new Map;for(const i of t||[])s.set(i.key,i);for(const i of e||[])i&&s.set(i.key,i);return[...s.values()]}function G6(t,e,n){if(typeof EventSource>"u"||!t)return()=>{};const s=new EventSource(`/api/events?token=${encodeURIComponent(t)}`);return s.onopen=()=>{typeof n=="function"&&n()},s.onmessage=i=>{try{const a=JSON.parse(i.data);a&&typeof a=="object"&&typeof a.type=="string"&&e(a)}catch{}},()=>{try{s.close()}catch{}}}const X6=6e3,J6=12e3,Zn=(t,e,n)=>`${e||""}:${n||t}`,Q6=(t,e)=>{const n=t&&t[e];return n?n.stale===!0||n.error===!0?"degraded":"live":"missing"},yE=600*1e3,Ug=new Map,Yo=t=>Object.hasOwn(t,"ownerAskTs")?t.ownerAskTs:t.ownerAskId||t.originNode?null:t.ts;function wE(t,e){Ug.set(t,e?{at:Date.now(),local:!0,ts:Yo(e),fingerprint:e.question===void 0?null:JSON.stringify([e.question,e.options||[],e.session])}:{at:Date.now()})}function bE(t){const e=Zn(t.id,t.ownerId,t.ownerAskId),n=Ug.get(e);if(n===void 0)return!1;if(n.local){const s=Yo(t);return!(n.ts&&s&&n.ts!==s)&&(n.fingerprint===null||n.fingerprint===JSON.stringify([t.question,t.options||[],t.session]))}return Date.now()-n.at>yE?(Ug.delete(e),!1):!0}function xd(t,e){const n=new Map(t.map(s=>[Zn(s.id,s.ownerId,s.ownerAskId),s]));for(const s of e||[]){if(!s||!s.id||bE(s))continue;const i=Zn(s.id,s.ownerId,s.ownerAskId),a=n.get(i),c=Yo(s),u=a&&Yo(a);(!a||Number.isSafeInteger(c)&&c>0&&Number.isSafeInteger(u)&&u>0&&c>u)&&n.set(i,s)}return[...n.values()]}function Z6(t,e){const n=xd([],t.filter(a=>a.imported)),s=new Set(n.map(a=>Zn(a.id,a.ownerId,a.ownerAskId)));return[...(e||[]).filter(a=>a&&a.id&&!s.has(Zn(a.id,a.ownerId,a.ownerAskId))&&!bE(a)),...n]}function e4({n:t,onClose:e}){return l.jsxs("div",{className:`nc-ntf-toast${t.urgency==="high"?" high":""}`,role:"status","aria-live":"polite",children:[l.jsxs("div",{className:"nc-ntf-toast-txt",children:[l.jsx("b",{children:t.title}),t.body&&l.jsx("small",{children:t.body}),t.session&&l.jsx("span",{className:"nc-ntf-from",children:t.session}),t.ownerId&&l.jsx("span",{className:"nc-ntf-from",children:p("feed-owner")})]}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:e,title:p("close"),children:l.jsx(Tt,{name:"x",size:14})})]})}function t4({ask:t,token:e,onAnswered:n,onDismiss:s,askReplyAccess:i=!1,feedViewState:a="live",initialUncertainRid:c=null,canDismissLocal:u=!1,canDismissRemote:h=!1,capabilityStatus:f="loading",onRefused:g=()=>{}}){const[v,_]=w.useState(""),[b,x]=w.useState(!1),[L,k]=w.useState(null),[R,S]=w.useState(!1),[j,E]=w.useState(c),[F,$]=w.useState(!1),[G,K]=w.useState(!1),Y=w.useRef(null);w.useEffect(()=>{c&&E(c)},[c]);const te=R||b||!!j||G||!!t.ownerId&&f==="loading",q=!!t.ownerId&&!h,D=async M=>{const z=String(M||"").trim();if(!(!z||b||R||j||G)){k(null),x(!0);try{if(t.ownerId){const T=t.ownerAskId||t.id,A=await d5(e,{ownerId:t.ownerId,askId:T,text:z,requestId:Y.current||(Y.current=crypto.randomUUID())});if(A&&A.uncertain){const N=A.reason==="delivery-unknown-block"&&!A.originalRequestId;E(N?null:A.originalRequestId||A.requestId||Y.current),K(N);return}if(!A||A.status!=="committed"){Y.current=null,g(),k(p("ask-reconcile"));return}n(t.id,t.ownerId,t.ownerAskId)}else await c5(e,t.id,z),n(t.id)}catch(T){k(String(T.message||T)),t.ownerId&&!T.status?E(Y.current):Y.current=null,g()}finally{x(!1)}}},I=async()=>{if(!te){k(null),S(!0);try{let M;if(q){if(M=await g5(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id}),(M==null?void 0:M.dismissed)!==!0||M.scope!=="local"||!["pending","blocked"].includes(M.ownerSync))throw new Error(p("ask-dismiss-unconfirmed"))}else t.ownerId?await m5(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id}):await u5(e,t.id);wE(Zn(t.id,t.ownerId,t.ownerAskId),q?t:null),s(t.id,t.ownerId,t.ownerAskId,M)}catch(M){k(String(M&&M.message||M)),g()}finally{S(!1)}}},O=p(j||G?"ask-uncertain":q?"ask-dismiss-local":a==="degraded"?"ask-dismiss-stale":"ask-dismiss");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:t.session}),t.ownerId&&l.jsx("span",{className:"nc-ntf-from",children:p("feed-owner")}),l.jsxs("code",{className:"nc-ask-id",children:["#",t.id]}),l.jsx("button",{type:"button",className:"nc-ask-dismiss",title:O,"aria-label":O,disabled:te,onClick:I,children:l.jsx(Tt,{name:"x",size:14})})]}),l.jsx("div",{className:"nc-ask-q",children:t.question}),t.ownerId&&i===!1&&l.jsx("small",{className:"nc-set-hint",children:p(f==="loading"?"ask-capability-loading":f==="unsupported"?"ask-capability-unsupported":f==="unreachable"?"ask-capability-unreachable":"ask-remote-readonly")}),t.ownerId&&i!==!1&&a==="degraded"&&l.jsx("small",{className:"nc-set-hint",children:p("ask-feed-stale")}),(j||G)&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-err",children:p("ask-uncertain")}),G&&!j&&l.jsx("div",{className:"nc-err",children:p("ask-reconcile")}),j&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:F,onClick:async()=>{$(!0);try{const M=await h5(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id,requestId:j});(M==null?void 0:M.state)==="committed"?n(t.id,t.ownerId,t.ownerAskId):(M==null?void 0:M.state)==="failed"&&(E(null),Y.current=null,g())}catch(M){k(String(M.message||M)),g()}finally{$(!1)}},children:p("ask-verify")})]}),(!t.ownerId||i===!0)&&!j&&!G&&l.jsxs(l.Fragment,{children:[Array.isArray(t.options)&&t.options.length>0&&l.jsx("div",{className:"nc-ask-opts",children:t.options.map(M=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:b||R,onClick:()=>D(M),children:M},M))}),l.jsxs("div",{className:"nc-ask-reply",children:[l.jsx("textarea",{rows:2,placeholder:p("ask-reply-ph"),value:v,disabled:b||R,onChange:M=>_(M.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:b||R||!v.trim(),onClick:()=>D(v),children:p("send")})]})]}),L&&l.jsx("div",{className:"nc-err",children:L})]})}function n4({token:t}){const[e]=zn(),[n]=dE(),[s,i]=w.useState([]),[a,c]=w.useState([]),[u,h]=w.useState(null),[f,g]=w.useState([]),[v,_]=w.useState(()=>{try{return/(?:^|[#&])ask=/.test(location.hash)}catch{return!1}}),[b,x]=w.useState({}),L=w.useRef(new Map),k=w.useRef(0),[R,S]=w.useState(0),j=w.useRef(new Map),E=w.useRef(0),F=w.useRef(new Map),$=w.useRef(new Map),G=w.useRef(new Map),K=J=>(J||[]).filter(Q=>{const ve=j.current.get(Zn(Q.id,Q.ownerId,Q.ownerAskId));if(!ve)return!0;if(Date.now()-ve.at>yE)return j.current.delete(Zn(Q.id,Q.ownerId,Q.ownerAskId)),!0;const de=Yo(Q);return Number.isSafeInteger(de)&&de>0&&Number.isSafeInteger(ve.ts)&&ve.ts>0?de!==ve.ts:ve.fingerprint!==null&&ve.fingerprint!==void 0&&ve.fingerprint!==JSON.stringify([Q.question,Q.options||[],Q.session])}),Y=w.useRef(a);Y.current=a;const te=w.useCallback((J=!1)=>{if(!t)return;const Q=new Set;for(const ve of Y.current){if(!ve.ownerId)continue;const de=ve.ownerAskId||ve.id,ne=`${ve.ownerId}|${de}`;Q.add(ne);const xe=L.current.get(ne);if(xe&&(!J||xe.pending))continue;const $e=new AbortController,rt=k.current,je={controller:$e,pending:!0};L.current.set(ne,je),x(Ie=>({...Ie,[ne]:{canReply:!1,status:"loading"}})),f5(t,{ownerId:ve.ownerId,askId:de},{signal:$e.signal}).then(Ie=>{if(rt!==k.current||$e.signal.aborted||L.current.get(ne)!==je)return;const oe=Ie&&Ie.ownerId===ve.ownerId&&Ie.askId===de&&typeof Ie.canReply=="boolean"&&(!Ie.canReply||Ie.status==="open");x(Ne=>({...Ne,[ne]:oe?Ie:{canReply:!1,status:"unreachable"}}))}).catch(()=>{rt===k.current&&!$e.signal.aborted&&L.current.get(ne)===je&&x(Ie=>({...Ie,[ne]:{canReply:!1,status:"unreachable"}}))}).finally(()=>{je.pending=!1})}for(const[ve,de]of L.current)Q.has(ve)||(de.controller.abort(),L.current.delete(ve))},[t]);w.useEffect(()=>{k.current++;for(const J of L.current.values())J.controller.abort();return L.current.clear(),x({}),()=>{k.current++;for(const J of L.current.values())J.controller.abort();L.current.clear()}},[t]),w.useEffect(()=>{te()},[a,te]);const q=w.useRef(!1);w.useEffect(()=>{v&&(q.current&&te(!0),q.current=!0)},[v,te]);const D=w.useRef(0),I=w.useRef(null);I.current||(I.current=d6());const O=w.useRef({enabled:n,lang:e});O.current={enabled:n,lang:e};const M=w.useCallback(J=>{i(Q=>Q.filter(ve=>ve.key!==J))},[]),z=w.useCallback(J=>{if(J.askId&&J.ownerId){const de=Number.isSafeInteger(J.ownerAskTs)&&J.ownerAskTs>0?J.ownerAskTs:J.ownerAskFingerprint;if(de){const ne=JSON.stringify([J.ownerId,J.ownerAskId||J.askId,de]),xe=Date.now();for(const[$e,rt]of G.current)xe-rt>1440*60*1e3&&G.current.delete($e);if(G.current.has(ne))return;G.current.set(ne,xe),G.current.size>4096&&G.current.delete(G.current.keys().next().value)}}const Q=`t${D.current+=1}`;i(de=>[...de.slice(-3),{...J,key:Q}]),setTimeout(()=>M(Q),J.urgency==="high"?J6:X6);const ve=O.current;if(ve.enabled)try{I.current.enqueue(J,o6(J,ve.lang))}catch{}},[M]);w.useEffect(()=>{n||I.current.stop()},[n]),w.useEffect(()=>{const J=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&I.current.stop()},Q=()=>I.current.stop();return document.addEventListener("visibilitychange",J),window.addEventListener("blur",J),window.addEventListener(Ig,Q),()=>{document.removeEventListener("visibilitychange",J),window.removeEventListener("blur",J),window.removeEventListener(Ig,Q),typeof I.current.dispose=="function"?I.current.dispose():I.current.stop()}},[]);const T=J=>{if(J.ownerAskId||!J.ownerId)return J;const Q=Y.current.filter(de=>de.ownerId===J.ownerId&&(de.id===J.id||de.ownerAskId===J.id)),ve=new Set(Q.map(de=>de.ownerAskId||de.id));return ve.size>1?null:{...J,ownerAskId:ve.size===1?[...ve][0]:J.id}},A=(J,Q)=>{const ve=Y.current.find(ne=>Zn(ne.id,ne.ownerId,ne.ownerAskId)===J),de=ve&&Yo(ve);return Number.isSafeInteger(Q==null?void 0:Q.ownerAskTs)&&Q.ownerAskTs>0&&Number.isSafeInteger(de)&&de>0&&Q.ownerAskTs!==de},N=(J,Q,ve,de)=>{const ne=Zn(J,Q,ve);(de==null?void 0:de.scope)==="local"&&["pending","blocked"].includes(de.ownerSync)&&h(de.ownerSync);const xe=Y.current.find(je=>Zn(je.id,je.ownerId,je.ownerAskId)===ne),$e=xe&&Yo(xe);if(A(ne,de))return;const rt=xe||(de==null?void 0:de.askGeneration);j.current.set(ne,{at:Date.now(),ts:xe?$e:de==null?void 0:de.ownerAskTs,fingerprint:rt&&rt.question!==void 0?JSON.stringify([rt.question,rt.options||[],rt.session]):null}),F.current.delete(ne),j.current.size>4096&&j.current.delete(j.current.keys().next().value),c(je=>je.filter(Ie=>Zn(Ie.id,Ie.ownerId,Ie.ownerAskId)!==ne))};w.useEffect(()=>{if(!t)return;const J=G6(t,Q=>{if(Q.type==="feed-state-changed"){S(ve=>ve+1);return}if(Q.type==="notify"&&Q.ownerId&&Q.eventId){const ve=n1(Q,Q.ownerId);ve&&g(de=>s1(Y6(de,[ve],null)))}if(Q.type==="notify")z(Q);else if(Q.type==="ask"&&Q.ask&&Q.ask.id){const ve=Zn(Q.ask.id,Q.ask.ownerId,Q.ask.ownerAskId);F.current.set(ve,++E.current),F.current.size>4096&&F.current.delete(F.current.keys().next().value),c(de=>xd(de,K([Q.ask])))}else if(Q.type==="ask-answered"&&Q.id){const ve=T(Q);ve&&N(ve.id,ve.ownerId,ve.ownerAskId,Q)}else if(Q.type==="ask-dismissed"&&(Q.id||Q.ownerAskId)){const ve=T(Q);if(!ve)return;const de=Zn(ve.id,ve.ownerId,ve.ownerAskId);if(A(de,Q))return;const ne=Q.scope==="local"&&Y.current.find(xe=>Zn(xe.id,xe.ownerId,xe.ownerAskId)===de);wE(de,Q.scope==="local"?ne||{...Q.askGeneration,ownerAskTs:Q.ownerAskTs}:null),N(ve.id,ve.ownerId,ve.ownerAskId,Q)}},()=>{te(!0),S(Q=>Q+1)});return()=>{J()}},[t,z,te]),w.useEffect(()=>{let J=!0;const Q=E.current;return t&&l5(t).then(ve=>{J&&c(de=>xd(Z6(de,K((ve.asks||[]).filter(ne=>!ne.ownerId||($.current.get(ne.ownerId)||0)<=Q))),K(de.filter(ne=>(F.current.get(Zn(ne.id,ne.ownerId,ne.ownerAskId))||0)>Q))))}).catch(()=>{}),()=>{J=!1}},[t,R]);const[U,P]=w.useState({});w.useEffect(()=>{if(!t)return;let J=!0;return p5(t).then(Q=>{if(!J)return;const ve={};for(const de of Q&&Q.attempts||[])de&&de.state==="uncertain"&&de.ownerId&&de.askId&&de.requestId&&(ve[de.ownerId+"|"+de.askId]=de.requestId);P(ve)}).catch(()=>{}),()=>{J=!1}},[t]);const[H,ie]=w.useState({});return w.useEffect(()=>{let J=!0;const Q=E.current;return v5(t).then(ve=>{if(!J)return;const de={},ne=[],xe=new Map,$e=new Set;for(const je of ve&&ve.views||[]){de[je.ownerId]={stale:je.stale===!0,error:!!je.lastError},$e.add(je.ownerId);for(const Ie of je.asks||[])Ie&&Ie.id&&ne.push({...Ie,ownerId:je.ownerId,imported:!0});for(const Ie of je.notifications||[]){const oe=n1(Ie,je.ownerId);oe&&xe.set(oe.key,oe)}}ie(de);const rt=new Set((ve&&ve.views||[]).filter(je=>{const Ie=typeof je.cursor=="string"&&/^([1-9]\d*):(\d+)$/.exec(je.cursor);return je.stale===!1&&Number.isSafeInteger(je.viewEpoch)&&je.viewEpoch>0&&Ie&&Number(Ie[1])===je.viewEpoch&&Number.isSafeInteger(Number(Ie[2]))&&!je.lastError&&!je.error&&je.resyncRequired!==!0&&Array.isArray(je.asks)&&je.asks.length<100}).map(je=>je.ownerId));for(const je of rt)$.current.delete(je),$.current.set(je,++E.current),$.current.size>4096&&$.current.delete($.current.keys().next().value);c(je=>xd(je.filter(Ie=>!rt.has(Ie.ownerId)||(F.current.get(Zn(Ie.id,Ie.ownerId,Ie.ownerAskId))||0)>Q),K(ne))),g(je=>{const Ie=[];for(const oe of je)$e.has(oe.ownerId)&&Ie.push(oe);for(const oe of xe.values())Ie.push({...oe,key:oe.key});return s1(Ie)})}).catch(()=>{}),()=>{J=!1}},[t,R]),l.jsxs(l.Fragment,{children:[u&&l.jsx("div",{className:"nc-ntf-toasts",children:l.jsxs("div",{className:"nc-ntf-toast",role:"status",children:[l.jsx("div",{className:"nc-ntf-toast-txt",children:p(u==="blocked"?"ask-dismiss-local-blocked":"ask-dismiss-local-pending")}),l.jsx("button",{type:"button",className:"nc-ntf-x",title:p("close"),onClick:()=>h(null),children:l.jsx(Tt,{name:"x",size:14})})]})}),s.length>0&&l.jsx("div",{className:"nc-ntf-toasts",children:s.map(J=>l.jsx(e4,{n:J,onClose:()=>M(J.key)},J.key))}),(a.length>0||f.length>0)&&!v&&l.jsxs("button",{type:"button",className:"nc-ask-badge",onClick:()=>_(!0),title:p("asks-title"),children:["? ",l.jsx("span",{className:"nc-ask-count",children:a.length+f.length})]}),(a.length>0||f.length>0)&&v&&l.jsxs("div",{className:"nc-ask-panel",children:[l.jsxs("div",{className:"nc-ask-panel-head",children:[l.jsx("b",{children:p("asks-title")}),l.jsx("span",{className:"nc-ask-count",children:a.length}),l.jsx("button",{type:"button",className:"nc-ntf-x",onClick:()=>_(!1),title:p("close"),children:l.jsx(Tt,{name:"x",size:16})})]}),l.jsxs("div",{className:"nc-ask-panel-body",children:[a.map(J=>{var Q,ve,de,ne,xe,$e;return l.jsx(t4,{ask:J,token:t,askReplyAccess:!J.ownerId||((Q=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:Q.canReply)===!0,canDismissLocal:((ve=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:ve.canDismissLocal)===!0,canDismissRemote:((de=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:de.canDismissRemote)===!0||((ne=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:ne.canDismissRemote)===void 0&&((xe=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:xe.canReply)===!0,capabilityStatus:(($e=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:$e.status)||"loading",onRefused:()=>te(!0),feedViewState:J.ownerId?Q6(H,J.ownerId):"live",initialUncertainRid:J.ownerId&&U[J.ownerId+"|"+(J.ownerAskId||J.id)]||null,onAnswered:N,onDismiss:N},Zn(J.id,J.ownerId,J.ownerAskId))}),f.length>0&&l.jsxs("div",{className:"nc-remote-notices",children:[l.jsx("div",{className:"nc-remote-notices-head",children:l.jsx("b",{children:p("remote-notices-title")})}),f.map(J=>l.jsxs("div",{className:"nc-remote-notice"+(J.urgency==="high"?" nc-remote-notice-high":""),children:[J.title?l.jsx("b",{children:J.title}):null,J.body?l.jsx("div",{children:J.body}):null,l.jsxs("div",{className:"nc-remote-notice-meta",children:[J.ownerId.slice(0,8)," · ",new Date(J.ts||Date.now()).toLocaleString()]})]},J.key))]})]})]})]})}const SE="nc_fontsize",xE=9,kE=24;function Wg(t=globalThis.localStorage){const e=Number(t.getItem(SE));return e>=xE&&e<=kE?e:13}function CE(t,e=globalThis.localStorage){const n=Math.max(xE,Math.min(kE,t));return e.setItem(SE,String(n)),n}const s4=4e3;async function i4(t){const e=await qn("/api/sessions",t);if((e==null?void 0:e.ok)===!1)throw new Error(`HTTP ${e.status}`);const n=await e.json();if(!Array.isArray(n==null?void 0:n.sessions))throw new Error("invalid sessions payload");return n.sessions}async function lm(t,e=[]){var u;const[n,s]=await Promise.allSettled([e.length?Qg(t,e):i4(t),Qa(t,e)]),i=n.status==="fulfilled"&&Array.isArray((u=n.value)==null?void 0:u.sessions)?n.value.sessions:Array.isArray(n.value)?n.value:null,a=s.status==="fulfilled"?s.value:null,c=(a==null?void 0:a.available)===!0&&Array.isArray(a.cells)?a.cells:null;return{sessions:i,cells:c,fresh:Array.isArray(i)&&Array.isArray(c)}}function EE(t,e,n){return n===!0&&(t==null?void 0:t.degraded)!==!0&&(t==null?void 0:t.active)===!0&&t.tmux!==!1&&!!t.tmuxSession&&(e||[]).some(s=>(s==null?void 0:s.name)===t.tmuxSession)}function r4(t){const e=new Map((t.sessions||[]).map(i=>[i.name,i])),n=[],s=(i,a,c,u=[],h="")=>{const f=new Map((a||[]).map(g=>[g.name,g]));for(const g of i||[]){const v=f.get(g.tmuxSession)||{},_=dh(g,v),b=EE(g,a,c);n.push({key:qa(u,g.tmuxSession||g.cell),session:g.tmuxSession,route:u,cellName:g.cell,label:g.cell,node:u.length?u.join("/"):"",nodeLabel:h,live:b,selectable:b,verified:c===!0,keepVisible:c!==!0&&i.length>0,working:_.working,degraded:!!g.degraded,active:g.active===!0,activity:v.activity||g.activity||0,subtitle:_.subtitle,preview:v.preview||g.preview||"",telemetry:v.telemetry||null,panelUrl:g.panelUrl||""})}};s(t.cells,[...e.values()],t.localFresh===!0);for(const i of t.nodeGroups||[]){const a=Array.isArray(i.route)?i.route:[];i.kind==="vl"||!a.length||s(i.cells,i.sessions,i.switcherFresh===!0,a,i.label||i.name||"")}return n}function o4(t){const e=new Map,n=Array.isArray(t.sessions)?t.sessions:[],s=Array.isArray(t.cells)?t.cells:[],i=new Map(n.map(c=>[c.name,c])),a=new Set(s.map(c=>c.tmuxSession).filter(Boolean));e.set("local",Av(s,n.filter(c=>!a.has(c.name)),i));for(const c of t.nodeGroups||[]){const u=Array.isArray(c.route)?c.route:[];if(c.kind==="vl"||!u.length)continue;const h=Array.isArray(c.cells)?c.cells:[],f=Array.isArray(c.sessions)?c.sessions:[],g=new Set(h.map(v=>v.tmuxSession).filter(Boolean));e.set(u.join("/"),gc({...c,route:u,cells:h,sessions:f,unmanaged:f.filter(v=>!g.has(v.name))}).rawItems)}return e}function a4(t,e,n,s,i,a,c,u){const h=new Map((u||[]).filter(v=>Array.isArray(v.route)&&v.route.length).map(v=>[v.route.join("/"),v])),f=v=>{if(v==="local")return-1;const _=h.get(v);if(!_)return Number.MAX_SAFE_INTEGER;const b=c.indexOf(ao(_));return b>=0?b:Number.MAX_SAFE_INTEGER};return[...new Set(t.map(v=>v.node||"local"))].map((v,_)=>({position:v,index:_})).sort((v,_)=>f(v.position)-f(_.position)||v.index-_.index).map(({position:v})=>v).flatMap(v=>{const _=t.filter(j=>(j.node||"local")===v),b=new Map((e.get(v)||[]).map(j=>[j.key,j])),x=new Map(_.map(j=>[j.key,j])),L=_.map(j=>{const E=b.get(j.key);return{...j,label:(E==null?void 0:E.label)||j.label,live:(E==null?void 0:E.live)??j.live,fresh:(E==null?void 0:E.fresh)===!0,activity:(E==null?void 0:E.activity)??j.activity,selectable:v==="local"?j.selectable:(E==null?void 0:E.live)===!0}}),k=kr(L,n,a(v).filter,wi(s,v)),R=new Set(k.map(j=>j.key)),S=kr(L.filter(j=>!R.has(j.key)),n,"all",wi(s,v));return[...k,...S].map(j=>{const E=x.get(j.key);return E?{...E,selectable:j.selectable}:null}).filter(Boolean)})}function l4({token:t,current:e,onPick:n,onClose:s,panelPort:i=0,nodePanelPorts:a={},localNodeLabel:c="",hostByRoute:u={},onDesignateCell:h,onClearHostCell:f,onLiveHostApplied:g,sideKey:v=null,onToggleSide:_,pollMs:b=s4}){const[x,L]=w.useState(F0),[k,R]=w.useState(!1),[S,j]=w.useState(!1),[E,F]=w.useState(""),[$,G]=w.useState(null),K="stream",[Y,te]=w.useState(Wg),q=X=>te(ue=>CE(ue+X)),[D,I]=w.useState(null),[O,M]=w.useState(!1),[z,T]=w.useState(""),A=w.useRef(null),N=w.useRef(null),U=w.useMemo(()=>r4(x),[x]),P=w.useMemo(()=>o4(x),[x]),{pins:H,orders:ie,views:J,viewFor:Q,togglePin:ve,removePin:de,pinError:ne,canMoveRoster:xe,moveRoster:$e,stepRoster:rt}=Cv(),{order:je}=ch(),Ie=w.useMemo(()=>a4(U,P,H,ie,J,Q,je,x.nodeGroups),[U,P,H,ie,J,Q,je,x.nodeGroups]),oe=w.useMemo(()=>k?Ie:Ie.filter(X=>X.selectable||X.degraded&&X.active||X.keepVisible===!0),[Ie,k]),Ne=w.useMemo(()=>$?oe.find(X=>X.key===$&&X.selectable):null,[oe,$]);w.useEffect(()=>{$&&!oe.some(X=>X.key===$&&X.selectable)&&G(null)},[oe,$]);const me=w.useMemo(()=>D?U.find(X=>X.key===D.key):null,[U,D]),Ce=!!(D&&me);w.useEffect(()=>{ne&&ne.message&&F(ne.message)},[ne]),w.useEffect(()=>{var Ze;const X=document.activeElement;(Ze=N.current)==null||Ze.focus();const ue=se=>{se.key==="Escape"&&!Ce&&s()};return document.addEventListener("keydown",ue),()=>{var se;document.removeEventListener("keydown",ue),(se=X==null?void 0:X.focus)==null||se.call(X)}},[s,Ce]),w.useEffect(()=>{let X=!0,ue=!1;const Ze=async()=>{if(ue)return;ue=!0;const Be=F0(),ht=Array.isArray(Be.nodeGroups)?Be.nodeGroups:[],Pt=lm(t),St=dt=>dt.kind!=="vl"&&Array.isArray(dt.route)&&dt.route.length>0,Nt=await Promise.all(ht.filter(St).map(async dt=>({group:dt,result:await lm(t,dt.route)}))),ut=await Pt;if(!X)return;const zt=new Map(Nt.map(({group:dt,result:qt})=>[JSON.stringify(dt.route||[]),qt])),Yt=ht.map(dt=>{if(!St(dt))return{...dt,switcherFresh:!1};const qt=zt.get(JSON.stringify(dt.route||[]));return qt?{...dt,sessions:qt.sessions||dt.sessions||[],cells:qt.cells||dt.cells||[],switcherFresh:qt.fresh}:{...dt,switcherFresh:!1}}),Ut=nC({...Be,sessions:ut.sessions||Be.sessions||[],cells:ut.cells||Be.cells||[],localFresh:ut.fresh,nodeGroups:Yt,refreshedAt:Date.now()});L(Ut),j(!0),ue=!1};Ze();const se=setInterval(Ze,b);return()=>{X=!1,clearInterval(se)}},[t,b]);const[V,ge]=w.useState(""),Le={getLiveHost:X=>Jd(t,X),designateHostCell:(X,ue,Ze)=>Qd(t,X,ue,Ze),clearHostCell:(X,ue)=>Zd(t,X,ue)},ke=X=>(u[Cs(X)]||{}).hostCell||null,We=async(X,ue)=>{ge(X.key);const Ze=await th({action:ue?"remove":"use",cellId:X.cellName,route:X.route||[],api:Le});ge(""),F(p(Ze.messageKey).replace("{cell}",Ze.hostCell||X.cellName)),Ze.ok&&g&&g({route:X.route||[],hostCell:Ze.hostCell,revision:Ze.revision})},Re=X=>X.degraded?p("cell-degraded"):X.verified?X.selectable?X.working?p("cell-working"):p("cell-idle"):p("cell-off"):p("cell-switcher-not-confirmed"),_e=async X=>{if(F(""),!X.selectable){F(X.verified?p("cell-switcher-not-active"):p("cell-switcher-not-confirmed"));return}if(X.verified!==!0){n({session:X.session,...X.node?{node:X.node}:{},cellName:X.cellName}),s();return}T(X.key);try{const ue=await lm(t,X.route),Ze=(ue.cells||[]).find(se=>(se==null?void 0:se.cell)===X.cellName&&(se==null?void 0:se.tmuxSession)===X.session);if(ue.fresh!==!0){F(p("cell-switcher-verify-failed"));return}if(!EE(Ze,ue.sessions,ue.fresh)){F(p("cell-switcher-not-active"));return}n({session:X.session,...X.node?{node:X.node}:{},cellName:X.cellName}),s()}catch{F(p("cell-switcher-verify-failed"))}finally{T("")}},st=X=>{if(!X.selectable){_e(X);return}if($===X.key){_e(X);return}G(X.key)},Xe=w.useRef(null),De=8,He=X=>{const ue=Xe.current;if(X.isPrimary===!1){ue&&ue.state==="open"&&(ue.state="invalid");return}if(ue&&ue.state==="open"&&(ue.id!==X.pointerId||ue.row!==X.currentTarget)){ue.state="invalid";return}Xe.current={id:X.pointerId,row:X.currentTarget,x:X.clientX,y:X.clientY,maxDelta:0,state:"open"}},Ke=X=>{const ue=Xe.current;!ue||ue.state!=="open"||ue.id!==X.pointerId||(ue.maxDelta=Math.max(ue.maxDelta,Math.hypot(X.clientX-ue.x,X.clientY-ue.y)),ue.maxDelta>De&&(ue.state="invalid"))},wt=X=>{const ue=Xe.current;!ue||ue.id!==X.pointerId||ue.state!=="open"||(ue.state=ue.maxDelta<=De?"tap":"invalid")},fe=X=>{const ue=Xe.current;ue&&ue.id===X.pointerId&&(ue.state="invalid")},he=X=>{const ue=Xe.current;return Xe.current=null,X.detail===0?!0:!ue||ue.state==="invalid"||ue.row!==X.currentTarget?!1:Math.hypot(X.clientX-ue.x,X.clientY-ue.y)<=De},Z=X=>({onToggleLive:()=>We(X,ke(X.route||[])===X.cellName),onTogglePin:()=>Ev({view:uh({item:{key:X.key,value:{cell:X.cellName}},pins:H,hostByRoute:u,route:X.route||[]}),itemKey:X.key,togglePin:ve,removePin:de})});return l.jsxs("div",{className:"nc-cell-switcher-backdrop",onClick:s,children:[Ne&&l.jsxs("div",{className:"nc-cell-switcher-anteprima","data-testid":"cell-switcher-anteprima",onClick:X=>X.stopPropagation(),children:[l.jsxs("div",{className:"nc-cell-switcher-anteprima-testa",children:[l.jsxs("b",{children:[p("cell-switcher-preview-word")," ",Ne.cellName]}),l.jsx("small",{children:p("cell-switcher-preview-readonly")}),l.jsxs("span",{className:"nc-cell-switcher-anteprima-zoom",children:[l.jsx("button",{type:"button",onClick:()=>q(-1),title:p("zoom-out"),"aria-label":p("zoom-out"),children:"−"}),l.jsxs("span",{"data-testid":"cell-switcher-fontsize",children:[Y," px"]}),l.jsx("button",{type:"button",onClick:()=>q(1),title:p("zoom-in"),"aria-label":p("zoom-in"),children:"+"})]})]}),l.jsx(vv,{row:Ne,token:t,source:K,chrome:!1,panelPort:Cc(Ne.route||[],a,i),liveHost:Va({liveHost:u[Cs(Ne.route||[])],cells:x.cells||[]}),onLiveHostApplied:g,fontSize:Y,readOnly:!0})]}),l.jsxs("aside",{ref:A,className:`nc-cell-switcher${Ne?" with-anteprima":""}`,role:"dialog","aria-label":p("fleet-cells"),tabIndex:-1,onClick:X=>X.stopPropagation(),children:[l.jsxs("div",{className:"nc-cell-switcher-controls",children:[l.jsx("b",{children:p("cell-switcher-title")}),c&&l.jsx("small",{className:"nc-cell-switcher-node",children:c}),l.jsxs("div",{className:"nc-cell-switcher-filter",role:"group","aria-label":p("cell-switcher-filter"),children:[l.jsx("button",{type:"button",className:k?"":"on","aria-pressed":!k,onClick:()=>{F(""),R(!1)},children:p("cell-switcher-show-active")}),l.jsx("button",{type:"button",className:k?"on":"","aria-pressed":k,onClick:()=>{F(""),R(!0)},children:p("cell-switcher-show-all")})]}),l.jsx("button",{type:"button",className:`nc-cell-switcher-reorder${O?" on":""}`,"aria-pressed":O,title:p("reorder-help"),"aria-label":p("reorder"),onClick:()=>{F(""),M(X=>!X)},children:"↕"}),l.jsx("button",{ref:N,type:"button",className:"nc-cell-switcher-close","aria-label":p("cell-switcher-close"),title:p("cell-switcher-close"),onClick:s,children:"×"})]}),!Ne&&l.jsx("div",{className:"nc-cell-switcher-hint",children:p("cell-switcher-tap-hint")}),l.jsxs("div",{className:"nc-cell-switcher-list",children:[(()=>{const X=Va({liveHost:u[Cs([])],cells:x.cells||[]});if(!X||!X.cell)return null;const{modeKey:ue}=vP(X);return l.jsx("div",{className:"nc-cell-switcher-live-strip","data-testid":"cell-switcher-live-strip",children:p("cell-switcher-live-strip").replace("{cell}",X.cell).replace("{mode}",p(ue||"live-host-mode-unknown"))})})(),!S&&l.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-refreshing")}),S&&oe.length===0&&l.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-empty-active")}),oe.map((X,ue)=>{const Ze=(e==null?void 0:e.session)===X.session&&((e==null?void 0:e.node)||"")===X.node,se=!!D&&D.key===X.key,Be=v!=null&&v===X.key,ht=Re(X),Pt=dg(p,X.activity),St=hg(p,X.telemetry),Nt=[Pt,St].filter(Boolean).join(" · "),ut=X.node||"local",zt=ue>0?oe[ue-1].node||"local":null,Yt=ut!==zt,Ut=P.get(ut)||U.filter(dt=>(dt.node||"local")===ut);return l.jsxs(w.Fragment,{children:[Yt&&l.jsx("div",{className:"nc-cell-switcher-position",children:p("cell-switcher-group").replace("{node}",X.nodeLabel||c||p("cell-switcher-group-local"))}),l.jsxs("div",{className:`nc-cell-switcher-row${Ze?" current":""}${$===X.key?" selected":""}${Be?" side":""}${X.selectable?"":" off"}`,"data-roster-key":X.key,"data-position":ut,children:[O&&l.jsx(Gi,{position:ut,itemKey:X.key,label:X.cellName,canMove:xe,onMove:(dt,qt)=>$e(ut,dt,qt,Ut),onStep:dt=>rt(ut,X.key,dt,Ut)}),l.jsx("span",{className:"nc-cell-switcher-peek",children:l.jsx("span",{className:`nc-cell-switcher-dot${X.degraded?" warn":X.live?` on${X.working?" working":""}`:""}`})}),l.jsx("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":Ze?"true":void 0,"aria-disabled":!X.selectable,"data-selected":$===X.key?"true":void 0,disabled:z===X.key,onPointerDown:He,onPointerMove:Ke,onPointerUp:wt,onPointerCancel:fe,onClick:dt=>{he(dt)&&st(X)},children:l.jsxs("span",{className:"nc-cell-switcher-copy",children:[l.jsxs("span",{className:"nc-cell-switcher-nameline",children:[l.jsx("b",{children:X.cellName}),Ze&&l.jsx("span",{className:"nc-cell-switcher-here",children:p("cell-switcher-here")}),$===X.key&&l.jsx("span",{className:"nc-cell-switcher-taptwo",children:p("cell-switcher-two-taps")})]}),l.jsxs("span",{className:"nc-cell-switcher-stateline",children:[l.jsx("small",{className:"nc-cell-switcher-state",children:ht}),Nt&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:Nt})]})]})}),_&&l.jsx("button",{type:"button",className:`nc-cell-switcher-side${Be?" on":""}`,title:p(Be?"cell-switcher-side-remove":"cell-switcher-side-add"),"aria-label":p(Be?"cell-switcher-side-remove":"cell-switcher-side-add"),"aria-pressed":Be?"true":"false",disabled:Ze||!X.selectable,onClick:dt=>{dt.stopPropagation(),!Ze&&X.selectable&&_(X)},children:l.jsx(Tt,{name:"splitView",size:20})}),l.jsx("button",{type:"button",className:`nc-cell-switcher-menu${se?" on":""}`,title:`${p("cell-actions-open")}: ${X.cellName}`,"aria-label":`${p("cell-actions-open")}: ${X.cellName}`,"aria-haspopup":"menu","aria-expanded":se?"true":"false",onClick:dt=>{dt.stopPropagation(),I({key:X.key})},children:"⋯"})]})]},X.key)})]}),E&&l.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:E}),Ce&&(()=>{const X=me,ue=Nv({...lo({item:{key:X.key,value:{cell:X.cellName}},cellName:X.cellName,route:X.route||[],pins:H,hostByRoute:u}),canBoot:!1,alive:X.selectable,handlers:Z(X)});return l.jsx(Rv,{cellName:X.cellName,items:ue,busy:V===X.key,onClose:()=>I(null)})})()]})]})}const c4=2e3;function u4(t){if(t.kind==="gap")return`${p("vl-events-gap")} ${t.count||"?"}`;if(t.kind==="truncate")return p("vl-events-truncated");if(t.kind==="turn_end")return p("vl-events-turn-end");if(t.kind==="done")return p("vl-events-done");if(t.kind==="writer_epoch")return p("vl-events-writer-epoch");if(t.kind==="tool_start")return`${p("vl-events-tool")} ${t.name||""}`.trim();if(t.kind==="tool_end"){const e=t.isError?p("vl-events-tool-failed"):p("vl-events-tool-ok");return`${p("vl-events-tool")} ${t.name||""} — ${e}`.trim()}return t.kind==="usage"?t.text||p("vl-events-usage"):t.text||""}function d4({token:t,nodeId:e,route:n=[]}){const[s,i]=w.useState([]),[a,c]=w.useState(!1),u=w.useRef(0),h=w.useRef(!1);return w.useEffect(()=>{let f=!0;u.current=0,h.current=!1,i([]);const g=async()=>{if(!h.current){h.current=!0;try{const b=await $N(t,e,u.current,n);if(!f)return;c(!1);const L=(Array.isArray(b==null?void 0:b.events)?b.events:[]).filter(k=>Number.isSafeInteger(k==null?void 0:k.seq)&&k.seq>u.current);L.length&&(i(k=>k.concat(L).slice(-500)),u.current=L[L.length-1].seq),Number.isSafeInteger(b==null?void 0:b.cursor)&&b.cursor>u.current&&(u.current=b.cursor)}catch{f&&c(!0)}finally{h.current=!1}}},v=()=>{g().catch(()=>{})};v();const _=setInterval(v,c4);return()=>{f=!1,clearInterval(_)}},[t,e,JSON.stringify(n)]),l.jsxs("div",{className:"nc-vl-events",children:[a&&l.jsx("div",{className:"nc-set-hint nc-vl-events-stale",children:p("vl-events-stale")}),s.length===0&&!a&&l.jsx("small",{className:"nc-set-hint","data-testid":"vl-events-empty",children:p("vl-events-empty")}),s.length>0&&l.jsx("ol",{className:"nc-vl-events-list",children:s.map(f=>l.jsx("li",{"data-testid":`vl-ev-${f.seq}`,className:`nc-vl-ev nc-vl-ev-${f.kind}${f.isError?" error":""}${f.kind==="gap"?" gap":""}`,children:u4(f)},`${f.seq}-${f.kind}`))})]})}function i1({peer:t,token:e,onBack:n}){var s;return zn(),t?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:p("back"),children:[l.jsx(Tt,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:p("back")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:t.label,children:t.label}),((s=t.session)==null?void 0:s.profile)&&l.jsxs("small",{className:"nc-bar-sub",children:[t.session.profile," · ",p("vl-events-title")]})]}),l.jsx("span",{className:"nc-bar-right"})]}),l.jsx("div",{className:"nc-vl-session-body",children:l.jsx(d4,{token:e,nodeId:t.nodeId,route:t.route||[]})})]}):null}const qd="nc_dual_side";function qg(t,e){return!t||!e?!1:t.session===e.session&&(t.node||"")===(e.node||"")}function h4(t,e,n){return!n||!n.session||t&&qg(t,n)?e:e&&qg(e,n)?null:{session:n.session,...n.node?{node:n.node}:{},...n.ownerId?{ownerId:n.ownerId}:{}}}function f4(){try{const t=JSON.parse(localStorage.getItem(qd)||"null");return!t||!t.main||!t.side||!t.main.session||!t.side.session?null:t}catch{return null}}function p4(t,e){try{if(!t||!e||!t.session||!e.session){localStorage.removeItem(qd);return}const n=s=>({session:s.session,...s.node?{node:s.node}:{}});localStorage.setItem(qd,JSON.stringify({main:n(t),side:n(e)}))}catch{}}function r1(){try{localStorage.removeItem(qd)}catch{}}const m4=.2;function ad(t){return Math.max(m4,t)}function g4(){try{if(typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches)return!0}catch{}try{return Number(globalThis.navigator&&globalThis.navigator.maxTouchPoints)>0}catch{return!1}}function v4({onSubmit:t,reason:e=""}){zn();const[n,s]=w.useState(""),[i,a]=w.useState(g4),c=n.trim(),u=h=>{h&&h.preventDefault&&h.preventDefault(),c&&t(c,i)};return l.jsxs("form",{className:"nc-auth",onSubmit:u,children:[l.jsx("p",{children:p("auth-prompt")}),e==="invalid"&&l.jsx("p",{className:"nc-auth-error",role:"alert",children:p("auth-invalid")}),l.jsx("input",{type:"text",value:n,placeholder:"token","aria-label":"token",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,onChange:h=>s(h.target.value)}),l.jsxs("label",{children:[l.jsx("input",{type:"checkbox",checked:i,onChange:h=>a(h.target.checked)})," ",p("remember-device")]}),l.jsx("button",{type:"submit",disabled:!c,children:"ok"})]})}const cm=t=>_s(Ii(t)).length===0;function za(t,e){return Array.isArray(t)?t.flatMap(n=>{var c;const s={session:n.session,height:1,fontSize:n.fontSize};n.node&&(s.node=n.node),n.ownerId&&(s.ownerId=n.ownerId);const i=(c=e({columns:[{width:1,tiles:[s]}]}).columns[0])==null?void 0:c.tiles[0];if(!i)return[];const a={session:i.session,x:n.x,y:n.y,w:n.w,h:n.h,fontSize:n.fontSize};return i.node&&(a.node=i.node),i.ownerId&&(a.ownerId=i.ownerId),[a]}):[]}function o1(t,e){return t.length?t:Array.isArray(e.floating)&&e.floating.length?[]:void 0}function _4(t,e,n,s,i){const a=c=>za(c&&c.floating,u=>Ha(u,s,i));return LP(a(t),a(e),n)}function a1(t,e,n,s,i,a){const c=v=>Ha(v,i,a),u=v=>za(v&&v.floating,c),{grid:h,floating:f}=Bd(n),g=AP(s(h),_4(t,e,f,i,a),{grid:t?c(t.layout):ho(),floating:u(t)},{grid:c(e.layout),floating:u(e)},{grid:h,floating:f});return kg(g.grid,g.floating)}const um=t=>Array.isArray(t)?t.join("/"):"",y4="nc-decks-cache-v1",NE=t=>`${y4}:${t}`;function w4(t){if(!t)return[];try{const e=localStorage.getItem(NE(t));if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)&&n.every(s=>s&&typeof s.id=="string"&&typeof s.name=="string")?n:[]}catch{return[]}}function b4(t,e){if(t)try{localStorage.setItem(NE(t),JSON.stringify(e))}catch{}}function S4(t){const e=new Set,n=[];for(const s of Array.isArray(t)?t:[])!s||!Ws.test(String(s.instanceId||""))||!Array.isArray(s.route)||!s.route.length||e.has(s.instanceId)||(e.add(s.instanceId),n.push({instanceId:s.instanceId,route:[...s.route],label:String(s.label||s.name||s.route.join(" › ")),status:s.status||"offline",stale:s.stale===!0,checking:s.checking===!0}));return n.sort((s,i)=>s.label.localeCompare(i.label))}function ec(t){return{instanceId:t.ownerId,route:t.ownerRoute||[],label:t.ownerLabel,status:t.available===!1?"offline":"up"}}function Oo(t,e,n,s=!1,i=!0){const a=e.instanceId;return{...t,id:Vo(s?null:a,t.name),ownerId:a,ownerRoute:s?[]:[...e.route],ownerLabel:s?"Local":e.label,local:s,available:i,ownerTopology:Array.isArray(n)?n:[],layout:Mg(t.layout,a,n)}}function x4(t,e,n,s,i=[],a=[]){const[c,u]=w.useState([]),[h,f]=w.useState(!1),[g,v]=w.useState("idle"),[_,b]=w.useState(""),[x,L]=w.useState(!1),[k,R]=w.useState(""),S=w.useRef([]),j=w.useRef([]),E=w.useRef([]),F=w.useRef(new Map),$=w.useRef(""),G=w.useRef(e),K=w.useRef(n),Y=w.useRef(!1),te=w.useRef(!0),q=w.useRef(""),D=w.useMemo(()=>S4(i),[i]),I=D.map(oe=>`${oe.instanceId}:${um(oe.route)}`).join("|"),O=D.map(oe=>`${oe.instanceId}:${oe.status??""}:${oe.checking?"checking":"settled"}`).join("|"),M=w.useRef(new Map(D.map(oe=>[oe.instanceId,oe.checking?"pending":oe.status])));j.current=D,E.current=a,K.current=n,G.current=e,S.current=c;const z=w.useCallback(oe=>Ha(oe.layout,$.current,j.current),[]),T=w.useCallback(()=>Xl(G.current,$.current),[]),A=w.useCallback(oe=>(Array.isArray(oe)?oe:[]).find(Ne=>Ne.id===T()),[T]),N=w.useCallback((oe,Ne=!0,me)=>{const Ce=me===void 0?T():Xl(me,$.current),V=Tp(oe,Ql(),E.current),ge=S.current.some(ke=>ke.id===Ce);S.current=V,u(V),b4($.current,V.map(ke=>{if(!ke.refreshFailedAt)return ke;const We={...ke};return delete We.refreshFailedAt,We}));const Le=V.find(ke=>ke.id===Ce);if(Ne&&Le){te.current=!0;const ke=kg(z(Le),za(Le.floating,We=>Ha(We,$.current,j.current)));s(ke),Le.local&&YI(Le.name,Ii(ke))}else ge&&!Le&&(te.current=!0,s(ho()),b("deck non più condiviso dal nodo owner"));WI(V.filter(ke=>ke.local).map(ke=>ke.name))},[s,z]),U=w.useCallback(async oe=>{let Ne=await Fu(t);const me=Ne.decks.find(Ce=>Ce.name==="main");if(Ne.decks.length===1&&me&&me.revision===0&&cm(me.layout)){const Ce=UI(),V=Ii(Tg("main")||ho());if(!cm(V)){const ge=Mg(V,oe,[]);Ne.decks[0]=await Hu(t,"main",ge,0,[])}for(const ge of Ce.filter(Le=>Le!=="main"))try{let Le=await $w(t,ge,[]);const ke=Ii(Tg(ge)||ho());cm(ke)||(Le=await Hu(t,ge,Mg(ke,oe,[]),Le.revision,[]))}catch{}Ne=await Fu(t)}return Ne},[t]),P=w.useCallback((oe,Ne)=>{const me=new Map(Ne.map(ge=>[ge.id,ge])),Ce=new Set,V=[];for(const ge of S.current){if(ge.local||ge.ownerId!==oe.instanceId){V.push(ge);continue}const Le=me.get(ge.id);Le&&(V.push(Le),Ce.add(ge.id))}for(const ge of Ne)Ce.has(ge.id)||V.push(ge);N(V,!1)},[N]),H=w.useCallback(async oe=>{try{const[Ne,me]=await Promise.all([Fu(t,oe.route),Dw(t,oe.route).catch(()=>({nodes:[]}))]);P(oe,Ne.decks.map(Ce=>Oo(Ce,oe,me.nodes,!1,!0)))}catch(Ne){if(Ne&&(Ne.status===403||Ne.status===404)){P(oe,[]);return}const me=S.current.filter(Ce=>!Ce.local&&Ce.ownerId===oe.instanceId).map(Ce=>({...Ce,stale:!0,refreshFailedAt:Date.now(),ownerRoute:[...oe.route],ownerLabel:oe.label}));P(oe,me)}},[t,P]),ie=w.useCallback(async({migrate:oe=!1}={})=>{const Ne=await Ic(t,[]),me=Ws.test(String(Ne.instanceId||""))?Ne.instanceId:"";if(!me)throw new Error("instanceId locale non disponibile");$.current=me,R(me);const[Ce,V]=await Promise.all([oe?U(me):Fu(t),Dw(t,[]).catch(()=>({nodes:[]}))]),ge={instanceId:me,route:[],label:"Local"},Le=Ce.decks.map(Xe=>Oo(Xe,ge,V.nodes,!0,!0)),ke=new Map(j.current.map(Xe=>[Xe.instanceId,Xe])),We=S.current.length?S.current:w4(me),Re=F.current,_e=Date.now(),st=We.filter(Xe=>!Xe.local).flatMap(Xe=>{const De=ke.get(Xe.ownerId);if(!De){const wt=Re.get(Xe.ownerId);return wt===void 0?(Re.set(Xe.ownerId,_e),[{...Xe,available:!1,stale:!0}]):_e-wt>Sv?[]:[{...Xe,available:!1,stale:!0}]}Re.delete(Xe.ownerId);const He=De.status==="up",Ke=De.status==="pending"||De.checking===!0;return[{...Xe,available:Ke?Xe.available:He?Xe.available!==!1:!1,stale:De.stale===!0,ownerRoute:[...De.route],ownerLabel:De.label}]});return setTimeout(()=>{for(const Xe of ke.values())Xe.status==="up"&&!Xe.checking&&H(Xe)},0),[...Le,...st]},[t,U,H,I]);w.useEffect(()=>{if(!t)return;let oe=!1;const Ne=q.current!==t;return q.current=t,ie({migrate:Ne}).then(me=>{if(oe)return;const Ce=A(S.current),V=A(me),ge=V&&(!Ce||V.revision>Ce.revision||Ce.available!==V.available||um(Ce.ownerRoute)!==um(V.ownerRoute));N(me,Ne||!!ge&&!Y.current),f(!0),V&&b("")}).catch(me=>{oe||(f(!0),b(String(me.message||me)))}),()=>{oe=!0}},[N,ie,I,t,A]),w.useEffect(()=>{if(!S.current.length)return;const oe=Tp(S.current,Ql(),a);(oe.length!==S.current.length||oe.some((me,Ce)=>me.id!==S.current[Ce].id))&&(S.current=oe,u(oe))},[a]),w.useEffect(()=>{const oe=M.current,Ne=new Map;for(const me of j.current){if(me.checking||me.status==="pending"){Ne.set(me.instanceId,oe.get(me.instanceId)||"pending");continue}me.status==="up"&&oe.get(me.instanceId)!=="up"&&H(me),Ne.set(me.instanceId,me.status)}M.current=Ne},[O,H]);const J=w.useCallback(async(oe,Ne=!0)=>{if(!h||!Y.current)return!0;const me=oe===void 0?T():Xl(oe,$.current),Ce=S.current.find(V=>V.id===me);if(!Ce)return b(`deck inesistente: ${me}`),!1;if(Ce.available===!1)return b(`nodo owner offline: ${Ce.ownerLabel}`),!1;v("saving");try{const{grid:V,floating:ge}=Bd(K.current),Le=Jl(Ii(V),Ce.ownerId,Ce.ownerTopology),ke=za(ge,_e=>Jl(_e,Ce.ownerId,Ce.ownerTopology)),We=await Hu(t,Ce.name,Le,Ce.revision,Ce.ownerRoute,o1(ke,Ce)),Re=Oo(We,ec(Ce),Ce.ownerTopology,Ce.local,!0);return N(S.current.map(_e=>_e.id===me?Re:_e),!1),Y.current=!1,v("saved"),b(""),L(!1),setTimeout(()=>v("idle"),1500),!0}catch(V){if(Ne&&V.status===409&&V.data&&V.data.current){const ge=S.current.find(Le=>Le.id===me);if(ge){const Le=Oo(V.data.current,ec(ge),ge.ownerTopology,ge.local,!0),ke=a1(ge,Le,K.current,We=>We,$.current,j.current);return jP(ke,K.current)||(K.current=ke,te.current=!0,s(ke)),N(S.current.map(We=>We.id===me?Le:We),!1),Y.current=!0,J(me,!1)}}return v("error"),b(String(V.message||V)),V.status===409&&L(!0),!1}},[h,t,N,s]),Q=w.useCallback(async()=>{try{const oe=await ie();Y.current=!1,L(!1),N(oe,!0),b("")}catch(oe){b(String(oe.message||oe))}},[ie,N]);w.useEffect(()=>{if(!h)return;const oe=te.current&&!Y.current;if(te.current=!1,oe)return;Y.current=!0,v("saving");const Ne=setTimeout(J,650);return()=>clearTimeout(Ne)},[n,h,J]),w.useEffect(()=>{if(!h)return;const oe=()=>{if(!Y.current)return;const Ne=S.current.find(Le=>Le.id===T());if(!Ne||Ne.available===!1)return;const{grid:me,floating:Ce}=Bd(K.current),V=Jl(Ii(me),Ne.ownerId,Ne.ownerTopology),ge=za(Ce,Le=>Jl(Le,Ne.ownerId,Ne.ownerTopology));_5(t,Ne.name,V,Ne.revision,Ne.ownerRoute,o1(ge,Ne))};return window.addEventListener("pagehide",oe),window.addEventListener("beforeunload",oe),()=>{window.removeEventListener("pagehide",oe),window.removeEventListener("beforeunload",oe)}},[h,t,T]),w.useEffect(()=>{if(!h)return;const oe=setInterval(async()=>{try{const Ne=await ie(),me=A(S.current),Ce=A(Ne),V=!!(Ce&&me&&Ce.revision>me.revision),ge=!!(Ce&&(!me||V||me.available!==Ce.available));if(V&&Y.current&&Ce){const Le=a1(me,Ce,K.current,ke=>PP(z(Ce),ke),$.current,j.current);N(Ne,!1),s(Le);return}N(Ne,ge&&!Y.current)}catch{}},5e3);return()=>clearInterval(oe)},[h,ie,N,z,s]);const ve=w.useCallback(oe=>{s(Ne=>{const me=oe(Ne);return me!==Ne&&(te.current=!0),me})},[]),de=async(oe,Ne=null)=>{const me=Ne===Xi?S.current.find(ge=>ge.local):Ne?S.current.find(ge=>ge.ownerId===Ne):null;if(!me||me.available===!1)throw new Error("nodo owner non disponibile");const Ce=await $w(t,oe,me.ownerRoute),V=Oo(Ce,ec(me),me.ownerTopology,me.local,!0);return N([...S.current,V],!1),V},ne=async(oe,Ne)=>{const me=S.current.find(ke=>ke.id===oe);if(!me)throw new Error("deck inesistente");if(Xl(oe,$.current)===T()&&Y.current&&!await J(oe))throw new Error(`salvataggio di "${me.name}" fallito: rinomina annullata`);const Ce=S.current.find(ke=>ke.id===oe);if(!Ce)throw new Error("deck inesistente");const V=await y5(t,Ce.name,Ne,Ce.revision,Ce.ownerRoute),ge=Oo(V,ec(Ce),Ce.ownerTopology,Ce.local,!0),Le=Ce.local?Xi:Ce.ownerId;return Mp(KI(Ql(),Le,oe,ge.id)),N(S.current.map(ke=>ke.id===oe?ge:ke),!1),ge},xe=async oe=>{const Ne=S.current.find(Ce=>Ce.id===oe);if(!Ne)throw new Error("deck inesistente");Xl(oe,$.current)===T()&&(Y.current=!1),await w5(t,Ne.name,Ne.revision,Ne.ownerRoute);const me=Ne.local?Xi:Ne.ownerId;Mp(VI(Ql(),me,oe)),N(S.current.filter(Ce=>Ce.id!==oe),!1)},$e=(oe,Ne)=>{const me=S.current.find(We=>We.id===oe),Ce=S.current.find(We=>We.id===Ne);if(!me||!Ce)return!1;const V=me.local?Xi:me.ownerId,ge=Ce.local?Xi:Ce.ownerId;if(V!==ge)return!1;const Le=S.current.filter(We=>(We.local?Xi:We.ownerId)===V).map(We=>We.id),ke=Mp(qI(Ql(),V,oe,Ne,Le));return N(Tp(S.current,ke),!1),!0},rt=async(oe,Ne)=>{const me=S.current.find(We=>We.id===oe);if(!me)throw new Error("deck inesistente");if(me.available===!1)throw new Error(`nodo owner offline: ${me.ownerLabel}`);const Ce=_C(Ne,$.current,j.current);if(!Ce)throw new Error("riferimento sessione non valido");const V=z(me),ge=Jl(Kk(V,Ce),me.ownerId,me.ownerTopology),Le=await Hu(t,me.name,ge,me.revision,me.ownerRoute),ke=Oo(Le,ec(me),me.ownerTopology,me.local,!0);return N(S.current.map(We=>We.id===oe?ke:We),!1),ke},je=w.useCallback(oe=>kg(z(oe),za(oe.floating,Ne=>Ha(Ne,$.current,j.current))),[z]);return{decks:c,records:c,localNodeId:k,ready:h,saveState:g,error:_,setError:b,conflict:x,reloadCurrent:Q,saveNow:J,select:async oe=>{if(Y.current&&!await J(T()))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const Ne=S.current.find(me=>me.id===oe);if(!Ne)throw new Error(`deck inesistente: ${oe}`);return Y.current=!1,te.current=!0,je(Ne)},add:de,rename:ne,remove:xe,reorder:$e,addTileTo:rt,viewUpdate:ve,vistaMaterializzata:je,localMainId:Vo(null,"main"),parseDeckId:Uc}}const k4="/sw.js",Kg="nc-sw-update";let Pc=null,Kd=!1,Vd=null,RE=Object.freeze({needed:!1,kind:null,version:"",browserVersion:""}),LE=!1;function l_(){typeof window<"u"&&window.dispatchEvent(new Event(Kg))}function c_(){const t=Vd||(Kd?{kind:"reload",version:"",browserVersion:""}:null);RE=Object.freeze({needed:!!t,kind:(t==null?void 0:t.kind)||null,version:(t==null?void 0:t.version)||"",browserVersion:(t==null?void 0:t.browserVersion)||""})}function l1(){return RE}function C4(t){return typeof window>"u"?()=>{}:(window.addEventListener(Kg,t),()=>window.removeEventListener(Kg,t))}function u_(t){Kd!==t&&(Kd=t,c_(),l_())}const ld="nc-auto-reload",Yd="nc-reload";function d_(){try{return typeof location<"u"?location:null}catch{return null}}function AE(){try{return typeof history<"u"?history:null}catch{return null}}function E4(t){const e=t===void 0?d_():t;if(!e||typeof e.search!="string")return null;try{return new URLSearchParams(e.search).get(Yd)}catch{return null}}function N4(t,{location:e,history:n}={}){const s=e===void 0?d_():e,i=n===void 0?AE():n;if(!s||!i||typeof i.replaceState!="function")return!1;try{const a=new URLSearchParams(s.search||"");return a.set(Yd,t),i.replaceState(i.state??null,"",`${s.pathname||"/"}?${a.toString()}${s.hash||""}`),!0}catch{return!1}}function R4({location:t,history:e}={}){const n=t===void 0?d_():t,s=e===void 0?AE():e;if(!n||!s||typeof s.replaceState!="function")return!1;try{const i=new URLSearchParams(n.search||"");if(!i.has(Yd))return!1;i.delete(Yd);const a=i.toString();return s.replaceState(s.state??null,"",`${n.pathname||"/"}${a?`?${a}`:""}${n.hash||""}`),!0}catch{return!1}}const jE="nc-update-dismissed";function ME(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function L4(t,e,n){return[t,e,n].map(s=>s||"").join("|")}let Vg=null;function A4(t,e,n){const s=n;return t&&e&&t!==e&&t!==s?{kind:"install",version:t,browserVersion:s}:e&&s&&e!==s?{kind:"stale",version:e,browserVersion:s}:null}function j4(t,e){if(!t)return!1;try{return t.getItem(jE)===e}catch{return!1}}function M4(t={}){const e=t.storage===void 0?ME():t.storage;if(Vg&&e)try{e.setItem(jE,Vg)}catch{}Kd=!1,Vd=null,c_(),l_()}function T4(t,e,n,s={}){const i=s.storage===void 0?ME():s.storage,a=n,c=L4(t,e,a);Vg=c;const u=A4(t,e,a);let h=j4(i,c)?null:u;if(h&&h.kind==="stale"){const g=`${e}|${a}`,v=E4(s.location)===g;let _=!1;if(!v&&i&&i.getItem(ld)!==g){try{i.setItem(ld,g)}catch{}_=i.getItem(ld)===g}_&&(N4(g,{location:s.location,history:s.history}),(s.applyImpl||TE)(),h=null)}const f=JSON.stringify(h)===JSON.stringify(Vd);if(Vd=h,c_(),f||l_(),!u){try{i&&i.removeItem(ld)}catch{}R4({location:s.location,history:s.history})}}const P4=1200;async function c1(t){if(typeof fetch=="function")try{await Promise.race([fetch(t,{cache:"reload"}),new Promise(e=>setTimeout(e,P4))])}catch{}}async function TE(){try{Pc&&await Pc.update()}catch{}typeof location<"u"&&(await c1(location.pathname),await c1("/version.json"),location.reload())}function I4(t){t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&u_(!0)})}function D4(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{LE&&location.reload()}),navigator.serviceWorker.register(k4).then(t=>{Pc=t,t.waiting&&u_(!0),t.addEventListener("updatefound",()=>{const e=t.installing;e&&I4(e)}),setInterval(()=>{t.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function O4(){LE=!0,u_(!1);const t=Pc&&Pc.waiting;t?(t.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function B4({hash:t="",origin:e="",pathname:n="",search:s=""}={}){const i=String(t||"").replace(/^#/,""),a=`${n||""}${s||""}`;if(!i)return{token:"",pair:"",device:"",nextUrl:a};const c=new URLSearchParams(i),u=c.get("token")||"",h=c.get("device")||"",f=/^[a-f0-9]{32}$/.test(h)?h:"",g=c.get("pair")||"",v=g?`${e||""}${n||""}#pair=${g}`:"";return{token:u,pair:v,device:f,nextUrl:a}}const PE="nc_side_w",u1="nc_side_min",$4=240,d1=new Set(["absent","present","active","unknown"]);function z4(){const t=Number(localStorage.getItem(PE));return t>=180&&t<=480?t:$4}function F4(){const t={token:"",pair:""};try{const{token:e,pair:n,device:s,nextUrl:i}=B4({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(e&&(t.token=e,S1(e,{remember:!0})),s&&y6(s),n){t.pair=n;try{sessionStorage.setItem("nc_pair",n)}catch{}}if(location.hash)try{history.replaceState(null,"",i)}catch{}}catch{}if(t.token||(t.token=yN()),!t.pair){const e=sessionStorage.getItem("nc_pair");e&&(t.pair=e)}return t}function h1(t){try{return Ii(Tg(t))}catch{return ho()}}function f1(t){if(!t)return"";const e=Math.floor(Date.now()/1e3)-t;return e<0||e<60?"ora":e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}g`}function H4({showComposer:t,showFiles:e,showPanel:n,hasPanel:s,rendererKind:i,filesSetting:a=null,handlers:c={}}={}){const u=[];return typeof c.onToggleComposer=="function"&&u.push({id:"keyboard",kind:"switch",on:!!t,labelKey:"bar-menu-keyboard",descKey:"bar-menu-keyboard-desc",run:c.onToggleComposer}),typeof c.onToggleFiles=="function"&&u.push(a===null?{id:"files",kind:"switch",on:!!e,labelKey:"bar-menu-files",descKey:"bar-menu-files-desc",run:c.onToggleFiles}:{id:"files",kind:"switch",on:!!a,labelKey:"bar-menu-files",descKey:"bar-menu-files-setting-desc",run:c.onToggleFiles}),s&&typeof c.onTogglePanel=="function"&&u.push({id:"panel",kind:"switch",on:!!n,labelKey:"bar-menu-panel",descKey:"bar-menu-panel-desc",run:c.onTogglePanel}),typeof c.onSwitchRenderer=="function"&&u.push({id:"renderer",kind:"switch",on:i==="webgl",labelKey:"bar-menu-renderer",descKey:"bar-menu-renderer-desc",run:c.onSwitchRenderer}),u}function U4(t,e){if(!t||!t.tmux)return"";const n=dh(t,e||{});return n.stato==="lavora"?p("cell-working"):n.stato==="attesa"?p("cell-permission"):n.stato==="ferma"?p("cell-idle"):""}function p1({session:t,node:e,ownerId:n,cellName:s,token:i,readonly:a=!1,panelPort:c=0,onBack:u,onCellSwitcher:h,cellSwitcherOpen:f=!1,liveHost:g=null,side:v=null,onSideClose:_=null,onSideGone:b=null}){var le;zn();const[x]=Dv(),L=_k(),[k,R]=w.useState(!1),[S,j]=w.useState(null),[E,F]=w.useState(()=>x.showComposer),[$,G]=w.useState(Wg),[K,Y]=w.useState(()=>kc()),te=()=>{pk(OM(kc())),typeof window<"u"&&window.location.reload()},[q,D]=w.useState(s||t),[I,O]=w.useState(""),[M,z]=w.useState(""),[T,A]=w.useState(""),[N,U]=w.useState(!1),[P,H]=w.useState(!1),ie=!!v&&P,[J,Q]=w.useState(!1),[ve,de]=w.useState({v:{main:1,side:1},h:{main:1,side:1}}),[ne,xe]=w.useState(()=>window.matchMedia("(orientation: landscape)").matches);w.useEffect(()=>{const re=window.matchMedia("(orientation: landscape)"),Te=Ge=>xe(Ge.matches);return re.addEventListener("change",Te),()=>re.removeEventListener("change",Te)},[]);const $e=ne?ve.h:ve.v,rt=w.useRef($e);rt.current=$e;const[je,Ie]=w.useState(null),[oe,Ne]=w.useState(!0),me=w.useRef(()=>{}),Ce=w.useRef(()=>!1),V=w.useRef(()=>{}),ge=w.useRef(!1),Le=w.useRef(!1),ke=w.useRef(null),We=w.useRef(null),[Re,_e]=w.useState(null),st=w.useCallback(re=>_e({source:"main",ev:re}),[]),Xe=w.useCallback(re=>_e({source:"side",ev:re}),[]),De=!!v&&(Re==null?void 0:Re.source)==="side",He=re=>{H(re),St((re?ge:ht).current),zt((re?Le:Nt).current)},Ke=v?`${v.node||""}:${v.session}`:"";w.useEffect(()=>{H(!1),Q(!1),de({v:{main:1,side:1},h:{main:1,side:1}}),Ie(null),_e(re=>re&&re.source==="side"?null:re)},[Ke]);const wt=w.useMemo(()=>{const re=new Map;return Te=>{if(re.has(Te))return re.get(Te);let Ge=Te*.6;try{const gt=document.createElement("span");gt.style.cssText="position:absolute;visibility:hidden;white-space:pre;font-family:courier-new,courier,monospace;",gt.style.fontSize=`${Te}px`,gt.textContent="0".repeat(20),document.body.appendChild(gt);const W=gt.getBoundingClientRect().width;document.body.removeChild(gt),Number.isFinite(W)&&W>0&&(Ge=W/20)}catch{}return re.set(Te,Ge),Ge}},[]),fe=Math.max(.01,$e.main+$e.side),he=((le=We.current)==null?void 0:le.clientWidth)||window.innerWidth,Z=Math.max(0,he-12)*(Math.min($e.main,$e.side)/fe)-26,X=!!v&&ne&&Z/wt(Math.max(1,$))<40,ue=re=>G(Te=>CE(Te+re));w.useEffect(()=>{f||G(Wg())},[f]);const Ze=w.useRef(()=>{}),se=w.useRef(()=>!1),Be=w.useRef(()=>{}),ht=w.useRef(!1),[Pt,St]=w.useState(!1),Nt=w.useRef(!1),[ut,zt]=w.useState(!1),Yt=w.useRef(null),[Ut,dt]=w.useState(!1),qt=()=>{const re=ie?ge:ht;re.current=!re.current,St(re.current)},In=()=>{const re=ie?Le:Nt;re.current=!re.current,zt(re.current)};w.useEffect(()=>{D(s||t),U(!1)},[s,t]);const Kt=re=>{const Te=!re||re.sessionsError?null:re.sessionsJson;let Ge=null;Te&&Array.isArray(Te.sessions)&&(Ge=Te.sessions.find(Ae=>Ae.name===t));const gt=!re||re.fleetError?null:re.fs;let W=null;gt&>.available&&Array.isArray(gt.cells)&&(W=gt.cells.find(Ae=>Ae.tmuxSession===t)),D(Lc({session:t,cell:W||(s?{cell:s}:null)})),z(typeof(W==null?void 0:W.panelUrl)=="string"?W.panelUrl.trim():""),A(typeof(W==null?void 0:W.cell)=="string"?W.cell:"");let ae="";W?ae=[`${W.engine}${W.key?`·${W.key}`:""}`,U4(W,Ge)].filter(Boolean).join(" · "):Ge&&(ae=Ge.attached?`attached · ${f1(Ge.activity)}`:Ge.activity?f1(Ge.activity):""),O(ae),Ne(!!(Ge||W))},wn=w.useRef(Kt);wn.current=Kt,w.useEffect(()=>{const re=e?e.split("/"):[],Te=Ge=>wn.current(Ge);return Te(nc(re)),Cd(i,re,Te)},[e,i]),w.useEffect(()=>{wn.current(nc(e?e.split("/"):[]))},[t,s]);const tn=w.useRef(b);tn.current=b;const bn=re=>{var Je;if(!v)return;const Te=!re||re.sessionsError?null:re.sessionsJson;let Ge=null,gt=!1;Te&&Array.isArray(Te.sessions)&&(gt=!0,Ge=Te.sessions.find(Pe=>Pe.name===v.session));const W=!re||re.fleetError?null:re.fs;let ae=null,Ae=!1;W&&W.available&&Array.isArray(W.cells)&&(Ae=!0,ae=W.cells.find(Pe=>Pe.tmuxSession===v.session)),Ie({title:Lc({session:v.session,cell:ae}),present:!!(Ge||ae)}),(gt||Ae)&&!Ge&&!ae&&((Je=tn.current)==null||Je.call(tn))},Ft=w.useRef(bn);Ft.current=bn,w.useEffect(()=>{if(!v){Ie(null);return}const re=v.node?v.node.split("/"):[],Te=Ge=>Ft.current(Ge);return Te(nc(re)),Cd(i,re,Te)},[v,v==null?void 0:v.node,i]),w.useEffect(()=>{v&&Ft.current(nc(v.node?v.node.split("/"):[]))},[v==null?void 0:v.session]);const Jt=ie?"side":"main",Qt=()=>_e(re=>re&&re.source===Jt?null:{source:Jt,ev:null}),[Zt,ls]=w.useState(nE),[cs]=w.useState(iE),[mn]=w.useState(rE),gn=H4({showComposer:E,showFiles:(Re==null?void 0:Re.source)===Jt,showPanel:N,hasPanel:!!M,rendererKind:K,filesSetting:L?null:Zt,handlers:{onToggleComposer:()=>F(re=>!re),onToggleFiles:L?Qt:()=>ls(re=>(sE(!re),!re)),onTogglePanel:()=>U(re=>!re),onSwitchRenderer:te}}),qs=re=>{re.preventDefault();const Te=We.current;if(!Te)return;const Ge=(xt,vt)=>de(Qe=>({...Qe,[ne?"h":"v"]:{main:xt,side:vt}}));if(ne){const xt=re.clientX,vt=rt.current,Qe=Te.clientWidth||1,Rt=J?-1:1,ot=Wt=>{const Sn=vt.main+vt.side,Se=(Wt.clientX-xt)/Qe*Sn*Rt,Me=ad(vt.main+Se);Ge(Me,ad(Sn-Me))},ze=()=>{window.removeEventListener("pointermove",ot),window.removeEventListener("pointerup",ze),window.removeEventListener("pointercancel",ze),window.removeEventListener("blur",ze)};window.addEventListener("pointermove",ot),window.addEventListener("pointerup",ze),window.addEventListener("pointercancel",ze),window.addEventListener("blur",ze);return}const gt=re.clientY,W=rt.current,ae=Te.clientHeight||1,Ae=J?-1:1,Je=xt=>{const vt=W.main+W.side,Qe=(xt.clientY-gt)/ae*vt*Ae,Rt=ad(W.main+Qe);Ge(Rt,ad(vt-Rt))},Pe=()=>{window.removeEventListener("pointermove",Je),window.removeEventListener("pointerup",Pe),window.removeEventListener("pointercancel",Pe),window.removeEventListener("blur",Pe)};window.addEventListener("pointermove",Je),window.addEventListener("pointerup",Pe),window.addEventListener("pointercancel",Pe),window.addEventListener("blur",Pe)},Vn=v&&l.jsxs("div",{className:`nc-dual-pane${ie?"":" foco"}${X&&ie?" nascosto":""}`,"data-testid":"pane-main",style:{flexGrow:$e.main,flexBasis:ne?0:void 0},onPointerDown:()=>He(!1),children:[l.jsxs("div",{className:"nc-dual-strip",children:[l.jsx("span",{className:`nc-dual-dot${oe?" on":""}`,"aria-hidden":"true"}),l.jsx("b",{children:q}),!ie&&l.jsx("span",{className:"nc-dual-matita","aria-hidden":"true",title:p("dual-focus"),children:"✎"}),X&&l.jsxs("button",{type:"button",className:"nc-dual-alt",title:p("dual-go-to").replace("{cell}",(je==null?void 0:je.title)||v.session),"aria-label":p("dual-go-to").replace("{cell}",(je==null?void 0:je.title)||v.session),onPointerDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),He(!ie)},children:[l.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true",focusable:"false",children:[l.jsx("rect",{x:"3.5",y:"6",width:"17",height:"12",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("rect",{x:"3.5",y:"6",width:"8.5",height:"12",fill:"currentColor"})]}),l.jsx("span",{className:`nc-dual-dot${je!=null&&je.present?" on":""}`,"aria-hidden":"true"})]})]}),l.jsx("div",{className:"nc-dual-body",children:l.jsx(mc,{session:t,node:e,token:i,readonly:a,takeSize:!0,focused:!ie,sendRef:Ze,composerRef:se,actionRef:Be,ctrlRef:ht,setCtrlArmed:St,altRef:Nt,setAltArmed:zt,keyboardRef:Yt,onFiles:st,fontSize:$,selectionMode:Ut,onSelectionModeChange:dt,keyboardGesture:x.terminalKeyboardGesture,onRendererChange:Y})})]},"pane-main"),bt=v&&l.jsxs("div",{className:`nc-dual-pane${ie?" foco":""}${X&&!ie?" nascosto":""}`,"data-testid":"pane-side",style:{flexGrow:$e.side,flexBasis:ne?0:void 0},onPointerDown:()=>He(!0),children:[l.jsxs("div",{className:"nc-dual-strip",children:[l.jsx("span",{className:`nc-dual-dot${je!=null&&je.present?" on":""}`,"aria-hidden":"true"}),l.jsx("b",{children:je?je.title:v.session}),ie&&l.jsx("span",{className:"nc-dual-matita","aria-hidden":"true",title:p("dual-focus"),children:"✎"}),l.jsxs("span",{className:"nc-dual-tasti",children:[l.jsx("button",{type:"button",title:p("dual-swap"),"aria-label":p("dual-swap"),onPointerDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),Q(Te=>!Te)},children:ne?"⇆":"⇅"}),l.jsx("button",{type:"button",title:p("dual-close"),"aria-label":p("dual-close"),onPointerDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),_==null||_()},children:"✕"})]}),X&&l.jsxs("button",{type:"button",className:"nc-dual-alt",title:p("dual-go-to").replace("{cell}",q),"aria-label":p("dual-go-to").replace("{cell}",q),onPointerDown:re=>re.stopPropagation(),onClick:re=>{re.stopPropagation(),He(!ie)},children:[l.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14","aria-hidden":"true",focusable:"false",children:[l.jsx("rect",{x:"3.5",y:"6",width:"17",height:"12",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("rect",{x:"12",y:"6",width:"8.5",height:"12",fill:"currentColor"})]}),l.jsx("span",{className:`nc-dual-dot${oe?" on":""}`,"aria-hidden":"true"})]})]}),l.jsx("div",{className:"nc-dual-body",children:l.jsx(mc,{session:v.session,node:v.node,token:i,readonly:a,takeSize:!1,focused:ie,sendRef:me,composerRef:Ce,actionRef:V,ctrlRef:ge,setCtrlArmed:St,altRef:Le,setAltArmed:zt,keyboardRef:ke,onFiles:Xe,fontSize:$,selectionMode:Ut,onSelectionModeChange:dt,keyboardGesture:x.terminalKeyboardGesture})})]},"pane-side"),us=l.jsx("div",{className:"nc-dual-handle","data-testid":"dual-handle",role:"separator","aria-orientation":ne?"vertical":"horizontal",onPointerDown:qs},"dual-handle");return l.jsxs("div",{className:"nc-app",children:[l.jsxs("header",{className:"nc-bar nc-bar-single",children:[l.jsxs("button",{onClick:u,title:p("sessions"),children:[l.jsx(Tt,{name:"chevronLeft",size:18}),l.jsx("span",{className:"nc-bar-label",children:p("sessions")})]}),l.jsxs("span",{className:"nc-bar-center",children:[l.jsx("b",{title:e?`${q} · ${e}`:q,children:q}),g&&g.cell&&g.cell===s?l.jsx("span",{className:`nc-live-host-dot ${Lv(g)} nc-live-host-dot-header`,"data-testid":"live-host-header-dot",title:p("live-host-indicator").replace("{cell}",g.cell).replace("{mode}",p(g.mode?`live-host-mode-${g.mode}`:"live-host-mode-unknown")).replace("{state}",p(`live-host-state-${g.state}`))}):null,I&&l.jsx("small",{className:"nc-bar-sub",children:I})]}),l.jsxs("span",{className:"nc-bar-right",children:[l.jsx("button",{onClick:()=>ue(-1),title:p("zoom-out"),"aria-label":p("zoom-out"),children:l.jsx(Tt,{name:"zoomOut",size:18})}),l.jsx("button",{onClick:()=>ue(1),title:p("zoom-in"),"aria-label":p("zoom-in"),children:l.jsx(Tt,{name:"zoomIn",size:18})}),Zt&&l.jsx("button",{type:"button",onClick:Qt,title:p("bar-menu-files"),"aria-label":p("bar-menu-files"),"aria-pressed":(Re==null?void 0:Re.source)===Jt?"true":"false",children:l.jsx(Tt,{name:"folder",size:18})}),cs&&l.jsx("button",{type:"button",onClick:()=>F(re=>!re),title:p("bar-menu-keyboard"),"aria-label":p("bar-menu-keyboard"),"aria-pressed":E?"true":"false",children:l.jsx(Tt,{name:"keyboard",size:18})}),M&&mn&&l.jsx("button",{type:"button",onClick:()=>U(re=>!re),title:p("bar-menu-panel"),"aria-label":p("bar-menu-panel"),"aria-pressed":N?"true":"false",children:l.jsx(Tt,{name:"monitor",size:18})}),l.jsx("button",{type:"button",className:`nc-bar-menu${k?" on":""}`,title:p("bar-menu-open"),"aria-label":p("bar-menu-open"),"aria-haspopup":"menu","aria-expanded":k?"true":"false",onClick:re=>{k||j(re.currentTarget.getBoundingClientRect()),R(Te=>!Te)},children:"⋯"})]})]}),l.jsxs("div",{className:"nc-termwrap",children:[v?l.jsx("div",{className:`nc-dual${ne?" row":""}`,ref:We,children:X?J?[bt,Vn]:[Vn,bt]:J?[bt,us,Vn]:[Vn,us,bt]}):l.jsx(mc,{session:t,node:e,token:i,readonly:a,takeSize:!0,sendRef:Ze,composerRef:se,actionRef:Be,ctrlRef:ht,setCtrlArmed:St,altRef:Nt,setAltArmed:zt,keyboardRef:Yt,onFiles:st,fontSize:$,selectionMode:Ut,onSelectionModeChange:dt,keyboardGesture:x.terminalKeyboardGesture,onRendererChange:Y}),N&&M&&T&&l.jsx(gv,{cellId:T,panelUrl:M,route:e?e.split("/"):[],panelPort:c,token:i,title:q})]}),l.jsx(sI,{onKeyboard:()=>F(re=>!re),onCellSwitcher:h,cellSwitcherOpen:f,send:re=>(ie?me:Ze).current(re),action:re=>(ie?V:Be).current(re),ctrlArmed:Pt,onCtrl:qt,altArmed:ut,onAlt:In,onAltConsume:()=>{const re=ie?Le:Nt;re.current=!1,zt(!1)},onKeyboardKeep:()=>{var re,Te;return(Te=(re=ie?ke:Yt).current)==null?void 0:Te.call(re)},selectionMode:Ut,onSelectionMode:dt,keepKeyboardClosed:x.keybarKeepsKeyboardClosed,showEnter:x.showKeybarEnter,keybarLayout:x.keybarLayout}),E&&l.jsx(dC,{submitText:re=>(ie?Ce:se).current(re),token:i,session:ie?v.session:t,node:ie?v.node:e,ownerId:ie?v.ownerId:n,readonly:a,keepKeyboardClosedOnVoice:x.voiceKeepsKeyboardClosed}),Re&&(De?l.jsx(Rg,{session:v.session,node:v.node,token:i,filesEvent:Re.ev,onClose:()=>_e(null)}):Re.source==="main"?l.jsx(Rg,{session:t,node:e,token:i,filesEvent:Re.ev,onClose:()=>_e(null)}):null),k&&(L?l.jsx(Ok,{anchorRect:S,items:gn,onClose:()=>R(!1)}):l.jsx(Rv,{cellName:q,items:gn,onClose:()=>R(!1)}))]})}function W4(){zn();const[t]=w.useState(F4),[e,n]=w.useState(t.token),[s,i]=w.useState(!1);L6(s?"":e);const a=w.useRef(t.token);a.current=e,w.useEffect(()=>{const Se=Me=>{Me&&Me.detail&&Me.detail.token===a.current&&i(!0)};return window.addEventListener(hm,Se),()=>window.removeEventListener(hm,Se)},[]);const c=w.useCallback((Se,Me)=>{const qe=S1(Se,{remember:Me});if(!qe.ok||Me&&qe.where!=="local")try{window.dispatchEvent(new CustomEvent(fm))}catch{}i(!1),n(Se)},[]),[u,h]=w.useState(t.pair||""),f=w.useCallback(()=>{h("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),g=_k(),[v]=w.useState(()=>HI(typeof location<"u"?location.pathname:"/")),[_,b]=w.useState(v.id),x=_===Vo(null,ti),[L,k]=w.useState(null),R=Se=>{const Me=Er(Se);k(Me?{...Me,...typeof(Se==null?void 0:Se.cellName)=="string"&&Se.cellName?{cellName:Se.cellName}:{}}:null)},[S,j]=w.useState(null);w.useEffect(()=>{const Se=f4();j(Se&&L&&qg(Se.main,L)?Se.side:null)},[L]);const E=Se=>{const Me=L?{session:L.session,node:L.node}:null,qe=h4(Me,S,Se);j(qe),qe?p4(Me,qe):r1()},F=()=>{j(null),r1()},[$,G]=w.useState([]),[K,Y]=w.useState(!0),[te,q]=w.useState(null),[D,I]=w.useState([]),[O,M]=w.useState([]),[z,T]=w.useState(!1),[A,N]=w.useState(null),[U,P]=w.useState(()=>v.ownerId?ho():h1(v.name)),[H,ie]=w.useState(null),[J,Q]=w.useState(null),ve=Se=>Q(Er(Se)),[de,ne]=w.useState(null),xe=xv(e,g),$e=w.useMemo(()=>(xe||[]).filter(Se=>Se.instanceId).map(Se=>({instanceId:Se.instanceId,route:Se.route,label:Se.label,status:Se.status,stale:Se.stale===!0,checking:Se.checking===!0})),[xe]),{order:rt}=ch(),je=x4(e,_,U,P,$e,rt),{notice:Ie,showActionNotice:oe}=tC(),Ne=je.decks;w.useEffect(()=>{const Se=new Map;for(const Me of xe||[]){const qe=(Me.route||[Me.name]).join("/"),ct=new Set((Me.sessions||[]).map(Lt=>Lt.name));for(const Lt of Me.cells||[])!Lt.cell||!Lt.tmuxSession||Lt.cell===Lt.tmuxSession||ct.has(Lt.cell)||Se.set(`${qe}:${Lt.cell}`,`${qe}:${Lt.tmuxSession}`)}P(Me=>xP(Me,Se))},[xe]),w.useEffect(()=>{je.localNodeId&&v.ownerId&&v.ownerId===je.localNodeId&&P(Se=>Se.columns.some(Me=>Me.tiles.length)?Se:h1(v.name))},[je.localNodeId]),w.useEffect(()=>{je.localNodeId&&(OI($e),je.viewUpdate(Se=>{const Me=Ha(Se,je.localNodeId,$e);return JSON.stringify(Me)===JSON.stringify(Se)?Se:Me}))},[$e,je.localNodeId,je.viewUpdate]);const[me,Ce]=w.useState(null),[V,ge]=w.useState(null),Le=w.useRef(0),[ke,We]=w.useState(!1),[Re,_e]=w.useState(z4),[st,Xe]=w.useState(!x),[De,He]=w.useState(()=>x?localStorage.getItem(u1)==="1":!0),[Ke,wt]=w.useState(!1),[fe,he]=w.useState("nodes"),[Z,X]=w.useState(!1),[ue,Ze]=w.useState(""),[se,Be]=w.useState(!1),ht=(Se="nodes",Me=!1,qe="")=>{he(Se),X(Me),Ze(qe),wt(!0)},[Pt,St]=w.useState(!1),[Nt,ut]=w.useState(null),[zt,Yt]=w.useState({deviceDefault:"",localNodeId:"",localNameDefault:"",deviceNameNeeded:!1,deviceNameSuggestion:""}),[Ut,dt]=w.useState(""),[qt,In]=w.useState(!1),[Kt,wn]=w.useState(0),[tn,bn]=w.useState({});w.useEffect(()=>{try{localStorage.setItem(PE,String(Re))}catch{}},[Re]),w.useEffect(()=>{try{localStorage.setItem(u1,De?"1":"")}catch{}},[De]),w.useEffect(()=>{if(!e)return;let Se=!1;return Promise.all([j1(e),qn("/api/config",e).then(Me=>Me.json())]).then(([Me,qe])=>{if(!Se){if(Yt({deviceDefault:Me.deviceName||"",localNodeId:Me.nodeId||"",localNameDefault:Me.localName||"",deviceNameNeeded:Me.deviceNameNeeded===!0,deviceNameSuggestion:Me.deviceNameSuggestion||""}),dt(Me.deviceName||""),In(!!qe.readonlyDefault),FM(qe.terminal),wn(Number.isInteger(qe.panelPort)?qe.panelPort:0),bn(qe.nodePanelPorts&&typeof qe.nodePanelPorts=="object"&&!Array.isArray(qe.nodePanelPorts)?qe.nodePanelPorts:{}),Me.firstRun===!0&&!qe.readonlyDefault)St(!0);else if(u)St(!0);else if(Me.deviceNameNeeded===!0&&!qe.readonlyDefault){let ct=!1;try{ct=sessionStorage.getItem("nc_device_ask_later")==="1"}catch{}ct||ut({suggestion:Me.deviceNameSuggestion||""})}}}).catch(()=>{}),()=>{Se=!0}},[e,u]);const[Ft,Jt]=w.useState({}),Qt=w.useCallback(({route:Se,hostCell:Me,revision:qe})=>{const ct=Cs(Se);Jt(Lt=>({...Lt,[ct]:{hostCell:Me||null,hostLease:null,hostRevision:Number.isInteger(qe)?qe:(Lt[ct]||{}).hostRevision||0,threadStatus:"absent"}}))},[]),Zt=Se=>{const Me=Cs(Se),qe=Se.length?((xe||[]).find(ct=>Cs(Array.isArray(ct.route)?ct.route:[])===Me)||{}).cells||[]:D;return Va({liveHost:Ft[Me]||null,cells:qe,localNodeId:je.localNodeId,ownerId:Se.length?Me:je.localNodeId})},ls=w.useRef(xe);w.useEffect(()=>{ls.current=xe},[xe]);const cs=w.useRef(null);cs.current||(cs.current=eh());const mn=3500;w.useEffect(()=>{let Se=!1;const Me=async()=>{const ct=cs.current,Lt=ct.begin();if(Lt!==null)try{const Ks=[[],...(ls.current||[]).filter(en=>en.kind!=="vl"&&en.status==="up").map(en=>Array.isArray(en.route)&&en.route.length?en.route:[en.name])],Vs=await Promise.all(Ks.map(async en=>{const nn=Cs(en);try{const on=await Jd(e,en,{timeoutMs:mn});return[nn,{hostCell:on&&typeof on.hostCell=="string"?on.hostCell:null,hostLease:on&&on.host&&typeof on.host.lease=="string"?on.host.lease:null,hostRevision:Number.isInteger(on&&on.revision)?on.revision:0,threadStatus:on&&d1.has(on.threadStatus)?on.threadStatus:"unknown"}]}catch{return[nn,{error:!0}]}}));if(Se||!ct.isCurrent(Lt))return;Jt(en=>{let nn=!1;const on={...en};for(const Si of Vs){if(!Si)continue;const[go,rr]=Si;on[go]=rr.error?{...en[go]||{},threadStatus:"unknown"}:rr,nn=!0}return nn?on:en})}finally{ct.end(Lt)}};Me();const qe=setInterval(Me,4e3);return()=>{Se=!0,clearInterval(qe),cs.current.reset()}},[e]),w.useEffect(()=>{if(!g)return;const Se=Me=>{if(!Me)return;const qe=Me.sessionsError?null:Me.sessionsJson;qe&&!qe.error?(G(qe.sessions||[]),Y(!0),q(Me.at)):Y(!1);const ct=bv({fs:Me.fs,error:Me.fleetError});ct.kind==="data"?(Ka("local",ct.cells),I(ct.cells),M(ct.capabilities),T(!1),N(null)):ct.kind==="stale"?(I(Lt=>Lt.length?Lt:wv("local")),T(!0),N(null)):(I([]),Ka("local",[]),M([]),T(!1),N(ct.reason||""))};return Se(nc([])),Cd(e,[],Se)},[g,e]);const gn=w.useCallback(async(Se,Me=[])=>{const qe=Cs(Me),ct=Ft[qe]&&Ft[qe].hostRevision||0;try{const Lt=await Qd(e,Se,ct,Me);return Jt(Ks=>({...Ks,[qe]:{hostCell:Lt.hostCell||null,hostLease:Lt.host&&typeof Lt.host.lease=="string"?Lt.host.lease:null,hostRevision:Number.isInteger(Lt.revision)?Lt.revision:ct,threadStatus:d1.has(Lt.threadStatus)?Lt.threadStatus:"unknown"}})),{ok:!0}}catch(Lt){return{ok:!1,error:Lt}}},[e,Ft]),qs=w.useCallback(async(Se,Me=[])=>{const qe=await gn(Se,Me);return qe.ok||window.alert(p(gm(qe.error))),qe.ok},[gn]),Vn=w.useCallback(async(Se=[])=>{const Me=Cs(Se),qe=Ft[Me]&&Ft[Me].hostRevision||0;try{const ct=await Zd(e,qe,Se);return Jt(Lt=>({...Lt,[Me]:{hostCell:ct.hostCell||null,hostLease:null,hostRevision:Number.isInteger(ct.revision)?ct.revision:qe,threadStatus:"unknown"}})),{ok:!0}}catch(ct){return{ok:!1,error:ct}}},[e,Ft]),bt=w.useCallback(async(Se=[])=>{const Me=await Vn(Se);return Me.ok||window.alert(p(gm(Me.error))),Me.ok},[Vn]);w.useEffect(()=>{let Se=!1;const Me=()=>{qn("/api/config",e).then(ct=>ct.json()).then(ct=>{Se||T4(ct.version,ct.uiVersion,"0.9.62")}).catch(()=>{})};Me();const qe=setInterval(Me,6e4);return()=>{Se=!0,clearInterval(qe)}},[e]);const us=new Set([...$.map(Se=>Se.name),...xe.flatMap(Se=>Se.sessions.map(Me=>Me.key))]),le=w.useMemo(()=>{const Se=new Map;for(const Me of $)Me&&typeof Me.name=="string"&&Number.isFinite(Me.created)&&Se.set(Me.name,Me.created);return Se},[$]),re=_s(U),Te=Se=>P(Me=>{const qe=_C(Se,je.localNodeId,$e)||Se,ct=Kk(Me,qe);return ct===Me&&_s(Me).length>=9&&je.setError(p("grid-full")),ct}),Ge=async(Se,Me=[])=>{try{await Xg(e,Se,Me)}catch{return}const qe=Me.length?`${Me.join("/")}:${Se}`:Se;P(ct=>Rc(ct,qe)),sc(Me,e)},gt=async(Se,Me,qe=[])=>{try{await A1(e,Se,Me,qe)}catch{return}sc(qe,e)},W=async(Se,Me,qe=[])=>{await N1(e,{cell:Se,enabled:!!Me},qe),sc(qe,e)},ae=async Se=>{if(!me)return;const{cell:Me}=me,qe=Array.isArray(me.route)?me.route:[];if(!await Mv({token:e,powerCell:me,payload:Se,onNotice:oe})){const Lt=Se.action==="up"?!!Se.boot:Se.boot?!1:!!me.boot;ge({id:++Le.current,cell:Me,route:qe,enabled:Lt})}sc(qe,e)},Ae=w.useCallback(Se=>{ge(Me=>(Me==null?void 0:Me.id)===Se?null:Me)},[]),Je=async Se=>{if(!(!(Se!=null&&Se.direct)||ke)){We(!0);try{await Zg(e,Se.name,Se.tunnelStatus==="up"?"down":"up")}finally{We(!1)}}},Pe=async(Se,Me)=>{const qe=String(Me||"").trim();return!(Se!=null&&Se.direct)||!Ga(qe)?!1:(await I1(e,Se.name,qe),!0)},xt=Se=>{const Me=Ne.find(qe=>qe.id===Se);if(!Me)return!1;try{const qe=window.open(jp(Me,e),"_blank");return qe&&(qe.opener=null),!!qe}catch{return!1}},vt=async Se=>{if(!Se||Se===_)return;const Me=await je.select(Se),qe=je.records.find(ct=>ct.id===Se);b(Se),P(Me),ie(null),Q(null);try{history.replaceState(null,"",jp(qe||Se,null))}catch{}},Qe=async(Se,Me)=>{const qe=await je.add(Se,Me);await vt(qe.id)},Rt=async(Se,Me)=>{const qe=await je.rename(Se,Me);if(Se===_){b(qe.id),P(je.vistaMaterializzata(qe)),ie(null),Q(null);try{history.replaceState(null,"",jp(qe,null))}catch{}}},ot=async Se=>{await je.remove(Se),Se===_&&await vt(je.localMainId)},ze=async(Se,Me)=>{!Me||Me===_||(await je.addTileTo(Me,Se),P(qe=>Rc(qe,Se)))};if(!e||s)return l.jsx(v4,{onSubmit:c,reason:s?"invalid":""});const Wt=l.jsxs(l.Fragment,{children:[Ke&&l.jsx(H6,{token:e,initialTab:fe,initialLocation:ue,startNewCell:Z,onClose:()=>{wt(!1),X(!1),Ze("")}}),Pt&&l.jsx(U6,{token:e,initialPair:u,...zt,onPairDone:f,onDone:()=>St(!1)}),Nt&&l.jsx(W6,{token:e,suggestion:Nt.suggestion,onSaved:Se=>{dt(Se),Yt(Me=>({...Me,deviceDefault:Se,deviceNameNeeded:!1})),ut(null)},onLater:()=>{try{sessionStorage.setItem("nc_device_ask_later","1")}catch{}ut(null)}}),l.jsx(n4,{token:e})]});if(!g)return de?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-single-overlay",children:l.jsx(i1,{peer:de,token:e,onBack:()=>ne(null)})}),Wt]}):L?l.jsxs(l.Fragment,{children:[l.jsx(p1,{session:L.session,node:L.node,ownerId:L.ownerId,cellName:L.cellName,token:e,readonly:qt,liveHost:Zt(L.node?L.node.split("/"):[]),panelPort:Cc(L.node?L.node.split("/"):[],tn,Kt),side:S,onSideClose:F,onSideGone:F,onBack:()=>k(null),onCellSwitcher:()=>Be(!0),cellSwitcherOpen:se}),se&&l.jsx(l4,{token:e,current:L,localNodeLabel:Ut,panelPort:Kt,nodePanelPorts:tn,hostByRoute:Ft,onDesignateCell:gn,onClearHostCell:Vn,onLiveHostApplied:Qt,sideKey:S?qa(S.node?S.node.split("/"):[],S.session):null,onToggleSide:E,onPick:Se=>{R(Se),Be(!1)},onClose:()=>Be(!1)}),Wt]}):l.jsxs(l.Fragment,{children:[l.jsx(JP,{onPick:R,token:e,onSettings:ht,onOpenVlSession:ne,panelPort:Kt,nodePanelPorts:tn,hostByRoute:Ft,onDesignateCell:qs,onClearHostCell:bt}),Wt]});const Sn=x||!st;return l.jsxs("div",{className:"nc-workspace",children:[Sn&&l.jsx(SI,{sessions:$,cells:D,localVerified:K,activeSessions:re,nodeGroups:xe,token:e,onPeekOpen:()=>Be(!1),overlayOpen:se,fleetCapabilities:O,fleetStale:z,fleetOff:A,bootSettlement:V,onBootSettlementApplied:Ae,localNodeId:je.localNodeId,hostByRoute:Ft,onDesignateCell:qs,onClearHostCell:bt,onPick:ve,onAddTile:Te,onPower:Ce,onBoot:W,onBootError:Se=>je.setError(String((Se==null?void 0:Se.message)||Se)),onNodePower:Je,onNodeRename:Pe,onKill:Ge,onVisibility:gt,onNew:()=>ht("fleet",!0),onSettings:ht,onOpenVlSession:ne,width:Re,collapsed:De,onResize:_e,onToggleCollapse:()=>He(Se=>!Se)}),l.jsxs("div",{className:"nc-workspace-main",children:[l.jsx(dD,{decks:Ne,currentDeck:_,onCreate:Qe,onRename:Rt,onDelete:ot,onReorder:je.reorder,onOpenWindow:xt,onNavigate:vt,saveState:je.saveState,error:je.error,conflict:je.conflict,onReloadDeck:je.reloadCurrent,sidebarVisible:Sn,onToggleSidebar:x?null:()=>Xe(Se=>!Se)}),Ie&&l.jsx("div",{className:"nc-notice nc-deck-notice",role:"status",title:Ie,children:Ie}),l.jsx(DI,{layout:U,onLayoutChange:P,onResizeEnd:()=>{je.saveNow()},token:e,readonly:qt,sessionsAlive:us,localVerified:K,localIdentities:le,localVerifiedAt:te,focusSession:H,onFocus:ie,onOpenSingle:ve,decks:Ne,currentDeck:_,onSendToDeck:ze,cells:D,nodeGroups:xe,panelPort:Kt,nodePanelPorts:tn})]}),de&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(i1,{peer:de,token:e,onBack:()=>ne(null)})}),J&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(p1,{session:J.session,node:J.node,ownerId:J.ownerId,cellName:Lc({session:J.session,node:J.node,ownerId:J.ownerId,cells:D,nodeGroups:xe}),token:e,readonly:qt,liveHost:Zt(J.node?J.node.split("/"):[]),panelPort:Cc(J.node?J.node.split("/"):[],tn,Kt),onBack:()=>Q(null)})}),me&&l.jsx(Id,{cell:me,token:e,route:Array.isArray(me.route)?me.route:[],onConfirm:ae,onClose:()=>Ce(null)}),Wt]})}function q4(t){return t.kind==="install"?p("update-installed-restart").replace("{v}",t.version):t.kind==="stale"?p("update-stale").replace("{ui}",t.version).replace("{browser}",t.browserVersion):p("update-available").replace("{v}",t.version).replace(" "," ").trim()}function K4(){zn();const t=w.useSyncExternalStore(C4,l1,l1);return t.needed?l.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"nc-update-msg",children:q4(t)}),t.kind==="stale"&&l.jsx("button",{className:"nc-update-btn",onClick:TE,children:p("reload-no-cache")}),t.kind==="reload"&&l.jsx("button",{className:"nc-update-btn",onClick:O4,children:p("reload")}),l.jsx("button",{className:"nc-update-close",onClick:M4,"aria-label":p("update-dismiss"),title:p("update-dismiss"),children:"×"})]}):null}function V4(){zn();const[t,e]=w.useState(!1);return w.useEffect(()=>{const n=()=>e(!0);return window.addEventListener(fm,n),()=>window.removeEventListener(fm,n)},[]),t?l.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"nc-update-msg",children:p("auth-not-remembered")}),l.jsx("button",{className:"nc-update-close",onClick:()=>e(!1),"aria-label":p("update-dismiss"),title:p("update-dismiss"),children:"×"})]}):null}D4();f6();vN.createRoot(document.getElementById("root")).render(l.jsxs(uN.StrictMode,{children:[l.jsx(W4,{}),l.jsx(K4,{}),l.jsx(V4,{})]}));
|