@mmmbuto/nexuscrew 0.9.66 → 0.9.68
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 +21 -1
- package/docs/NODES.md +14 -3
- package/frontend/dist/assets/index-Bq57nMaf.js +169 -0
- package/frontend/dist/index.html +1 -1
- package/frontend/dist/version.json +1 -1
- package/lib/audio/dispatch.js +14 -1
- package/lib/audio/routes.js +2 -2
- package/lib/live-host/federation.js +10 -0
- package/lib/live-host/routes.js +12 -2
- package/lib/nodes/reverse-slot-listeners.js +4 -1
- package/lib/nodes/store.js +10 -2
- package/lib/proxy/federation.js +266 -14
- package/lib/proxy/node-proxy.js +86 -3
- package/lib/server.js +98 -7
- package/lib/ws/bridge.js +17 -1
- package/package.json +1 -1
- package/frontend/dist/assets/index-DhZOap1-.js +0 -169
|
@@ -0,0 +1,169 @@
|
|
|
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 Qg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Uf={exports:{}},Ol={},Wf={exports:{}},Ut={};/**
|
|
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 Nw;function gN(){if(Nw)return Ut;Nw=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 _(I){return I===null||typeof I!="object"?null:(I=v&&I[v]||I["@@iterator"],typeof I=="function"?I:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,R={};function C(I,W,se){this.props=I,this.context=W,this.refs=R,this.updater=se||b}C.prototype.isReactComponent={},C.prototype.setState=function(I,W){if(typeof I!="object"&&typeof I!="function"&&I!=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,I,W,"setState")},C.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function L(){}L.prototype=C.prototype;function S(I,W,se){this.props=I,this.context=W,this.refs=R,this.updater=se||b}var T=S.prototype=new L;T.constructor=S,k(T,C.prototype),T.isPureReactComponent=!0;var E=Array.isArray,H=Object.prototype.hasOwnProperty,F={current:null},X={key:!0,ref:!0,__self:!0,__source:!0};function V(I,W,se){var me,pe={},Ie=null,J=null;if(W!=null)for(me in W.ref!==void 0&&(J=W.ref),W.key!==void 0&&(Ie=""+W.key),W)H.call(W,me)&&!X.hasOwnProperty(me)&&(pe[me]=W[me]);var te=arguments.length-2;if(te===1)pe.children=se;else if(1<te){for(var ge=Array(te),Se=0;Se<te;Se++)ge[Se]=arguments[Se+2];pe.children=ge}if(I&&I.defaultProps)for(me in te=I.defaultProps,te)pe[me]===void 0&&(pe[me]=te[me]);return{$$typeof:t,type:I,key:Ie,ref:J,props:pe,_owner:F.current}}function G(I,W){return{$$typeof:t,type:I.type,key:W,ref:I.ref,props:I.props,_owner:I._owner}}function ne(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function Y(I){var W={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(se){return W[se]})}var B=/\/+/g;function P(I,W){return typeof I=="object"&&I!==null&&I.key!=null?Y(""+I.key):W.toString(36)}function D(I,W,se,me,pe){var Ie=typeof I;(Ie==="undefined"||Ie==="boolean")&&(I=null);var J=!1;if(I===null)J=!0;else switch(Ie){case"string":case"number":J=!0;break;case"object":switch(I.$$typeof){case t:case e:J=!0}}if(J)return J=I,pe=pe(J),I=me===""?"."+P(J,0):me,E(pe)?(se="",I!=null&&(se=I.replace(B,"$&/")+"/"),D(pe,W,se,"",function(Se){return Se})):pe!=null&&(ne(pe)&&(pe=G(pe,se+(!pe.key||J&&J.key===pe.key?"":(""+pe.key).replace(B,"$&/")+"/")+I)),W.push(pe)),1;if(J=0,me=me===""?".":me+":",E(I))for(var te=0;te<I.length;te++){Ie=I[te];var ge=me+P(Ie,te);J+=D(Ie,W,se,ge,pe)}else if(ge=_(I),typeof ge=="function")for(I=ge.call(I),te=0;!(Ie=I.next()).done;)Ie=Ie.value,ge=me+P(Ie,te++),J+=D(Ie,W,se,ge,pe);else if(Ie==="object")throw W=String(I),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return J}function M(I,W,se){if(I==null)return I;var me=[],pe=0;return D(I,me,"","",function(Ie){return W.call(se,Ie,pe++)}),me}function $(I){if(I._status===-1){var W=I._result;W=W(),W.then(function(se){(I._status===0||I._status===-1)&&(I._status=1,I._result=se)},function(se){(I._status===0||I._status===-1)&&(I._status=2,I._result=se)}),I._status===-1&&(I._status=0,I._result=W)}if(I._status===1)return I._result.default;throw I._result}var A={current:null},j={transition:null},N={ReactCurrentDispatcher:A,ReactCurrentBatchConfig:j,ReactCurrentOwner:F};function U(){throw Error("act(...) is not supported in production builds of React.")}return Ut.Children={map:M,forEach:function(I,W,se){M(I,function(){W.apply(this,arguments)},se)},count:function(I){var W=0;return M(I,function(){W++}),W},toArray:function(I){return M(I,function(W){return W})||[]},only:function(I){if(!ne(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},Ut.Component=C,Ut.Fragment=n,Ut.Profiler=i,Ut.PureComponent=S,Ut.StrictMode=s,Ut.Suspense=h,Ut.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=N,Ut.act=U,Ut.cloneElement=function(I,W,se){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var me=k({},I.props),pe=I.key,Ie=I.ref,J=I._owner;if(W!=null){if(W.ref!==void 0&&(Ie=W.ref,J=F.current),W.key!==void 0&&(pe=""+W.key),I.type&&I.type.defaultProps)var te=I.type.defaultProps;for(ge in W)H.call(W,ge)&&!X.hasOwnProperty(ge)&&(me[ge]=W[ge]===void 0&&te!==void 0?te[ge]:W[ge])}var ge=arguments.length-2;if(ge===1)me.children=se;else if(1<ge){te=Array(ge);for(var Se=0;Se<ge;Se++)te[Se]=arguments[Se+2];me.children=te}return{$$typeof:t,type:I.type,key:pe,ref:Ie,props:me,_owner:J}},Ut.createContext=function(I){return I={$$typeof:c,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:a,_context:I},I.Consumer=I},Ut.createElement=V,Ut.createFactory=function(I){var W=V.bind(null,I);return W.type=I,W},Ut.createRef=function(){return{current:null}},Ut.forwardRef=function(I){return{$$typeof:u,render:I}},Ut.isValidElement=ne,Ut.lazy=function(I){return{$$typeof:g,_payload:{_status:-1,_result:I},_init:$}},Ut.memo=function(I,W){return{$$typeof:f,type:I,compare:W===void 0?null:W}},Ut.startTransition=function(I){var W=j.transition;j.transition={};try{I()}finally{j.transition=W}},Ut.unstable_act=U,Ut.useCallback=function(I,W){return A.current.useCallback(I,W)},Ut.useContext=function(I){return A.current.useContext(I)},Ut.useDebugValue=function(){},Ut.useDeferredValue=function(I){return A.current.useDeferredValue(I)},Ut.useEffect=function(I,W){return A.current.useEffect(I,W)},Ut.useId=function(){return A.current.useId()},Ut.useImperativeHandle=function(I,W,se){return A.current.useImperativeHandle(I,W,se)},Ut.useInsertionEffect=function(I,W){return A.current.useInsertionEffect(I,W)},Ut.useLayoutEffect=function(I,W){return A.current.useLayoutEffect(I,W)},Ut.useMemo=function(I,W){return A.current.useMemo(I,W)},Ut.useReducer=function(I,W,se){return A.current.useReducer(I,W,se)},Ut.useRef=function(I){return A.current.useRef(I)},Ut.useState=function(I){return A.current.useState(I)},Ut.useSyncExternalStore=function(I,W,se){return A.current.useSyncExternalStore(I,W,se)},Ut.useTransition=function(){return A.current.useTransition()},Ut.version="18.3.1",Ut}var Rw;function Zg(){return Rw||(Rw=1,Wf.exports=gN()),Wf.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 Lw;function vN(){if(Lw)return Ol;Lw=1;var t=Zg(),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 Ol.Fragment=n,Ol.jsx=c,Ol.jsxs=c,Ol}var Aw;function _N(){return Aw||(Aw=1,Uf.exports=vN()),Uf.exports}var l=_N(),w=Zg();const yN=Qg(w);var Hu={},qf={exports:{}},Us={},Kf={exports:{}},Vf={};/**
|
|
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 jw;function wN(){return jw||(jw=1,(function(t){function e(j,N){var U=j.length;j.push(N);e:for(;0<U;){var I=U-1>>>1,W=j[I];if(0<i(W,N))j[I]=N,j[U]=W,U=I;else break e}}function n(j){return j.length===0?null:j[0]}function s(j){if(j.length===0)return null;var N=j[0],U=j.pop();if(U!==N){j[0]=U;e:for(var I=0,W=j.length,se=W>>>1;I<se;){var me=2*(I+1)-1,pe=j[me],Ie=me+1,J=j[Ie];if(0>i(pe,U))Ie<W&&0>i(J,pe)?(j[I]=J,j[Ie]=U,I=Ie):(j[I]=pe,j[me]=U,I=me);else if(Ie<W&&0>i(J,U))j[I]=J,j[Ie]=U,I=Ie;else break e}}return N}function i(j,N){var U=j.sortIndex-N.sortIndex;return U!==0?U:j.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,k=!1,R=!1,C=typeof setTimeout=="function"?setTimeout:null,L=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 T(j){for(var N=n(f);N!==null;){if(N.callback===null)s(f);else if(N.startTime<=j)s(f),N.sortIndex=N.expirationTime,e(h,N);else break;N=n(f)}}function E(j){if(R=!1,T(j),!k)if(n(h)!==null)k=!0,$(H);else{var N=n(f);N!==null&&A(E,N.startTime-j)}}function H(j,N){k=!1,R&&(R=!1,L(V),V=-1),b=!0;var U=_;try{for(T(N),v=n(h);v!==null&&(!(v.expirationTime>N)||j&&!Y());){var I=v.callback;if(typeof I=="function"){v.callback=null,_=v.priorityLevel;var W=I(v.expirationTime<=N);N=t.unstable_now(),typeof W=="function"?v.callback=W:v===n(h)&&s(h),T(N)}else s(h);v=n(h)}if(v!==null)var se=!0;else{var me=n(f);me!==null&&A(E,me.startTime-N),se=!1}return se}finally{v=null,_=U,b=!1}}var F=!1,X=null,V=-1,G=5,ne=-1;function Y(){return!(t.unstable_now()-ne<G)}function B(){if(X!==null){var j=t.unstable_now();ne=j;var N=!0;try{N=X(!0,j)}finally{N?P():(F=!1,X=null)}}else F=!1}var P;if(typeof S=="function")P=function(){S(B)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,M=D.port2;D.port1.onmessage=B,P=function(){M.postMessage(null)}}else P=function(){C(B,0)};function $(j){X=j,F||(F=!0,P())}function A(j,N){V=C(function(){j(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(j){j.callback=null},t.unstable_continueExecution=function(){k||b||(k=!0,$(H))},t.unstable_forceFrameRate=function(j){0>j||125<j?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):G=0<j?Math.floor(1e3/j):5},t.unstable_getCurrentPriorityLevel=function(){return _},t.unstable_getFirstCallbackNode=function(){return n(h)},t.unstable_next=function(j){switch(_){case 1:case 2:case 3:var N=3;break;default:N=_}var U=_;_=N;try{return j()}finally{_=U}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(j,N){switch(j){case 1:case 2:case 3:case 4:case 5:break;default:j=3}var U=_;_=j;try{return N()}finally{_=U}},t.unstable_scheduleCallback=function(j,N,U){var I=t.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?I+U:I):U=I,j){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=U+W,j={id:g++,callback:N,priorityLevel:j,startTime:U,expirationTime:W,sortIndex:-1},U>I?(j.sortIndex=U,e(f,j),n(h)===null&&j===n(f)&&(R?(L(V),V=-1):R=!0,A(E,U-I))):(j.sortIndex=W,e(h,j),k||b||(k=!0,$(H))),j},t.unstable_shouldYield=Y,t.unstable_wrapCallback=function(j){var N=_;return function(){var U=_;_=N;try{return j.apply(this,arguments)}finally{_=U}}}})(Vf)),Vf}var Mw;function bN(){return Mw||(Mw=1,Kf.exports=wN()),Kf.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 Tw;function SN(){if(Tw)return Us;Tw=1;var t=Zg(),e=bN();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 k(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 R(r,o,d,m,y,x,z){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=x,this.removeEmptyString=z}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(r){C[r]=new R(r,0,!1,r,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(r){var o=r[0];C[o]=new R(o,1,!1,r[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(r){C[r]=new R(r,2,!1,r.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(r){C[r]=new R(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){C[r]=new R(r,3,!1,r.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(r){C[r]=new R(r,3,!0,r,null,!1,!1)}),["capture","download"].forEach(function(r){C[r]=new R(r,4,!1,r,null,!1,!1)}),["cols","rows","size","span"].forEach(function(r){C[r]=new R(r,6,!1,r,null,!1,!1)}),["rowSpan","start"].forEach(function(r){C[r]=new R(r,5,!1,r.toLowerCase(),null,!1,!1)});var L=/[\-:]([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(L,S);C[o]=new R(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(L,S);C[o]=new R(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(L,S);C[o]=new R(o,1,!1,r,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(r){C[r]=new R(r,1,!1,r.toLowerCase(),null,!1,!1)}),C.xlinkHref=new R("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(r){C[r]=new R(r,1,!1,r.toLowerCase(),null,!0,!0)});function T(r,o,d,m){var y=C.hasOwnProperty(o)?C[o]:null;(y!==null?y.type!==0:m||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(k(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,H=Symbol.for("react.element"),F=Symbol.for("react.portal"),X=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),ne=Symbol.for("react.provider"),Y=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),A=Symbol.for("react.offscreen"),j=Symbol.iterator;function N(r){return r===null||typeof r!="object"?null:(r=j&&r[j]||r["@@iterator"],typeof r=="function"?r:null)}var U=Object.assign,I;function W(r){if(I===void 0)try{throw Error()}catch(d){var o=d.stack.trim().match(/\n( *(at )?)/);I=o&&o[1]||""}return`
|
|
34
|
+
`+I+r}var se=!1;function me(r,o){if(!r||se)return"";se=!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(Ne){var m=Ne}Reflect.construct(r,[],o)}else{try{o.call()}catch(Ne){m=Ne}r.call(o.prototype)}else{try{throw Error()}catch(Ne){m=Ne}r()}}catch(Ne){if(Ne&&m&&typeof Ne.stack=="string"){for(var y=Ne.stack.split(`
|
|
35
|
+
`),x=m.stack.split(`
|
|
36
|
+
`),z=y.length-1,ee=x.length-1;1<=z&&0<=ee&&y[z]!==x[ee];)ee--;for(;1<=z&&0<=ee;z--,ee--)if(y[z]!==x[ee]){if(z!==1||ee!==1)do if(z--,ee--,0>ee||y[z]!==x[ee]){var ue=`
|
|
37
|
+
`+y[z].replace(" at new "," at ");return r.displayName&&ue.includes("<anonymous>")&&(ue=ue.replace("<anonymous>",r.displayName)),ue}while(1<=z&&0<=ee);break}}}finally{se=!1,Error.prepareStackTrace=d}return(r=r?r.displayName||r.name:"")?W(r):""}function pe(r){switch(r.tag){case 5:return W(r.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return r=me(r.type,!1),r;case 11:return r=me(r.type.render,!1),r;case 1:return r=me(r.type,!0),r;default:return""}}function Ie(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 X:return"Fragment";case F:return"Portal";case G:return"Profiler";case V:return"StrictMode";case P:return"Suspense";case D:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case Y:return(r.displayName||"Context")+".Consumer";case ne:return(r._context.displayName||"Context")+".Provider";case B: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:Ie(r.type)||"Memo";case $:o=r._payload,r=r._init;try{return Ie(r(o))}catch{}}return null}function J(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 Ie(o);case 8:return o===V?"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 te(r){switch(typeof r){case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function ge(r){var o=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function Se(r){var o=ge(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,x=d.set;return Object.defineProperty(r,o,{configurable:!0,get:function(){return y.call(this)},set:function(z){m=""+z,x.call(this,z)}}),Object.defineProperty(r,o,{enumerable:d.enumerable}),{getValue:function(){return m},setValue:function(z){m=""+z},stopTracking:function(){r._valueTracker=null,delete r[o]}}}}function Be(r){r._valueTracker||(r._valueTracker=Se(r))}function Le(r){if(!r)return!1;var o=r._valueTracker;if(!o)return!0;var d=o.getValue(),m="";return r&&(m=ge(r)?r.checked?"true":"false":r.value),r=m,r!==d?(o.setValue(r),!0):!1}function ze(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 Q(r,o){var d=o.checked;return U({},o,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??r._wrapperState.initialChecked})}function ve(r,o){var d=o.defaultValue==null?"":o.defaultValue,m=o.checked!=null?o.checked:o.defaultChecked;d=te(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 Z(r,o){o=o.checked,o!=null&&T(r,"checked",o,!1)}function be(r,o){Z(r,o);var d=te(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")?fe(r,o.type,d):o.hasOwnProperty("defaultValue")&&fe(r,o.type,te(o.defaultValue)),o.checked==null&&o.defaultChecked!=null&&(r.defaultChecked=!!o.defaultChecked)}function K(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 fe(r,o,d){(o!=="number"||ze(r.ownerDocument)!==r)&&(d==null?r.defaultValue=""+r._wrapperState.initialValue:r.defaultValue!==""+d&&(r.defaultValue=""+d))}var Re=Array.isArray;function Ee(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=""+te(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 qe(r,o){if(o.dangerouslySetInnerHTML!=null)throw Error(n(91));return U({},o,{value:void 0,defaultValue:void 0,children:""+r._wrapperState.initialValue})}function Ze(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(Re(d)){if(1<d.length)throw Error(n(93));d=d[0]}o=d}o==null&&(o=""),d=o}r._wrapperState={initialValue:te(d)}}function at(r,o){var d=te(o.value),m=te(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 Oe(r){var o=r.textContent;o===r._wrapperState.initialValue&&o!==""&&o!==null&&(r.value=o)}function _e(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 $e(r,o){return r==null||r==="http://www.w3.org/1999/xhtml"?_e(o):r==="http://www.w3.org/2000/svg"&&o==="foreignObject"?"http://www.w3.org/1999/xhtml":r}var nt,Fe=(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(nt=nt||document.createElement("div"),nt.innerHTML="<svg>"+o.valueOf().toString()+"</svg>",o=nt.firstChild;r.firstChild;)r.removeChild(r.firstChild);for(;o.firstChild;)r.appendChild(o.firstChild)}});function rt(r,o){if(o){var d=r.firstChild;if(d&&d===r.lastChild&&d.nodeType===3){d.nodeValue=o;return}}r.textContent=o}var re={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},ce=["Webkit","ms","Moz","O"];Object.keys(re).forEach(function(r){ce.forEach(function(o){o=o+r.charAt(0).toUpperCase()+r.substring(1),re[o]=re[r]})});function O(r,o,d){return o==null||typeof o=="boolean"||o===""?"":d||typeof o!="number"||o===0||re.hasOwnProperty(r)&&re[r]?(""+o).trim():o+"px"}function de(r,o){r=r.style;for(var d in o)if(o.hasOwnProperty(d)){var m=d.indexOf("--")===0,y=O(d,o[d],m);d==="float"&&(d="cssFloat"),m?r.setProperty(d,y):r[d]=y}}var we=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 We(r,o){if(o){if(we[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 ie(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 Pe=null;function ft(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Pt=null,bt=null,xt=null;function vt(r){if(r=Sl(r)){if(typeof Pt!="function")throw Error(n(280));var o=r.stateNode;o&&(o=su(o),Pt(r.stateNode,r.type,o))}}function Mt(r){bt?xt?xt.push(r):xt=[r]:bt=r}function Qt(){if(bt){var r=bt,o=xt;if(xt=bt=null,vt(r),o)for(r=0;r<o.length;r++)vt(o[r])}}function Dt(r,o){return r(o)}function It(){}var en=!1;function Kn(r,o,d){if(en)return r(o,d);en=!0;try{return Dt(r,o,d)}finally{en=!1,(bt!==null||xt!==null)&&(It(),Qt())}}function rn(r,o){var d=r.stateNode;if(d===null)return null;var m=su(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 tn=!1;if(u)try{var nn={};Object.defineProperty(nn,"passive",{get:function(){tn=!0}}),window.addEventListener("test",nn,nn),window.removeEventListener("test",nn,nn)}catch{tn=!1}function mn(r,o,d,m,y,x,z,ee,ue){var Ne=Array.prototype.slice.call(arguments,3);try{o.apply(d,Ne)}catch(Ue){this.onError(Ue)}}var Wt=!1,Zt=null,yn=!1,Vt=null,ln={onError:function(r){Wt=!0,Zt=r}};function Vs(r,o,d,m,y,x,z,ee,ue){Wt=!1,Zt=null,mn.apply(ln,arguments)}function vs(r,o,d,m,y,x,z,ee,ue){if(Vs.apply(this,arguments),Wt){if(Wt){var Ne=Zt;Wt=!1,Zt=null}else throw Error(n(198));yn||(yn=!0,Vt=Ne)}}function qt(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 Ys(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(qt(r)!==r)throw Error(n(188))}function ls(r){var o=r.alternate;if(!o){if(o=qt(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 x=y.alternate;if(x===null){if(m=y.return,m!==null){d=m;continue}break}if(y.child===x.child){for(x=y.child;x;){if(x===d)return Vn(y),r;if(x===m)return Vn(y),o;x=x.sibling}throw Error(n(188))}if(d.return!==m.return)d=y,m=x;else{for(var z=!1,ee=y.child;ee;){if(ee===d){z=!0,d=y,m=x;break}if(ee===m){z=!0,m=y,d=x;break}ee=ee.sibling}if(!z){for(ee=x.child;ee;){if(ee===d){z=!0,d=x,m=y;break}if(ee===m){z=!0,m=x,d=y;break}ee=ee.sibling}if(!z)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 St(r){return r=ls(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 oe=e.unstable_scheduleCallback,Me=e.unstable_cancelCallback,Ke=e.unstable_shouldYield,mt=e.unstable_requestPaint,q=e.unstable_now,ae=e.unstable_getCurrentPriorityLevel,Te=e.unstable_ImmediatePriority,Ge=e.unstable_UserBlockingPriority,Ae=e.unstable_NormalPriority,Ct=e.unstable_LowPriority,_t=e.unstable_IdlePriority,Qe=null,Lt=null;function Tn(r){if(Lt&&typeof Lt.onCommitFiberRoot=="function")try{Lt.onCommitFiberRoot(Qe,r,void 0,(r.current.flags&128)===128)}catch{}}var Xe=Math.clz32?Math.clz32:ke,st=Math.log,Ht=Math.LN2;function ke(r){return r>>>=0,r===0?32:31-(st(r)/Ht|0)|0}var je=64,Je=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 kt(r,o){var d=r.pendingLanes;if(d===0)return 0;var m=0,y=r.suspendedLanes,x=r.pingedLanes,z=d&268435455;if(z!==0){var ee=z&~y;ee!==0?m=ct(ee):(x&=z,x!==0&&(m=ct(x)))}else z=d&~y,z!==0?m=ct(z):x!==0&&(m=ct(x));if(m===0)return 0;if(o!==0&&o!==m&&(o&y)===0&&(y=m&-m,x=o&-o,y>=x||y===16&&(x&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-Xe(o),y=1<<d,m|=r[d],o&=~y;return m}function Gs(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 wi(r,o){for(var d=r.suspendedLanes,m=r.pingedLanes,y=r.expirationTimes,x=r.pendingLanes;0<x;){var z=31-Xe(x),ee=1<<z,ue=y[z];ue===-1?((ee&d)===0||(ee&m)!==0)&&(y[z]=Gs(ee,o)):ue<=o&&(r.expiredLanes|=ee),x&=~ee}}function Jt(r){return r=r.pendingLanes&-1073741825,r!==0?r:r&1073741824?1073741824:0}function _s(){var r=je;return je<<=1,(je&4194240)===0&&(je=64),r}function Ot(r){for(var o=[],d=0;31>d;d++)o.push(r);return o}function Os(r,o,d){r.pendingLanes|=o,o!==536870912&&(r.suspendedLanes=0,r.pingedLanes=0),r=r.eventTimes,o=31-Xe(o),r[o]=d}function po(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-Xe(d),x=1<<y;o[y]=0,m[y]=-1,r[y]=-1,d&=~x}}function sr(r,o){var d=r.entangledLanes|=o;for(r=r.entanglements;d;){var m=31-Xe(d),y=1<<m;y&o|r[m]&o&&(r[m]|=o),d&=~y}}var Gt=0;function il(r){return r&=-r,1<r?4<r?(r&268435455)!==0?16:536870912:4:1}var rl,Qo,Xs,ol,al,Zo=!1,ir=[],ys=null,Js=null,bi=null,rr=new Map,jr=new Map,Ls=[],Yc="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 or(r,o){switch(r){case"focusin":case"focusout":ys=null;break;case"dragenter":case"dragleave":Js=null;break;case"mouseover":case"mouseout":bi=null;break;case"pointerover":case"pointerout":rr.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":jr.delete(o.pointerId)}}function ws(r,o,d,m,y,x){return r===null||r.nativeEvent!==x?(r={blockedOn:o,domEventName:d,eventSystemFlags:m,nativeEvent:x,targetContainers:[y]},o!==null&&(o=Sl(o),o!==null&&Qo(o)),r):(r.eventSystemFlags|=m,o=r.targetContainers,y!==null&&o.indexOf(y)===-1&&o.push(y),r)}function ll(r,o,d,m,y){switch(o){case"focusin":return ys=ws(ys,r,o,d,m,y),!0;case"dragenter":return Js=ws(Js,r,o,d,m,y),!0;case"mouseover":return bi=ws(bi,r,o,d,m,y),!0;case"pointerover":var x=y.pointerId;return rr.set(x,ws(rr.get(x)||null,r,o,d,m,y)),!0;case"gotpointercapture":return x=y.pointerId,jr.set(x,ws(jr.get(x)||null,r,o,d,m,y)),!0}return!1}function cl(r){var o=vo(r.target);if(o!==null){var d=qt(o);if(d!==null){if(o=d.tag,o===13){if(o=Ys(d),o!==null){r.blockedOn=o,al(r.priority,function(){Xs(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 Yn(r){if(r.blockedOn!==null)return!1;for(var o=r.targetContainers;0<o.length;){var d=sa(r.domEventName,r.eventSystemFlags,o[0],r.nativeEvent);if(d===null){d=r.nativeEvent;var m=new d.constructor(d.type,d);Pe=m,d.target.dispatchEvent(m),Pe=null}else return o=Sl(d),o!==null&&Qo(o),r.blockedOn=d,!1;o.shift()}return!0}function ul(r,o,d){Yn(r)&&d.delete(o)}function ea(){Zo=!1,ys!==null&&Yn(ys)&&(ys=null),Js!==null&&Yn(Js)&&(Js=null),bi!==null&&Yn(bi)&&(bi=null),rr.forEach(ul),jr.forEach(ul)}function Si(r,o){r.blockedOn===o&&(r.blockedOn=null,Zo||(Zo=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,ea)))}function Di(r){function o(y){return Si(y,r)}if(0<ir.length){Si(ir[0],r);for(var d=1;d<ir.length;d++){var m=ir[d];m.blockedOn===r&&(m.blockedOn=null)}}for(ys!==null&&Si(ys,r),Js!==null&&Si(Js,r),bi!==null&&Si(bi,r),rr.forEach(o),jr.forEach(o),d=0;d<Ls.length;d++)m=Ls[d],m.blockedOn===r&&(m.blockedOn=null);for(;0<Ls.length&&(d=Ls[0],d.blockedOn===null);)cl(d),d.blockedOn===null&&Ls.shift()}var ar=E.ReactCurrentBatchConfig,lr=!0;function Gc(r,o,d,m){var y=Gt,x=ar.transition;ar.transition=null;try{Gt=1,na(r,o,d,m)}finally{Gt=y,ar.transition=x}}function ta(r,o,d,m){var y=Gt,x=ar.transition;ar.transition=null;try{Gt=4,na(r,o,d,m)}finally{Gt=y,ar.transition=x}}function na(r,o,d,m){if(lr){var y=sa(r,o,d,m);if(y===null)Mh(r,o,m,mo,d),or(r,m);else if(ll(y,r,o,d,m))m.stopPropagation();else if(or(r,m),o&4&&-1<Yc.indexOf(r)){for(;y!==null;){var x=Sl(y);if(x!==null&&rl(x),x=sa(r,o,d,m),x===null&&Mh(r,o,m,mo,d),x===y)break;y=x}y!==null&&m.stopPropagation()}else Mh(r,o,m,null,d)}}var mo=null;function sa(r,o,d,m){if(mo=null,r=ft(m),r=vo(r),r!==null)if(o=qt(r),o===null)r=null;else if(d=o.tag,d===13){if(r=Ys(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 mo=r,null}function dl(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 Te:return 1;case Ge:return 4;case Ae:case Ct:return 16;case _t:return 536870912;default:return 16}default:return 16}}var xi=null,ia=null,ye=null;function Ye(){if(ye)return ye;var r,o=ia,d=o.length,m,y="value"in xi?xi.value:xi.textContent,x=y.length;for(r=0;r<d&&o[r]===y[r];r++);var z=d-r;for(m=1;m<=z&&o[d-m]===y[x-m];m++);return ye=y.slice(r,1<m?1-m:void 0)}function tt(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 dt(){return!0}function Rt(){return!1}function wt(r){function o(d,m,y,x,z){this._reactName=d,this._targetInst=y,this.type=m,this.nativeEvent=x,this.target=z,this.currentTarget=null;for(var ee in r)r.hasOwnProperty(ee)&&(d=r[ee],this[ee]=d?d(x):x[ee]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?dt:Rt,this.isPropagationStopped=Rt,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=dt)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=dt)},persist:function(){},isPersistent:dt}),o}var Kt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cn=wt(Kt),Pn=U({},Kt,{view:0,detail:0}),Ln=wt(Pn),bs,ii,go,hl=U({},Pn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bh,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!==go&&(go&&r.type==="mousemove"?(bs=r.screenX-go.screenX,ii=r.screenY-go.screenY):ii=bs=0,go=r),bs)},movementY:function(r){return"movementY"in r?r.movementY:ii}}),g_=wt(hl),WE=U({},hl,{dataTransfer:0}),qE=wt(WE),KE=U({},Pn,{relatedTarget:0}),wh=wt(KE),VE=U({},Kt,{animationName:0,elapsedTime:0,pseudoElement:0}),YE=wt(VE),GE=U({},Kt,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),XE=wt(GE),JE=U({},Kt,{data:0}),v_=wt(JE),QE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ZE={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"},e2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function t2(r){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(r):(r=e2[r])?!!o[r]:!1}function bh(){return t2}var n2=U({},Pn,{key:function(r){if(r.key){var o=QE[r.key]||r.key;if(o!=="Unidentified")return o}return r.type==="keypress"?(r=tt(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?ZE[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bh,charCode:function(r){return r.type==="keypress"?tt(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?tt(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),s2=wt(n2),i2=U({},hl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),__=wt(i2),r2=U({},Pn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bh}),o2=wt(r2),a2=U({},Kt,{propertyName:0,elapsedTime:0,pseudoElement:0}),l2=wt(a2),c2=U({},hl,{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}),u2=wt(c2),d2=[9,13,27,32],Sh=u&&"CompositionEvent"in window,fl=null;u&&"documentMode"in document&&(fl=document.documentMode);var h2=u&&"TextEvent"in window&&!fl,y_=u&&(!Sh||fl&&8<fl&&11>=fl),w_=" ",b_=!1;function S_(r,o){switch(r){case"keyup":return d2.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function x_(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var ra=!1;function f2(r,o){switch(r){case"compositionend":return x_(o);case"keypress":return o.which!==32?null:(b_=!0,w_);case"textInput":return r=o.data,r===w_&&b_?null:r;default:return null}}function p2(r,o){if(ra)return r==="compositionend"||!Sh&&S_(r,o)?(r=Ye(),ye=ia=xi=null,ra=!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 y_&&o.locale!=="ko"?null:o.data;default:return null}}var m2={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 k_(r){var o=r&&r.nodeName&&r.nodeName.toLowerCase();return o==="input"?!!m2[r.type]:o==="textarea"}function C_(r,o,d,m){Mt(m),o=eu(o,"onChange"),0<o.length&&(d=new cn("onChange","change",null,d,m),r.push({event:d,listeners:o}))}var pl=null,ml=null;function g2(r){U_(r,0)}function Xc(r){var o=ua(r);if(Le(o))return r}function v2(r,o){if(r==="change")return o}var E_=!1;if(u){var xh;if(u){var kh="oninput"in document;if(!kh){var N_=document.createElement("div");N_.setAttribute("oninput","return;"),kh=typeof N_.oninput=="function"}xh=kh}else xh=!1;E_=xh&&(!document.documentMode||9<document.documentMode)}function R_(){pl&&(pl.detachEvent("onpropertychange",L_),ml=pl=null)}function L_(r){if(r.propertyName==="value"&&Xc(ml)){var o=[];C_(o,ml,r,ft(r)),Kn(g2,o)}}function _2(r,o,d){r==="focusin"?(R_(),pl=o,ml=d,pl.attachEvent("onpropertychange",L_)):r==="focusout"&&R_()}function y2(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Xc(ml)}function w2(r,o){if(r==="click")return Xc(o)}function b2(r,o){if(r==="input"||r==="change")return Xc(o)}function S2(r,o){return r===o&&(r!==0||1/r===1/o)||r!==r&&o!==o}var ki=typeof Object.is=="function"?Object.is:S2;function gl(r,o){if(ki(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)||!ki(r[y],o[y]))return!1}return!0}function A_(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function j_(r,o){var d=A_(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=A_(d)}}function M_(r,o){return r&&o?r===o?!0:r&&r.nodeType===3?!1:o&&o.nodeType===3?M_(r,o.parentNode):"contains"in r?r.contains(o):r.compareDocumentPosition?!!(r.compareDocumentPosition(o)&16):!1:!1}function T_(){for(var r=window,o=ze();o instanceof r.HTMLIFrameElement;){try{var d=typeof o.contentWindow.location.href=="string"}catch{d=!1}if(d)r=o.contentWindow;else break;o=ze(r.document)}return o}function Ch(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 x2(r){var o=T_(),d=r.focusedElem,m=r.selectionRange;if(o!==d&&d&&d.ownerDocument&&M_(d.ownerDocument.documentElement,d)){if(m!==null&&Ch(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,x=Math.min(m.start,y);m=m.end===void 0?x:Math.min(m.end,y),!r.extend&&x>m&&(y=m,m=x,x=y),y=j_(d,x);var z=j_(d,m);y&&z&&(r.rangeCount!==1||r.anchorNode!==y.node||r.anchorOffset!==y.offset||r.focusNode!==z.node||r.focusOffset!==z.offset)&&(o=o.createRange(),o.setStart(y.node,y.offset),r.removeAllRanges(),x>m?(r.addRange(o),r.extend(z.node,z.offset)):(o.setEnd(z.node,z.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 k2=u&&"documentMode"in document&&11>=document.documentMode,oa=null,Eh=null,vl=null,Nh=!1;function P_(r,o,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Nh||oa==null||oa!==ze(m)||(m=oa,"selectionStart"in m&&Ch(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}),vl&&gl(vl,m)||(vl=m,m=eu(Eh,"onSelect"),0<m.length&&(o=new cn("onSelect","select",null,o,d),r.push({event:o,listeners:m}),o.target=oa)))}function Jc(r,o){var d={};return d[r.toLowerCase()]=o.toLowerCase(),d["Webkit"+r]="webkit"+o,d["Moz"+r]="moz"+o,d}var aa={animationend:Jc("Animation","AnimationEnd"),animationiteration:Jc("Animation","AnimationIteration"),animationstart:Jc("Animation","AnimationStart"),transitionend:Jc("Transition","TransitionEnd")},Rh={},I_={};u&&(I_=document.createElement("div").style,"AnimationEvent"in window||(delete aa.animationend.animation,delete aa.animationiteration.animation,delete aa.animationstart.animation),"TransitionEvent"in window||delete aa.transitionend.transition);function Qc(r){if(Rh[r])return Rh[r];if(!aa[r])return r;var o=aa[r],d;for(d in o)if(o.hasOwnProperty(d)&&d in I_)return Rh[r]=o[d];return r}var D_=Qc("animationend"),O_=Qc("animationiteration"),B_=Qc("animationstart"),$_=Qc("transitionend"),z_=new Map,F_="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 Mr(r,o){z_.set(r,o),a(o,[r])}for(var Lh=0;Lh<F_.length;Lh++){var Ah=F_[Lh],C2=Ah.toLowerCase(),E2=Ah[0].toUpperCase()+Ah.slice(1);Mr(C2,"on"+E2)}Mr(D_,"onAnimationEnd"),Mr(O_,"onAnimationIteration"),Mr(B_,"onAnimationStart"),Mr("dblclick","onDoubleClick"),Mr("focusin","onFocus"),Mr("focusout","onBlur"),Mr($_,"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 _l="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(" "),N2=new Set("cancel close invalid load scroll toggle".split(" ").concat(_l));function H_(r,o,d){var m=r.type||"unknown-event";r.currentTarget=d,vs(m,o,void 0,r),r.currentTarget=null}function U_(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 x=void 0;if(o)for(var z=m.length-1;0<=z;z--){var ee=m[z],ue=ee.instance,Ne=ee.currentTarget;if(ee=ee.listener,ue!==x&&y.isPropagationStopped())break e;H_(y,ee,Ne),x=ue}else for(z=0;z<m.length;z++){if(ee=m[z],ue=ee.instance,Ne=ee.currentTarget,ee=ee.listener,ue!==x&&y.isPropagationStopped())break e;H_(y,ee,Ne),x=ue}}}if(yn)throw r=Vt,yn=!1,Vt=null,r}function un(r,o){var d=o[Bh];d===void 0&&(d=o[Bh]=new Set);var m=r+"__bubble";d.has(m)||(W_(o,r,2,!1),d.add(m))}function jh(r,o,d){var m=0;o&&(m|=4),W_(d,r,m,o)}var Zc="_reactListening"+Math.random().toString(36).slice(2);function yl(r){if(!r[Zc]){r[Zc]=!0,s.forEach(function(d){d!=="selectionchange"&&(N2.has(d)||jh(d,!1,r),jh(d,!0,r))});var o=r.nodeType===9?r:r.ownerDocument;o===null||o[Zc]||(o[Zc]=!0,jh("selectionchange",!1,o))}}function W_(r,o,d,m){switch(dl(o)){case 1:var y=Gc;break;case 4:y=ta;break;default:y=na}d=y.bind(null,o,d,r),y=void 0,!tn||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 Mh(r,o,d,m,y){var x=m;if((o&1)===0&&(o&2)===0&&m!==null)e:for(;;){if(m===null)return;var z=m.tag;if(z===3||z===4){var ee=m.stateNode.containerInfo;if(ee===y||ee.nodeType===8&&ee.parentNode===y)break;if(z===4)for(z=m.return;z!==null;){var ue=z.tag;if((ue===3||ue===4)&&(ue=z.stateNode.containerInfo,ue===y||ue.nodeType===8&&ue.parentNode===y))return;z=z.return}for(;ee!==null;){if(z=vo(ee),z===null)return;if(ue=z.tag,ue===5||ue===6){m=x=z;continue e}ee=ee.parentNode}}m=m.return}Kn(function(){var Ne=x,Ue=ft(d),Ve=[];e:{var He=z_.get(r);if(He!==void 0){var ut=cn,pt=r;switch(r){case"keypress":if(tt(d)===0)break e;case"keydown":case"keyup":ut=s2;break;case"focusin":pt="focus",ut=wh;break;case"focusout":pt="blur",ut=wh;break;case"beforeblur":case"afterblur":ut=wh;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":ut=g_;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ut=qE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ut=o2;break;case D_:case O_:case B_:ut=YE;break;case $_:ut=l2;break;case"scroll":ut=Ln;break;case"wheel":ut=u2;break;case"copy":case"cut":case"paste":ut=XE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ut=__}var gt=(o&4)!==0,An=!gt&&r==="scroll",xe=gt?He!==null?He+"Capture":null:He;gt=[];for(var he=Ne,Ce;he!==null;){Ce=he;var et=Ce.stateNode;if(Ce.tag===5&&et!==null&&(Ce=et,xe!==null&&(et=rn(he,xe),et!=null&>.push(wl(he,et,Ce)))),An)break;he=he.return}0<gt.length&&(He=new ut(He,pt,null,d,Ue),Ve.push({event:He,listeners:gt}))}}if((o&7)===0){e:{if(He=r==="mouseover"||r==="pointerover",ut=r==="mouseout"||r==="pointerout",He&&d!==Pe&&(pt=d.relatedTarget||d.fromElement)&&(vo(pt)||pt[cr]))break e;if((ut||He)&&(He=Ue.window===Ue?Ue:(He=Ue.ownerDocument)?He.defaultView||He.parentWindow:window,ut?(pt=d.relatedTarget||d.toElement,ut=Ne,pt=pt?vo(pt):null,pt!==null&&(An=qt(pt),pt!==An||pt.tag!==5&&pt.tag!==6)&&(pt=null)):(ut=null,pt=Ne),ut!==pt)){if(gt=g_,et="onMouseLeave",xe="onMouseEnter",he="mouse",(r==="pointerout"||r==="pointerover")&&(gt=__,et="onPointerLeave",xe="onPointerEnter",he="pointer"),An=ut==null?He:ua(ut),Ce=pt==null?He:ua(pt),He=new gt(et,he+"leave",ut,d,Ue),He.target=An,He.relatedTarget=Ce,et=null,vo(Ue)===Ne&&(gt=new gt(xe,he+"enter",pt,d,Ue),gt.target=Ce,gt.relatedTarget=An,et=gt),An=et,ut&&pt)t:{for(gt=ut,xe=pt,he=0,Ce=gt;Ce;Ce=la(Ce))he++;for(Ce=0,et=xe;et;et=la(et))Ce++;for(;0<he-Ce;)gt=la(gt),he--;for(;0<Ce-he;)xe=la(xe),Ce--;for(;he--;){if(gt===xe||xe!==null&>===xe.alternate)break t;gt=la(gt),xe=la(xe)}gt=null}else gt=null;ut!==null&&q_(Ve,He,ut,gt,!1),pt!==null&&An!==null&&q_(Ve,An,pt,gt,!0)}}e:{if(He=Ne?ua(Ne):window,ut=He.nodeName&&He.nodeName.toLowerCase(),ut==="select"||ut==="input"&&He.type==="file")var yt=v2;else if(k_(He))if(E_)yt=b2;else{yt=y2;var Et=_2}else(ut=He.nodeName)&&ut.toLowerCase()==="input"&&(He.type==="checkbox"||He.type==="radio")&&(yt=w2);if(yt&&(yt=yt(r,Ne))){C_(Ve,yt,d,Ue);break e}Et&&Et(r,He,Ne),r==="focusout"&&(Et=He._wrapperState)&&Et.controlled&&He.type==="number"&&fe(He,"number",He.value)}switch(Et=Ne?ua(Ne):window,r){case"focusin":(k_(Et)||Et.contentEditable==="true")&&(oa=Et,Eh=Ne,vl=null);break;case"focusout":vl=Eh=oa=null;break;case"mousedown":Nh=!0;break;case"contextmenu":case"mouseup":case"dragend":Nh=!1,P_(Ve,d,Ue);break;case"selectionchange":if(k2)break;case"keydown":case"keyup":P_(Ve,d,Ue)}var Nt;if(Sh)e:{switch(r){case"compositionstart":var At="onCompositionStart";break e;case"compositionend":At="onCompositionEnd";break e;case"compositionupdate":At="onCompositionUpdate";break e}At=void 0}else ra?S_(r,d)&&(At="onCompositionEnd"):r==="keydown"&&d.keyCode===229&&(At="onCompositionStart");At&&(y_&&d.locale!=="ko"&&(ra||At!=="onCompositionStart"?At==="onCompositionEnd"&&ra&&(Nt=Ye()):(xi=Ue,ia="value"in xi?xi.value:xi.textContent,ra=!0)),Et=eu(Ne,At),0<Et.length&&(At=new v_(At,r,null,d,Ue),Ve.push({event:At,listeners:Et}),Nt?At.data=Nt:(Nt=x_(d),Nt!==null&&(At.data=Nt)))),(Nt=h2?f2(r,d):p2(r,d))&&(Ne=eu(Ne,"onBeforeInput"),0<Ne.length&&(Ue=new v_("onBeforeInput","beforeinput",null,d,Ue),Ve.push({event:Ue,listeners:Ne}),Ue.data=Nt))}U_(Ve,o)})}function wl(r,o,d){return{instance:r,listener:o,currentTarget:d}}function eu(r,o){for(var d=o+"Capture",m=[];r!==null;){var y=r,x=y.stateNode;y.tag===5&&x!==null&&(y=x,x=rn(r,d),x!=null&&m.unshift(wl(r,x,y)),x=rn(r,o),x!=null&&m.push(wl(r,x,y))),r=r.return}return m}function la(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5);return r||null}function q_(r,o,d,m,y){for(var x=o._reactName,z=[];d!==null&&d!==m;){var ee=d,ue=ee.alternate,Ne=ee.stateNode;if(ue!==null&&ue===m)break;ee.tag===5&&Ne!==null&&(ee=Ne,y?(ue=rn(d,x),ue!=null&&z.unshift(wl(d,ue,ee))):y||(ue=rn(d,x),ue!=null&&z.push(wl(d,ue,ee)))),d=d.return}z.length!==0&&r.push({event:o,listeners:z})}var R2=/\r\n?/g,L2=/\u0000|\uFFFD/g;function K_(r){return(typeof r=="string"?r:""+r).replace(R2,`
|
|
38
|
+
`).replace(L2,"")}function tu(r,o,d){if(o=K_(o),K_(r)!==o&&d)throw Error(n(425))}function nu(){}var Th=null,Ph=null;function Ih(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 Dh=typeof setTimeout=="function"?setTimeout:void 0,A2=typeof clearTimeout=="function"?clearTimeout:void 0,V_=typeof Promise=="function"?Promise:void 0,j2=typeof queueMicrotask=="function"?queueMicrotask:typeof V_<"u"?function(r){return V_.resolve(null).then(r).catch(M2)}:Dh;function M2(r){setTimeout(function(){throw r})}function Oh(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),Di(o);return}m--}else d!=="$"&&d!=="$?"&&d!=="$!"||m++;d=y}while(d);Di(o)}function Tr(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 Y_(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 ca=Math.random().toString(36).slice(2),Oi="__reactFiber$"+ca,bl="__reactProps$"+ca,cr="__reactContainer$"+ca,Bh="__reactEvents$"+ca,T2="__reactListeners$"+ca,P2="__reactHandles$"+ca;function vo(r){var o=r[Oi];if(o)return o;for(var d=r.parentNode;d;){if(o=d[cr]||d[Oi]){if(d=o.alternate,o.child!==null||d!==null&&d.child!==null)for(r=Y_(r);r!==null;){if(d=r[Oi])return d;r=Y_(r)}return o}r=d,d=r.parentNode}return null}function Sl(r){return r=r[Oi]||r[cr],!r||r.tag!==5&&r.tag!==6&&r.tag!==13&&r.tag!==3?null:r}function ua(r){if(r.tag===5||r.tag===6)return r.stateNode;throw Error(n(33))}function su(r){return r[bl]||null}var $h=[],da=-1;function Pr(r){return{current:r}}function dn(r){0>da||(r.current=$h[da],$h[da]=null,da--)}function on(r,o){da++,$h[da]=r.current,r.current=o}var Ir={},Ss=Pr(Ir),Bs=Pr(!1),_o=Ir;function ha(r,o){var d=r.type.contextTypes;if(!d)return Ir;var m=r.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===o)return m.__reactInternalMemoizedMaskedChildContext;var y={},x;for(x in d)y[x]=o[x];return m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=o,r.__reactInternalMemoizedMaskedChildContext=y),y}function $s(r){return r=r.childContextTypes,r!=null}function iu(){dn(Bs),dn(Ss)}function G_(r,o,d){if(Ss.current!==Ir)throw Error(n(168));on(Ss,o),on(Bs,d)}function X_(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,J(r)||"Unknown",y));return U({},d,m)}function ru(r){return r=(r=r.stateNode)&&r.__reactInternalMemoizedMergedChildContext||Ir,_o=Ss.current,on(Ss,r),on(Bs,Bs.current),!0}function J_(r,o,d){var m=r.stateNode;if(!m)throw Error(n(169));d?(r=X_(r,o,_o),m.__reactInternalMemoizedMergedChildContext=r,dn(Bs),dn(Ss),on(Ss,r)):dn(Bs),on(Bs,d)}var ur=null,ou=!1,zh=!1;function Q_(r){ur===null?ur=[r]:ur.push(r)}function I2(r){ou=!0,Q_(r)}function Dr(){if(!zh&&ur!==null){zh=!0;var r=0,o=Gt;try{var d=ur;for(Gt=1;r<d.length;r++){var m=d[r];do m=m(!0);while(m!==null)}ur=null,ou=!1}catch(y){throw ur!==null&&(ur=ur.slice(r+1)),oe(Te,Dr),y}finally{Gt=o,zh=!1}}return null}var fa=[],pa=0,au=null,lu=0,ri=[],oi=0,yo=null,dr=1,hr="";function wo(r,o){fa[pa++]=lu,fa[pa++]=au,au=r,lu=o}function Z_(r,o,d){ri[oi++]=dr,ri[oi++]=hr,ri[oi++]=yo,yo=r;var m=dr;r=hr;var y=32-Xe(m)-1;m&=~(1<<y),d+=1;var x=32-Xe(o)+y;if(30<x){var z=y-y%5;x=(m&(1<<z)-1).toString(32),m>>=z,y-=z,dr=1<<32-Xe(o)+y|d<<y|m,hr=x+r}else dr=1<<x|d<<y|m,hr=r}function Fh(r){r.return!==null&&(wo(r,1),Z_(r,1,0))}function Hh(r){for(;r===au;)au=fa[--pa],fa[pa]=null,lu=fa[--pa],fa[pa]=null;for(;r===yo;)yo=ri[--oi],ri[oi]=null,hr=ri[--oi],ri[oi]=null,dr=ri[--oi],ri[oi]=null}var Qs=null,Zs=null,gn=!1,Ci=null;function ey(r,o){var d=ui(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 ty(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,Qs=r,Zs=Tr(o.firstChild),!0):!1;case 6:return o=r.pendingProps===""||o.nodeType!==3?null:o,o!==null?(r.stateNode=o,Qs=r,Zs=null,!0):!1;case 13:return o=o.nodeType!==8?null:o,o!==null?(d=yo!==null?{id:dr,overflow:hr}:null,r.memoizedState={dehydrated:o,treeContext:d,retryLane:1073741824},d=ui(18,null,null,0),d.stateNode=o,d.return=r,r.child=d,Qs=r,Zs=null,!0):!1;default:return!1}}function Uh(r){return(r.mode&1)!==0&&(r.flags&128)===0}function Wh(r){if(gn){var o=Zs;if(o){var d=o;if(!ty(r,o)){if(Uh(r))throw Error(n(418));o=Tr(d.nextSibling);var m=Qs;o&&ty(r,o)?ey(m,d):(r.flags=r.flags&-4097|2,gn=!1,Qs=r)}}else{if(Uh(r))throw Error(n(418));r.flags=r.flags&-4097|2,gn=!1,Qs=r}}}function ny(r){for(r=r.return;r!==null&&r.tag!==5&&r.tag!==3&&r.tag!==13;)r=r.return;Qs=r}function cu(r){if(r!==Qs)return!1;if(!gn)return ny(r),gn=!0,!1;var o;if((o=r.tag!==3)&&!(o=r.tag!==5)&&(o=r.type,o=o!=="head"&&o!=="body"&&!Ih(r.type,r.memoizedProps)),o&&(o=Zs)){if(Uh(r))throw sy(),Error(n(418));for(;o;)ey(r,o),o=Tr(o.nextSibling)}if(ny(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){Zs=Tr(r.nextSibling);break e}o--}else d!=="$"&&d!=="$!"&&d!=="$?"||o++}r=r.nextSibling}Zs=null}}else Zs=Qs?Tr(r.stateNode.nextSibling):null;return!0}function sy(){for(var r=Zs;r;)r=Tr(r.nextSibling)}function ma(){Zs=Qs=null,gn=!1}function qh(r){Ci===null?Ci=[r]:Ci.push(r)}var D2=E.ReactCurrentBatchConfig;function xl(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,x=""+r;return o!==null&&o.ref!==null&&typeof o.ref=="function"&&o.ref._stringRef===x?o.ref:(o=function(z){var ee=y.refs;z===null?delete ee[x]:ee[x]=z},o._stringRef=x,o)}if(typeof r!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,r))}return r}function uu(r,o){throw r=Object.prototype.toString.call(o),Error(n(31,r==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":r))}function iy(r){var o=r._init;return o(r._payload)}function ry(r){function o(xe,he){if(r){var Ce=xe.deletions;Ce===null?(xe.deletions=[he],xe.flags|=16):Ce.push(he)}}function d(xe,he){if(!r)return null;for(;he!==null;)o(xe,he),he=he.sibling;return null}function m(xe,he){for(xe=new Map;he!==null;)he.key!==null?xe.set(he.key,he):xe.set(he.index,he),he=he.sibling;return xe}function y(xe,he){return xe=Wr(xe,he),xe.index=0,xe.sibling=null,xe}function x(xe,he,Ce){return xe.index=Ce,r?(Ce=xe.alternate,Ce!==null?(Ce=Ce.index,Ce<he?(xe.flags|=2,he):Ce):(xe.flags|=2,he)):(xe.flags|=1048576,he)}function z(xe){return r&&xe.alternate===null&&(xe.flags|=2),xe}function ee(xe,he,Ce,et){return he===null||he.tag!==6?(he=Of(Ce,xe.mode,et),he.return=xe,he):(he=y(he,Ce),he.return=xe,he)}function ue(xe,he,Ce,et){var yt=Ce.type;return yt===X?Ue(xe,he,Ce.props.children,et,Ce.key):he!==null&&(he.elementType===yt||typeof yt=="object"&&yt!==null&&yt.$$typeof===$&&iy(yt)===he.type)?(et=y(he,Ce.props),et.ref=xl(xe,he,Ce),et.return=xe,et):(et=Pu(Ce.type,Ce.key,Ce.props,null,xe.mode,et),et.ref=xl(xe,he,Ce),et.return=xe,et)}function Ne(xe,he,Ce,et){return he===null||he.tag!==4||he.stateNode.containerInfo!==Ce.containerInfo||he.stateNode.implementation!==Ce.implementation?(he=Bf(Ce,xe.mode,et),he.return=xe,he):(he=y(he,Ce.children||[]),he.return=xe,he)}function Ue(xe,he,Ce,et,yt){return he===null||he.tag!==7?(he=Ro(Ce,xe.mode,et,yt),he.return=xe,he):(he=y(he,Ce),he.return=xe,he)}function Ve(xe,he,Ce){if(typeof he=="string"&&he!==""||typeof he=="number")return he=Of(""+he,xe.mode,Ce),he.return=xe,he;if(typeof he=="object"&&he!==null){switch(he.$$typeof){case H:return Ce=Pu(he.type,he.key,he.props,null,xe.mode,Ce),Ce.ref=xl(xe,null,he),Ce.return=xe,Ce;case F:return he=Bf(he,xe.mode,Ce),he.return=xe,he;case $:var et=he._init;return Ve(xe,et(he._payload),Ce)}if(Re(he)||N(he))return he=Ro(he,xe.mode,Ce,null),he.return=xe,he;uu(xe,he)}return null}function He(xe,he,Ce,et){var yt=he!==null?he.key:null;if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number")return yt!==null?null:ee(xe,he,""+Ce,et);if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case H:return Ce.key===yt?ue(xe,he,Ce,et):null;case F:return Ce.key===yt?Ne(xe,he,Ce,et):null;case $:return yt=Ce._init,He(xe,he,yt(Ce._payload),et)}if(Re(Ce)||N(Ce))return yt!==null?null:Ue(xe,he,Ce,et,null);uu(xe,Ce)}return null}function ut(xe,he,Ce,et,yt){if(typeof et=="string"&&et!==""||typeof et=="number")return xe=xe.get(Ce)||null,ee(he,xe,""+et,yt);if(typeof et=="object"&&et!==null){switch(et.$$typeof){case H:return xe=xe.get(et.key===null?Ce:et.key)||null,ue(he,xe,et,yt);case F:return xe=xe.get(et.key===null?Ce:et.key)||null,Ne(he,xe,et,yt);case $:var Et=et._init;return ut(xe,he,Ce,Et(et._payload),yt)}if(Re(et)||N(et))return xe=xe.get(Ce)||null,Ue(he,xe,et,yt,null);uu(he,et)}return null}function pt(xe,he,Ce,et){for(var yt=null,Et=null,Nt=he,At=he=0,Jn=null;Nt!==null&&At<Ce.length;At++){Nt.index>At?(Jn=Nt,Nt=null):Jn=Nt.sibling;var Xt=He(xe,Nt,Ce[At],et);if(Xt===null){Nt===null&&(Nt=Jn);break}r&&Nt&&Xt.alternate===null&&o(xe,Nt),he=x(Xt,he,At),Et===null?yt=Xt:Et.sibling=Xt,Et=Xt,Nt=Jn}if(At===Ce.length)return d(xe,Nt),gn&&wo(xe,At),yt;if(Nt===null){for(;At<Ce.length;At++)Nt=Ve(xe,Ce[At],et),Nt!==null&&(he=x(Nt,he,At),Et===null?yt=Nt:Et.sibling=Nt,Et=Nt);return gn&&wo(xe,At),yt}for(Nt=m(xe,Nt);At<Ce.length;At++)Jn=ut(Nt,xe,At,Ce[At],et),Jn!==null&&(r&&Jn.alternate!==null&&Nt.delete(Jn.key===null?At:Jn.key),he=x(Jn,he,At),Et===null?yt=Jn:Et.sibling=Jn,Et=Jn);return r&&Nt.forEach(function(qr){return o(xe,qr)}),gn&&wo(xe,At),yt}function gt(xe,he,Ce,et){var yt=N(Ce);if(typeof yt!="function")throw Error(n(150));if(Ce=yt.call(Ce),Ce==null)throw Error(n(151));for(var Et=yt=null,Nt=he,At=he=0,Jn=null,Xt=Ce.next();Nt!==null&&!Xt.done;At++,Xt=Ce.next()){Nt.index>At?(Jn=Nt,Nt=null):Jn=Nt.sibling;var qr=He(xe,Nt,Xt.value,et);if(qr===null){Nt===null&&(Nt=Jn);break}r&&Nt&&qr.alternate===null&&o(xe,Nt),he=x(qr,he,At),Et===null?yt=qr:Et.sibling=qr,Et=qr,Nt=Jn}if(Xt.done)return d(xe,Nt),gn&&wo(xe,At),yt;if(Nt===null){for(;!Xt.done;At++,Xt=Ce.next())Xt=Ve(xe,Xt.value,et),Xt!==null&&(he=x(Xt,he,At),Et===null?yt=Xt:Et.sibling=Xt,Et=Xt);return gn&&wo(xe,At),yt}for(Nt=m(xe,Nt);!Xt.done;At++,Xt=Ce.next())Xt=ut(Nt,xe,At,Xt.value,et),Xt!==null&&(r&&Xt.alternate!==null&&Nt.delete(Xt.key===null?At:Xt.key),he=x(Xt,he,At),Et===null?yt=Xt:Et.sibling=Xt,Et=Xt);return r&&Nt.forEach(function(mN){return o(xe,mN)}),gn&&wo(xe,At),yt}function An(xe,he,Ce,et){if(typeof Ce=="object"&&Ce!==null&&Ce.type===X&&Ce.key===null&&(Ce=Ce.props.children),typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case H:e:{for(var yt=Ce.key,Et=he;Et!==null;){if(Et.key===yt){if(yt=Ce.type,yt===X){if(Et.tag===7){d(xe,Et.sibling),he=y(Et,Ce.props.children),he.return=xe,xe=he;break e}}else if(Et.elementType===yt||typeof yt=="object"&&yt!==null&&yt.$$typeof===$&&iy(yt)===Et.type){d(xe,Et.sibling),he=y(Et,Ce.props),he.ref=xl(xe,Et,Ce),he.return=xe,xe=he;break e}d(xe,Et);break}else o(xe,Et);Et=Et.sibling}Ce.type===X?(he=Ro(Ce.props.children,xe.mode,et,Ce.key),he.return=xe,xe=he):(et=Pu(Ce.type,Ce.key,Ce.props,null,xe.mode,et),et.ref=xl(xe,he,Ce),et.return=xe,xe=et)}return z(xe);case F:e:{for(Et=Ce.key;he!==null;){if(he.key===Et)if(he.tag===4&&he.stateNode.containerInfo===Ce.containerInfo&&he.stateNode.implementation===Ce.implementation){d(xe,he.sibling),he=y(he,Ce.children||[]),he.return=xe,xe=he;break e}else{d(xe,he);break}else o(xe,he);he=he.sibling}he=Bf(Ce,xe.mode,et),he.return=xe,xe=he}return z(xe);case $:return Et=Ce._init,An(xe,he,Et(Ce._payload),et)}if(Re(Ce))return pt(xe,he,Ce,et);if(N(Ce))return gt(xe,he,Ce,et);uu(xe,Ce)}return typeof Ce=="string"&&Ce!==""||typeof Ce=="number"?(Ce=""+Ce,he!==null&&he.tag===6?(d(xe,he.sibling),he=y(he,Ce),he.return=xe,xe=he):(d(xe,he),he=Of(Ce,xe.mode,et),he.return=xe,xe=he),z(xe)):d(xe,he)}return An}var ga=ry(!0),oy=ry(!1),du=Pr(null),hu=null,va=null,Kh=null;function Vh(){Kh=va=hu=null}function Yh(r){var o=du.current;dn(du),r._currentValue=o}function Gh(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 _a(r,o){hu=r,Kh=va=null,r=r.dependencies,r!==null&&r.firstContext!==null&&((r.lanes&o)!==0&&(zs=!0),r.firstContext=null)}function ai(r){var o=r._currentValue;if(Kh!==r)if(r={context:r,memoizedValue:o,next:null},va===null){if(hu===null)throw Error(n(308));va=r,hu.dependencies={lanes:0,firstContext:r}}else va=va.next=r;return o}var bo=null;function Xh(r){bo===null?bo=[r]:bo.push(r)}function ay(r,o,d,m){var y=o.interleaved;return y===null?(d.next=d,Xh(o)):(d.next=y.next,y.next=d),o.interleaved=d,fr(r,m)}function fr(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 Or=!1;function Jh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ly(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 pr(r,o){return{eventTime:r,lane:o,tag:0,payload:null,callback:null,next:null}}function Br(r,o,d){var m=r.updateQueue;if(m===null)return null;if(m=m.shared,(Yt&2)!==0){var y=m.pending;return y===null?o.next=o:(o.next=y.next,y.next=o),m.pending=o,fr(r,d)}return y=m.interleaved,y===null?(o.next=o,Xh(m)):(o.next=y.next,y.next=o),m.interleaved=o,fr(r,d)}function fu(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,sr(r,d)}}function cy(r,o){var d=r.updateQueue,m=r.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var y=null,x=null;if(d=d.firstBaseUpdate,d!==null){do{var z={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};x===null?y=x=z:x=x.next=z,d=d.next}while(d!==null);x===null?y=x=o:x=x.next=o}else y=x=o;d={baseState:m.baseState,firstBaseUpdate:y,lastBaseUpdate:x,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 pu(r,o,d,m){var y=r.updateQueue;Or=!1;var x=y.firstBaseUpdate,z=y.lastBaseUpdate,ee=y.shared.pending;if(ee!==null){y.shared.pending=null;var ue=ee,Ne=ue.next;ue.next=null,z===null?x=Ne:z.next=Ne,z=ue;var Ue=r.alternate;Ue!==null&&(Ue=Ue.updateQueue,ee=Ue.lastBaseUpdate,ee!==z&&(ee===null?Ue.firstBaseUpdate=Ne:ee.next=Ne,Ue.lastBaseUpdate=ue))}if(x!==null){var Ve=y.baseState;z=0,Ue=Ne=ue=null,ee=x;do{var He=ee.lane,ut=ee.eventTime;if((m&He)===He){Ue!==null&&(Ue=Ue.next={eventTime:ut,lane:0,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null});e:{var pt=r,gt=ee;switch(He=o,ut=d,gt.tag){case 1:if(pt=gt.payload,typeof pt=="function"){Ve=pt.call(ut,Ve,He);break e}Ve=pt;break e;case 3:pt.flags=pt.flags&-65537|128;case 0:if(pt=gt.payload,He=typeof pt=="function"?pt.call(ut,Ve,He):pt,He==null)break e;Ve=U({},Ve,He);break e;case 2:Or=!0}}ee.callback!==null&&ee.lane!==0&&(r.flags|=64,He=y.effects,He===null?y.effects=[ee]:He.push(ee))}else ut={eventTime:ut,lane:He,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},Ue===null?(Ne=Ue=ut,ue=Ve):Ue=Ue.next=ut,z|=He;if(ee=ee.next,ee===null){if(ee=y.shared.pending,ee===null)break;He=ee,ee=He.next,He.next=null,y.lastBaseUpdate=He,y.shared.pending=null}}while(!0);if(Ue===null&&(ue=Ve),y.baseState=ue,y.firstBaseUpdate=Ne,y.lastBaseUpdate=Ue,o=y.shared.interleaved,o!==null){y=o;do z|=y.lane,y=y.next;while(y!==o)}else x===null&&(y.shared.lanes=0);ko|=z,r.lanes=z,r.memoizedState=Ve}}function uy(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 kl={},Bi=Pr(kl),Cl=Pr(kl),El=Pr(kl);function So(r){if(r===kl)throw Error(n(174));return r}function Qh(r,o){switch(on(El,o),on(Cl,r),on(Bi,kl),r=o.nodeType,r){case 9:case 11:o=(o=o.documentElement)?o.namespaceURI:$e(null,"");break;default:r=r===8?o.parentNode:o,o=r.namespaceURI||null,r=r.tagName,o=$e(o,r)}dn(Bi),on(Bi,o)}function ya(){dn(Bi),dn(Cl),dn(El)}function dy(r){So(El.current);var o=So(Bi.current),d=$e(o,r.type);o!==d&&(on(Cl,r),on(Bi,d))}function Zh(r){Cl.current===r&&(dn(Bi),dn(Cl))}var wn=Pr(0);function mu(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 ef=[];function tf(){for(var r=0;r<ef.length;r++)ef[r]._workInProgressVersionPrimary=null;ef.length=0}var gu=E.ReactCurrentDispatcher,nf=E.ReactCurrentBatchConfig,xo=0,bn=null,zn=null,Gn=null,vu=!1,Nl=!1,Rl=0,O2=0;function xs(){throw Error(n(321))}function sf(r,o){if(o===null)return!1;for(var d=0;d<o.length&&d<r.length;d++)if(!ki(r[d],o[d]))return!1;return!0}function rf(r,o,d,m,y,x){if(xo=x,bn=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,gu.current=r===null||r.memoizedState===null?F2:H2,r=d(m,y),Nl){x=0;do{if(Nl=!1,Rl=0,25<=x)throw Error(n(301));x+=1,Gn=zn=null,o.updateQueue=null,gu.current=U2,r=d(m,y)}while(Nl)}if(gu.current=wu,o=zn!==null&&zn.next!==null,xo=0,Gn=zn=bn=null,vu=!1,o)throw Error(n(300));return r}function of(){var r=Rl!==0;return Rl=0,r}function $i(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Gn===null?bn.memoizedState=Gn=r:Gn=Gn.next=r,Gn}function li(){if(zn===null){var r=bn.alternate;r=r!==null?r.memoizedState:null}else r=zn.next;var o=Gn===null?bn.memoizedState:Gn.next;if(o!==null)Gn=o,zn=r;else{if(r===null)throw Error(n(310));zn=r,r={memoizedState:zn.memoizedState,baseState:zn.baseState,baseQueue:zn.baseQueue,queue:zn.queue,next:null},Gn===null?bn.memoizedState=Gn=r:Gn=Gn.next=r}return Gn}function Ll(r,o){return typeof o=="function"?o(r):o}function af(r){var o=li(),d=o.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=r;var m=zn,y=m.baseQueue,x=d.pending;if(x!==null){if(y!==null){var z=y.next;y.next=x.next,x.next=z}m.baseQueue=y=x,d.pending=null}if(y!==null){x=y.next,m=m.baseState;var ee=z=null,ue=null,Ne=x;do{var Ue=Ne.lane;if((xo&Ue)===Ue)ue!==null&&(ue=ue.next={lane:0,action:Ne.action,hasEagerState:Ne.hasEagerState,eagerState:Ne.eagerState,next:null}),m=Ne.hasEagerState?Ne.eagerState:r(m,Ne.action);else{var Ve={lane:Ue,action:Ne.action,hasEagerState:Ne.hasEagerState,eagerState:Ne.eagerState,next:null};ue===null?(ee=ue=Ve,z=m):ue=ue.next=Ve,bn.lanes|=Ue,ko|=Ue}Ne=Ne.next}while(Ne!==null&&Ne!==x);ue===null?z=m:ue.next=ee,ki(m,o.memoizedState)||(zs=!0),o.memoizedState=m,o.baseState=z,o.baseQueue=ue,d.lastRenderedState=m}if(r=d.interleaved,r!==null){y=r;do x=y.lane,bn.lanes|=x,ko|=x,y=y.next;while(y!==r)}else y===null&&(d.lanes=0);return[o.memoizedState,d.dispatch]}function lf(r){var o=li(),d=o.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=r;var m=d.dispatch,y=d.pending,x=o.memoizedState;if(y!==null){d.pending=null;var z=y=y.next;do x=r(x,z.action),z=z.next;while(z!==y);ki(x,o.memoizedState)||(zs=!0),o.memoizedState=x,o.baseQueue===null&&(o.baseState=x),d.lastRenderedState=x}return[x,m]}function hy(){}function fy(r,o){var d=bn,m=li(),y=o(),x=!ki(m.memoizedState,y);if(x&&(m.memoizedState=y,zs=!0),m=m.queue,cf(gy.bind(null,d,m,r),[r]),m.getSnapshot!==o||x||Gn!==null&&Gn.memoizedState.tag&1){if(d.flags|=2048,Al(9,my.bind(null,d,m,y,o),void 0,null),Xn===null)throw Error(n(349));(xo&30)!==0||py(d,o,y)}return y}function py(r,o,d){r.flags|=16384,r={getSnapshot:o,value:d},o=bn.updateQueue,o===null?(o={lastEffect:null,stores:null},bn.updateQueue=o,o.stores=[r]):(d=o.stores,d===null?o.stores=[r]:d.push(r))}function my(r,o,d,m){o.value=d,o.getSnapshot=m,vy(o)&&_y(r)}function gy(r,o,d){return d(function(){vy(o)&&_y(r)})}function vy(r){var o=r.getSnapshot;r=r.value;try{var d=o();return!ki(r,d)}catch{return!0}}function _y(r){var o=fr(r,1);o!==null&&Li(o,r,1,-1)}function yy(r){var o=$i();return typeof r=="function"&&(r=r()),o.memoizedState=o.baseState=r,r={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ll,lastRenderedState:r},o.queue=r,r=r.dispatch=z2.bind(null,bn,r),[o.memoizedState,r]}function Al(r,o,d,m){return r={tag:r,create:o,destroy:d,deps:m,next:null},o=bn.updateQueue,o===null?(o={lastEffect:null,stores:null},bn.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 wy(){return li().memoizedState}function _u(r,o,d,m){var y=$i();bn.flags|=r,y.memoizedState=Al(1|o,d,void 0,m===void 0?null:m)}function yu(r,o,d,m){var y=li();m=m===void 0?null:m;var x=void 0;if(zn!==null){var z=zn.memoizedState;if(x=z.destroy,m!==null&&sf(m,z.deps)){y.memoizedState=Al(o,d,x,m);return}}bn.flags|=r,y.memoizedState=Al(1|o,d,x,m)}function by(r,o){return _u(8390656,8,r,o)}function cf(r,o){return yu(2048,8,r,o)}function Sy(r,o){return yu(4,2,r,o)}function xy(r,o){return yu(4,4,r,o)}function ky(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 Cy(r,o,d){return d=d!=null?d.concat([r]):null,yu(4,4,ky.bind(null,o,r),d)}function uf(){}function Ey(r,o){var d=li();o=o===void 0?null:o;var m=d.memoizedState;return m!==null&&o!==null&&sf(o,m[1])?m[0]:(d.memoizedState=[r,o],r)}function Ny(r,o){var d=li();o=o===void 0?null:o;var m=d.memoizedState;return m!==null&&o!==null&&sf(o,m[1])?m[0]:(r=r(),d.memoizedState=[r,o],r)}function Ry(r,o,d){return(xo&21)===0?(r.baseState&&(r.baseState=!1,zs=!0),r.memoizedState=d):(ki(d,o)||(d=_s(),bn.lanes|=d,ko|=d,r.baseState=!0),o)}function B2(r,o){var d=Gt;Gt=d!==0&&4>d?d:4,r(!0);var m=nf.transition;nf.transition={};try{r(!1),o()}finally{Gt=d,nf.transition=m}}function Ly(){return li().memoizedState}function $2(r,o,d){var m=Hr(r);if(d={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null},Ay(r))jy(o,d);else if(d=ay(r,o,d,m),d!==null){var y=js();Li(d,r,m,y),My(d,o,m)}}function z2(r,o,d){var m=Hr(r),y={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null};if(Ay(r))jy(o,y);else{var x=r.alternate;if(r.lanes===0&&(x===null||x.lanes===0)&&(x=o.lastRenderedReducer,x!==null))try{var z=o.lastRenderedState,ee=x(z,d);if(y.hasEagerState=!0,y.eagerState=ee,ki(ee,z)){var ue=o.interleaved;ue===null?(y.next=y,Xh(o)):(y.next=ue.next,ue.next=y),o.interleaved=y;return}}catch{}finally{}d=ay(r,o,y,m),d!==null&&(y=js(),Li(d,r,m,y),My(d,o,m))}}function Ay(r){var o=r.alternate;return r===bn||o!==null&&o===bn}function jy(r,o){Nl=vu=!0;var d=r.pending;d===null?o.next=o:(o.next=d.next,d.next=o),r.pending=o}function My(r,o,d){if((d&4194240)!==0){var m=o.lanes;m&=r.pendingLanes,d|=m,o.lanes=d,sr(r,d)}}var wu={readContext:ai,useCallback:xs,useContext:xs,useEffect:xs,useImperativeHandle:xs,useInsertionEffect:xs,useLayoutEffect:xs,useMemo:xs,useReducer:xs,useRef:xs,useState:xs,useDebugValue:xs,useDeferredValue:xs,useTransition:xs,useMutableSource:xs,useSyncExternalStore:xs,useId:xs,unstable_isNewReconciler:!1},F2={readContext:ai,useCallback:function(r,o){return $i().memoizedState=[r,o===void 0?null:o],r},useContext:ai,useEffect:by,useImperativeHandle:function(r,o,d){return d=d!=null?d.concat([r]):null,_u(4194308,4,ky.bind(null,o,r),d)},useLayoutEffect:function(r,o){return _u(4194308,4,r,o)},useInsertionEffect:function(r,o){return _u(4,2,r,o)},useMemo:function(r,o){var d=$i();return o=o===void 0?null:o,r=r(),d.memoizedState=[r,o],r},useReducer:function(r,o,d){var m=$i();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=$2.bind(null,bn,r),[m.memoizedState,r]},useRef:function(r){var o=$i();return r={current:r},o.memoizedState=r},useState:yy,useDebugValue:uf,useDeferredValue:function(r){return $i().memoizedState=r},useTransition:function(){var r=yy(!1),o=r[0];return r=B2.bind(null,r[1]),$i().memoizedState=r,[o,r]},useMutableSource:function(){},useSyncExternalStore:function(r,o,d){var m=bn,y=$i();if(gn){if(d===void 0)throw Error(n(407));d=d()}else{if(d=o(),Xn===null)throw Error(n(349));(xo&30)!==0||py(m,o,d)}y.memoizedState=d;var x={value:d,getSnapshot:o};return y.queue=x,by(gy.bind(null,m,x,r),[r]),m.flags|=2048,Al(9,my.bind(null,m,x,d,o),void 0,null),d},useId:function(){var r=$i(),o=Xn.identifierPrefix;if(gn){var d=hr,m=dr;d=(m&~(1<<32-Xe(m)-1)).toString(32)+d,o=":"+o+"R"+d,d=Rl++,0<d&&(o+="H"+d.toString(32)),o+=":"}else d=O2++,o=":"+o+"r"+d.toString(32)+":";return r.memoizedState=o},unstable_isNewReconciler:!1},H2={readContext:ai,useCallback:Ey,useContext:ai,useEffect:cf,useImperativeHandle:Cy,useInsertionEffect:Sy,useLayoutEffect:xy,useMemo:Ny,useReducer:af,useRef:wy,useState:function(){return af(Ll)},useDebugValue:uf,useDeferredValue:function(r){var o=li();return Ry(o,zn.memoizedState,r)},useTransition:function(){var r=af(Ll)[0],o=li().memoizedState;return[r,o]},useMutableSource:hy,useSyncExternalStore:fy,useId:Ly,unstable_isNewReconciler:!1},U2={readContext:ai,useCallback:Ey,useContext:ai,useEffect:cf,useImperativeHandle:Cy,useInsertionEffect:Sy,useLayoutEffect:xy,useMemo:Ny,useReducer:lf,useRef:wy,useState:function(){return lf(Ll)},useDebugValue:uf,useDeferredValue:function(r){var o=li();return zn===null?o.memoizedState=r:Ry(o,zn.memoizedState,r)},useTransition:function(){var r=lf(Ll)[0],o=li().memoizedState;return[r,o]},useMutableSource:hy,useSyncExternalStore:fy,useId:Ly,unstable_isNewReconciler:!1};function Ei(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 df(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 bu={isMounted:function(r){return(r=r._reactInternals)?qt(r)===r:!1},enqueueSetState:function(r,o,d){r=r._reactInternals;var m=js(),y=Hr(r),x=pr(m,y);x.payload=o,d!=null&&(x.callback=d),o=Br(r,x,y),o!==null&&(Li(o,r,y,m),fu(o,r,y))},enqueueReplaceState:function(r,o,d){r=r._reactInternals;var m=js(),y=Hr(r),x=pr(m,y);x.tag=1,x.payload=o,d!=null&&(x.callback=d),o=Br(r,x,y),o!==null&&(Li(o,r,y,m),fu(o,r,y))},enqueueForceUpdate:function(r,o){r=r._reactInternals;var d=js(),m=Hr(r),y=pr(d,m);y.tag=2,o!=null&&(y.callback=o),o=Br(r,y,m),o!==null&&(Li(o,r,m,d),fu(o,r,m))}};function Ty(r,o,d,m,y,x,z){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(m,x,z):o.prototype&&o.prototype.isPureReactComponent?!gl(d,m)||!gl(y,x):!0}function Py(r,o,d){var m=!1,y=Ir,x=o.contextType;return typeof x=="object"&&x!==null?x=ai(x):(y=$s(o)?_o:Ss.current,m=o.contextTypes,x=(m=m!=null)?ha(r,y):Ir),o=new o(d,x),r.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=bu,r.stateNode=o,o._reactInternals=r,m&&(r=r.stateNode,r.__reactInternalMemoizedUnmaskedChildContext=y,r.__reactInternalMemoizedMaskedChildContext=x),o}function Iy(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&&bu.enqueueReplaceState(o,o.state,null)}function hf(r,o,d,m){var y=r.stateNode;y.props=d,y.state=r.memoizedState,y.refs={},Jh(r);var x=o.contextType;typeof x=="object"&&x!==null?y.context=ai(x):(x=$s(o)?_o:Ss.current,y.context=ha(r,x)),y.state=r.memoizedState,x=o.getDerivedStateFromProps,typeof x=="function"&&(df(r,o,x,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&&bu.enqueueReplaceState(y,y.state,null),pu(r,d,y,m),y.state=r.memoizedState),typeof y.componentDidMount=="function"&&(r.flags|=4194308)}function wa(r,o){try{var d="",m=o;do d+=pe(m),m=m.return;while(m);var y=d}catch(x){y=`
|
|
39
|
+
Error generating stack: `+x.message+`
|
|
40
|
+
`+x.stack}return{value:r,source:o,stack:y,digest:null}}function ff(r,o,d){return{value:r,source:null,stack:d??null,digest:o??null}}function pf(r,o){try{console.error(o.value)}catch(d){setTimeout(function(){throw d})}}var W2=typeof WeakMap=="function"?WeakMap:Map;function Dy(r,o,d){d=pr(-1,d),d.tag=3,d.payload={element:null};var m=o.value;return d.callback=function(){Ru||(Ru=!0,Lf=m),pf(r,o)},d}function Oy(r,o,d){d=pr(-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(){pf(r,o)}}var x=r.stateNode;return x!==null&&typeof x.componentDidCatch=="function"&&(d.callback=function(){pf(r,o),typeof m!="function"&&(zr===null?zr=new Set([this]):zr.add(this));var z=o.stack;this.componentDidCatch(o.value,{componentStack:z!==null?z:""})}),d}function By(r,o,d){var m=r.pingCache;if(m===null){m=r.pingCache=new W2;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=iN.bind(null,r,o,d),o.then(r,r))}function $y(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 zy(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=pr(-1,1),o.tag=2,Br(d,o,1))),d.lanes|=1),r):(r.flags|=65536,r.lanes=y,r)}var q2=E.ReactCurrentOwner,zs=!1;function As(r,o,d,m){o.child=r===null?oy(o,null,d,m):ga(o,r.child,d,m)}function Fy(r,o,d,m,y){d=d.render;var x=o.ref;return _a(o,y),m=rf(r,o,d,m,x,y),d=of(),r!==null&&!zs?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~y,mr(r,o,y)):(gn&&d&&Fh(o),o.flags|=1,As(r,o,m,y),o.child)}function Hy(r,o,d,m,y){if(r===null){var x=d.type;return typeof x=="function"&&!Df(x)&&x.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(o.tag=15,o.type=x,Uy(r,o,x,m,y)):(r=Pu(d.type,null,m,o,o.mode,y),r.ref=o.ref,r.return=o,o.child=r)}if(x=r.child,(r.lanes&y)===0){var z=x.memoizedProps;if(d=d.compare,d=d!==null?d:gl,d(z,m)&&r.ref===o.ref)return mr(r,o,y)}return o.flags|=1,r=Wr(x,m),r.ref=o.ref,r.return=o,o.child=r}function Uy(r,o,d,m,y){if(r!==null){var x=r.memoizedProps;if(gl(x,m)&&r.ref===o.ref)if(zs=!1,o.pendingProps=m=x,(r.lanes&y)!==0)(r.flags&131072)!==0&&(zs=!0);else return o.lanes=r.lanes,mr(r,o,y)}return mf(r,o,d,m,y)}function Wy(r,o,d){var m=o.pendingProps,y=m.children,x=r!==null?r.memoizedState:null;if(m.mode==="hidden")if((o.mode&1)===0)o.memoizedState={baseLanes:0,cachePool:null,transitions:null},on(Sa,ei),ei|=d;else{if((d&1073741824)===0)return r=x!==null?x.baseLanes|d:d,o.lanes=o.childLanes=1073741824,o.memoizedState={baseLanes:r,cachePool:null,transitions:null},o.updateQueue=null,on(Sa,ei),ei|=r,null;o.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=x!==null?x.baseLanes:d,on(Sa,ei),ei|=m}else x!==null?(m=x.baseLanes|d,o.memoizedState=null):m=d,on(Sa,ei),ei|=m;return As(r,o,y,d),o.child}function qy(r,o){var d=o.ref;(r===null&&d!==null||r!==null&&r.ref!==d)&&(o.flags|=512,o.flags|=2097152)}function mf(r,o,d,m,y){var x=$s(d)?_o:Ss.current;return x=ha(o,x),_a(o,y),d=rf(r,o,d,m,x,y),m=of(),r!==null&&!zs?(o.updateQueue=r.updateQueue,o.flags&=-2053,r.lanes&=~y,mr(r,o,y)):(gn&&m&&Fh(o),o.flags|=1,As(r,o,d,y),o.child)}function Ky(r,o,d,m,y){if($s(d)){var x=!0;ru(o)}else x=!1;if(_a(o,y),o.stateNode===null)xu(r,o),Py(o,d,m),hf(o,d,m,y),m=!0;else if(r===null){var z=o.stateNode,ee=o.memoizedProps;z.props=ee;var ue=z.context,Ne=d.contextType;typeof Ne=="object"&&Ne!==null?Ne=ai(Ne):(Ne=$s(d)?_o:Ss.current,Ne=ha(o,Ne));var Ue=d.getDerivedStateFromProps,Ve=typeof Ue=="function"||typeof z.getSnapshotBeforeUpdate=="function";Ve||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(ee!==m||ue!==Ne)&&Iy(o,z,m,Ne),Or=!1;var He=o.memoizedState;z.state=He,pu(o,m,z,y),ue=o.memoizedState,ee!==m||He!==ue||Bs.current||Or?(typeof Ue=="function"&&(df(o,d,Ue,m),ue=o.memoizedState),(ee=Or||Ty(o,d,ee,m,He,ue,Ne))?(Ve||typeof z.UNSAFE_componentWillMount!="function"&&typeof z.componentWillMount!="function"||(typeof z.componentWillMount=="function"&&z.componentWillMount(),typeof z.UNSAFE_componentWillMount=="function"&&z.UNSAFE_componentWillMount()),typeof z.componentDidMount=="function"&&(o.flags|=4194308)):(typeof z.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=m,o.memoizedState=ue),z.props=m,z.state=ue,z.context=Ne,m=ee):(typeof z.componentDidMount=="function"&&(o.flags|=4194308),m=!1)}else{z=o.stateNode,ly(r,o),ee=o.memoizedProps,Ne=o.type===o.elementType?ee:Ei(o.type,ee),z.props=Ne,Ve=o.pendingProps,He=z.context,ue=d.contextType,typeof ue=="object"&&ue!==null?ue=ai(ue):(ue=$s(d)?_o:Ss.current,ue=ha(o,ue));var ut=d.getDerivedStateFromProps;(Ue=typeof ut=="function"||typeof z.getSnapshotBeforeUpdate=="function")||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(ee!==Ve||He!==ue)&&Iy(o,z,m,ue),Or=!1,He=o.memoizedState,z.state=He,pu(o,m,z,y);var pt=o.memoizedState;ee!==Ve||He!==pt||Bs.current||Or?(typeof ut=="function"&&(df(o,d,ut,m),pt=o.memoizedState),(Ne=Or||Ty(o,d,Ne,m,He,pt,ue)||!1)?(Ue||typeof z.UNSAFE_componentWillUpdate!="function"&&typeof z.componentWillUpdate!="function"||(typeof z.componentWillUpdate=="function"&&z.componentWillUpdate(m,pt,ue),typeof z.UNSAFE_componentWillUpdate=="function"&&z.UNSAFE_componentWillUpdate(m,pt,ue)),typeof z.componentDidUpdate=="function"&&(o.flags|=4),typeof z.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof z.componentDidUpdate!="function"||ee===r.memoizedProps&&He===r.memoizedState||(o.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||ee===r.memoizedProps&&He===r.memoizedState||(o.flags|=1024),o.memoizedProps=m,o.memoizedState=pt),z.props=m,z.state=pt,z.context=ue,m=Ne):(typeof z.componentDidUpdate!="function"||ee===r.memoizedProps&&He===r.memoizedState||(o.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||ee===r.memoizedProps&&He===r.memoizedState||(o.flags|=1024),m=!1)}return gf(r,o,d,m,x,y)}function gf(r,o,d,m,y,x){qy(r,o);var z=(o.flags&128)!==0;if(!m&&!z)return y&&J_(o,d,!1),mr(r,o,x);m=o.stateNode,q2.current=o;var ee=z&&typeof d.getDerivedStateFromError!="function"?null:m.render();return o.flags|=1,r!==null&&z?(o.child=ga(o,r.child,null,x),o.child=ga(o,null,ee,x)):As(r,o,ee,x),o.memoizedState=m.state,y&&J_(o,d,!0),o.child}function Vy(r){var o=r.stateNode;o.pendingContext?G_(r,o.pendingContext,o.pendingContext!==o.context):o.context&&G_(r,o.context,!1),Qh(r,o.containerInfo)}function Yy(r,o,d,m,y){return ma(),qh(y),o.flags|=256,As(r,o,d,m),o.child}var vf={dehydrated:null,treeContext:null,retryLane:0};function _f(r){return{baseLanes:r,cachePool:null,transitions:null}}function Gy(r,o,d){var m=o.pendingProps,y=wn.current,x=!1,z=(o.flags&128)!==0,ee;if((ee=z)||(ee=r!==null&&r.memoizedState===null?!1:(y&2)!==0),ee?(x=!0,o.flags&=-129):(r===null||r.memoizedState!==null)&&(y|=1),on(wn,y&1),r===null)return Wh(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):(z=m.children,r=m.fallback,x?(m=o.mode,x=o.child,z={mode:"hidden",children:z},(m&1)===0&&x!==null?(x.childLanes=0,x.pendingProps=z):x=Iu(z,m,0,null),r=Ro(r,m,d,null),x.return=o,r.return=o,x.sibling=r,o.child=x,o.child.memoizedState=_f(d),o.memoizedState=vf,r):yf(o,z));if(y=r.memoizedState,y!==null&&(ee=y.dehydrated,ee!==null))return K2(r,o,z,m,ee,y,d);if(x){x=m.fallback,z=o.mode,y=r.child,ee=y.sibling;var ue={mode:"hidden",children:m.children};return(z&1)===0&&o.child!==y?(m=o.child,m.childLanes=0,m.pendingProps=ue,o.deletions=null):(m=Wr(y,ue),m.subtreeFlags=y.subtreeFlags&14680064),ee!==null?x=Wr(ee,x):(x=Ro(x,z,d,null),x.flags|=2),x.return=o,m.return=o,m.sibling=x,o.child=m,m=x,x=o.child,z=r.child.memoizedState,z=z===null?_f(d):{baseLanes:z.baseLanes|d,cachePool:null,transitions:z.transitions},x.memoizedState=z,x.childLanes=r.childLanes&~d,o.memoizedState=vf,m}return x=r.child,r=x.sibling,m=Wr(x,{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 yf(r,o){return o=Iu({mode:"visible",children:o},r.mode,0,null),o.return=r,r.child=o}function Su(r,o,d,m){return m!==null&&qh(m),ga(o,r.child,null,d),r=yf(o,o.pendingProps.children),r.flags|=2,o.memoizedState=null,r}function K2(r,o,d,m,y,x,z){if(d)return o.flags&256?(o.flags&=-257,m=ff(Error(n(422))),Su(r,o,z,m)):o.memoizedState!==null?(o.child=r.child,o.flags|=128,null):(x=m.fallback,y=o.mode,m=Iu({mode:"visible",children:m.children},y,0,null),x=Ro(x,y,z,null),x.flags|=2,m.return=o,x.return=o,m.sibling=x,o.child=m,(o.mode&1)!==0&&ga(o,r.child,null,z),o.child.memoizedState=_f(z),o.memoizedState=vf,x);if((o.mode&1)===0)return Su(r,o,z,null);if(y.data==="$!"){if(m=y.nextSibling&&y.nextSibling.dataset,m)var ee=m.dgst;return m=ee,x=Error(n(419)),m=ff(x,m,void 0),Su(r,o,z,m)}if(ee=(z&r.childLanes)!==0,zs||ee){if(m=Xn,m!==null){switch(z&-z){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|z))!==0?0:y,y!==0&&y!==x.retryLane&&(x.retryLane=y,fr(r,y),Li(m,r,y,-1))}return If(),m=ff(Error(n(421))),Su(r,o,z,m)}return y.data==="$?"?(o.flags|=128,o.child=r.child,o=rN.bind(null,r),y._reactRetry=o,null):(r=x.treeContext,Zs=Tr(y.nextSibling),Qs=o,gn=!0,Ci=null,r!==null&&(ri[oi++]=dr,ri[oi++]=hr,ri[oi++]=yo,dr=r.id,hr=r.overflow,yo=o),o=yf(o,m.children),o.flags|=4096,o)}function Xy(r,o,d){r.lanes|=o;var m=r.alternate;m!==null&&(m.lanes|=o),Gh(r.return,o,d)}function wf(r,o,d,m,y){var x=r.memoizedState;x===null?r.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:m,tail:d,tailMode:y}:(x.isBackwards=o,x.rendering=null,x.renderingStartTime=0,x.last=m,x.tail=d,x.tailMode=y)}function Jy(r,o,d){var m=o.pendingProps,y=m.revealOrder,x=m.tail;if(As(r,o,m.children,d),m=wn.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&&Xy(r,d,o);else if(r.tag===19)Xy(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(on(wn,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&&mu(r)===null&&(y=d),d=d.sibling;d=y,d===null?(y=o.child,o.child=null):(y=d.sibling,d.sibling=null),wf(o,!1,y,d,x);break;case"backwards":for(d=null,y=o.child,o.child=null;y!==null;){if(r=y.alternate,r!==null&&mu(r)===null){o.child=y;break}r=y.sibling,y.sibling=d,d=y,y=r}wf(o,!0,d,null,x);break;case"together":wf(o,!1,null,null,void 0);break;default:o.memoizedState=null}return o.child}function xu(r,o){(o.mode&1)===0&&r!==null&&(r.alternate=null,o.alternate=null,o.flags|=2)}function mr(r,o,d){if(r!==null&&(o.dependencies=r.dependencies),ko|=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=Wr(r,r.pendingProps),o.child=d,d.return=o;r.sibling!==null;)r=r.sibling,d=d.sibling=Wr(r,r.pendingProps),d.return=o;d.sibling=null}return o.child}function V2(r,o,d){switch(o.tag){case 3:Vy(o),ma();break;case 5:dy(o);break;case 1:$s(o.type)&&ru(o);break;case 4:Qh(o,o.stateNode.containerInfo);break;case 10:var m=o.type._context,y=o.memoizedProps.value;on(du,m._currentValue),m._currentValue=y;break;case 13:if(m=o.memoizedState,m!==null)return m.dehydrated!==null?(on(wn,wn.current&1),o.flags|=128,null):(d&o.child.childLanes)!==0?Gy(r,o,d):(on(wn,wn.current&1),r=mr(r,o,d),r!==null?r.sibling:null);on(wn,wn.current&1);break;case 19:if(m=(d&o.childLanes)!==0,(r.flags&128)!==0){if(m)return Jy(r,o,d);o.flags|=128}if(y=o.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),on(wn,wn.current),m)break;return null;case 22:case 23:return o.lanes=0,Wy(r,o,d)}return mr(r,o,d)}var Qy,bf,Zy,ew;Qy=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}},bf=function(){},Zy=function(r,o,d,m){var y=r.memoizedProps;if(y!==m){r=o.stateNode,So(Bi.current);var x=null;switch(d){case"input":y=Q(r,y),m=Q(r,m),x=[];break;case"select":y=U({},y,{value:void 0}),m=U({},m,{value:void 0}),x=[];break;case"textarea":y=qe(r,y),m=qe(r,m),x=[];break;default:typeof y.onClick!="function"&&typeof m.onClick=="function"&&(r.onclick=nu)}We(d,m);var z;d=null;for(Ne in y)if(!m.hasOwnProperty(Ne)&&y.hasOwnProperty(Ne)&&y[Ne]!=null)if(Ne==="style"){var ee=y[Ne];for(z in ee)ee.hasOwnProperty(z)&&(d||(d={}),d[z]="")}else Ne!=="dangerouslySetInnerHTML"&&Ne!=="children"&&Ne!=="suppressContentEditableWarning"&&Ne!=="suppressHydrationWarning"&&Ne!=="autoFocus"&&(i.hasOwnProperty(Ne)?x||(x=[]):(x=x||[]).push(Ne,null));for(Ne in m){var ue=m[Ne];if(ee=y!=null?y[Ne]:void 0,m.hasOwnProperty(Ne)&&ue!==ee&&(ue!=null||ee!=null))if(Ne==="style")if(ee){for(z in ee)!ee.hasOwnProperty(z)||ue&&ue.hasOwnProperty(z)||(d||(d={}),d[z]="");for(z in ue)ue.hasOwnProperty(z)&&ee[z]!==ue[z]&&(d||(d={}),d[z]=ue[z])}else d||(x||(x=[]),x.push(Ne,d)),d=ue;else Ne==="dangerouslySetInnerHTML"?(ue=ue?ue.__html:void 0,ee=ee?ee.__html:void 0,ue!=null&&ee!==ue&&(x=x||[]).push(Ne,ue)):Ne==="children"?typeof ue!="string"&&typeof ue!="number"||(x=x||[]).push(Ne,""+ue):Ne!=="suppressContentEditableWarning"&&Ne!=="suppressHydrationWarning"&&(i.hasOwnProperty(Ne)?(ue!=null&&Ne==="onScroll"&&un("scroll",r),x||ee===ue||(x=[])):(x=x||[]).push(Ne,ue))}d&&(x=x||[]).push("style",d);var Ne=x;(o.updateQueue=Ne)&&(o.flags|=4)}},ew=function(r,o,d,m){d!==m&&(o.flags|=4)};function jl(r,o){if(!gn)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 ks(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 Y2(r,o,d){var m=o.pendingProps;switch(Hh(o),o.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ks(o),null;case 1:return $s(o.type)&&iu(),ks(o),null;case 3:return m=o.stateNode,ya(),dn(Bs),dn(Ss),tf(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(r===null||r.child===null)&&(cu(o)?o.flags|=4:r===null||r.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,Ci!==null&&(Mf(Ci),Ci=null))),bf(r,o),ks(o),null;case 5:Zh(o);var y=So(El.current);if(d=o.type,r!==null&&o.stateNode!=null)Zy(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 ks(o),null}if(r=So(Bi.current),cu(o)){m=o.stateNode,d=o.type;var x=o.memoizedProps;switch(m[Oi]=o,m[bl]=x,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<_l.length;y++)un(_l[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":ve(m,x),un("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!x.multiple},un("invalid",m);break;case"textarea":Ze(m,x),un("invalid",m)}We(d,x),y=null;for(var z in x)if(x.hasOwnProperty(z)){var ee=x[z];z==="children"?typeof ee=="string"?m.textContent!==ee&&(x.suppressHydrationWarning!==!0&&tu(m.textContent,ee,r),y=["children",ee]):typeof ee=="number"&&m.textContent!==""+ee&&(x.suppressHydrationWarning!==!0&&tu(m.textContent,ee,r),y=["children",""+ee]):i.hasOwnProperty(z)&&ee!=null&&z==="onScroll"&&un("scroll",m)}switch(d){case"input":Be(m),K(m,x,!0);break;case"textarea":Be(m),Oe(m);break;case"select":case"option":break;default:typeof x.onClick=="function"&&(m.onclick=nu)}m=y,o.updateQueue=m,m!==null&&(o.flags|=4)}else{z=y.nodeType===9?y:y.ownerDocument,r==="http://www.w3.org/1999/xhtml"&&(r=_e(d)),r==="http://www.w3.org/1999/xhtml"?d==="script"?(r=z.createElement("div"),r.innerHTML="<script><\/script>",r=r.removeChild(r.firstChild)):typeof m.is=="string"?r=z.createElement(d,{is:m.is}):(r=z.createElement(d),d==="select"&&(z=r,m.multiple?z.multiple=!0:m.size&&(z.size=m.size))):r=z.createElementNS(r,d),r[Oi]=o,r[bl]=m,Qy(r,o,!1,!1),o.stateNode=r;e:{switch(z=ie(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<_l.length;y++)un(_l[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":ve(r,m),y=Q(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":Ze(r,m),y=qe(r,m),un("invalid",r);break;default:y=m}We(d,y),ee=y;for(x in ee)if(ee.hasOwnProperty(x)){var ue=ee[x];x==="style"?de(r,ue):x==="dangerouslySetInnerHTML"?(ue=ue?ue.__html:void 0,ue!=null&&Fe(r,ue)):x==="children"?typeof ue=="string"?(d!=="textarea"||ue!=="")&&rt(r,ue):typeof ue=="number"&&rt(r,""+ue):x!=="suppressContentEditableWarning"&&x!=="suppressHydrationWarning"&&x!=="autoFocus"&&(i.hasOwnProperty(x)?ue!=null&&x==="onScroll"&&un("scroll",r):ue!=null&&T(r,x,ue,z))}switch(d){case"input":Be(r),K(r,m,!1);break;case"textarea":Be(r),Oe(r);break;case"option":m.value!=null&&r.setAttribute("value",""+te(m.value));break;case"select":r.multiple=!!m.multiple,x=m.value,x!=null?Ee(r,!!m.multiple,x,!1):m.defaultValue!=null&&Ee(r,!!m.multiple,m.defaultValue,!0);break;default:typeof y.onClick=="function"&&(r.onclick=nu)}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 ks(o),null;case 6:if(r&&o.stateNode!=null)ew(r,o,r.memoizedProps,m);else{if(typeof m!="string"&&o.stateNode===null)throw Error(n(166));if(d=So(El.current),So(Bi.current),cu(o)){if(m=o.stateNode,d=o.memoizedProps,m[Oi]=o,(x=m.nodeValue!==d)&&(r=Qs,r!==null))switch(r.tag){case 3:tu(m.nodeValue,d,(r.mode&1)!==0);break;case 5:r.memoizedProps.suppressHydrationWarning!==!0&&tu(m.nodeValue,d,(r.mode&1)!==0)}x&&(o.flags|=4)}else m=(d.nodeType===9?d:d.ownerDocument).createTextNode(m),m[Oi]=o,o.stateNode=m}return ks(o),null;case 13:if(dn(wn),m=o.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(gn&&Zs!==null&&(o.mode&1)!==0&&(o.flags&128)===0)sy(),ma(),o.flags|=98560,x=!1;else if(x=cu(o),m!==null&&m.dehydrated!==null){if(r===null){if(!x)throw Error(n(318));if(x=o.memoizedState,x=x!==null?x.dehydrated:null,!x)throw Error(n(317));x[Oi]=o}else ma(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;ks(o),x=!1}else Ci!==null&&(Mf(Ci),Ci=null),x=!0;if(!x)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||(wn.current&1)!==0?Fn===0&&(Fn=3):If())),o.updateQueue!==null&&(o.flags|=4),ks(o),null);case 4:return ya(),bf(r,o),r===null&&yl(o.stateNode.containerInfo),ks(o),null;case 10:return Yh(o.type._context),ks(o),null;case 17:return $s(o.type)&&iu(),ks(o),null;case 19:if(dn(wn),x=o.memoizedState,x===null)return ks(o),null;if(m=(o.flags&128)!==0,z=x.rendering,z===null)if(m)jl(x,!1);else{if(Fn!==0||r!==null&&(r.flags&128)!==0)for(r=o.child;r!==null;){if(z=mu(r),z!==null){for(o.flags|=128,jl(x,!1),m=z.updateQueue,m!==null&&(o.updateQueue=m,o.flags|=4),o.subtreeFlags=0,m=d,d=o.child;d!==null;)x=d,r=m,x.flags&=14680066,z=x.alternate,z===null?(x.childLanes=0,x.lanes=r,x.child=null,x.subtreeFlags=0,x.memoizedProps=null,x.memoizedState=null,x.updateQueue=null,x.dependencies=null,x.stateNode=null):(x.childLanes=z.childLanes,x.lanes=z.lanes,x.child=z.child,x.subtreeFlags=0,x.deletions=null,x.memoizedProps=z.memoizedProps,x.memoizedState=z.memoizedState,x.updateQueue=z.updateQueue,x.type=z.type,r=z.dependencies,x.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),d=d.sibling;return on(wn,wn.current&1|2),o.child}r=r.sibling}x.tail!==null&&q()>xa&&(o.flags|=128,m=!0,jl(x,!1),o.lanes=4194304)}else{if(!m)if(r=mu(z),r!==null){if(o.flags|=128,m=!0,d=r.updateQueue,d!==null&&(o.updateQueue=d,o.flags|=4),jl(x,!0),x.tail===null&&x.tailMode==="hidden"&&!z.alternate&&!gn)return ks(o),null}else 2*q()-x.renderingStartTime>xa&&d!==1073741824&&(o.flags|=128,m=!0,jl(x,!1),o.lanes=4194304);x.isBackwards?(z.sibling=o.child,o.child=z):(d=x.last,d!==null?d.sibling=z:o.child=z,x.last=z)}return x.tail!==null?(o=x.tail,x.rendering=o,x.tail=o.sibling,x.renderingStartTime=q(),o.sibling=null,d=wn.current,on(wn,m?d&1|2:d&1),o):(ks(o),null);case 22:case 23:return Pf(),m=o.memoizedState!==null,r!==null&&r.memoizedState!==null!==m&&(o.flags|=8192),m&&(o.mode&1)!==0?(ei&1073741824)!==0&&(ks(o),o.subtreeFlags&6&&(o.flags|=8192)):ks(o),null;case 24:return null;case 25:return null}throw Error(n(156,o.tag))}function G2(r,o){switch(Hh(o),o.tag){case 1:return $s(o.type)&&iu(),r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 3:return ya(),dn(Bs),dn(Ss),tf(),r=o.flags,(r&65536)!==0&&(r&128)===0?(o.flags=r&-65537|128,o):null;case 5:return Zh(o),null;case 13:if(dn(wn),r=o.memoizedState,r!==null&&r.dehydrated!==null){if(o.alternate===null)throw Error(n(340));ma()}return r=o.flags,r&65536?(o.flags=r&-65537|128,o):null;case 19:return dn(wn),null;case 4:return ya(),null;case 10:return Yh(o.type._context),null;case 22:case 23:return Pf(),null;case 24:return null;default:return null}}var ku=!1,Cs=!1,X2=typeof WeakSet=="function"?WeakSet:Set,ht=null;function ba(r,o){var d=r.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(m){kn(r,o,m)}else d.current=null}function Sf(r,o,d){try{d()}catch(m){kn(r,o,m)}}var tw=!1;function J2(r,o){if(Th=lr,r=T_(),Ch(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,x=m.focusNode;m=m.focusOffset;try{d.nodeType,x.nodeType}catch{d=null;break e}var z=0,ee=-1,ue=-1,Ne=0,Ue=0,Ve=r,He=null;t:for(;;){for(var ut;Ve!==d||y!==0&&Ve.nodeType!==3||(ee=z+y),Ve!==x||m!==0&&Ve.nodeType!==3||(ue=z+m),Ve.nodeType===3&&(z+=Ve.nodeValue.length),(ut=Ve.firstChild)!==null;)He=Ve,Ve=ut;for(;;){if(Ve===r)break t;if(He===d&&++Ne===y&&(ee=z),He===x&&++Ue===m&&(ue=z),(ut=Ve.nextSibling)!==null)break;Ve=He,He=Ve.parentNode}Ve=ut}d=ee===-1||ue===-1?null:{start:ee,end:ue}}else d=null}d=d||{start:0,end:0}}else d=null;for(Ph={focusedElem:r,selectionRange:d},lr=!1,ht=o;ht!==null;)if(o=ht,r=o.child,(o.subtreeFlags&1028)!==0&&r!==null)r.return=o,ht=r;else for(;ht!==null;){o=ht;try{var pt=o.alternate;if((o.flags&1024)!==0)switch(o.tag){case 0:case 11:case 15:break;case 1:if(pt!==null){var gt=pt.memoizedProps,An=pt.memoizedState,xe=o.stateNode,he=xe.getSnapshotBeforeUpdate(o.elementType===o.type?gt:Ei(o.type,gt),An);xe.__reactInternalSnapshotBeforeUpdate=he}break;case 3:var Ce=o.stateNode.containerInfo;Ce.nodeType===1?Ce.textContent="":Ce.nodeType===9&&Ce.documentElement&&Ce.removeChild(Ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(et){kn(o,o.return,et)}if(r=o.sibling,r!==null){r.return=o.return,ht=r;break}ht=o.return}return pt=tw,tw=!1,pt}function Ml(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 x=y.destroy;y.destroy=void 0,x!==void 0&&Sf(o,d,x)}y=y.next}while(y!==m)}}function Cu(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 xf(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 nw(r){var o=r.alternate;o!==null&&(r.alternate=null,nw(o)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(o=r.stateNode,o!==null&&(delete o[Oi],delete o[bl],delete o[Bh],delete o[T2],delete o[P2])),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 sw(r){return r.tag===5||r.tag===3||r.tag===4}function iw(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||sw(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 kf(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=nu));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}function Cf(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(Cf(r,o,d),r=r.sibling;r!==null;)Cf(r,o,d),r=r.sibling}var cs=null,Ni=!1;function $r(r,o,d){for(d=d.child;d!==null;)rw(r,o,d),d=d.sibling}function rw(r,o,d){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(Qe,d)}catch{}switch(d.tag){case 5:Cs||ba(d,o);case 6:var m=cs,y=Ni;cs=null,$r(r,o,d),cs=m,Ni=y,cs!==null&&(Ni?(r=cs,d=d.stateNode,r.nodeType===8?r.parentNode.removeChild(d):r.removeChild(d)):cs.removeChild(d.stateNode));break;case 18:cs!==null&&(Ni?(r=cs,d=d.stateNode,r.nodeType===8?Oh(r.parentNode,d):r.nodeType===1&&Oh(r,d),Di(r)):Oh(cs,d.stateNode));break;case 4:m=cs,y=Ni,cs=d.stateNode.containerInfo,Ni=!0,$r(r,o,d),cs=m,Ni=y;break;case 0:case 11:case 14:case 15:if(!Cs&&(m=d.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){y=m=m.next;do{var x=y,z=x.destroy;x=x.tag,z!==void 0&&((x&2)!==0||(x&4)!==0)&&Sf(d,o,z),y=y.next}while(y!==m)}$r(r,o,d);break;case 1:if(!Cs&&(ba(d,o),m=d.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=d.memoizedProps,m.state=d.memoizedState,m.componentWillUnmount()}catch(ee){kn(d,o,ee)}$r(r,o,d);break;case 21:$r(r,o,d);break;case 22:d.mode&1?(Cs=(m=Cs)||d.memoizedState!==null,$r(r,o,d),Cs=m):$r(r,o,d);break;default:$r(r,o,d)}}function ow(r){var o=r.updateQueue;if(o!==null){r.updateQueue=null;var d=r.stateNode;d===null&&(d=r.stateNode=new X2),o.forEach(function(m){var y=oN.bind(null,r,m);d.has(m)||(d.add(m),m.then(y,y))})}}function Ri(r,o){var d=o.deletions;if(d!==null)for(var m=0;m<d.length;m++){var y=d[m];try{var x=r,z=o,ee=z;e:for(;ee!==null;){switch(ee.tag){case 5:cs=ee.stateNode,Ni=!1;break e;case 3:cs=ee.stateNode.containerInfo,Ni=!0;break e;case 4:cs=ee.stateNode.containerInfo,Ni=!0;break e}ee=ee.return}if(cs===null)throw Error(n(160));rw(x,z,y),cs=null,Ni=!1;var ue=y.alternate;ue!==null&&(ue.return=null),y.return=null}catch(Ne){kn(y,o,Ne)}}if(o.subtreeFlags&12854)for(o=o.child;o!==null;)aw(o,r),o=o.sibling}function aw(r,o){var d=r.alternate,m=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:if(Ri(o,r),zi(r),m&4){try{Ml(3,r,r.return),Cu(3,r)}catch(gt){kn(r,r.return,gt)}try{Ml(5,r,r.return)}catch(gt){kn(r,r.return,gt)}}break;case 1:Ri(o,r),zi(r),m&512&&d!==null&&ba(d,d.return);break;case 5:if(Ri(o,r),zi(r),m&512&&d!==null&&ba(d,d.return),r.flags&32){var y=r.stateNode;try{rt(y,"")}catch(gt){kn(r,r.return,gt)}}if(m&4&&(y=r.stateNode,y!=null)){var x=r.memoizedProps,z=d!==null?d.memoizedProps:x,ee=r.type,ue=r.updateQueue;if(r.updateQueue=null,ue!==null)try{ee==="input"&&x.type==="radio"&&x.name!=null&&Z(y,x),ie(ee,z);var Ne=ie(ee,x);for(z=0;z<ue.length;z+=2){var Ue=ue[z],Ve=ue[z+1];Ue==="style"?de(y,Ve):Ue==="dangerouslySetInnerHTML"?Fe(y,Ve):Ue==="children"?rt(y,Ve):T(y,Ue,Ve,Ne)}switch(ee){case"input":be(y,x);break;case"textarea":at(y,x);break;case"select":var He=y._wrapperState.wasMultiple;y._wrapperState.wasMultiple=!!x.multiple;var ut=x.value;ut!=null?Ee(y,!!x.multiple,ut,!1):He!==!!x.multiple&&(x.defaultValue!=null?Ee(y,!!x.multiple,x.defaultValue,!0):Ee(y,!!x.multiple,x.multiple?[]:"",!1))}y[bl]=x}catch(gt){kn(r,r.return,gt)}}break;case 6:if(Ri(o,r),zi(r),m&4){if(r.stateNode===null)throw Error(n(162));y=r.stateNode,x=r.memoizedProps;try{y.nodeValue=x}catch(gt){kn(r,r.return,gt)}}break;case 3:if(Ri(o,r),zi(r),m&4&&d!==null&&d.memoizedState.isDehydrated)try{Di(o.containerInfo)}catch(gt){kn(r,r.return,gt)}break;case 4:Ri(o,r),zi(r);break;case 13:Ri(o,r),zi(r),y=r.child,y.flags&8192&&(x=y.memoizedState!==null,y.stateNode.isHidden=x,!x||y.alternate!==null&&y.alternate.memoizedState!==null||(Rf=q())),m&4&&ow(r);break;case 22:if(Ue=d!==null&&d.memoizedState!==null,r.mode&1?(Cs=(Ne=Cs)||Ue,Ri(o,r),Cs=Ne):Ri(o,r),zi(r),m&8192){if(Ne=r.memoizedState!==null,(r.stateNode.isHidden=Ne)&&!Ue&&(r.mode&1)!==0)for(ht=r,Ue=r.child;Ue!==null;){for(Ve=ht=Ue;ht!==null;){switch(He=ht,ut=He.child,He.tag){case 0:case 11:case 14:case 15:Ml(4,He,He.return);break;case 1:ba(He,He.return);var pt=He.stateNode;if(typeof pt.componentWillUnmount=="function"){m=He,d=He.return;try{o=m,pt.props=o.memoizedProps,pt.state=o.memoizedState,pt.componentWillUnmount()}catch(gt){kn(m,d,gt)}}break;case 5:ba(He,He.return);break;case 22:if(He.memoizedState!==null){uw(Ve);continue}}ut!==null?(ut.return=He,ht=ut):uw(Ve)}Ue=Ue.sibling}e:for(Ue=null,Ve=r;;){if(Ve.tag===5){if(Ue===null){Ue=Ve;try{y=Ve.stateNode,Ne?(x=y.style,typeof x.setProperty=="function"?x.setProperty("display","none","important"):x.display="none"):(ee=Ve.stateNode,ue=Ve.memoizedProps.style,z=ue!=null&&ue.hasOwnProperty("display")?ue.display:null,ee.style.display=O("display",z))}catch(gt){kn(r,r.return,gt)}}}else if(Ve.tag===6){if(Ue===null)try{Ve.stateNode.nodeValue=Ne?"":Ve.memoizedProps}catch(gt){kn(r,r.return,gt)}}else if((Ve.tag!==22&&Ve.tag!==23||Ve.memoizedState===null||Ve===r)&&Ve.child!==null){Ve.child.return=Ve,Ve=Ve.child;continue}if(Ve===r)break e;for(;Ve.sibling===null;){if(Ve.return===null||Ve.return===r)break e;Ue===Ve&&(Ue=null),Ve=Ve.return}Ue===Ve&&(Ue=null),Ve.sibling.return=Ve.return,Ve=Ve.sibling}}break;case 19:Ri(o,r),zi(r),m&4&&ow(r);break;case 21:break;default:Ri(o,r),zi(r)}}function zi(r){var o=r.flags;if(o&2){try{e:{for(var d=r.return;d!==null;){if(sw(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&&(rt(y,""),m.flags&=-33);var x=iw(r);Cf(r,x,y);break;case 3:case 4:var z=m.stateNode.containerInfo,ee=iw(r);kf(r,ee,z);break;default:throw Error(n(161))}}catch(ue){kn(r,r.return,ue)}r.flags&=-3}o&4096&&(r.flags&=-4097)}function Q2(r,o,d){ht=r,lw(r)}function lw(r,o,d){for(var m=(r.mode&1)!==0;ht!==null;){var y=ht,x=y.child;if(y.tag===22&&m){var z=y.memoizedState!==null||ku;if(!z){var ee=y.alternate,ue=ee!==null&&ee.memoizedState!==null||Cs;ee=ku;var Ne=Cs;if(ku=z,(Cs=ue)&&!Ne)for(ht=y;ht!==null;)z=ht,ue=z.child,z.tag===22&&z.memoizedState!==null?dw(y):ue!==null?(ue.return=z,ht=ue):dw(y);for(;x!==null;)ht=x,lw(x),x=x.sibling;ht=y,ku=ee,Cs=Ne}cw(r)}else(y.subtreeFlags&8772)!==0&&x!==null?(x.return=y,ht=x):cw(r)}}function cw(r){for(;ht!==null;){var o=ht;if((o.flags&8772)!==0){var d=o.alternate;try{if((o.flags&8772)!==0)switch(o.tag){case 0:case 11:case 15:Cs||Cu(5,o);break;case 1:var m=o.stateNode;if(o.flags&4&&!Cs)if(d===null)m.componentDidMount();else{var y=o.elementType===o.type?d.memoizedProps:Ei(o.type,d.memoizedProps);m.componentDidUpdate(y,d.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var x=o.updateQueue;x!==null&&uy(o,x,m);break;case 3:var z=o.updateQueue;if(z!==null){if(d=null,o.child!==null)switch(o.child.tag){case 5:d=o.child.stateNode;break;case 1:d=o.child.stateNode}uy(o,z,d)}break;case 5:var ee=o.stateNode;if(d===null&&o.flags&4){d=ee;var ue=o.memoizedProps;switch(o.type){case"button":case"input":case"select":case"textarea":ue.autoFocus&&d.focus();break;case"img":ue.src&&(d.src=ue.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(o.memoizedState===null){var Ne=o.alternate;if(Ne!==null){var Ue=Ne.memoizedState;if(Ue!==null){var Ve=Ue.dehydrated;Ve!==null&&Di(Ve)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Cs||o.flags&512&&xf(o)}catch(He){kn(o,o.return,He)}}if(o===r){ht=null;break}if(d=o.sibling,d!==null){d.return=o.return,ht=d;break}ht=o.return}}function uw(r){for(;ht!==null;){var o=ht;if(o===r){ht=null;break}var d=o.sibling;if(d!==null){d.return=o.return,ht=d;break}ht=o.return}}function dw(r){for(;ht!==null;){var o=ht;try{switch(o.tag){case 0:case 11:case 15:var d=o.return;try{Cu(4,o)}catch(ue){kn(o,d,ue)}break;case 1:var m=o.stateNode;if(typeof m.componentDidMount=="function"){var y=o.return;try{m.componentDidMount()}catch(ue){kn(o,y,ue)}}var x=o.return;try{xf(o)}catch(ue){kn(o,x,ue)}break;case 5:var z=o.return;try{xf(o)}catch(ue){kn(o,z,ue)}}}catch(ue){kn(o,o.return,ue)}if(o===r){ht=null;break}var ee=o.sibling;if(ee!==null){ee.return=o.return,ht=ee;break}ht=o.return}}var Z2=Math.ceil,Eu=E.ReactCurrentDispatcher,Ef=E.ReactCurrentOwner,ci=E.ReactCurrentBatchConfig,Yt=0,Xn=null,In=null,us=0,ei=0,Sa=Pr(0),Fn=0,Tl=null,ko=0,Nu=0,Nf=0,Pl=null,Fs=null,Rf=0,xa=1/0,gr=null,Ru=!1,Lf=null,zr=null,Lu=!1,Fr=null,Au=0,Il=0,Af=null,ju=-1,Mu=0;function js(){return(Yt&6)!==0?q():ju!==-1?ju:ju=q()}function Hr(r){return(r.mode&1)===0?1:(Yt&2)!==0&&us!==0?us&-us:D2.transition!==null?(Mu===0&&(Mu=_s()),Mu):(r=Gt,r!==0||(r=window.event,r=r===void 0?16:dl(r.type)),r)}function Li(r,o,d,m){if(50<Il)throw Il=0,Af=null,Error(n(185));Os(r,d,m),((Yt&2)===0||r!==Xn)&&(r===Xn&&((Yt&2)===0&&(Nu|=d),Fn===4&&Ur(r,us)),Hs(r,m),d===1&&Yt===0&&(o.mode&1)===0&&(xa=q()+500,ou&&Dr()))}function Hs(r,o){var d=r.callbackNode;wi(r,o);var m=kt(r,r===Xn?us:0);if(m===0)d!==null&&Me(d),r.callbackNode=null,r.callbackPriority=0;else if(o=m&-m,r.callbackPriority!==o){if(d!=null&&Me(d),o===1)r.tag===0?I2(fw.bind(null,r)):Q_(fw.bind(null,r)),j2(function(){(Yt&6)===0&&Dr()}),d=null;else{switch(il(m)){case 1:d=Te;break;case 4:d=Ge;break;case 16:d=Ae;break;case 536870912:d=_t;break;default:d=Ae}d=bw(d,hw.bind(null,r))}r.callbackPriority=o,r.callbackNode=d}}function hw(r,o){if(ju=-1,Mu=0,(Yt&6)!==0)throw Error(n(327));var d=r.callbackNode;if(ka()&&r.callbackNode!==d)return null;var m=kt(r,r===Xn?us:0);if(m===0)return null;if((m&30)!==0||(m&r.expiredLanes)!==0||o)o=Tu(r,m);else{o=m;var y=Yt;Yt|=2;var x=mw();(Xn!==r||us!==o)&&(gr=null,xa=q()+500,Eo(r,o));do try{nN();break}catch(ee){pw(r,ee)}while(!0);Vh(),Eu.current=x,Yt=y,In!==null?o=0:(Xn=null,us=0,o=Fn)}if(o!==0){if(o===2&&(y=Jt(r),y!==0&&(m=y,o=jf(r,y))),o===1)throw d=Tl,Eo(r,0),Ur(r,m),Hs(r,q()),d;if(o===6)Ur(r,m);else{if(y=r.current.alternate,(m&30)===0&&!eN(y)&&(o=Tu(r,m),o===2&&(x=Jt(r),x!==0&&(m=x,o=jf(r,x))),o===1))throw d=Tl,Eo(r,0),Ur(r,m),Hs(r,q()),d;switch(r.finishedWork=y,r.finishedLanes=m,o){case 0:case 1:throw Error(n(345));case 2:No(r,Fs,gr);break;case 3:if(Ur(r,m),(m&130023424)===m&&(o=Rf+500-q(),10<o)){if(kt(r,0)!==0)break;if(y=r.suspendedLanes,(y&m)!==m){js(),r.pingedLanes|=r.suspendedLanes&y;break}r.timeoutHandle=Dh(No.bind(null,r,Fs,gr),o);break}No(r,Fs,gr);break;case 4:if(Ur(r,m),(m&4194240)===m)break;for(o=r.eventTimes,y=-1;0<m;){var z=31-Xe(m);x=1<<z,z=o[z],z>y&&(y=z),m&=~x}if(m=y,m=q()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*Z2(m/1960))-m,10<m){r.timeoutHandle=Dh(No.bind(null,r,Fs,gr),m);break}No(r,Fs,gr);break;case 5:No(r,Fs,gr);break;default:throw Error(n(329))}}}return Hs(r,q()),r.callbackNode===d?hw.bind(null,r):null}function jf(r,o){var d=Pl;return r.current.memoizedState.isDehydrated&&(Eo(r,o).flags|=256),r=Tu(r,o),r!==2&&(o=Fs,Fs=d,o!==null&&Mf(o)),r}function Mf(r){Fs===null?Fs=r:Fs.push.apply(Fs,r)}function eN(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],x=y.getSnapshot;y=y.value;try{if(!ki(x(),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 Ur(r,o){for(o&=~Nf,o&=~Nu,r.suspendedLanes|=o,r.pingedLanes&=~o,r=r.expirationTimes;0<o;){var d=31-Xe(o),m=1<<d;r[d]=-1,o&=~m}}function fw(r){if((Yt&6)!==0)throw Error(n(327));ka();var o=kt(r,0);if((o&1)===0)return Hs(r,q()),null;var d=Tu(r,o);if(r.tag!==0&&d===2){var m=Jt(r);m!==0&&(o=m,d=jf(r,m))}if(d===1)throw d=Tl,Eo(r,0),Ur(r,o),Hs(r,q()),d;if(d===6)throw Error(n(345));return r.finishedWork=r.current.alternate,r.finishedLanes=o,No(r,Fs,gr),Hs(r,q()),null}function Tf(r,o){var d=Yt;Yt|=1;try{return r(o)}finally{Yt=d,Yt===0&&(xa=q()+500,ou&&Dr())}}function Co(r){Fr!==null&&Fr.tag===0&&(Yt&6)===0&&ka();var o=Yt;Yt|=1;var d=ci.transition,m=Gt;try{if(ci.transition=null,Gt=1,r)return r()}finally{Gt=m,ci.transition=d,Yt=o,(Yt&6)===0&&Dr()}}function Pf(){ei=Sa.current,dn(Sa)}function Eo(r,o){r.finishedWork=null,r.finishedLanes=0;var d=r.timeoutHandle;if(d!==-1&&(r.timeoutHandle=-1,A2(d)),In!==null)for(d=In.return;d!==null;){var m=d;switch(Hh(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&iu();break;case 3:ya(),dn(Bs),dn(Ss),tf();break;case 5:Zh(m);break;case 4:ya();break;case 13:dn(wn);break;case 19:dn(wn);break;case 10:Yh(m.type._context);break;case 22:case 23:Pf()}d=d.return}if(Xn=r,In=r=Wr(r.current,null),us=ei=o,Fn=0,Tl=null,Nf=Nu=ko=0,Fs=Pl=null,bo!==null){for(o=0;o<bo.length;o++)if(d=bo[o],m=d.interleaved,m!==null){d.interleaved=null;var y=m.next,x=d.pending;if(x!==null){var z=x.next;x.next=y,m.next=z}d.pending=m}bo=null}return r}function pw(r,o){do{var d=In;try{if(Vh(),gu.current=wu,vu){for(var m=bn.memoizedState;m!==null;){var y=m.queue;y!==null&&(y.pending=null),m=m.next}vu=!1}if(xo=0,Gn=zn=bn=null,Nl=!1,Rl=0,Ef.current=null,d===null||d.return===null){Fn=1,Tl=o,In=null;break}e:{var x=r,z=d.return,ee=d,ue=o;if(o=us,ee.flags|=32768,ue!==null&&typeof ue=="object"&&typeof ue.then=="function"){var Ne=ue,Ue=ee,Ve=Ue.tag;if((Ue.mode&1)===0&&(Ve===0||Ve===11||Ve===15)){var He=Ue.alternate;He?(Ue.updateQueue=He.updateQueue,Ue.memoizedState=He.memoizedState,Ue.lanes=He.lanes):(Ue.updateQueue=null,Ue.memoizedState=null)}var ut=$y(z);if(ut!==null){ut.flags&=-257,zy(ut,z,ee,x,o),ut.mode&1&&By(x,Ne,o),o=ut,ue=Ne;var pt=o.updateQueue;if(pt===null){var gt=new Set;gt.add(ue),o.updateQueue=gt}else pt.add(ue);break e}else{if((o&1)===0){By(x,Ne,o),If();break e}ue=Error(n(426))}}else if(gn&&ee.mode&1){var An=$y(z);if(An!==null){(An.flags&65536)===0&&(An.flags|=256),zy(An,z,ee,x,o),qh(wa(ue,ee));break e}}x=ue=wa(ue,ee),Fn!==4&&(Fn=2),Pl===null?Pl=[x]:Pl.push(x),x=z;do{switch(x.tag){case 3:x.flags|=65536,o&=-o,x.lanes|=o;var xe=Dy(x,ue,o);cy(x,xe);break e;case 1:ee=ue;var he=x.type,Ce=x.stateNode;if((x.flags&128)===0&&(typeof he.getDerivedStateFromError=="function"||Ce!==null&&typeof Ce.componentDidCatch=="function"&&(zr===null||!zr.has(Ce)))){x.flags|=65536,o&=-o,x.lanes|=o;var et=Oy(x,ee,o);cy(x,et);break e}}x=x.return}while(x!==null)}vw(d)}catch(yt){o=yt,In===d&&d!==null&&(In=d=d.return);continue}break}while(!0)}function mw(){var r=Eu.current;return Eu.current=wu,r===null?wu:r}function If(){(Fn===0||Fn===3||Fn===2)&&(Fn=4),Xn===null||(ko&268435455)===0&&(Nu&268435455)===0||Ur(Xn,us)}function Tu(r,o){var d=Yt;Yt|=2;var m=mw();(Xn!==r||us!==o)&&(gr=null,Eo(r,o));do try{tN();break}catch(y){pw(r,y)}while(!0);if(Vh(),Yt=d,Eu.current=m,In!==null)throw Error(n(261));return Xn=null,us=0,Fn}function tN(){for(;In!==null;)gw(In)}function nN(){for(;In!==null&&!Ke();)gw(In)}function gw(r){var o=ww(r.alternate,r,ei);r.memoizedProps=r.pendingProps,o===null?vw(r):In=o,Ef.current=null}function vw(r){var o=r;do{var d=o.alternate;if(r=o.return,(o.flags&32768)===0){if(d=Y2(d,o,ei),d!==null){In=d;return}}else{if(d=G2(d,o),d!==null){d.flags&=32767,In=d;return}if(r!==null)r.flags|=32768,r.subtreeFlags=0,r.deletions=null;else{Fn=6,In=null;return}}if(o=o.sibling,o!==null){In=o;return}In=o=r}while(o!==null);Fn===0&&(Fn=5)}function No(r,o,d){var m=Gt,y=ci.transition;try{ci.transition=null,Gt=1,sN(r,o,d,m)}finally{ci.transition=y,Gt=m}return null}function sN(r,o,d,m){do ka();while(Fr!==null);if((Yt&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 x=d.lanes|d.childLanes;if(po(r,x),r===Xn&&(In=Xn=null,us=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||Lu||(Lu=!0,bw(Ae,function(){return ka(),null})),x=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||x){x=ci.transition,ci.transition=null;var z=Gt;Gt=1;var ee=Yt;Yt|=4,Ef.current=null,J2(r,d),aw(d,r),x2(Ph),lr=!!Th,Ph=Th=null,r.current=d,Q2(d),mt(),Yt=ee,Gt=z,ci.transition=x}else r.current=d;if(Lu&&(Lu=!1,Fr=r,Au=y),x=r.pendingLanes,x===0&&(zr=null),Tn(d.stateNode),Hs(r,q()),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(Ru)throw Ru=!1,r=Lf,Lf=null,r;return(Au&1)!==0&&r.tag!==0&&ka(),x=r.pendingLanes,(x&1)!==0?r===Af?Il++:(Il=0,Af=r):Il=0,Dr(),null}function ka(){if(Fr!==null){var r=il(Au),o=ci.transition,d=Gt;try{if(ci.transition=null,Gt=16>r?16:r,Fr===null)var m=!1;else{if(r=Fr,Fr=null,Au=0,(Yt&6)!==0)throw Error(n(331));var y=Yt;for(Yt|=4,ht=r.current;ht!==null;){var x=ht,z=x.child;if((ht.flags&16)!==0){var ee=x.deletions;if(ee!==null){for(var ue=0;ue<ee.length;ue++){var Ne=ee[ue];for(ht=Ne;ht!==null;){var Ue=ht;switch(Ue.tag){case 0:case 11:case 15:Ml(8,Ue,x)}var Ve=Ue.child;if(Ve!==null)Ve.return=Ue,ht=Ve;else for(;ht!==null;){Ue=ht;var He=Ue.sibling,ut=Ue.return;if(nw(Ue),Ue===Ne){ht=null;break}if(He!==null){He.return=ut,ht=He;break}ht=ut}}}var pt=x.alternate;if(pt!==null){var gt=pt.child;if(gt!==null){pt.child=null;do{var An=gt.sibling;gt.sibling=null,gt=An}while(gt!==null)}}ht=x}}if((x.subtreeFlags&2064)!==0&&z!==null)z.return=x,ht=z;else e:for(;ht!==null;){if(x=ht,(x.flags&2048)!==0)switch(x.tag){case 0:case 11:case 15:Ml(9,x,x.return)}var xe=x.sibling;if(xe!==null){xe.return=x.return,ht=xe;break e}ht=x.return}}var he=r.current;for(ht=he;ht!==null;){z=ht;var Ce=z.child;if((z.subtreeFlags&2064)!==0&&Ce!==null)Ce.return=z,ht=Ce;else e:for(z=he;ht!==null;){if(ee=ht,(ee.flags&2048)!==0)try{switch(ee.tag){case 0:case 11:case 15:Cu(9,ee)}}catch(yt){kn(ee,ee.return,yt)}if(ee===z){ht=null;break e}var et=ee.sibling;if(et!==null){et.return=ee.return,ht=et;break e}ht=ee.return}}if(Yt=y,Dr(),Lt&&typeof Lt.onPostCommitFiberRoot=="function")try{Lt.onPostCommitFiberRoot(Qe,r)}catch{}m=!0}return m}finally{Gt=d,ci.transition=o}}return!1}function _w(r,o,d){o=wa(d,o),o=Dy(r,o,1),r=Br(r,o,1),o=js(),r!==null&&(Os(r,1,o),Hs(r,o))}function kn(r,o,d){if(r.tag===3)_w(r,r,d);else for(;o!==null;){if(o.tag===3){_w(o,r,d);break}else if(o.tag===1){var m=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(zr===null||!zr.has(m))){r=wa(d,r),r=Oy(o,r,1),o=Br(o,r,1),r=js(),o!==null&&(Os(o,1,r),Hs(o,r));break}}o=o.return}}function iN(r,o,d){var m=r.pingCache;m!==null&&m.delete(o),o=js(),r.pingedLanes|=r.suspendedLanes&d,Xn===r&&(us&d)===d&&(Fn===4||Fn===3&&(us&130023424)===us&&500>q()-Rf?Eo(r,0):Nf|=d),Hs(r,o)}function yw(r,o){o===0&&((r.mode&1)===0?o=1:(o=Je,Je<<=1,(Je&130023424)===0&&(Je=4194304)));var d=js();r=fr(r,o),r!==null&&(Os(r,o,d),Hs(r,d))}function rN(r){var o=r.memoizedState,d=0;o!==null&&(d=o.retryLane),yw(r,d)}function oN(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),yw(r,d)}var ww;ww=function(r,o,d){if(r!==null)if(r.memoizedProps!==o.pendingProps||Bs.current)zs=!0;else{if((r.lanes&d)===0&&(o.flags&128)===0)return zs=!1,V2(r,o,d);zs=(r.flags&131072)!==0}else zs=!1,gn&&(o.flags&1048576)!==0&&Z_(o,lu,o.index);switch(o.lanes=0,o.tag){case 2:var m=o.type;xu(r,o),r=o.pendingProps;var y=ha(o,Ss.current);_a(o,d),y=rf(null,o,m,r,y,d);var x=of();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,$s(m)?(x=!0,ru(o)):x=!1,o.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,Jh(o),y.updater=bu,o.stateNode=y,y._reactInternals=o,hf(o,m,r,d),o=gf(null,o,m,!0,x,d)):(o.tag=0,gn&&x&&Fh(o),As(null,o,y,d),o=o.child),o;case 16:m=o.elementType;e:{switch(xu(r,o),r=o.pendingProps,y=m._init,m=y(m._payload),o.type=m,y=o.tag=lN(m),r=Ei(m,r),y){case 0:o=mf(null,o,m,r,d);break e;case 1:o=Ky(null,o,m,r,d);break e;case 11:o=Fy(null,o,m,r,d);break e;case 14:o=Hy(null,o,m,Ei(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:Ei(m,y),mf(r,o,m,y,d);case 1:return m=o.type,y=o.pendingProps,y=o.elementType===m?y:Ei(m,y),Ky(r,o,m,y,d);case 3:e:{if(Vy(o),r===null)throw Error(n(387));m=o.pendingProps,x=o.memoizedState,y=x.element,ly(r,o),pu(o,m,null,d);var z=o.memoizedState;if(m=z.element,x.isDehydrated)if(x={element:m,isDehydrated:!1,cache:z.cache,pendingSuspenseBoundaries:z.pendingSuspenseBoundaries,transitions:z.transitions},o.updateQueue.baseState=x,o.memoizedState=x,o.flags&256){y=wa(Error(n(423)),o),o=Yy(r,o,m,d,y);break e}else if(m!==y){y=wa(Error(n(424)),o),o=Yy(r,o,m,d,y);break e}else for(Zs=Tr(o.stateNode.containerInfo.firstChild),Qs=o,gn=!0,Ci=null,d=oy(o,null,m,d),o.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(ma(),m===y){o=mr(r,o,d);break e}As(r,o,m,d)}o=o.child}return o;case 5:return dy(o),r===null&&Wh(o),m=o.type,y=o.pendingProps,x=r!==null?r.memoizedProps:null,z=y.children,Ih(m,y)?z=null:x!==null&&Ih(m,x)&&(o.flags|=32),qy(r,o),As(r,o,z,d),o.child;case 6:return r===null&&Wh(o),null;case 13:return Gy(r,o,d);case 4:return Qh(o,o.stateNode.containerInfo),m=o.pendingProps,r===null?o.child=ga(o,null,m,d):As(r,o,m,d),o.child;case 11:return m=o.type,y=o.pendingProps,y=o.elementType===m?y:Ei(m,y),Fy(r,o,m,y,d);case 7:return As(r,o,o.pendingProps,d),o.child;case 8:return As(r,o,o.pendingProps.children,d),o.child;case 12:return As(r,o,o.pendingProps.children,d),o.child;case 10:e:{if(m=o.type._context,y=o.pendingProps,x=o.memoizedProps,z=y.value,on(du,m._currentValue),m._currentValue=z,x!==null)if(ki(x.value,z)){if(x.children===y.children&&!Bs.current){o=mr(r,o,d);break e}}else for(x=o.child,x!==null&&(x.return=o);x!==null;){var ee=x.dependencies;if(ee!==null){z=x.child;for(var ue=ee.firstContext;ue!==null;){if(ue.context===m){if(x.tag===1){ue=pr(-1,d&-d),ue.tag=2;var Ne=x.updateQueue;if(Ne!==null){Ne=Ne.shared;var Ue=Ne.pending;Ue===null?ue.next=ue:(ue.next=Ue.next,Ue.next=ue),Ne.pending=ue}}x.lanes|=d,ue=x.alternate,ue!==null&&(ue.lanes|=d),Gh(x.return,d,o),ee.lanes|=d;break}ue=ue.next}}else if(x.tag===10)z=x.type===o.type?null:x.child;else if(x.tag===18){if(z=x.return,z===null)throw Error(n(341));z.lanes|=d,ee=z.alternate,ee!==null&&(ee.lanes|=d),Gh(z,d,o),z=x.sibling}else z=x.child;if(z!==null)z.return=x;else for(z=x;z!==null;){if(z===o){z=null;break}if(x=z.sibling,x!==null){x.return=z.return,z=x;break}z=z.return}x=z}As(r,o,y.children,d),o=o.child}return o;case 9:return y=o.type,m=o.pendingProps.children,_a(o,d),y=ai(y),m=m(y),o.flags|=1,As(r,o,m,d),o.child;case 14:return m=o.type,y=Ei(m,o.pendingProps),y=Ei(m.type,y),Hy(r,o,m,y,d);case 15:return Uy(r,o,o.type,o.pendingProps,d);case 17:return m=o.type,y=o.pendingProps,y=o.elementType===m?y:Ei(m,y),xu(r,o),o.tag=1,$s(m)?(r=!0,ru(o)):r=!1,_a(o,d),Py(o,m,y),hf(o,m,y,d),gf(null,o,m,!0,r,d);case 19:return Jy(r,o,d);case 22:return Wy(r,o,d)}throw Error(n(156,o.tag))};function bw(r,o){return oe(r,o)}function aN(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 ui(r,o,d,m){return new aN(r,o,d,m)}function Df(r){return r=r.prototype,!(!r||!r.isReactComponent)}function lN(r){if(typeof r=="function")return Df(r)?1:0;if(r!=null){if(r=r.$$typeof,r===B)return 11;if(r===M)return 14}return 2}function Wr(r,o){var d=r.alternate;return d===null?(d=ui(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 Pu(r,o,d,m,y,x){var z=2;if(m=r,typeof r=="function")Df(r)&&(z=1);else if(typeof r=="string")z=5;else e:switch(r){case X:return Ro(d.children,y,x,o);case V:z=8,y|=8;break;case G:return r=ui(12,d,o,y|2),r.elementType=G,r.lanes=x,r;case P:return r=ui(13,d,o,y),r.elementType=P,r.lanes=x,r;case D:return r=ui(19,d,o,y),r.elementType=D,r.lanes=x,r;case A:return Iu(d,y,x,o);default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case ne:z=10;break e;case Y:z=9;break e;case B:z=11;break e;case M:z=14;break e;case $:z=16,m=null;break e}throw Error(n(130,r==null?r:typeof r,""))}return o=ui(z,d,o,y),o.elementType=r,o.type=m,o.lanes=x,o}function Ro(r,o,d,m){return r=ui(7,r,m,o),r.lanes=d,r}function Iu(r,o,d,m){return r=ui(22,r,m,o),r.elementType=A,r.lanes=d,r.stateNode={isHidden:!1},r}function Of(r,o,d){return r=ui(6,r,null,o),r.lanes=d,r}function Bf(r,o,d){return o=ui(4,r.children!==null?r.children:[],r.key,o),o.lanes=d,o.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},o}function cN(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=Ot(0),this.expirationTimes=Ot(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ot(0),this.identifierPrefix=m,this.onRecoverableError=y,this.mutableSourceEagerHydrationData=null}function $f(r,o,d,m,y,x,z,ee,ue){return r=new cN(r,o,d,ee,ue),o===1?(o=1,x===!0&&(o|=8)):o=0,x=ui(3,null,null,o),r.current=x,x.stateNode=r,x.memoizedState={element:m,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Jh(x),r}function uN(r,o,d){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:F,key:m==null?null:""+m,children:r,containerInfo:o,implementation:d}}function Sw(r){if(!r)return Ir;r=r._reactInternals;e:{if(qt(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($s(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($s(d))return X_(r,d,o)}return o}function xw(r,o,d,m,y,x,z,ee,ue){return r=$f(d,m,!0,r,y,x,z,ee,ue),r.context=Sw(null),d=r.current,m=js(),y=Hr(d),x=pr(m,y),x.callback=o??null,Br(d,x,y),r.current.lanes=y,Os(r,y,m),Hs(r,m),r}function Du(r,o,d,m){var y=o.current,x=js(),z=Hr(y);return d=Sw(d),o.context===null?o.context=d:o.pendingContext=d,o=pr(x,z),o.payload={element:r},m=m===void 0?null:m,m!==null&&(o.callback=m),r=Br(y,o,z),r!==null&&(Li(r,y,z,x),fu(r,y,z)),z}function Ou(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 kw(r,o){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var d=r.retryLane;r.retryLane=d!==0&&d<o?d:o}}function zf(r,o){kw(r,o),(r=r.alternate)&&kw(r,o)}function dN(){return null}var Cw=typeof reportError=="function"?reportError:function(r){console.error(r)};function Ff(r){this._internalRoot=r}Bu.prototype.render=Ff.prototype.render=function(r){var o=this._internalRoot;if(o===null)throw Error(n(409));Du(r,o,null,null)},Bu.prototype.unmount=Ff.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var o=r.containerInfo;Co(function(){Du(null,r,null,null)}),o[cr]=null}};function Bu(r){this._internalRoot=r}Bu.prototype.unstable_scheduleHydration=function(r){if(r){var o=ol();r={blockedOn:null,target:r,priority:o};for(var d=0;d<Ls.length&&o!==0&&o<Ls[d].priority;d++);Ls.splice(d,0,r),d===0&&cl(r)}};function Hf(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function $u(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11&&(r.nodeType!==8||r.nodeValue!==" react-mount-point-unstable "))}function Ew(){}function hN(r,o,d,m,y){if(y){if(typeof m=="function"){var x=m;m=function(){var Ne=Ou(z);x.call(Ne)}}var z=xw(o,m,r,0,null,!1,!1,"",Ew);return r._reactRootContainer=z,r[cr]=z.current,yl(r.nodeType===8?r.parentNode:r),Co(),z}for(;y=r.lastChild;)r.removeChild(y);if(typeof m=="function"){var ee=m;m=function(){var Ne=Ou(ue);ee.call(Ne)}}var ue=$f(r,0,!1,null,null,!1,!1,"",Ew);return r._reactRootContainer=ue,r[cr]=ue.current,yl(r.nodeType===8?r.parentNode:r),Co(function(){Du(o,ue,d,m)}),ue}function zu(r,o,d,m,y){var x=d._reactRootContainer;if(x){var z=x;if(typeof y=="function"){var ee=y;y=function(){var ue=Ou(z);ee.call(ue)}}Du(o,z,r,y)}else z=hN(d,o,r,y,m);return Ou(z)}rl=function(r){switch(r.tag){case 3:var o=r.stateNode;if(o.current.memoizedState.isDehydrated){var d=ct(o.pendingLanes);d!==0&&(sr(o,d|1),Hs(o,q()),(Yt&6)===0&&(xa=q()+500,Dr()))}break;case 13:Co(function(){var m=fr(r,1);if(m!==null){var y=js();Li(m,r,1,y)}}),zf(r,1)}},Qo=function(r){if(r.tag===13){var o=fr(r,134217728);if(o!==null){var d=js();Li(o,r,134217728,d)}zf(r,134217728)}},Xs=function(r){if(r.tag===13){var o=Hr(r),d=fr(r,o);if(d!==null){var m=js();Li(d,r,o,m)}zf(r,o)}},ol=function(){return Gt},al=function(r,o){var d=Gt;try{return Gt=r,o()}finally{Gt=d}},Pt=function(r,o,d){switch(o){case"input":if(be(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=su(m);if(!y)throw Error(n(90));Le(m),be(m,y)}}}break;case"textarea":at(r,d);break;case"select":o=d.value,o!=null&&Ee(r,!!d.multiple,o,!1)}},Dt=Tf,It=Co;var fN={usingClientEntryPoint:!1,Events:[Sl,ua,su,Mt,Qt,Tf]},Dl={findFiberByHostInstance:vo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},pN={bundleType:Dl.bundleType,version:Dl.version,rendererPackageName:Dl.rendererPackageName,rendererConfig:Dl.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=St(r),r===null?null:r.stateNode},findFiberByHostInstance:Dl.findFiberByHostInstance||dN,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 Fu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fu.isDisabled&&Fu.supportsFiber)try{Qe=Fu.inject(pN),Lt=Fu}catch{}}return Us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=fN,Us.createPortal=function(r,o){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Hf(o))throw Error(n(200));return uN(r,o,null,d)},Us.createRoot=function(r,o){if(!Hf(r))throw Error(n(299));var d=!1,m="",y=Cw;return o!=null&&(o.unstable_strictMode===!0&&(d=!0),o.identifierPrefix!==void 0&&(m=o.identifierPrefix),o.onRecoverableError!==void 0&&(y=o.onRecoverableError)),o=$f(r,1,!1,null,null,d,!1,m,y),r[cr]=o.current,yl(r.nodeType===8?r.parentNode:r),new Ff(o)},Us.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=St(o),r=r===null?null:r.stateNode,r},Us.flushSync=function(r){return Co(r)},Us.hydrate=function(r,o,d){if(!$u(o))throw Error(n(200));return zu(null,r,o,!0,d)},Us.hydrateRoot=function(r,o,d){if(!Hf(r))throw Error(n(405));var m=d!=null&&d.hydratedSources||null,y=!1,x="",z=Cw;if(d!=null&&(d.unstable_strictMode===!0&&(y=!0),d.identifierPrefix!==void 0&&(x=d.identifierPrefix),d.onRecoverableError!==void 0&&(z=d.onRecoverableError)),o=xw(o,null,r,1,d??null,y,!1,x,z),r[cr]=o.current,yl(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 Bu(o)},Us.render=function(r,o,d){if(!$u(o))throw Error(n(200));return zu(null,r,o,!1,d)},Us.unmountComponentAtNode=function(r){if(!$u(r))throw Error(n(40));return r._reactRootContainer?(Co(function(){zu(null,null,r,!1,function(){r._reactRootContainer=null,r[cr]=null})}),!0):!1},Us.unstable_batchedUpdates=Tf,Us.unstable_renderSubtreeIntoContainer=function(r,o,d,m){if(!$u(d))throw Error(n(200));if(r==null||r._reactInternals===void 0)throw Error(n(38));return zu(r,o,d,!1,m)},Us.version="18.3.1-next-f1338f8080-20240426",Us}var Pw;function xN(){if(Pw)return qf.exports;Pw=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(),qf.exports=SN(),qf.exports}var Iw;function kN(){if(Iw)return Hu;Iw=1;var t=xN();return Hu.createRoot=t.createRoot,Hu.hydrateRoot=t.hydrateRoot,Hu}var CN=kN();const EN=Qg(CN),fm="nc_token",pm="nc:auth-invalid",mm="nc:token-not-remembered";function NN(t){return typeof t=="string"&&t.startsWith("/api/")&&!t.startsWith("/api/route/")}const yc=(t,e)=>{try{return t()}catch{return e}};function N1(t={}){return{local:t.local!==void 0?t.local:yc(()=>globalThis.localStorage,null),session:t.session!==void 0?t.session:yc(()=>globalThis.sessionStorage,null)}}const Dw=t=>yc(()=>t?String(t.getItem(fm)||"").trim():"","");function RN(t){const{local:e,session:n}=N1(t);return Dw(e)||Dw(n)||""}function R1(t,{remember:e=!0,local:n,session:s}={}){const i=String(t||"").trim();if(!i)return{ok:!1,where:null};const a=N1({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&&yc(()=>(h.setItem(fm,i),!0),!1))return yc(()=>{f&&f.removeItem(fm)},null),{ok:!0,where:u};return{ok:!1,where:null}}function Ow(t,e,n){if(!(!n||n.status!==401||!NN(t)))try{window.dispatchEvent(new CustomEvent(pm,{detail:{token:e,path:t}}))}catch{}}const LN=8e3,AN=4e3,L1=8e3;function jN(t){const e=new AbortController,n=setTimeout(()=>e.abort(new DOMException("timeout","TimeoutError")),t);return{signal:e.signal,cancel:()=>clearTimeout(n),controller:e}}function Bw(t,e){return e.redirect!==void 0?e:/^\/(?:api\/route|node)\//.test(String(t))?{...e,redirect:"error"}:e}function Wn(t,e,n={}){const s=Number(n.timeoutMs);if(!Number.isFinite(s)||s<=0)return fetch(t,{...Bw(t,n),headers:{...n.headers||{},Authorization:`Bearer ${e}`}}).then(_=>(Ow(t,e,_),_));const{signal:i,cancel:a,controller:c}=jN(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,{...Bw(t,v),signal:i,headers:{...v.headers||{},Authorization:`Bearer ${e}`}}).then(_=>(_.__cleanupTimeout=f,Ow(t,e,_),_),_=>{throw f(),_})}const A1=t=>`nc_seen_${t}`;async function ot(t,e,n={}){const s=await Wn(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 _n=t=>Array.isArray(t)&&t.length?`/api/route/${t.map(encodeURIComponent).join("/")}/_`:"/api",Mn=(t,e)=>`${_n(t)}/fleet/${e}`;async function MN(t,e,n,{signal:s}={}){const i=await Wn(`${_n(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 Ja=(t,e,n)=>ot(Mn(e,"status"),t,n),j1=6e4,TN=(t,e,n)=>ot(Mn(n,"up"),t,{method:"POST",body:e,timeoutMs:j1}),M1=(t,e,n)=>ot(Mn(n,"down"),t,{method:"POST",body:e,timeoutMs:j1}),T1=(t,e,n)=>ot(Mn(n,"boot"),t,{method:"POST",body:e}),nc=(t,e,n)=>ot(Mn(n,"restart"),t,{method:"POST",body:{cell:e}}),Xd=(t,e)=>ot(Mn(e,"definitions"),t),PN=(t,e)=>ot(Mn(e,"credentials/status"),t),$w=(t,e,n,s)=>ot(Mn(s,"credentials/set"),t,{method:"POST",body:{envKey:e,value:n}}),IN=(t,e,n)=>ot(Mn(n,"credentials/remove"),t,{method:"POST",body:{envKey:e}}),DN=(t,e,n)=>ot(Mn(n,"define-engine"),t,{method:"POST",body:{def:e}}),ON=(t,e,n,s,i)=>ot(Mn(i,"edit-engine"),t,{method:"POST",body:{id:e,patch:n,envChanges:s}}),BN=(t,e,n)=>ot(Mn(n,"remove-engine"),t,{method:"POST",body:{id:e}}),$N=(t,e,n)=>ot(Mn(n,"define-model"),t,{method:"POST",body:{def:e}}),zN=(t,e,n,s)=>ot(Mn(s,"remove-model"),t,{method:"POST",body:{id:e,engine:n}}),FN=(t,e,n,s)=>ot(Mn(s,"model-test"),t,{method:"POST",body:{engine:e,model:n}}),HN=(t,e,n)=>ot(Mn(n,"define-cell"),t,{method:"POST",body:{def:e}}),P1=(t,e,n,s)=>ot(Mn(s,"edit-cell"),t,{method:"POST",body:{id:e,patch:n}}),I1=(t,e,n=!1,s)=>ot(Mn(s,"remove-cell"),t,{method:"POST",body:{id:e,stop:n}}),UN=(t,e,n)=>ot(Mn(n,"import-cell"),t,{method:"POST",body:e}),WN=(t,e,n)=>ot(Mn(n,"restore-cells"),t,{method:"POST",body:{cells:e}}),qN=(t,e,n,s,i)=>ot(Mn(s,"restore-engines"),t,{method:"POST",body:{engines:e,overwrite:!!n,...Array.isArray(i)&&i.length?{models:i}:{}}}),ev=(t,e,n)=>ot(`${_n(n)}/sessions/${encodeURIComponent(e)}`,t,{method:"DELETE"}),D1=(t,e,n,s)=>ot(`${_n(s)}/sessions/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{technical:!!n}}),tv=(t,e,n)=>ot(`${_n(n)}/fs/dirs${e?`?path=${encodeURIComponent(e)}`:""}`,t),O1=(t,e={})=>ot("/api/settings",t,e),KN=(t,e={})=>ot("/api/nodes",t,e),VN=(t,e={})=>ot("/api/peers",t,e),B1=(t,e=[],n={})=>ot(`${_n(e)}/vl-nodes`,t,{timeoutMs:AN,...n}),zw=(t,e,n,s={},i=[])=>ot(`${_n(i)}/vl-nodes/${encodeURIComponent(e)}/commands`,t,{method:"POST",body:{kind:n,args:s}}),YN=(t,e,n=0,s=[])=>ot(`${_n(s)}/vl-nodes/${encodeURIComponent(e)}/events${n?`?after=${encodeURIComponent(n)}`:""}`,t),$1=(t,e={})=>ot("/api/topology",t,e),nv=(t,e,n={})=>ot(`${_n(e)}/sessions`,t,n),Bc=(t,e,n={})=>ot(`${_n(e)}/config`,t,n),Fw=(t,e,n={})=>ot(`${_n(e)}/topology`,t,n),Ed=(t,e)=>ot("/api/settings/config",t,{method:"POST",body:e}),GN=t=>ot("/api/settings/ai-desktop",t),z1=(t,e)=>ot("/api/settings/ai-desktop",t,{method:"POST",body:{enabled:e}}),XN=t=>ot("/api/settings/token/rotate",t,{method:"POST"}),JN=(t,e)=>ot("/api/settings/nodes/pair",t,{method:"POST",body:e}),QN=(t,e,n=[])=>ot(`${_n(n)}/settings/peering/invite`,t,{method:"POST",body:e||{}}),F1=(t,e,n)=>ot(`/api/settings/nodes/${encodeURIComponent(e)}/label`,t,{method:"PATCH",body:{label:n}}),ZN=(t,e={})=>ot("/api/settings/node-aliases",t,e),e5=(t,e,n)=>ot(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{alias:n}}),Hw=(t,e)=>ot(`/api/settings/node-aliases/${encodeURIComponent(e)}`,t,{method:"DELETE"}),Yf=(t,e,n)=>ot(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"PATCH",body:n}),t5=(t,e)=>ot(`/api/settings/nodes/${encodeURIComponent(e)}`,t,{method:"DELETE"}),sv=(t,e,n)=>ot(`/api/settings/nodes/${encodeURIComponent(e)}/${n}`,t,{method:"POST"}),n5=(t,e,n)=>ot(`/api/settings/nodes/${encodeURIComponent(e)}/share`,t,{method:"PATCH",body:{shared:n}}),s5=(t,e,n,s=[])=>ot(`/api/settings/nodes/${encodeURIComponent(e)}/visibility`,t,{method:"PATCH",body:{visibility:n,selected:s}}),i5=t=>ot("/api/settings/audio",t),r5=(t,e)=>ot("/api/settings/audio/consent",t,{method:"PATCH",body:{consent:e}}),o5=t=>ot("/api/settings/audio/test",t,{method:"POST",body:{}}),a5=t=>ot("/api/settings/audio/stop",t,{method:"POST",body:{}}),l5=t=>ot("/api/settings/audio/groups",t),c5=(t,e,n)=>ot(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"PUT",body:n}),u5=(t,e)=>ot(`/api/settings/audio/groups/${encodeURIComponent(e)}`,t,{method:"DELETE"}),d5=t=>ot("/api/settings/service/regenerate",t,{method:"POST"}),h5=t=>ot("/api/settings/update/check",t,{method:"POST"}),f5=t=>ot("/api/settings/update/apply",t,{method:"POST"}),Jd=(t,e)=>`${_n(t)}/diagnostics/${e}`,p5=(t,e=[])=>ot(Jd(e,"status"),t),m5=(t,{after:e=0,limit:n=200}={},s=[])=>ot(`${Jd(s,"logs")}?after=${encodeURIComponent(e)}&limit=${encodeURIComponent(n)}`,t),Uw=(t,e,n,s=[])=>ot(Jd(s,"verbose"),t,{method:"PATCH",body:{enabled:e,durationSeconds:n}}),g5=(t,e=[])=>ot(Jd(e,"logs"),t,{method:"DELETE"}),v5=(t,e=!0)=>ot(`/api/asks${e?"?open=1":""}`,t),_5=(t,e,n)=>ot(`/api/asks/${encodeURIComponent(e)}/answer`,t,{method:"POST",body:{text:n}}),y5=(t,e)=>ot(`/api/asks/${encodeURIComponent(e)}`,t,{method:"DELETE"}),w5=(t,{ownerId:e,askId:n,text:s,requestId:i})=>ot("/api/asks-relay",t,{method:"POST",body:{ownerId:e,askId:n,text:s,requestId:i}}),b5=(t,{ownerId:e,askId:n,requestId:s})=>ot("/api/asks-relay",t,{method:"POST",body:{action:"verify",ownerId:e,askId:n,requestId:s}}),S5=(t,{ownerId:e,askId:n},s={})=>ot(`/api/asks-relay/capability?ownerId=${encodeURIComponent(e)}&askId=${encodeURIComponent(n)}&dismissals=1`,t,{timeoutMs:8e3,...s}),x5=t=>ot("/api/asks-relay/state",t),k5=(t,{ownerId:e,askId:n})=>ot("/api/asks-relay",t,{method:"POST",body:{action:"dismiss",ownerId:e,askId:n}}),C5=(t,{ownerId:e,askId:n})=>ot("/api/asks-relay",t,{method:"POST",body:{action:"dismiss-local",ownerId:e,askId:n}}),E5=t=>ot("/api/feed-state",t),N5=(t,{ownerId:e,eventId:n})=>ot("/api/notices-relay",t,{method:"POST",body:{action:"dismiss",ownerId:e,eventId:n}}),R5=(t,{owners:e})=>ot("/api/notices-relay",t,{method:"POST",body:{action:"dismiss-all",owners:e}}),Uu=(t,e=[])=>ot(`${_n(e)}/decks`,t,e.length?{timeoutMs:LN}:{}),Ww=(t,e,n=[])=>ot(`${_n(n)}/decks`,t,{method:"POST",body:{name:e}}),Wu=(t,e,n,s,i=[],a)=>ot(`${_n(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",body:{layout:n,expectedRevision:s,...a?{floating:a}:{}}}),L5=(t,e,n,s,i=[],a)=>Wn(`${_n(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PUT",keepalive:!0,headers:{"content-type":"application/json"},body:JSON.stringify({layout:n,expectedRevision:s,...a?{floating:a}:{}})}),A5=(t,e,n,s,i=[])=>ot(`${_n(i)}/decks/${encodeURIComponent(e)}`,t,{method:"PATCH",body:{name:n,expectedRevision:s}}),j5=(t,e,n,s=[])=>ot(`${_n(s)}/decks/${encodeURIComponent(e)}`,t,{method:"DELETE",body:{expectedRevision:n}}),Qd=(t,e=[],n)=>ot(`${_n(e)}/live-host`,t,n),Zd=(t,e,n,s=[])=>ot(`${_n(s)}/live-host/designate`,t,{method:"POST",body:{cellId:e,expectedRevision:n}}),eh=(t,e,n=[])=>ot(`${_n(n)}/live-host/clear`,t,{method:"POST",body:{expectedRevision:e}});function th(){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 H1=4e3,qw=3500,so=new Map,U1=()=>typeof document<"u"&&document.visibilityState==="hidden";let Kw=!1;function M5(){Kw||typeof document>"u"||!document.addEventListener||(Kw=!0,document.addEventListener("visibilitychange",()=>{const t=U1();for(const e of so.values())t?e.timer!==null&&(clearInterval(e.timer),e.timer=null):e.timer===null&&(e.timer=setInterval(e.cycle,H1),e.cycle())}))}const iv=(t,e)=>`${t}|${JSON.stringify(e||[])}`;function T5(t){return t&&t.length?`/api/route/${t.map(encodeURIComponent).join("/")}/_`:"/api"}function P5(t,e){const n=th(),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 Wn(`${T5(e)}/sessions`,t,{timeoutMs:qw})).json()}catch(g){u=g}let h=null,f=null;try{h=await Ja(t,e,{timeoutMs:qw})}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,M5(),U1()||(s.timer=setInterval(i,H1)),i(),s}function wc(t,e,n){const s=iv(t,e);let i=so.get(s);return i||(i=P5(t,e),so.set(s,i)),i.consumers.add(n),i.snapshot&&n(i.snapshot),()=>{const a=so.get(s);a&&(a.consumers.delete(n),a.consumers.size===0&&(a.timer!==null&&clearInterval(a.timer),so.delete(s)))}}function sc(t,e=null){if(e!==null){const s=so.get(iv(e,t));return s?s.snapshot:null}const n=`|${JSON.stringify(t||[])}`;for(const[s,i]of so)if(s.endsWith(n))return i.snapshot;return null}function ic(t,e=null){const n=`|${JSON.stringify(t||[])}`;for(const[s,i]of so)(e!==null?s===iv(e,t):s.endsWith(n))&&i.cycle()}const I5={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:I5[t]||null})}const rv=["it","en","es"];function D5(){try{const t=typeof navigator<"u"&&navigator.language||"",e=String(t).slice(0,2).toLowerCase();return rv.includes(e)?e:"en"}catch{return"en"}}const dd=D5(),W1="nc_lang",gm="nc-lang";function q1(){return typeof localStorage<"u"?localStorage:null}const qu={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-badge":"Live","live-badge-native":"Live attiva (thread nativo)","live-badge-tmux":"Live attiva in modalità tmux: non riceve messaggi","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","remote-notices-clear":"Pulisci","remote-notices-dismiss":"scarta questa notifica","remote-notices-dismiss-failed":"scarto non confermato: la notifica resta","remote-notices-clear-failed":"pulizia non confermata: le notifiche restano","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-badge":"Live","live-badge-native":"Live active (native thread)","live-badge-tmux":"Live active in tmux mode: it does not receive messages","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","remote-notices-clear":"Clear","remote-notices-dismiss":"dismiss this notice","remote-notices-dismiss-failed":"dismissal not confirmed: the notice stays","remote-notices-clear-failed":"clear not confirmed: the notices stay","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-badge":"Live","live-badge-native":"Live activa (thread nativo)","live-badge-tmux":"Live activa en modo tmux: no recibe mensajes","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","remote-notices-clear":"Limpiar","remote-notices-dismiss":"descartar esta notificación","remote-notices-dismiss-failed":"descarte no confirmado: la notificación permanece","remote-notices-clear-failed":"limpieza no confirmada: las notificaciones permanecen","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 Nd(){const t=q1(),e=t?t.getItem(W1):null;return rv.includes(e)?e:dd}function O5(t){const e=q1();if(e)try{e.setItem(W1,t)}catch{}typeof window<"u"&&window.dispatchEvent(new Event(gm))}function p(t){const e=Nd(),n=qu[e]||qu[dd];return Object.prototype.hasOwnProperty.call(n,t)?n[t]:Object.prototype.hasOwnProperty.call(qu[dd],t)?qu[dd][t]:t}function B5(t){return typeof window>"u"?()=>{}:(window.addEventListener(gm,t),()=>window.removeEventListener(gm,t))}const K1=rv,bc="none",V1="favorite",Y1="designated",G1="thread-present",X1="thread-active",J1="thread-unknown",Q1=new Set([Y1,G1,X1,J1]);function Z1(t){return t==="absent"?Y1:t==="present"?G1:t==="active"?X1:J1}function $5(t){return Q1.has(t)?`host-thread-${t.replace("thread-","")}`:null}function Rd({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?Z1(e):Array.isArray(n)&&s&&n.includes(s.key)?V1:bc}const z5=Object.freeze(["live","grace","expired","none","unavailable"]);function vm(t,e){return!Q1.has(t)||!z5.includes(e)?null:`host-lease-${e}`}const F5="local";function Ns(t){return Array.isArray(t)&&t.length?t.join("/"):F5}function _m(t){return(t&&t.data&&typeof t.data=="object"?t.data.reason:null)==="live-host-not-granted"?"live-host-not-granted":"live-host-error"}const ex="native",ym="tmux";function H5(t){return typeof t!="string"||!t?null:t.startsWith("codex-vl")?ex:ym}function Wa({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:H5(c),state:i?Z1(t&&t.threadStatus):bc,hostActive:!!(a&&a.active===!0&&a.tmux!==!1),remote:!!(s&&n&&s!==n),lease:t&&(t.hostLease||(t.host&&typeof t.host.lease=="string"?t.host.lease:null))||null}}function U5(t){const e=t&&t.state?t.state:bc;return{modeKey:t&&t.mode?`live-host-mode-${t.mode}`:null,stateKey:`live-host-state-${e}`}}function ov(t){const e=t&&t.state?t.state:bc;return e==="thread-active"?"active":e==="thread-present"?"present":e===bc?"none":e==="thread-unknown"?"unknown":"designated"}function W5(t){return!t||!t.cell||t.remote?null:t.state==="thread-present"||t.state==="thread-active"?ex:t.mode===ym&&t.hostActive?ym:null}function tx({view:t}){const e=W5(t);return e?l.jsx("span",{className:"nc-live-badge","data-testid":"live-badge","data-mode":e,title:p(`live-badge-${e}`),children:p("live-badge")}):null}const av="nc_popup_assetto",q5=320,K5=240,V5=1100,Y5=820,Vw=48,G5=44;function nx(){return{vw:window.innerWidth||1024,vh:window.innerHeight||768}}function rc(t){const{vw:e,vh:n}=nx(),s=Math.max(q5,Math.min(t.w,e)),i=Math.max(K5,Math.min(t.h,n)),a=Math.max(-(s-Vw),Math.min(t.x,e-Vw)),c=Math.max(0,Math.min(t.y,Math.max(0,n-G5)));return{x:a,y:c,w:s,h:i}}function Yw(){try{const t=window.localStorage.getItem(av);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:rc(e)}catch{return null}}function X5(t){try{window.localStorage.setItem(av,JSON.stringify(t))}catch{}}function J5(){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 sx({title:t,subtitle:e,onClose:n,children:s}){const i=w.useRef(null),a=w.useRef(null),c=J5(),[u,h]=w.useState(()=>c?null:Yw()),f=w.useRef(null),[g,v]=w.useState(!1),_=w.useCallback(()=>{n&&n()},[n]);w.useEffect(()=>{const L=S=>{S.key==="Escape"&&(S.stopPropagation(),_())};return document.addEventListener("keydown",L,!0),()=>document.removeEventListener("keydown",L,!0)},[_]),w.useEffect(()=>{const L=a.current;L&&typeof L.focus=="function"&&L.focus()},[]);const b=()=>{const{vw:L,vh:S}=nx(),T=Math.min(V5,Math.floor(L*.96)),E=Math.min(Y5,Math.floor(S*.92));return rc({x:Math.round((L-T)/2),y:Math.round((S-E)/2),w:T,h:E})},k=L=>S=>{if(c||S.button!==0||S.target&&typeof S.target.closest=="function"&&S.target.closest(".nc-popup-chiudi"))return;S.preventDefault();const T=u||b();f.current={mode:L,startX:S.clientX,startY:S.clientY,base:T},h(T),v(!0)};w.useEffect(()=>{if(!g)return;const L=T=>{const E=f.current;if(!E)return;const H=T.clientX-E.startX,F=T.clientY-E.startY;E.mode==="move"?h(rc({...E.base,x:E.base.x+H,y:E.base.y+F})):h(rc({...E.base,w:E.base.w+H,h:E.base.h+F}))},S=()=>{f.current=null,v(!1),h(T=>(T&&X5(T),T))};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",S)}},[g]);const R=()=>{if(!c){f.current=null,v(!1),h(null);try{window.localStorage.removeItem(av)}catch{}}};w.useEffect(()=>{if(c)return;const L=()=>h(S=>S&&rc(S));return window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[c]),w.useEffect(()=>{c||h(L=>L||Yw())},[c]);const C=!!(u&&!c);return l.jsxs("div",{className:"nc-popup-velo",onMouseDown:L=>{L.target===L.currentTarget&&_()},role:"presentation",children:[l.jsxs("div",{className:C?"nc-popup nc-popup-libera":"nc-popup",style:C?{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:k("move"),onDoubleClick:R,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:k("resize"),title:p("popup-resize-hint"),role:"presentation"})]}),g&&l.jsx("div",{className:"nc-popup-velo-drag",role:"presentation"})]})}function Gw(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":_m(t)}async function nh({action:t,cellId:e,route:n=[],token:s,api:i={}}={}){const a=i.getLiveHost||(g=>Qd(s,g)),c=i.designateHostCell||((g,v,_)=>Zd(s,g,v,_)),u=i.clearHostCell||((g,v)=>eh(s,g,v));let h;try{h=await a(n)}catch(g){return{ok:!1,messageKey:Gw(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:Gw(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 ix=Object.defineProperty,Q5=Object.getOwnPropertyDescriptor,Z5=(t,e)=>{for(var n in e)ix(t,n,{get:e[n],enumerable:!0})},Rn=(t,e,n,s)=>{for(var i=s>1?void 0:s?Q5(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&&ix(e,n,i),i},lt=(t,e)=>(n,s)=>e(n,s,t),Xw="Terminal input",wm={get:()=>Xw,set:t=>Xw=t},Jw="Too much output to announce, navigate to rows manually to read",bm={get:()=>Jw,set:t=>Jw=t};function eR(t){return t.replace(/\r?\n/g,"\r")}function tR(t,e){return e?"\x1B[200~"+t+"\x1B[201~":t}function nR(t,e){t.clipboardData&&t.clipboardData.setData("text/plain",e.selectionText),t.preventDefault()}function sR(t,e,n,s){if(t.stopPropagation(),t.clipboardData){let i=t.clipboardData.getData("text/plain");rx(i,e,n,s)}}function rx(t,e,n,s){t=eR(t),t=tR(t,n.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(t,!0),e.value=""}function ox(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 Qw(t,e,n,s,i){ox(t,e,n),i&&s.rightClickSelect(t),e.value=s.selectionText,e.select()}function no(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}function sh(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 iR=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}},rR=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,k=this.interim[0];k&=(k&224)===192?31:(k&240)===224?15:7;let R=0,C;for(;(C=this.interim[++R]&63)&&R<4;)k<<=6,k|=C;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,S=L-R;for(;g<S;){if(g>=s)return 0;if(C=e[g++],(C&192)!==128){g--,b=!0;break}else this.interim[R++]=C,k<<=6,k|=C&63}b||(L===2?k<128?g--:n[i++]=k:L===3?k<2048||k>=55296&&k<=57343||k===65279||(n[i++]=k):k<65536||k>1114111||(n[i++]=k)),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}},ax="",io=" ",$c=class lx{constructor(){this.fg=0,this.bg=0,this.extended=new Ld}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 lx;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}},Ld=class cx{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 cx(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},yi=class ux extends $c{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ld,this.combinedData=""}static fromCharData(e){let n=new ux;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?no(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()]}},Zw="di$target",Sm="di$dependencies",Gf=new Map;function oR(t){return t[Sm]||[]}function as(t){if(Gf.has(t))return Gf.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");aR(e,n,i)};return e._id=t,Gf.set(t,e),e}function aR(t,e,n){e[Zw]===e?e[Sm].push({id:t,index:n}):(e[Sm]=[{id:t,index:n}],e[Zw]=e)}var Is=as("BufferService"),dx=as("CoreMouseService"),Go=as("CoreService"),lR=as("CharsetService"),lv=as("InstantiationService"),hx=as("LogService"),Ds=as("OptionsService"),fx=as("OscLinkService"),cR=as("UnicodeService"),zc=as("DecorationService"),xm=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 yi,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 k={start:{x:f+1,y:e},end:{x:_+(!g&&_===u-1?1:0),y:e}},R=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let C=new URL(b);["http:","https:"].includes(C.protocol)||(R=!0)}catch{R=!0}R||i.push({text:b,range:k,activate:(C,L)=>a?a.activate(C,L,k):uR(C,L),hover:(C,L)=>{var S;return(S=a==null?void 0:a.hover)==null?void 0:S.call(a,C,L,k)},leave:(C,L)=>{var S;return(S=a==null?void 0:a.leave)==null?void 0:S.call(a,C,L,k)}})}g=!1,c.hasExtendedAttrs()&&c.extended.urlId?(f=_,h=c.extended.urlId):(f=-1,h=-1)}}n(i)}};xm=Rn([lt(0,Is),lt(1,Ds),lt(2,fx)],xm);function uR(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 ih=as("CharSizeService"),Rr=as("CoreBrowserService"),cv=as("MouseService"),Lr=as("RenderService"),dR=as("SelectionService"),px=as("CharacterJoinerService"),Qa=as("ThemeService"),mx=as("LinkProviderService"),hR=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?eb.isErrorNoTelemetry(e)?new eb(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)}},fR=new hR;function hd(t){pR(t)||fR.onUnexpectedError(t)}var km="Canceled";function pR(t){return t instanceof mR?!0:t instanceof Error&&t.name===km&&t.message===km}var mR=class extends Error{constructor(){super(km),this.name=this.message}};function gR(t){return new Error(`Illegal argument: ${t}`)}var eb=class Cm extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Cm)return e;let n=new Cm;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Em=class gx extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,gx.prototype)}};function ti(t,e=0){return t[t.length-(1+e)]}var vR;(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})(vR||(vR={}));function _R(t,e){let n=this,s=!1,i;return function(){return s||(s=!0,e||(i=t.apply(n,arguments))),i}}var vx;(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 H=E.length-1;H>=0;H--)yield E[H]}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,H){let F=0;for(let X of E)if(H(X,F++))return!0;return!1}t.some=g;function v(E,H){for(let F of E)if(H(F))return F}t.find=v;function*_(E,H){for(let F of E)H(F)&&(yield F)}t.filter=_;function*b(E,H){let F=0;for(let X of E)yield H(X,F++)}t.map=b;function*k(E,H){let F=0;for(let X of E)yield*H(X,F++)}t.flatMap=k;function*R(...E){for(let H of E)yield*H}t.concat=R;function C(E,H,F){let X=F;for(let V of E)X=H(X,V);return X}t.reduce=C;function*L(E,H,F=E.length){for(H<0&&(H+=E.length),F<0?F+=E.length:F>E.length&&(F=E.length);H<F;H++)yield E[H]}t.slice=L;function S(E,H=Number.POSITIVE_INFINITY){let F=[];if(H===0)return[F,E];let X=E[Symbol.iterator]();for(let V=0;V<H;V++){let G=X.next();if(G.done)return[F,t.empty()];F.push(G.value)}return[F,{[Symbol.iterator](){return X}}]}t.consume=S;async function T(E){let H=[];for await(let F of E)H.push(F);return Promise.resolve(H)}t.asyncToArray=T})(vx||(vx={}));function qo(t){if(vx.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 yR(...t){return vn(()=>qo(t))}function vn(t){return{dispose:_R(()=>{t()})}}var _x=class yx{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{qo(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?yx.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)}};_x.DISABLE_DISPOSED_WARNING=!1;var ao=_x,Ft=class{constructor(){this._store=new ao,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)}};Ft.None=Object.freeze({dispose(){}});var qa=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}},kr=typeof window=="object"?window:globalThis,Nm=class Rm{constructor(e){this.element=e,this.next=Rm.Undefined,this.prev=Rm.Undefined}};Nm.Undefined=new Nm(void 0);var Sn=Nm,tb=class{constructor(){this._first=Sn.Undefined,this._last=Sn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Sn.Undefined}clear(){let e=this._first;for(;e!==Sn.Undefined;){let n=e.next;e.prev=Sn.Undefined,e.next=Sn.Undefined,e=n}this._first=Sn.Undefined,this._last=Sn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,n){let s=new Sn(e);if(this._first===Sn.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!==Sn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Sn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Sn.Undefined&&e.next!==Sn.Undefined){let n=e.prev;n.next=e.next,e.next.prev=n}else e.prev===Sn.Undefined&&e.next===Sn.Undefined?(this._first=Sn.Undefined,this._last=Sn.Undefined):e.next===Sn.Undefined?(this._last=this._last.prev,this._last.next=Sn.Undefined):e.prev===Sn.Undefined&&(this._first=this._first.next,this._first.prev=Sn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Sn.Undefined;)yield e.element,e=e.next}},wR=globalThis.performance&&typeof globalThis.performance.now=="function",bR=class wx{static create(e){return new wx(e)}constructor(e){this._now=wR&&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}},ms;(t=>{t.None=()=>Ft.None;function e(B,P){return v(B,()=>{},0,void 0,!0,void 0,P)}t.defer=e;function n(B){return(P,D=null,M)=>{let $=!1,A;return A=B(j=>{if(!$)return A?A.dispose():$=!0,P.call(D,j)},null,M),$&&A.dispose(),A}}t.once=n;function s(B,P,D){return f((M,$=null,A)=>B(j=>M.call($,P(j)),null,A),D)}t.map=s;function i(B,P,D){return f((M,$=null,A)=>B(j=>{P(j),M.call($,j)},null,A),D)}t.forEach=i;function a(B,P,D){return f((M,$=null,A)=>B(j=>P(j)&&M.call($,j),null,A),D)}t.filter=a;function c(B){return B}t.signal=c;function u(...B){return(P,D=null,M)=>{let $=yR(...B.map(A=>A(j=>P.call(D,j))));return g($,M)}}t.any=u;function h(B,P,D,M){let $=D;return s(B,A=>($=P($,A),$),M)}t.reduce=h;function f(B,P){let D,M={onWillAddFirstListener(){D=B($.fire,$)},onDidRemoveLastListener(){D==null||D.dispose()}},$=new it(M);return P==null||P.add($),$.event}function g(B,P){return P instanceof Array?P.push(B):P&&P.add(B),B}function v(B,P,D=100,M=!1,$=!1,A,j){let N,U,I,W=0,se,me={leakWarningThreshold:A,onWillAddFirstListener(){N=B(Ie=>{W++,U=P(U,Ie),M&&!I&&(pe.fire(U),U=void 0),se=()=>{let J=U;U=void 0,I=void 0,(!M||W>1)&&pe.fire(J),W=0},typeof D=="number"?(clearTimeout(I),I=setTimeout(se,D)):I===void 0&&(I=0,queueMicrotask(se))})},onWillRemoveListener(){$&&W>0&&(se==null||se())},onDidRemoveLastListener(){se=void 0,N.dispose()}},pe=new it(me);return j==null||j.add(pe),pe.event}t.debounce=v;function _(B,P=0,D){return t.debounce(B,(M,$)=>M?(M.push($),M):[$],P,void 0,!0,void 0,D)}t.accumulate=_;function b(B,P=(M,$)=>M===$,D){let M=!0,$;return a(B,A=>{let j=M||!P(A,$);return M=!1,$=A,j},D)}t.latch=b;function k(B,P,D){return[t.filter(B,P,D),t.filter(B,M=>!P(M),D)]}t.split=k;function R(B,P=!1,D=[],M){let $=D.slice(),A=B(U=>{$?$.push(U):N.fire(U)});M&&M.add(A);let j=()=>{$==null||$.forEach(U=>N.fire(U)),$=null},N=new it({onWillAddFirstListener(){A||(A=B(U=>N.fire(U)),M&&M.add(A))},onDidAddFirstListener(){$&&(P?setTimeout(j):j())},onDidRemoveLastListener(){A&&A.dispose(),A=null}});return M&&M.add(N),N.event}t.buffer=R;function C(B,P){return(D,M,$)=>{let A=P(new S);return B(function(j){let N=A.evaluate(j);N!==L&&D.call(M,N)},void 0,$)}}t.chain=C;let L=Symbol("HaltChainable");class S{constructor(){this.steps=[]}map(P){return this.steps.push(P),this}forEach(P){return this.steps.push(D=>(P(D),D)),this}filter(P){return this.steps.push(D=>P(D)?D:L),this}reduce(P,D){let M=D;return this.steps.push($=>(M=P(M,$),M)),this}latch(P=(D,M)=>D===M){let D=!0,M;return this.steps.push($=>{let A=D||!P($,M);return D=!1,M=$,A?$:L}),this}evaluate(P){for(let D of this.steps)if(P=D(P),P===L)break;return P}}function T(B,P,D=M=>M){let M=(...N)=>j.fire(D(...N)),$=()=>B.on(P,M),A=()=>B.removeListener(P,M),j=new it({onWillAddFirstListener:$,onDidRemoveLastListener:A});return j.event}t.fromNodeEventEmitter=T;function E(B,P,D=M=>M){let M=(...N)=>j.fire(D(...N)),$=()=>B.addEventListener(P,M),A=()=>B.removeEventListener(P,M),j=new it({onWillAddFirstListener:$,onDidRemoveLastListener:A});return j.event}t.fromDOMEventEmitter=E;function H(B){return new Promise(P=>n(B)(P))}t.toPromise=H;function F(B){let P=new it;return B.then(D=>{P.fire(D)},()=>{P.fire(void 0)}).finally(()=>{P.dispose()}),P.event}t.fromPromise=F;function X(B,P){return B(D=>P.fire(D))}t.forward=X;function V(B,P,D){return P(D),B(M=>P(M))}t.runAndSubscribe=V;class G{constructor(P,D){this._observable=P,this._counter=0,this._hasChanged=!1;let M={onWillAddFirstListener:()=>{P.addObserver(this)},onDidRemoveLastListener:()=>{P.removeObserver(this)}};this.emitter=new it(M),D&&D.add(this.emitter)}beginUpdate(P){this._counter++}handlePossibleChange(P){}handleChange(P,D){this._hasChanged=!0}endUpdate(P){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ne(B,P){return new G(B,P).emitter.event}t.fromObservable=ne;function Y(B){return(P,D,M)=>{let $=0,A=!1,j={beginUpdate(){$++},endUpdate(){$--,$===0&&(B.reportChanges(),A&&(A=!1,P.call(D)))},handlePossibleChange(){},handleChange(){A=!0}};B.addObserver(j),B.reportChanges();let N={dispose(){B.removeObserver(j)}};return M instanceof ao?M.add(N):Array.isArray(M)&&M.push(N),N}}t.fromObservableLight=Y})(ms||(ms={}));var Lm=class Am{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Am._idPool++}`,Am.all.add(this)}start(e){this._stopWatch=new bR,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}}};Lm.all=new Set,Lm._idPool=0;var SR=Lm,xR=-1,bx=class Sx{constructor(e,n,s=(Sx._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 ER(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}};bx._idPool=1;var kR=bx,CR=class xx{constructor(e){this.value=e}static create(){let e=new Error;return new xx(e.stack??"")}print(){console.warn(this.value.split(`
|
|
58
|
+
`).slice(2).join(`
|
|
59
|
+
`))}},ER=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},NR=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},RR=0,Xf=class{constructor(e){this.value=e,this.id=RR++}},LR=2,AR,it=class{constructor(t){var e,n,s,i;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new kR((t==null?void 0:t.onListenerError)??hd,((n=this._options)==null?void 0:n.leakWarningThreshold)??xR):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new SR(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 NR(`${v}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||hd)(b),Ft.None}if(this._disposed)return Ft.None;e&&(t=t.bind(e));let s=new Xf(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=CR.create(),i=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Xf?(this._deliveryQueue??(this._deliveryQueue=new jR),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=vn(()=>{i==null||i(),this._removeListener(s)});return n instanceof ao?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*LR<=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)||hd;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 Xf)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}},jR=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}},jm=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new it,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new it,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}};jm.INSTANCE=new jm;var uv=jm;function MR(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}uv.INSTANCE.onDidChangeZoomLevel;function TR(t){return uv.INSTANCE.getZoomFactor(t)}uv.INSTANCE.onDidChangeFullscreen;var Za=typeof navigator=="object"?navigator.userAgent:"",Mm=Za.indexOf("Firefox")>=0,PR=Za.indexOf("AppleWebKit")>=0,dv=Za.indexOf("Chrome")>=0,IR=!dv&&Za.indexOf("Safari")>=0;Za.indexOf("Electron/")>=0;Za.indexOf("Android")>=0;var Jf=!1;if(typeof kr.matchMedia=="function"){let t=kr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=kr.matchMedia("(display-mode: fullscreen)");Jf=t.matches,MR(kr,t,({matches:n})=>{Jf&&e.matches||(Jf=n)})}var Da="en",Tm=!1,Pm=!1,fd=!1,kx=!1,Ku,pd=Da,nb=Da,DR,Ai,zo=globalThis,fs,b1;typeof zo.vscode<"u"&&typeof zo.vscode.process<"u"?fs=zo.vscode.process:typeof process<"u"&&typeof((b1=process==null?void 0:process.versions)==null?void 0:b1.node)=="string"&&(fs=process);var S1,OR=typeof((S1=fs==null?void 0:fs.versions)==null?void 0:S1.electron)=="string",BR=OR&&(fs==null?void 0:fs.type)==="renderer",x1;if(typeof fs=="object"){Tm=fs.platform==="win32",Pm=fs.platform==="darwin",fd=fs.platform==="linux",fd&&fs.env.SNAP&&fs.env.SNAP_REVISION,fs.env.CI||fs.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ku=Da,pd=Da;let t=fs.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);Ku=e.userLocale,nb=e.osLocale,pd=e.resolvedLanguage||Da,DR=(x1=e.languagePack)==null?void 0:x1.translationsConfigFile}catch{}kx=!0}else typeof navigator=="object"&&!BR?(Ai=navigator.userAgent,Tm=Ai.indexOf("Windows")>=0,Pm=Ai.indexOf("Macintosh")>=0,(Ai.indexOf("Macintosh")>=0||Ai.indexOf("iPad")>=0||Ai.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,fd=Ai.indexOf("Linux")>=0,(Ai==null?void 0:Ai.indexOf("Mobi"))>=0,pd=globalThis._VSCODE_NLS_LANGUAGE||Da,Ku=navigator.language.toLowerCase(),nb=Ku):console.error("Unable to resolve platform.");var Cx=Tm,Qi=Pm,$R=fd,sb=kx,er=Ai,Kr=pd,zR;(t=>{function e(){return Kr}t.value=e;function n(){return Kr.length===2?Kr==="en":Kr.length>=3?Kr[0]==="e"&&Kr[1]==="n"&&Kr[2]==="-":!1}t.isDefaultVariant=n;function s(){return Kr==="en"}t.isDefault=s})(zR||(zR={}));var FR=typeof zo.postMessage=="function"&&!zo.importScripts;(()=>{if(FR){let t=[];zo.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}),zo.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var HR=!!(er&&er.indexOf("Chrome")>=0);er&&er.indexOf("Firefox")>=0;!HR&&er&&er.indexOf("Safari")>=0;er&&er.indexOf("Edg/")>=0;er&&er.indexOf("Android")>=0;var Ca=typeof navigator=="object"?navigator:{};sb||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ca&&Ca.clipboard&&Ca.clipboard.writeText,sb||Ca&&Ca.clipboard&&Ca.clipboard.readText;var hv=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}},Qf=new hv,ib=new hv,rb=new hv,UR=new Array(230),Ex;(t=>{function e(u){return Qf.keyCodeToStr(u)}t.toString=e;function n(u){return Qf.strToKeyCode(u)}t.fromString=n;function s(u){return ib.keyCodeToStr(u)}t.toUserSettingsUS=s;function i(u){return rb.keyCodeToStr(u)}t.toUserSettingsGeneral=i;function a(u){return ib.strToKeyCode(u)||rb.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 Qf.keyCodeToStr(u)}t.toElectronAccelerator=c})(Ex||(Ex={}));var WR=class Nx{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 Nx&&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 qR([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},qR=class{constructor(t){if(t.length===0)throw gR("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 KR(t){if(t.charCode){let n=String.fromCharCode(t.charCode).toUpperCase();return Ex.fromString(n)}let e=t.keyCode;if(e===3)return 7;if(Mm)switch(e){case 59:return 85;case 60:if($R)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Qi)return 57;break}else if(PR&&(Qi&&e===93||!Qi&&e===92))return 57;return UR[e]||0}var VR=Qi?256:2048,YR=512,GR=1024,XR=Qi?2048:256,ob=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=KR(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|=VR),this.altKey&&(e|=YR),this.shiftKey&&(e|=GR),this.metaKey&&(e|=XR),e|=t,e}_computeKeyCodeChord(){let t=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(t=this.keyCode),new WR(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,t)}},ab=new WeakMap;function JR(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 QR=class{static getSameOriginWindowChain(t){let e=ab.get(t);if(!e){e=[],ab.set(t,e);let n=t,s;do s=JR(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}}},Vu=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=QR.getPositionOfChildWindowRelativeToAncestorWindow(e,n.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},lb=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(dv){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?Mm&&!Qi?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof c.wheelDeltaX<"u")IR&&Cx?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?Mm&&!Qi?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()}},Rx=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),ZR;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof eL?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ms.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Rx})})(ZR||(ZR={}));var eL=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?Rx:(this._emitter||(this._emitter=new it),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},fv=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 Em("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},n)}setIfNotSet(e,n){if(this._isDisposed)throw new Em("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},n))}},tL=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 Em("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},n);this.disposable=vn(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},nL;(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})(nL||(nL={}));var cb=class hi{static fromArray(e){return new hi(n=>{n.emitMany(e)})}static fromPromise(e){return new hi(async n=>{n.emitMany(await e)})}static fromPromises(e){return new hi(async n=>{await Promise.all(e.map(async s=>n.emitOne(await s)))})}static merge(e){return new hi(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 it,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 ms.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 hi(async s=>{for await(let i of e)s.emitOne(n(i))})}map(e){return hi.map(this,e)}static filter(e,n){return new hi(async s=>{for await(let i of e)n(i)&&s.emitOne(i)})}filter(e){return hi.filter(this,e)}static coalesce(e){return hi.filter(e,n=>!!n)}coalesce(){return hi.coalesce(this)}static async toPromise(e){let n=[];for await(let s of e)n.push(s);return n}toPromise(){return hi.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())}};cb.EMPTY=cb.fromArray([]);var{getWindow:Ji,getWindowId:sL,onDidRegisterWindow:iL}=(function(){let t=new Map,e={window:kr,disposables:new ao};t.set(kr.vscodeWindowId,e);let n=new it,s=new it,i=new it;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 Ft.None;let u=new ao,h={window:c,disposables:u.add(new ao)};return t.set(c.vscodeWindowId,h),u.add(vn(()=>{t.delete(c.vscodeWindowId),s.fire(c)})),u.add(jt(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:kr},getDocument(c){return Ji(c).document}}})(),rL=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 jt(t,e,n,s){return new rL(t,e,n,s)}var ub=function(t,e,n,s){return jt(t,e,n,s)},pv,oL=class extends tL{constructor(t){super(),this.defaultTarget=t&&Ji(t)}cancelAndSet(t,e,n){return super.cancelAndSet(t,e,n??this.defaultTarget)}},db=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){hd(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(db.sort),c.shift().execute();s.set(a,!1)};pv=(a,c,u=0)=>{let h=sL(a),f=new db(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 aL(t){let e=t.getBoundingClientRect(),n=Ji(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"},lL=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=Ws(e);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let n=Ws(e);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(e){let n=Ws(e);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(e){let n=Ws(e);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(e){let n=Ws(e);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(e){let n=Ws(e);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(e){let n=Ws(e);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(e){let n=Ws(e);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let n=Ws(e);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let n=Ws(e);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let n=Ws(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=Ws(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=Ws(e);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let n=Ws(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 Ws(t){return typeof t=="number"?`${t}px`:t}function mc(t){return new lL(t)}var Lx=class{constructor(){this._hooks=new ao,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(vn(()=>{try{e.releasePointerCapture(n)}catch{}}))}catch{c=Ji(e)}this._hooks.add(jt(c,es.POINTER_MOVE,u=>{if(u.buttons!==s){this.stopMonitoring(!0);return}u.preventDefault(),this._pointerMoveCallback(u)})),this._hooks.add(jt(c,es.POINTER_UP,u=>this.stopMonitoring(!0)))}};function cL(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 qi;(t=>(t.Tap="-xterm-gesturetap",t.Change="-xterm-gesturechange",t.Start="-xterm-gesturestart",t.End="-xterm-gesturesend",t.Contextmenu="-xterm-gesturecontextmenu"))(qi||(qi={}));var oc=class Es extends Ft{constructor(){super(),this.dispatched=!1,this.targets=new tb,this.ignoreTargets=new tb,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ms.runAndSubscribe(iL,({window:e,disposables:n})=>{n.add(jt(e.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),n.add(jt(e.document,"touchend",s=>this.onTouchEnd(e,s))),n.add(jt(e.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:kr,disposables:this._store}))}static addTarget(e){if(!Es.isTouchDevice())return Ft.None;Es.INSTANCE||(Es.INSTANCE=new Es);let n=Es.INSTANCE.targets.push(e);return vn(n)}static ignoreTarget(e){if(!Es.isTouchDevice())return Ft.None;Es.INSTANCE||(Es.INSTANCE=new Es);let n=Es.INSTANCE.ignoreTargets.push(e);return vn(n)}static isTouchDevice(){return"ontouchstart"in kr||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(qi.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<Es.HOLD_DELAY&&Math.abs(h.initialPageX-ti(h.rollingPageX))<30&&Math.abs(h.initialPageY-ti(h.rollingPageY))<30){let g=this.newGestureEvent(qi.Tap,h.initialTarget);g.pageX=ti(h.rollingPageX),g.pageY=ti(h.rollingPageY),this.dispatchEvent(g)}else if(f>=Es.HOLD_DELAY&&Math.abs(h.initialPageX-ti(h.rollingPageX))<30&&Math.abs(h.initialPageY-ti(h.rollingPageY))<30){let g=this.newGestureEvent(qi.Contextmenu,h.initialTarget);g.pageX=ti(h.rollingPageX),g.pageY=ti(h.rollingPageY),this.dispatchEvent(g)}else if(i===1){let g=ti(h.rollingPageX),v=ti(h.rollingPageY),_=ti(h.rollingTimestamps)-h.rollingTimestamps[0],b=g-h.rollingPageX[0],k=v-h.rollingPageY[0],R=[...this.targets].filter(C=>h.initialTarget instanceof Node&&C.contains(h.initialTarget));this.inertia(e,R,s,Math.abs(b)/_,b>0?1:-1,g,Math.abs(k)/_,k>0?1:-1,v)}this.dispatchEvent(this.newGestureEvent(qi.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===qi.Tap){let n=new Date().getTime(),s=0;n-this._lastSetTapCountTime>Es.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=n,e.tapCount=s}else(e.type===qi.Change||e.type===qi.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=pv(e,()=>{let g=Date.now(),v=g-s,_=0,b=0,k=!0;i+=Es.SCROLL_FRICTION*v,u+=Es.SCROLL_FRICTION*v,i>0&&(k=!1,_=a*i*v),u>0&&(k=!1,b=h*u*v);let R=this.newGestureEvent(qi.Change);R.translationX=_,R.translationY=b,n.forEach(C=>C.dispatchEvent(R)),k||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(qi.Change,c.initialTarget);u.translationX=a.pageX-ti(c.rollingPageX),u.translationY=a.pageY-ti(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)}};oc.SCROLL_FRICTION=-.005,oc.HOLD_DELAY=700,oc.CLEAR_TAP_COUNT_TIME=400,Rn([cL],oc,"isTouchDevice",1);var uL=oc,mv=class extends Ft{onclick(e,n){this._register(jt(e,es.CLICK,s=>n(new Vu(Ji(e),s))))}onmousedown(e,n){this._register(jt(e,es.MOUSE_DOWN,s=>n(new Vu(Ji(e),s))))}onmouseover(e,n){this._register(jt(e,es.MOUSE_OVER,s=>n(new Vu(Ji(e),s))))}onmouseleave(e,n){this._register(jt(e,es.MOUSE_LEAVE,s=>n(new Vu(Ji(e),s))))}onkeydown(e,n){this._register(jt(e,es.KEY_DOWN,s=>n(new ob(s))))}onkeyup(e,n){this._register(jt(e,es.KEY_UP,s=>n(new ob(s))))}oninput(e,n){this._register(jt(e,es.INPUT,n))}onblur(e,n){this._register(jt(e,es.BLUR,n))}onfocus(e,n){this._register(jt(e,es.FOCUS,n))}onchange(e,n){this._register(jt(e,es.CHANGE,n))}ignoreGesture(e){return uL.ignoreTarget(e)}},hb=11,dL=class extends mv{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=hb+"px",this.domNode.style.height=hb+"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 Lx),this._register(ub(this.bgDomNode,es.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(ub(this.domNode,es.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new oL),this._pointerdownScheduleRepeatTimer=this._register(new fv)}_arrowPointerDown(t){if(!t.target||!(t.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Ji(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()}},hL=class Im{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 Im(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 Im(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}}},fL=class extends Ft{constructor(t){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new it),this.onScroll=this._onScroll.event,this._smoothScrollDuration=t.smoothScrollDuration,this._scheduleAtNextAnimationFrame=t.scheduleAtNextAnimationFrame,this._state=new hL(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 pb(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=pb.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)))}},fb=class{constructor(e,n,s){this.scrollLeft=e,this.scrollTop=n,this.isDone=s}};function Zf(t,e){let n=e-t;return function(s){return t+n*gL(s)}}function pL(t,e,n){return function(s){return s<n?t(s/n):e((s-n)/(1-n))}}var pb=class Dm{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),pL(Zf(e,i),Zf(a,n),.33)}return Zf(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 fb(s,i,!1)}return new fb(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,n,s){return Dm.start(e,n,s)}static start(e,n,s){s=s+10;let i=Date.now()-10;return new Dm(e,n,i,s)}};function mL(t){return Math.pow(t,3)}function gL(t){return 1-mL(1-t)}var vL=class extends Ft{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 fv)}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":"")))}},_L=140,Ax=class extends mv{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 vL(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Lx),this._shouldRender=!0,this.domNode=mc(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(jt(this.domNode.domNode,es.POINTER_DOWN,n=>this._domNodePointerDown(n)))}_createArrow(e){let n=this._register(new dL(e));this.domNode.domNode.appendChild(n.bgDomNode),this.domNode.domNode.appendChild(n.domNode)}_createSlider(e,n,s,i){this.slider=mc(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(jt(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=aL(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(Cx&&u>_L){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()}},jx=class Om{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 Om(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=Om._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)}},yL=class extends Ax{constructor(e,n,s){let i=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:s,scrollbarState:new jx(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}},wL=class extends Ax{constructor(t,e,n){let s=t.getScrollDimensions(),i=t.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:n,scrollbarState:new jx(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}},bL=500,mb=50,SL=class{constructor(e,n,s){this.timestamp=e,this.deltaX=n,this.deltaY=s,this.score=0}},Bm=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(dv){let n=Ji(e.browserEvent),s=TR(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 SL(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}};Bm.INSTANCE=new Bm;var xL=Bm,kL=class extends mv{constructor(t,e,n){super(),this._onScroll=this._register(new it),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new it),this.onWillScroll=this._onWillScroll.event,this._options=EL(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 wL(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new yL(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=mc(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=mc(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=mc(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 fv),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=qo(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,Qi&&(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 lb(t))}_setListeningToMouseWheel(t){if(this._mouseWheelToDispose.length>0!==t&&(this._mouseWheelToDispose=qo(this._mouseWheelToDispose),t)){let e=n=>{this._onMouseWheel(new lb(n))};this._mouseWheelToDispose.push(jt(this._listenOnDomNode,es.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(t){var i;if((i=t.browserEvent)!=null&&i.defaultPrevented)return;let e=xL.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=!Qi&&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=mb*a,v=h.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(f,v)}if(c){let g=mb*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(),bL)}},CL=class extends kL{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 EL(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,Qi&&(e.className+=" mac"),e}var $m=class extends Ft{constructor(e,n,s,i,a,c,u,h){super(),this._bufferService=s,this._optionsService=u,this._renderService=h,this._onRequestScrollLines=this._register(new it),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let f=this._register(new fL({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:g=>pv(i.window,g)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{f.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new CL(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(ms.runAndSubscribe(c.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=c.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(vn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),n.appendChild(this._styleElement),this._register(vn(()=>this._styleElement.remove())),this._register(ms.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}};$m=Rn([lt(2,Is),lt(3,Rr),lt(4,dx),lt(5,Qa),lt(6,Ds),lt(7,Lr)],$m);var zm=class extends Ft{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(vn(()=>{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()}};zm=Rn([lt(1,Is),lt(2,Rr),lt(3,zc),lt(4,Lr)],zm);var NL=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)}},Fi={full:0,left:0,center:0,right:0},Vr={full:0,left:0,center:0,right:0},Bl={full:0,left:0,center:0,right:0},Ad=class extends Ft{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 NL,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(vn(()=>{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);Vr.full=this._canvas.width,Vr.left=e,Vr.center=n,Vr.right=e,this._refreshDrawHeightConstants(),Bl.full=1,Bl.left=1,Bl.center=1+Vr.left,Bl.right=1+Vr.left+Vr.center}_refreshDrawHeightConstants(){Fi.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);Fi.left=n,Fi.center=n,Fi.right=n}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Fi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Fi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Fi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Fi.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(Bl[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Fi[e.position||"full"]/2),Vr[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Fi[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}))}};Ad=Rn([lt(2,Is),lt(3,zc),lt(4,Lr),lt(5,Ds),lt(6,Qa),lt(7,Rr)],Ad);var De;(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=""))(De||(De={}));var md;(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=""))(md||(md={}));var Mx;(t=>t.ST=`${De.ESC}\\`)(Mx||(Mx={}));var Fm=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(`${De.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)}}};Fm=Rn([lt(2,Is),lt(3,Ds),lt(4,Go),lt(5,Lr)],Fm);var ts=0,ns=0,ss=0,En=0,gb={css:"#00000000",rgba:0},Bn;(t=>{function e(i,a,c,u){return u!==void 0?`#${Lo(i)}${Lo(a)}${Lo(c)}${Lo(u)}`:`#${Lo(i)}${Lo(a)}${Lo(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})(Bn||(Bn={}));var fn;(t=>{function e(h,f){if(En=(f.rgba&255)/255,En===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,k=h.rgba>>16&255,R=h.rgba>>8&255;ts=b+Math.round((g-b)*En),ns=k+Math.round((v-k)*En),ss=R+Math.round((_-R)*En);let C=Bn.toCss(ts,ns,ss),L=Bn.toRgba(ts,ns,ss);return{css:C,rgba:L}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function s(h,f,g){let v=gd.ensureContrastRatio(h.rgba,f.rgba,g);if(v)return Bn.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]=gd.toChannels(f),{css:Bn.toCss(ts,ns,ss),rgba:f}}t.opaque=i;function a(h,f){return En=Math.round(f*255),[ts,ns,ss]=gd.toChannels(h.rgba),{css:Bn.toCss(ts,ns,ss,En),rgba:Bn.toRgba(ts,ns,ss,En)}}t.opacity=a;function c(h,f){return En=h.rgba&255,a(h,En*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 xn;(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),Bn.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),En=parseInt(i.slice(4,5).repeat(2),16),Bn.toColor(ts,ns,ss,En);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]),En=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),Bn.toColor(ts,ns,ss,En);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,En]=e.getImageData(0,0,1,1).data,En!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Bn.toRgba(ts,ns,ss,En),css:i}}t.toColor=s})(xn||(xn={}));var Ms;(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})(Ms||(Ms={}));var gd;(t=>{function e(c,u){if(En=(u&255)/255,En===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)*En),ns=_+Math.round((f-_)*En),ss=b+Math.round((g-b)*En),Bn.toRgba(ts,ns,ss)}t.blend=e;function n(c,u,h){let f=Ms.relativeLuminance(c>>8),g=Ms.relativeLuminance(u>>8);if(vr(f,g)<h){if(g<f){let b=s(c,u,h),k=vr(f,Ms.relativeLuminance(b>>8));if(k<h){let R=i(c,u,h),C=vr(f,Ms.relativeLuminance(R>>8));return k>C?b:R}return b}let v=i(c,u,h),_=vr(f,Ms.relativeLuminance(v>>8));if(_<h){let b=s(c,u,h),k=vr(f,Ms.relativeLuminance(b>>8));return _>k?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,k=u>>8&255,R=vr(Ms.relativeLuminance2(_,b,k),Ms.relativeLuminance2(f,g,v));for(;R<h&&(_>0||b>0||k>0);)_-=Math.max(0,Math.ceil(_*.1)),b-=Math.max(0,Math.ceil(b*.1)),k-=Math.max(0,Math.ceil(k*.1)),R=vr(Ms.relativeLuminance2(_,b,k),Ms.relativeLuminance2(f,g,v));return(_<<24|b<<16|k<<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,k=u>>8&255,R=vr(Ms.relativeLuminance2(_,b,k),Ms.relativeLuminance2(f,g,v));for(;R<h&&(_<255||b<255||k<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),R=vr(Ms.relativeLuminance2(_,b,k),Ms.relativeLuminance2(f,g,v));return(_<<24|b<<16|k<<8|255)>>>0}t.increaseLuminance=i;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}t.toChannels=a})(gd||(gd={}));function Lo(t){let e=t.toString(16);return e.length<2?"0"+e:e}function vr(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}var RL=class extends $c{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()]}},jd=class{constructor(t){this._bufferService=t,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new yi}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||io.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++)jd._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||io.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}};jd=Rn([lt(0,Is)],jd);function LL(t){return 57508<=t&&t<=57558}function AL(t){return 9472<=t&&t<=9631}function jL(t){return LL(t)||AL(t)}function ML(){return{css:{canvas:Yu(),cell:Yu()},device:{canvas:Yu(),cell:Yu(),char:{width:0,height:0,left:0,top:0}}}}function Yu(){return{width:0,height:0}}var Hm=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 yi,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),k=this._themeService.colors,R=e.getNoBgTrimmedLength();s&&R<c+1&&(R=c+1);let C,L=0,S="",T=0,E=0,H=0,F=0,X=!1,V=0,G=!1,ne=0,Y=0,B=[],P=g!==-1&&v!==-1;for(let D=0;D<R;D++){e.loadCell(D,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let $=!1,A=D>=Y,j=D,N=this._workCell;if(b.length>0&&D===b[0][0]&&A){let Q=b.shift(),ve=this._isCellInSelection(Q[0],n);for(T=Q[0]+1;T<Q[1];T++)A&&(A=ve===this._isCellInSelection(T,n));A&&(A=!s||c<Q[0]||c>=Q[1]),A?($=!0,N=new RL(this._workCell,e.translateToString(!0,Q[0],Q[1]),Q[1]-Q[0]),j=Q[1]-1,M=N.getWidth()):Y=Q[1]}let U=this._isCellInSelection(D,n),I=s&&D===c,W=P&&D>=g&&D<=v,se=!1;this._decorationService.forEachDecorationAtCell(D,n,void 0,Q=>{se=!0});let me=N.getChars()||io;if(me===" "&&(N.isUnderline()||N.isOverline())&&(me=" "),ne=M*h-f.get(me,N.isBold(),N.isItalic()),!C)C=this._document.createElement("span");else if(L&&(U&&G||!U&&!G&&N.bg===E)&&(U&&G&&k.selectionForeground||N.fg===H)&&N.extended.ext===F&&W===X&&ne===V&&!I&&!$&&!se&&A){N.isInvisible()?S+=io:S+=me,L++;continue}else L&&(C.textContent=S),C=this._document.createElement("span"),L=0,S="";if(E=N.bg,H=N.fg,F=N.extended.ext,X=W,V=ne,G=U,$&&c>=D&&c<=j&&(c=D),!this._coreService.isCursorHidden&&I&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)u&&B.push("xterm-cursor-blink"),B.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(N.isBold()&&B.push("xterm-bold"),N.isItalic()&&B.push("xterm-italic"),N.isDim()&&B.push("xterm-dim"),N.isInvisible()?S=io:S=N.getChars()||io,N.isUnderline()&&(B.push(`xterm-underline-${N.extended.underlineStyle}`),S===" "&&(S=" "),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())C.style.textDecorationColor=`rgb(${$c.toColorRGB(N.getUnderlineColor()).join(",")})`;else{let Q=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&Q<8&&(Q+=8),C.style.textDecorationColor=k.ansi[Q].css}N.isOverline()&&(B.push("xterm-overline"),S===" "&&(S=" ")),N.isStrikethrough()&&B.push("xterm-strikethrough"),W&&(C.style.textDecoration="underline");let pe=N.getFgColor(),Ie=N.getFgColorMode(),J=N.getBgColor(),te=N.getBgColorMode(),ge=!!N.isInverse();if(ge){let Q=pe;pe=J,J=Q;let ve=Ie;Ie=te,te=ve}let Se,Be,Le=!1;this._decorationService.forEachDecorationAtCell(D,n,void 0,Q=>{Q.options.layer!=="top"&&Le||(Q.backgroundColorRGB&&(te=50331648,J=Q.backgroundColorRGB.rgba>>8&16777215,Se=Q.backgroundColorRGB),Q.foregroundColorRGB&&(Ie=50331648,pe=Q.foregroundColorRGB.rgba>>8&16777215,Be=Q.foregroundColorRGB),Le=Q.options.layer==="top")}),!Le&&U&&(Se=this._coreBrowserService.isFocused?k.selectionBackgroundOpaque:k.selectionInactiveBackgroundOpaque,J=Se.rgba>>8&16777215,te=50331648,Le=!0,k.selectionForeground&&(Ie=50331648,pe=k.selectionForeground.rgba>>8&16777215,Be=k.selectionForeground)),Le&&B.push("xterm-decoration-top");let ze;switch(te){case 16777216:case 33554432:ze=k.ansi[J],B.push(`xterm-bg-${J}`);break;case 50331648:ze=Bn.toColor(J>>16,J>>8&255,J&255),this._addStyle(C,`background-color:#${vb((J>>>0).toString(16),"0",6)}`);break;case 0:default:ge?(ze=k.foreground,B.push("xterm-bg-257")):ze=k.background}switch(Se||N.isDim()&&(Se=fn.multiplyOpacity(ze,.5)),Ie){case 16777216:case 33554432:N.isBold()&&pe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(pe+=8),this._applyMinimumContrast(C,ze,k.ansi[pe],N,Se,void 0)||B.push(`xterm-fg-${pe}`);break;case 50331648:let Q=Bn.toColor(pe>>16&255,pe>>8&255,pe&255);this._applyMinimumContrast(C,ze,Q,N,Se,Be)||this._addStyle(C,`color:#${vb(pe.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(C,ze,k.foreground,N,Se,Be)||ge&&B.push("xterm-fg-257")}B.length&&(C.className=B.join(" "),B.length=0),!I&&!$&&!se&&A?L++:C.textContent=S,ne!==this.defaultSpacing&&(C.style.letterSpacing=`${ne}px`),_.push(C),D=j}return C&&L&&(C.textContent=S),_}_applyMinimumContrast(e,n,s,i,a,c){if(this._optionsService.rawOptions.minimumContrastRatio===1||jL(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]}};Hm=Rn([lt(1,px),lt(2,Ds),lt(3,Rr),lt(4,Go),lt(5,zc),lt(6,Qa)],Hm);function vb(t,e,n){for(;t.length<n;)t=e+t;return t}var TL=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}},PL=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 IL(){return new PL}var ep="xterm-dom-renderer-owner-",di="xterm-rows",Gu="xterm-fg-",_b="xterm-bg-",$l="xterm-focus",Xu="xterm-selection",DL=1,Um=class extends Ft{constructor(e,n,s,i,a,c,u,h,f,g,v,_,b,k){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=k,this._terminalClass=DL++,this._rowElements=[],this._selectionRenderModel=IL(),this.onRequestRedraw=this._register(new it).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(di),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(Xu),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=ML(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(R=>this._injectCss(R))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(Hm,document),this._element.classList.add(ep+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(R=>this._handleLinkHover(R))),this._register(this._linkifier2.onHideLinkUnderline(R=>this._handleLinkLeave(R))),this._register(vn(()=>{this._element.classList.remove(ep+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new TL(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} .${di} 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} .${di} { 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} .${di} .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} .${di}.${$l} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${di}.${$l} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${di}.${$l} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${di} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${di} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${di} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${di} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${di} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,n+=`${this._terminalSelector} .${Xu} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Xu} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Xu} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[c,u]of e.ansi.entries())n+=`${this._terminalSelector} .${Gu}${c} { color: ${u.css}; }${this._terminalSelector} .${Gu}${c}.xterm-dim { color: ${fn.multiplyOpacity(u,.5).css}; }${this._terminalSelector} .${_b}${c} { background-color: ${u.css}; }`;n+=`${this._terminalSelector} .${Gu}257 { color: ${fn.opaque(e.background).css}; }${this._terminalSelector} .${Gu}257.xterm-dim { color: ${fn.multiplyOpacity(fn.opaque(e.background),.5).css}; }${this._terminalSelector} .${_b}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($l),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add($l),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`.${ep}${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 k=s;k<=i;++k){let R=k+h.ydisp,C=this._rowElements[k],L=h.lines.get(R);if(!C||!L)break;C.replaceChildren(...this._rowFactory.createRow(L,R,R===f,_,b,g,v,this.dimensions.css.cell.width,this._widthCache,c?k===s?e:0:-1,c?(k===i?n:a)-1:-1))}}};Um=Rn([lt(7,lv),lt(8,ih),lt(9,Ds),lt(10,Is),lt(11,Go),lt(12,Rr),lt(13,Qa)],Um);var Wm=class extends Ft{constructor(e,n,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new it),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new BL(this._optionsService))}catch{this._measureStrategy=this._register(new OL(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())}};Wm=Rn([lt(2,Ds)],Wm);var Tx=class extends Ft{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)}},OL=class extends Tx{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}},BL=class extends Tx{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}},$L=class extends Ft{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 zL(this._window)),this._onDprChange=this._register(new it),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new it),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(ms.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(jt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(jt(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}},zL=class extends Ft{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new qa),this._onDprChange=this._register(new it),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(vn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=jt(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)}},FL=class extends Ft{constructor(){super(),this.linkProviders=[],this._register(vn(()=>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 gv(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 HL(t,e,n,s,i,a,c,u,h){if(!a)return;let f=gv(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 qm=class{constructor(e,n){this._renderService=e,this._charSizeService=n}getCoords(e,n,s,i,a){return HL(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=gv(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])}}};qm=Rn([lt(0,Lr),lt(1,ih)],qm);var UL=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=[]}},Px={};Z5(Px,{getSafariVersion:()=>qL,isChromeOS:()=>Bx,isFirefox:()=>Ix,isIpad:()=>KL,isIphone:()=>VL,isLegacyEdge:()=>WL,isLinux:()=>vv,isMac:()=>Md,isNode:()=>rh,isSafari:()=>Dx,isWindows:()=>Ox});var rh=typeof process<"u"&&"title"in process,Fc=rh?"node":navigator.userAgent,Hc=rh?"node":navigator.platform,Ix=Fc.includes("Firefox"),WL=Fc.includes("Edge"),Dx=/^((?!chrome|android).)*safari/i.test(Fc);function qL(){if(!Dx)return 0;let t=Fc.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}var Md=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Hc),KL=Hc==="iPad",VL=Hc==="iPhone",Ox=["Windows","Win16","Win32","WinCE"].includes(Hc),vv=Hc.indexOf("Linux")>=0,Bx=/\bCrOS\b/.test(Fc),$x=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()}},YL=class extends $x{_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())}}},GL=class extends $x{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Td=!rh&&"requestIdleCallback"in window?GL:YL,XL=class{constructor(){this._queue=new Td}set(t){this._queue.clear(),this._queue.enqueue(t)}flush(){this._queue.flush()}},Km=class extends Ft{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 qa),this._pausedResizeTask=new XL,this._observerDisposable=this._register(new qa),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 it),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new it),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new it),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new it),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new UL((g,v)=>this._renderRows(g,v),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new JL(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(vn(()=>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=vn(()=>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()}};Km=Rn([lt(2,Ds),lt(3,ih),lt(4,Go),lt(5,zc),lt(6,Is),lt(7,Rr),lt(8,Qa)],Km);var JL=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 QL(t,e,n,s){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return tA(i,a,t,e,n,s)+oh(a,e,n,s)+nA(i,a,t,e,n,s);let c;if(a===e)return c=i>t?"D":"C",xc(Math.abs(i-t),Sc(c,s));c=a>e?"D":"C";let u=Math.abs(a-e),h=eA(a>e?t:i,n)+(u-1)*n.cols+1+ZL(a>e?i:t);return xc(h,Sc(c,s))}function ZL(t,e){return t-1}function eA(t,e){return e.cols-t}function tA(t,e,n,s,i,a){return oh(e,s,i,a).length===0?"":xc(Fx(t,e,t,e-Ko(e,i),!1,i).length,Sc("D",a))}function oh(t,e,n,s){let i=t-Ko(t,n),a=e-Ko(e,n),c=Math.abs(i-a)-sA(t,e,n);return xc(c,Sc(zx(t,e),s))}function nA(t,e,n,s,i,a){let c;oh(e,s,i,a).length>0?c=s-Ko(s,i):c=e;let u=s,h=iA(t,e,n,s,i,a);return xc(Fx(t,c,n,u,h==="C",i).length,Sc(h,a))}function sA(t,e,n){var c;let s=0,i=t-Ko(t,n),a=e-Ko(e,n);for(let u=0;u<Math.abs(i-a);u++){let h=zx(t,e)==="A"?-1:1;(c=n.buffer.lines.get(i+h*u))!=null&&c.isWrapped&&s++}return s}function Ko(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 iA(t,e,n,s,i,a){let c;return oh(n,s,i,a).length>0?c=s-Ko(s,i):c=e,t<n&&c<=s||t>=n&&c<s?"C":"D"}function zx(t,e){return t>e?"A":"B"}function Fx(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 Sc(t,e){let n=e?"O":"[";return De.ESC+n+t}function xc(t,e){t=Math.floor(t);let n="";for(let s=0;s<t;s++)n+=e;return n}var rA=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 yb(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 tp=50,oA=15,aA=50,lA=500,cA=" ",uA=new RegExp(cA,"g"),Vm=class extends Ft{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 yi,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new it),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new it),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new it),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new it),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 rA(this._bufferService),this._activeSelectionMode=0,this._register(vn(()=>{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(uA," ")).join(Ox?`\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())),vv&&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=yb(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=gv(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,-tp),tp),n/=tp,n/Math.abs(n)+Math.round(n*(oA-1)))}shouldForceSelection(e){return Md?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(),aA)}_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&&!(Md&&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<lA&&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=QL(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,k=0;if(u.charAt(h)===" "){for(;h>0&&u.charAt(h-1)===" ";)h--;for(;f<u.length&&u.charAt(f+1)===" ";)f++}else{let L=e[0],S=e[0];c.getWidth(L)===0&&(v++,L--),c.getWidth(S)===2&&(_++,S++);let T=c.getString(S).length;for(T>1&&(k+=T-1,f+=T-1);L>0&&h>0&&!this._isCharWordSeparator(c.loadCell(L-1,this._workCell));){c.loadCell(L-1,this._workCell);let E=this._workCell.getChars().length;this._workCell.getWidth()===0?(v++,L--):E>1&&(b+=E-1,h-=E-1),h--,L--}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&&(k+=E-1,f+=E-1),f++,S++}}f++;let R=h+g-v+b,C=Math.min(this._bufferService.cols,f-h+v+_-b-k);if(!(!n&&u.slice(h,f).trim()==="")){if(s&&R===0&&c.getCodePoint(0)!==32){let L=a.lines.get(e[1]-1);if(L&&c.isWrapped&&L.getCodePoint(this._bufferService.cols-1)!==32){let S=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(S){let T=this._bufferService.cols-S.start;R-=T,C+=T}}}if(i&&R+C===this._bufferService.cols&&c.getCodePoint(this._bufferService.cols-1)!==32){let L=a.lines.get(e[1]+1);if(L!=null&&L.isWrapped&&L.getCodePoint(0)!==32){let S=this._getWordAt([0,e[1]+1],!1,!1,!0);S&&(C+=S.length)}}return{start:R,length:C}}}_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=yb(s,this._bufferService.cols)}};Vm=Rn([lt(3,Is),lt(4,Go),lt(5,cv),lt(6,Ds),lt(7,Lr),lt(8,Rr)],Vm);var wb=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={}}},bb=class{constructor(){this._color=new wb,this._css=new wb}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()}},Hn=Object.freeze((()=>{let t=[xn.toColor("#2e3436"),xn.toColor("#cc0000"),xn.toColor("#4e9a06"),xn.toColor("#c4a000"),xn.toColor("#3465a4"),xn.toColor("#75507b"),xn.toColor("#06989a"),xn.toColor("#d3d7cf"),xn.toColor("#555753"),xn.toColor("#ef2929"),xn.toColor("#8ae234"),xn.toColor("#fce94f"),xn.toColor("#729fcf"),xn.toColor("#ad7fa8"),xn.toColor("#34e2e2"),xn.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:Bn.toCss(s,i,a),rgba:Bn.toRgba(s,i,a)})}for(let n=0;n<24;n++){let s=8+n*10;t.push({css:Bn.toCss(s,s,s),rgba:Bn.toRgba(s,s,s)})}return t})()),To=xn.toColor("#ffffff"),ac=xn.toColor("#000000"),Sb=xn.toColor("#ffffff"),xb=ac,zl={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},dA=To,Ym=class extends Ft{constructor(e){super(),this._optionsService=e,this._contrastCache=new bb,this._halfContrastCache=new bb,this._onChangeColors=this._register(new it),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:To,background:ac,cursor:Sb,cursorAccent:xb,selectionForeground:void 0,selectionBackgroundTransparent:zl,selectionBackgroundOpaque:fn.blend(ac,zl),selectionInactiveBackgroundTransparent:zl,selectionInactiveBackgroundOpaque:fn.blend(ac,zl),scrollbarSliderBackground:fn.opacity(To,.2),scrollbarSliderHoverBackground:fn.opacity(To,.4),scrollbarSliderActiveBackground:fn.opacity(To,.5),overviewRulerBorder:To,ansi:Hn.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=sn(e.foreground,To),n.background=sn(e.background,ac),n.cursor=fn.blend(n.background,sn(e.cursor,Sb)),n.cursorAccent=fn.blend(n.background,sn(e.cursorAccent,xb)),n.selectionBackgroundTransparent=sn(e.selectionBackground,zl),n.selectionBackgroundOpaque=fn.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=sn(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=fn.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?sn(e.selectionForeground,gb):void 0,n.selectionForeground===gb&&(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=sn(e.scrollbarSliderBackground,fn.opacity(n.foreground,.2)),n.scrollbarSliderHoverBackground=sn(e.scrollbarSliderHoverBackground,fn.opacity(n.foreground,.4)),n.scrollbarSliderActiveBackground=sn(e.scrollbarSliderActiveBackground,fn.opacity(n.foreground,.5)),n.overviewRulerBorder=sn(e.overviewRulerBorder,dA),n.ansi=Hn.slice(),n.ansi[0]=sn(e.black,Hn[0]),n.ansi[1]=sn(e.red,Hn[1]),n.ansi[2]=sn(e.green,Hn[2]),n.ansi[3]=sn(e.yellow,Hn[3]),n.ansi[4]=sn(e.blue,Hn[4]),n.ansi[5]=sn(e.magenta,Hn[5]),n.ansi[6]=sn(e.cyan,Hn[6]),n.ansi[7]=sn(e.white,Hn[7]),n.ansi[8]=sn(e.brightBlack,Hn[8]),n.ansi[9]=sn(e.brightRed,Hn[9]),n.ansi[10]=sn(e.brightGreen,Hn[10]),n.ansi[11]=sn(e.brightYellow,Hn[11]),n.ansi[12]=sn(e.brightBlue,Hn[12]),n.ansi[13]=sn(e.brightMagenta,Hn[13]),n.ansi[14]=sn(e.brightCyan,Hn[14]),n.ansi[15]=sn(e.brightWhite,Hn[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]=sn(e.extendedAnsi[i],Hn[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()}}};Ym=Rn([lt(0,Ds)],Ym);function sn(t,e){if(t!==void 0)try{return xn.toColor(t)}catch{}return e}var hA=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)}},fA=class{constructor(){this._services=new hA,this._services.set(lv,this)}setService(t,e){this._services.set(t,e)}getService(t){return this._services.get(t)}createInstance(t,...e){let n=oR(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)}},pA={trace:0,debug:1,info:2,warn:3,error:4,off:5},mA="xterm.js: ",Gm=class extends Ft{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=pA[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?"":mA)+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)}};Gm=Rn([lt(0,Ds)],Gm);var kb=class extends Ft{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new it),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new it),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new it),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}},$t=3,Dn=Object.freeze(new $c),Ju=0,np=2,lc=class Hx{constructor(e,n,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*$t);let i=n||yi.fromCharData([0,ax,1,0]);for(let a=0;a<e;++a)this.setCell(a,i);this.length=e}get(e){let n=this._data[e*$t+0],s=n&2097151;return[this._data[e*$t+1],n&2097152?this._combined[e]:s?no(s):"",n>>22,n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,n){this._data[e*$t+1]=n[0],n[1].length>1?(this._combined[e]=n[1],this._data[e*$t+0]=e|2097152|n[2]<<22):this._data[e*$t+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(e){return this._data[e*$t+0]>>22}hasWidth(e){return this._data[e*$t+0]&12582912}getFg(e){return this._data[e*$t+1]}getBg(e){return this._data[e*$t+2]}hasContent(e){return this._data[e*$t+0]&4194303}getCodePoint(e){let n=this._data[e*$t+0];return n&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n&2097151}isCombined(e){return this._data[e*$t+0]&2097152}getString(e){let n=this._data[e*$t+0];return n&2097152?this._combined[e]:n&2097151?no(n&2097151):""}isProtected(e){return this._data[e*$t+2]&536870912}loadCell(e,n){return Ju=e*$t,n.content=this._data[Ju+0],n.fg=this._data[Ju+1],n.bg=this._data[Ju+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*$t+0]=n.content,this._data[e*$t+1]=n.fg,this._data[e*$t+2]=n.bg}setCellFromCodepoint(e,n,s,i){i.bg&268435456&&(this._extendedAttrs[e]=i.extended),this._data[e*$t+0]=n|s<<22,this._data[e*$t+1]=i.fg,this._data[e*$t+2]=i.bg}addCodepointToCell(e,n,s){let i=this._data[e*$t+0];i&2097152?this._combined[e]+=no(n):i&2097151?(this._combined[e]=no(i&2097151)+no(n),i&=-2097152,i|=2097152):i=n|1<<22,s&&(i&=-12582913,i|=s<<22),this._data[e*$t+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 yi;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 yi;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*np<this._data.buffer.byteLength;let s=e*$t;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*np<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*np<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 Hx(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*$t+0]&4194303)return e+(this._data[e*$t+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*$t+0]&4194303||this._data[e*$t+2]&50331648)return e+(this._data[e*$t+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<$t;f++)this._data[(s+h)*$t+f]=c[(n+h)*$t+f];c[(n+h)*$t+2]&268435456&&(this._extendedAttrs[s+h]=e._extendedAttrs[n+h])}else for(let h=0;h<i;h++){for(let f=0;f<$t;f++)this._data[(s+h)*$t+f]=c[(n+h)*$t+f];c[(n+h)*$t+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*$t+0],u=c&2097151,h=c&2097152?this._combined[n]:u?no(u):io;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 gA(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,_=kc(g,v,e),b=1,k=0;for(;b<g.length;){let C=kc(g,b,e),L=C-k,S=n-_,T=Math.min(L,S);g[v].copyCellsFrom(g[b],k,_,T,!1),_+=T,_===n&&(v++,_=0),k+=T,k===C&&(b++,k=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 R=0;for(let C=g.length-1;C>0&&(C>v||g[C].getTrimmedLength()===0);C--)R++;R>0&&(c.push(u+g.length-R),c.push(R)),u+=g.length-1}return c}function vA(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 _A(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 yA(t,e,n){let s=[],i=t.map((h,f)=>kc(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=kc(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 kc(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 Ux=class Wx{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=Wx._nextId++,this._onDispose=this.register(new it),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),qo(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Ux._nextId=1;var wA=Ux,qn={},Po=qn.B;qn[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:"≥","{":"π","|":"≠","}":"£","~":"·"};qn.A={"#":"£"};qn.B=void 0;qn[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};qn.C=qn[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};qn.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};qn.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};qn.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};qn.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};qn.E=qn[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};qn.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};qn.H=qn[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};qn["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Cb=4294967295,Eb=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=Dn.clone(),this.savedCharset=Po,this.markers=[],this._nullCell=yi.fromCharData([0,ax,1,0]),this._whitespaceCell=yi.fromCharData([0,io,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Td,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new kb(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 Ld),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 Ld),this._whitespaceCell}getBlankLine(t,e){return new lc(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>Cb?Cb:e}fillViewportRows(t){if(this.lines.length===0){t===void 0&&(t=Dn);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 kb(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(t,e){let n=this.getNullCell(Dn),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 lc(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 lc(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=gA(this.lines,this._cols,t,this.ybase+this.y,this.getNullCell(Dn),n);if(s.length>0){let i=vA(this.lines,s);_A(this.lines,i.layout),this._reflowLargerAdjustViewport(t,e,i.countRemoved)}}_reflowLargerAdjustViewport(t,e,n){let s=this.getNullCell(Dn),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new lc(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(Dn),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 T=this.ybase+this.y;if(T>=c&&T<c+h.length)continue}let f=h[h.length-1].getTrimmedLength(),g=yA(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 T=0;T<v;T++){let E=this.getBlankLine(Dn,!0);b.push(E)}b.length>0&&(i.push({start:c+h.length+a,newLines:b}),a+=b.length),h.push(...b);let k=g.length-1,R=g[k];R===0&&(k--,R=g[k]);let C=h.length-v-1,L=f;for(;C>=0;){let T=Math.min(L,R);if(h[k]===void 0)break;if(h[k].copyCellsFrom(h[C],L-T,R-T,T,!0),R-=T,R===0&&(k--,R=g[k]),L-=T,L===0){C--;let E=Math.max(C,0);L=kc(h,E,this._cols)}}for(let T=0;T<h.length;T++)g[T]<t&&h[T].setCell(g[T],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 R=0;R<this.lines.length;R++)u.push(this.lines.get(R));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 R=Math.min(this.lines.maxLength-1,h+a-1);R>=0;R--)if(v&&v.start>f+_){for(let C=v.newLines.length-1;C>=0;C--)this.lines.set(R--,v.newLines[C]);R++,c.push({index:f+1,amount:v.newLines.length}),_+=v.newLines.length,v=i[++g]}else this.lines.set(R,u[f--]);let b=0;for(let R=c.length-1;R>=0;R--)c[R].index+=b,this.lines.onInsertEmitter.fire(c[R]),b+=c[R].amount;let k=Math.max(0,h+a-this.lines.maxLength);k>0&&this.lines.onTrimEmitter.fire(k)}}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 wA(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)}},bA=class extends Ft{constructor(e,n){super(),this._optionsService=e,this._bufferService=n,this._onBufferActivate=this._register(new it),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 Eb(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Eb(!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)}},qx=2,Kx=1,Xm=class extends Ft{constructor(t){super(),this.isUserScrolling=!1,this._onResize=this._register(new it),this.onResize=this._onResize.event,this._onScroll=this._register(new it),this.onScroll=this._onScroll.event,this.cols=Math.max(t.rawOptions.cols||0,qx),this.rows=Math.max(t.rawOptions.rows||0,Kx),this.buffers=this._register(new bA(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))}};Xm=Rn([lt(0,Ds)],Xm);var Ea={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:Md,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},SA=["normal","bold","100","200","300","400","500","600","700","800","900"],xA=class extends Ft{constructor(e){super(),this._onOptionChange=this._register(new it),this.onOptionChange=this._onOptionChange.event;let n={...Ea};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(vn(()=>{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 Ea))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},n=(s,i)=>{if(!(s in Ea))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=Ea[e]),!kA(n))throw new Error(`"${n}" is not a valid value for ${e}`);break;case"wordSeparator":n||(n=Ea[e]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=SA.includes(n)?n:Ea[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 kA(t){return t==="block"||t==="underline"||t==="bar"}function cc(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]&&cc(t[s],e-1);return n}var Nb=Object.freeze({insertMode:!1}),Rb=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Jm=class extends Ft{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 it),this.onData=this._onData.event,this._onUserInput=this._register(new it),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new it),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new it),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=cc(Nb),this.decPrivateModes=cc(Rb)}reset(){this.modes=cc(Nb),this.decPrivateModes=cc(Rb)}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))}};Jm=Rn([lt(0,Is),lt(1,hx),lt(2,Ds)],Jm);var Lb={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 sp(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 ip=String.fromCharCode,Ab={DEFAULT:t=>{let e=[sp(t,!1)+32,t.col+32,t.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${ip(e[0])}${ip(e[1])}${ip(e[2])}`},SGR:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${sp(t,!0)};${t.col};${t.row}${e}`},SGR_PIXELS:t=>{let e=t.action===0&&t.button!==4?"m":"M";return`\x1B[<${sp(t,!0)};${t.x};${t.y}${e}`}},Qm=class extends Ft{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 it),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Lb))this.addProtocol(s,Lb[s]);for(let s of Object.keys(Ab))this.addEncoding(s,Ab[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)}};Qm=Rn([lt(0,Is),lt(1,Go),lt(2,Ds)],Qm);var rp=[[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]],CA=[[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]],Un;function EA(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 NA=class{constructor(){if(this.version="6",!Un){Un=new Uint8Array(65536),Un.fill(1),Un[0]=0,Un.fill(0,1,32),Un.fill(0,127,160),Un.fill(2,4352,4448),Un[9001]=2,Un[9002]=2,Un.fill(2,11904,42192),Un[12351]=1,Un.fill(2,44032,55204),Un.fill(2,63744,64256),Un.fill(2,65040,65050),Un.fill(2,65072,65136),Un.fill(2,65280,65377),Un.fill(2,65504,65511);for(let e=0;e<rp.length;++e)Un.fill(0,rp[e][0],rp[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Un[e]:EA(e,CA)?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=Do.extractWidth(n);a===0?i=!1:a>s&&(s=a)}return Do.createPropertyValue(0,s,i)}},Do=class vd{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new it,this.onChange=this._onChange.event;let e=new NA;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=vd.extractWidth(u);vd.extractShouldJoin(u)&&(h-=vd.extractWidth(s)),n+=h,s=u}return n}charProperties(e,n){return this._activeProvider.charProperties(e,n)}},RA=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 jb(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 Fl=2147483647,LA=256,Vx=class Zm{constructor(e=32,n=32){if(this.maxLength=e,this.maxSubParamsLength=n,n>LA)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 Zm;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 Zm(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>Fl?Fl: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>Fl?Fl: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,Fl):e}},Hl=[],AA=class{constructor(){this._state=0,this._active=Hl,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=Hl}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=Hl,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Hl,!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",sh(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=Hl,this._id=-1,this._state=0}}},ni=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,n,s){this._hitLimit||(this._data+=sh(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}},Ul=[],jA=class{constructor(){this._handlers=Object.create(null),this._active=Ul,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ul}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=Ul,this._ident=0}hook(e,n){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Ul,!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",sh(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=Ul,this._ident=0}},uc=new Vx;uc.addParam(0);var Mb=class{constructor(t){this._handler=t,this._data="",this._params=uc,this._hitLimit=!1}hook(t){this._params=t.length>1||t.params[0]?t.clone():uc,this._data="",this._hitLimit=!1}put(t,e,n){this._hitLimit||(this._data+=sh(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=uc,this._data="",this._hitLimit=!1,n));return this._params=uc,this._data="",this._hitLimit=!1,e}},MA=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}},mi=160,TA=(function(){let t=new MA(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(mi,0,2,0),t.add(mi,8,5,8),t.add(mi,6,0,6),t.add(mi,11,0,11),t.add(mi,13,13,13),t})(),PA=class extends Ft{constructor(e=TA){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 Vx,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(vn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new AA),this._dcsParser=this._register(new jA),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:mi)],a>>4){case 2:for(let b=h+1;;++b){if(b>=n||(i=e[b])<32||i>126&&i<mi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<mi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<mi){this._printHandler(e,h,b),h=b-1;break}if(++b>=n||(i=e[b])<32||i>126&&i<mi){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<mi){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<mi){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}}},IA=/^([\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})$/,DA=/^[\da-f]+$/;function Tb(t){if(!t)return;let e=t.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let n=IA.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),DA.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 op(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 OA(t,e=16){let[n,s,i]=t;return`rgb:${op(n,e)}/${op(s,e)}/${op(i,e)}`}var BA={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Yr=131072,Pb=10;function Ib(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 Db=5e3,Ob=0,$A=class extends Ft{constructor(t,e,n,s,i,a,c,u,h=new PA){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 iR,this._utf8Decoder=new rR,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Dn.clone(),this._eraseAttrDataInternal=Dn.clone(),this._onRequestBell=this._register(new it),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new it),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new it),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new it),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new it),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new it),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new it),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new it),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new it),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new it),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new it),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new it),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new it),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 eg(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(De.BEL,()=>this.bell()),this._parser.setExecuteHandler(De.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(De.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(De.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(De.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(De.BS,()=>this.backspace()),this._parser.setExecuteHandler(De.HT,()=>this.tab()),this._parser.setExecuteHandler(De.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(De.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(md.IND,()=>this.index()),this._parser.setExecuteHandler(md.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(md.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ni(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new ni(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new ni(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new ni(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new ni(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new ni(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new ni(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new ni(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new ni(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new ni(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new ni(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new ni(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in qn)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 Mb((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"),Db))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${Db} 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>Yr&&(a=this._parseStack.position+Yr)}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<Yr&&(this._parseBuffer=new Uint32Array(Math.min(t.length,Yr))),c||this._dirtyRowTracker.clearRange(),t.length>Yr)for(let f=a;f<t.length;f+=Yr){let g=f+Yr<t.length?f+Yr: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 L=a[String.fromCharCode(s)];L&&(s=L.charCodeAt(0))}let k=this._unicodeService.charProperties(s,_);i=Do.extractWidth(k);let R=Do.extractShouldJoin(k),C=R?Do.extractWidth(_):0;if(_=k,c&&this._onA11yChar.fire(no(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-C>u){if(h){let L=v,S=this._activeBuffer.x-C;for(this._activeBuffer.x=C,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),C>0&&v instanceof lc&&v.copyCellsFrom(L,S,0,C,!1);S<u;)L.setCellFromCodepoint(S++,0,1,g)}else if(this._activeBuffer.x=u-1,i===2)continue}if(R&&this._activeBuffer.x){let L=v.getWidth(this._activeBuffer.x-1)?1:2;v.addCodepointToCell(this._activeBuffer.x-L,s,i);for(let S=i-C;--S>=0;)v.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(f&&(v.insertCells(this._activeBuffer.x,i-C,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=>Ib(n.params[0],this._optionsService.rawOptions.windowOptions)?e(n):!0):this._parser.registerCsiHandler(t,e)}registerDcsHandler(t,e){return this._parser.registerDcsHandler(t,new Mb(e))}registerEscHandler(t,e){return this._parser.registerEscHandler(t,e)}registerOscHandler(t,e){return this._parser.registerOscHandler(t,new ni(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(Dn));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=Do.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(De.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(De.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(t){return t.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(De.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(De.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(t.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(De.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,Po),this._charsetService.setgCharset(1,Po),this._charsetService.setgCharset(2,Po),this._charsetService.setgCharset(3,Po);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){(R=>(R[R.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",R[R.SET=1]="SET",R[R.RESET=2]="RESET",R[R.PERMANENTLY_SET=3]="PERMANENTLY_SET",R[R.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,_=(R,C)=>(c.triggerDataEvent(`${De.ESC}[${e?"":"?"}${R};${C}$y`),!0),b=R=>R?1:2,k=t.params[0];return e?k===2?_(k,4):k===4?_(k,b(c.modes.insertMode)):k===12?_(k,3):k===20?_(k,b(v.convertEol)):_(k,0):k===1?_(k,b(s.applicationCursorKeys)):k===3?_(k,v.windowOptions.setWinLines?h===80?2:h===132?1:0:0):k===6?_(k,b(s.origin)):k===7?_(k,b(s.wraparound)):k===8?_(k,3):k===9?_(k,b(i==="X10")):k===12?_(k,b(v.cursorBlink)):k===25?_(k,b(!c.isCursorHidden)):k===45?_(k,b(s.reverseWraparound)):k===66?_(k,b(s.applicationKeypad)):k===67?_(k,4):k===1e3?_(k,b(i==="VT200")):k===1002?_(k,b(i==="DRAG")):k===1003?_(k,b(i==="ANY")):k===1004?_(k,b(s.sendFocus)):k===1005?_(k,4):k===1006?_(k,b(a==="SGR")):k===1015?_(k,4):k===1016?_(k,b(a==="SGR_PIXELS")):k===1048?_(k,1):k===47||k===1047||k===1049?_(k,b(f===g)):k===2004?_(k,b(s.bracketedPasteMode)):k===2026?_(k,b(s.synchronizedOutput)):_(k,0)}_updateAttrColor(t,e,n,s,i){return e===2?(t|=50331648,t&=-16777216,t|=$c.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=Dn.fg,t.bg=Dn.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|=Dn.fg&16777215):n===49?(s.bg&=-67108864,s.bg|=Dn.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|=Dn.fg&16777215,s.bg&=-67108864,s.bg|=Dn.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(t){switch(t.params[0]){case 5:this._coreService.triggerDataEvent(`${De.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${De.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(`${De.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=Dn.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(!Ib(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(`${De.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Pb&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Pb&&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(Bb(a))if(i==="?")e.push({type:0,index:a});else{let c=Tb(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=Tb(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]);Bb(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,Po),!0}selectCharset(t){return t.length!==2?(this.selectDefaultCharset(),!0):(t[0]==="/"||this._charsetService.setgCharset(BA[t[0]],qn[t[1]]||Po),!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=Dn.clone(),this._eraseAttrDataInternal=Dn.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 yi;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(`${De.ESC}${c}${De.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)}},eg=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&&(Ob=t,t=e,e=Ob),t<this.start&&(this.start=t),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};eg=Rn([lt(0,Is)],eg);function Bb(t){return 0<=t&&t<256}var zA=5e7,$b=12,FA=50,HA=class extends Ft{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 it),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>zA)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>=$b?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>=$b)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>FA&&(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()}},tg=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)))}};tg=Rn([lt(0,Is)],tg);var zb=!1,UA=class extends Ft{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new qa),this._onBinary=this._register(new it),this.onBinary=this._onBinary.event,this._onData=this._register(new it),this.onData=this._onData.event,this._onLineFeed=this._register(new it),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new it),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new it),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new it),this._instantiationService=new fA,this.optionsService=this._register(new xA(e)),this._instantiationService.setService(Ds,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Xm)),this._instantiationService.setService(Is,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Gm)),this._instantiationService.setService(hx,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Jm)),this._instantiationService.setService(Go,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Qm)),this._instantiationService.setService(dx,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Do)),this._instantiationService.setService(cR,this.unicodeService),this._charsetService=this._instantiationService.createInstance(RA),this._instantiationService.setService(lR,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(tg),this._instantiationService.setService(fx,this._oscLinkService),this._inputHandler=this._register(new $A(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ms.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ms.forward(this._bufferService.onResize,this._onResize)),this._register(ms.forward(this.coreService.onData,this._onData)),this._register(ms.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 HA((n,s)=>this._inputHandler.parse(n,s))),this._register(ms.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new it),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&&!zb&&(this._logService.warn("writeSync is unreliable and will be removed soon."),zb=!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,qx),n=Math.max(n,Kx),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(jb.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(jb(this._bufferService),!1))),this._windowsWrappingHeuristics.value=vn(()=>{for(let n of e)n.dispose()})}}},WA={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 qA(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=De.ESC+"OA":i.key=De.ESC+"[A":t.key==="UIKeyInputLeftArrow"?e?i.key=De.ESC+"OD":i.key=De.ESC+"[D":t.key==="UIKeyInputRightArrow"?e?i.key=De.ESC+"OC":i.key=De.ESC+"[C":t.key==="UIKeyInputDownArrow"&&(e?i.key=De.ESC+"OB":i.key=De.ESC+"[B");break;case 8:i.key=t.ctrlKey?"\b":De.DEL,t.altKey&&(i.key=De.ESC+i.key);break;case 9:if(t.shiftKey){i.key=De.ESC+"[Z";break}i.key=De.HT,i.cancel=!0;break;case 13:i.key=t.altKey?De.ESC+De.CR:De.CR,i.cancel=!0;break;case 27:i.key=De.ESC,t.altKey&&(i.key=De.ESC+De.ESC),i.cancel=!0;break;case 37:if(t.metaKey)break;a?i.key=De.ESC+"[1;"+(a+1)+"D":e?i.key=De.ESC+"OD":i.key=De.ESC+"[D";break;case 39:if(t.metaKey)break;a?i.key=De.ESC+"[1;"+(a+1)+"C":e?i.key=De.ESC+"OC":i.key=De.ESC+"[C";break;case 38:if(t.metaKey)break;a?i.key=De.ESC+"[1;"+(a+1)+"A":e?i.key=De.ESC+"OA":i.key=De.ESC+"[A";break;case 40:if(t.metaKey)break;a?i.key=De.ESC+"[1;"+(a+1)+"B":e?i.key=De.ESC+"OB":i.key=De.ESC+"[B";break;case 45:!t.shiftKey&&!t.ctrlKey&&(i.key=De.ESC+"[2~");break;case 46:a?i.key=De.ESC+"[3;"+(a+1)+"~":i.key=De.ESC+"[3~";break;case 36:a?i.key=De.ESC+"[1;"+(a+1)+"H":e?i.key=De.ESC+"OH":i.key=De.ESC+"[H";break;case 35:a?i.key=De.ESC+"[1;"+(a+1)+"F":e?i.key=De.ESC+"OF":i.key=De.ESC+"[F";break;case 33:t.shiftKey?i.type=2:t.ctrlKey?i.key=De.ESC+"[5;"+(a+1)+"~":i.key=De.ESC+"[5~";break;case 34:t.shiftKey?i.type=3:t.ctrlKey?i.key=De.ESC+"[6;"+(a+1)+"~":i.key=De.ESC+"[6~";break;case 112:a?i.key=De.ESC+"[1;"+(a+1)+"P":i.key=De.ESC+"OP";break;case 113:a?i.key=De.ESC+"[1;"+(a+1)+"Q":i.key=De.ESC+"OQ";break;case 114:a?i.key=De.ESC+"[1;"+(a+1)+"R":i.key=De.ESC+"OR";break;case 115:a?i.key=De.ESC+"[1;"+(a+1)+"S":i.key=De.ESC+"OS";break;case 116:a?i.key=De.ESC+"[15;"+(a+1)+"~":i.key=De.ESC+"[15~";break;case 117:a?i.key=De.ESC+"[17;"+(a+1)+"~":i.key=De.ESC+"[17~";break;case 118:a?i.key=De.ESC+"[18;"+(a+1)+"~":i.key=De.ESC+"[18~";break;case 119:a?i.key=De.ESC+"[19;"+(a+1)+"~":i.key=De.ESC+"[19~";break;case 120:a?i.key=De.ESC+"[20;"+(a+1)+"~":i.key=De.ESC+"[20~";break;case 121:a?i.key=De.ESC+"[21;"+(a+1)+"~":i.key=De.ESC+"[21~";break;case 122:a?i.key=De.ESC+"[23;"+(a+1)+"~":i.key=De.ESC+"[23~";break;case 123:a?i.key=De.ESC+"[24;"+(a+1)+"~":i.key=De.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=De.NUL:t.keyCode>=51&&t.keyCode<=55?i.key=String.fromCharCode(t.keyCode-51+27):t.keyCode===56?i.key=De.DEL:t.keyCode===219?i.key=De.ESC:t.keyCode===220?i.key=De.FS:t.keyCode===221&&(i.key=De.GS);else if((!n||s)&&t.altKey&&!t.metaKey){let u=(c=WA[t.keyCode])==null?void 0:c[t.shiftKey?1:0];if(u)i.key=De.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=De.ESC+f}else if(t.keyCode===32)i.key=De.ESC+(t.ctrlKey?De.NUL:" ");else if(t.key==="Dead"&&t.code.startsWith("Key")){let h=t.code.slice(3,4);t.shiftKey||(h=h.toLowerCase()),i.key=De.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=De.US),t.key==="@"&&(i.key=De.NUL));break}return i}var jn=0,KA=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Td,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Td,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||(jn=this._search(n),jn===-1)||this._getKey(this._array[jn])!==n)return!1;do if(this._array[jn]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(jn),!0;while(++jn<this._array.length&&this._getKey(this._array[jn])===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&&(jn=this._search(e),!(jn<0||jn>=this._array.length)&&this._getKey(this._array[jn])===e))do yield this._array[jn];while(++jn<this._array.length&&this._getKey(this._array[jn])===e)}forEachByKey(e,n){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(jn=this._search(e),!(jn<0||jn>=this._array.length)&&this._getKey(this._array[jn])===e))do n(this._array[jn]);while(++jn<this._array.length&&this._getKey(this._array[jn])===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}},ap=0,Fb=0,VA=class extends Ft{constructor(){super(),this._decorations=new KA(t=>t==null?void 0:t.marker.line),this._onDecorationRegistered=this._register(new it),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new it),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(vn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(t){if(t.marker.isDisposed)return;let e=new YA(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=>{ap=i.options.x??0,Fb=ap+(i.options.width??1),t>=ap&&t<Fb&&(!n||(i.options.layer??"bottom")===n)&&s(i)})}},YA=class extends ao{constructor(t){super(),this.options=t,this.onRenderEmitter=this.add(new it),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new it),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=xn.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=xn.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},GA=1e3,XA=class{constructor(e,n=GA){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)}},Hb=20,Pd=class extends Ft{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 XA(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(jt(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(vn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(t){for(let e=0;e<t;e++)this._handleChar(" ")}_handleChar(t){this._liveRegionLineCount<Hb+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==t&&(this._charsToAnnounce+=t):this._charsToAnnounce+=t,t===`
|
|
65
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Hb+1&&(this._liveRegion.textContent+=bm.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})`}};Pd=Rn([lt(1,lv),lt(2,Rr),lt(3,Lr)],Pd);var ng=class extends Ft{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 it),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new it),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(vn(()=>{var a;qo(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(jt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(jt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(jt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(jt(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&&JA(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,qo(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}}};ng=Rn([lt(1,cv),lt(2,Lr),lt(3,Is),lt(4,mx)],ng);function JA(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 QA=class extends UA{constructor(e={}){super(e),this._linkifier=this._register(new qa),this.browser=Px,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new qa),this._onCursorMove=this._register(new it),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new it),this.onKey=this._onKey.event,this._onRender=this._register(new it),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new it),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new it),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new it),this.onBell=this._onBell.event,this._onFocus=this._register(new it),this._onBlur=this._register(new it),this._onA11yCharEmitter=this._register(new it),this._onA11yTabEmitter=this._register(new it),this._onWillOpen=this._register(new it),this._setup(),this._decorationService=this._instantiationService.createInstance(VA),this._instantiationService.setService(zc,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(FL),this._instantiationService.setService(mx,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(xm)),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(ms.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ms.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ms.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ms.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(n=>this._afterResize(n.cols,n.rows))),this._register(vn(()=>{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(`${De.ESC}]${i};${OA(a)}${Mx.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(c=>c.ansi[n.index]=Bn.toColor(...n.color));else{let c=s;this._themeService.modifyColors(u=>u[c]=Bn.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(Pd,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(De.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(De.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(jt(this.element,"copy",n=>{this.hasSelection()&&nR(n,this._selectionService)}));let e=n=>sR(n,this.textarea,this.coreService,this.optionsService);this._register(jt(this.textarea,"paste",e)),this._register(jt(this.element,"paste",e)),Ix?this._register(jt(this.element,"mousedown",n=>{n.button===2&&Qw(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(jt(this.element,"contextmenu",n=>{Qw(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),vv&&this._register(jt(this.element,"auxclick",n=>{n.button===1&&ox(n,this.textarea,this.screenElement)}))}_bindKeys(){this._register(jt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(jt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(jt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(jt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(jt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(jt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(jt(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(jt(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",wm.get()),Bx||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($L,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Rr,this._coreBrowserService),this._register(jt(this.textarea,"focus",c=>this._handleTextAreaFocus(c))),this._register(jt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Wm,this._document,this._helperContainer),this._instantiationService.setService(ih,this._charSizeService),this._themeService=this._instantiationService.createInstance(Ym),this._instantiationService.setService(Qa,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(jd),this._instantiationService.setService(px,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Km,this.rows,this.screenElement)),this._instantiationService.setService(Lr,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(Fm,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(qm),this._instantiationService.setService(cv,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(ng,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($m,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(Vm,this.element,this.screenElement,i)),this._instantiationService.setService(dR,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(ms.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var c;this._selectionService.refresh(),(c=this._viewport)==null||c.queueSync()})),this._register(this._instantiationService.createInstance(zm,this.screenElement)),this._register(jt(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(Pd,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",c=>this._handleScreenReaderModeOptionChange(c))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ad,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",c=>{!this._overviewRulerRenderer&&c&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ad,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Um,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,k;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 R=c.deltaY;if(R===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,(k=e._coreBrowserService)==null?void 0:k.dpr)===0)return!1;f=R<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(jt(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(jt(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 _=De.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){rx(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=qA(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===De.ETX||s.key===De.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)&&(ZA(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(Dn));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(De.ESC+"[I"):this.coreService.triggerDataEvent(De.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(`${De.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(`${De.ESC}[6;${a};${i}t`);break}}cancel(e,n){if(!(!this.options.cancelEvents&&!n))return e.preventDefault(),e.stopPropagation(),!1}};function ZA(t){return t.keyCode===16||t.keyCode===17||t.keyCode===18}var ej=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)}},tj=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 yi)}translateToString(e,n,s){return this._line.translateToString(e,n,s)}},Ub=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 tj(e)}getNullCell(){return new yi}},nj=class extends Ft{constructor(t){super(),this._core=t,this._onBufferChange=this._register(new it),this.onBufferChange=this._onBufferChange.event,this._normal=new Ub(this._core.buffers.normal,"normal"),this._alternate=new Ub(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)}},sj=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)}},ij=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}},rj=["cols","rows"],Hi=0,oj=class extends Ft{constructor(t){super(),this._core=this._register(new QA(t)),this._addonManager=this._register(new ej),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(rj.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 sj(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new ij(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 nj(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 wm.get()},set promptLabel(t){wm.set(t)},get tooMuchOutput(){return bm.get()},set tooMuchOutput(t){bm.set(t)}}}_verifyIntegers(...t){for(Hi of t)if(Hi===1/0||isNaN(Hi)||Hi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(Hi of t)if(Hi&&(Hi===1/0||isNaN(Hi)||Hi%1!==0||Hi<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 aj=2,lj=1,cj=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(aj,Math.floor(g/t.css.cell.width)),rows:Math.max(lj,Math.floor(f/t.css.cell.height))}}};const uj=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]]),dj=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]]),hj="nc-15.1";function Wb(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 fj(t,e,n){return(t&16777215)<<3|(e&3)<<1|(n?1:0)}function qb(t){const e=Number(t);return!Number.isFinite(e)||e<0||e<32||e>=127&&e<160||Wb(dj,e)?0:Wb(uj,e)?2:1}function pj(){return{version:hj,wcwidth:qb,charProperties(t,e){let n=qb(t),s=n===0&&e!==0;if(s){const i=e>>1&3;i===0?s=!1:i>n&&(n=i)}return fj(t,n,s)}}}function mj(t){try{const e=t&&t.unicode;if(!e||typeof e.register!="function")return null;const n=pj();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 gj=(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},vj=(t,e)=>(n,s)=>e(n,s,t),_j=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(t){setTimeout(()=>{throw t.stack?Kb.isErrorNoTelemetry(t)?new Kb(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)}},yj=new _j;function lp(t){wj(t)||yj.onUnexpectedError(t)}var sg="Canceled";function wj(t){return t instanceof bj?!0:t instanceof Error&&t.name===sg&&t.message===sg}var bj=class extends Error{constructor(){super(sg),this.name=this.message}},Kb=class ig extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof ig)return e;let n=new ig;return n.message=e.message,n.stack=e.stack,n}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Sj;(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})(Sj||(Sj={}));function xj(t,e){let n=this,s=!1,i;return function(){return s||(s=!0,e||(i=t.apply(n,arguments))),i}}var Yx;(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 H=E.length-1;H>=0;H--)yield E[H]}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,H){let F=0;for(let X of E)if(H(X,F++))return!0;return!1}t.some=g;function v(E,H){for(let F of E)if(H(F))return F}t.find=v;function*_(E,H){for(let F of E)H(F)&&(yield F)}t.filter=_;function*b(E,H){let F=0;for(let X of E)yield H(X,F++)}t.map=b;function*k(E,H){let F=0;for(let X of E)yield*H(X,F++)}t.flatMap=k;function*R(...E){for(let H of E)yield*H}t.concat=R;function C(E,H,F){let X=F;for(let V of E)X=H(X,V);return X}t.reduce=C;function*L(E,H,F=E.length){for(H<0&&(H+=E.length),F<0?F+=E.length:F>E.length&&(F=E.length);H<F;H++)yield E[H]}t.slice=L;function S(E,H=Number.POSITIVE_INFINITY){let F=[];if(H===0)return[F,E];let X=E[Symbol.iterator]();for(let V=0;V<H;V++){let G=X.next();if(G.done)return[F,t.empty()];F.push(G.value)}return[F,{[Symbol.iterator](){return X}}]}t.consume=S;async function T(E){let H=[];for await(let F of E)H.push(F);return Promise.resolve(H)}t.asyncToArray=T})(Yx||(Yx={}));function Gx(t){if(Yx.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 Xx(...t){return Rs(()=>Gx(t))}function Rs(t){return{dispose:xj(()=>{t()})}}var Jx=class Qx{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{Gx(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?Qx.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)}};Jx.DISABLE_DISPOSED_WARNING=!1;var Fa=Jx,Pi=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)}};Pi.None=Object.freeze({dispose(){}});var Wl=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}},_v=typeof process<"u"&&"title"in process,ah=_v?"node":navigator.userAgent,kj=_v?"node":navigator.platform,Cj=ah.includes("Firefox"),Ej=ah.includes("Edge"),Zx=/^((?!chrome|android).)*safari/i.test(ah);function Nj(){if(!Zx)return 0;let t=ah.match(/Version\/(\d+)/);return t===null||t.length<2?0:parseInt(t[1])}kj.indexOf("Linux")>=0;var Rj="",is=0,rs=0,os=0,Nn=0,fi={css:"#00000000",rgba:0},Ps;(t=>{function e(i,a,c,u){return u!==void 0?`#${Ao(i)}${Ao(a)}${Ao(c)}${Ao(u)}`:`#${Ao(i)}${Ao(a)}${Ao(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})(Ps||(Ps={}));var dc;(t=>{function e(h,f){if(Nn=(f.rgba&255)/255,Nn===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,k=h.rgba>>16&255,R=h.rgba>>8&255;is=b+Math.round((g-b)*Nn),rs=k+Math.round((v-k)*Nn),os=R+Math.round((_-R)*Nn);let C=Ps.toCss(is,rs,os),L=Ps.toRgba(is,rs,os);return{css:C,rgba:L}}t.blend=e;function n(h){return(h.rgba&255)===255}t.isOpaque=n;function s(h,f,g){let v=Fo.ensureContrastRatio(h.rgba,f.rgba,g);if(v)return Ps.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]=Fo.toChannels(f),{css:Ps.toCss(is,rs,os),rgba:f}}t.opaque=i;function a(h,f){return Nn=Math.round(f*255),[is,rs,os]=Fo.toChannels(h.rgba),{css:Ps.toCss(is,rs,os,Nn),rgba:Ps.toRgba(is,rs,os,Nn)}}t.opacity=a;function c(h,f){return Nn=h.rgba&255,a(h,Nn*f/255)}t.multiplyOpacity=c;function u(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}t.toColorRGB=u})(dc||(dc={}));var Lj;(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),Ps.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),Nn=parseInt(i.slice(4,5).repeat(2),16),Ps.toColor(is,rs,os,Nn);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]),Nn=Math.round((a[5]===void 0?1:parseFloat(a[5]))*255),Ps.toColor(is,rs,os,Nn);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,Nn]=e.getImageData(0,0,1,1).data,Nn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ps.toRgba(is,rs,os,Nn),css:i}}t.toColor=s})(Lj||(Lj={}));var Ts;(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})(Ts||(Ts={}));var Fo;(t=>{function e(c,u){if(Nn=(u&255)/255,Nn===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)*Nn),rs=_+Math.round((f-_)*Nn),os=b+Math.round((g-b)*Nn),Ps.toRgba(is,rs,os)}t.blend=e;function n(c,u,h){let f=Ts.relativeLuminance(c>>8),g=Ts.relativeLuminance(u>>8);if(_r(f,g)<h){if(g<f){let b=s(c,u,h),k=_r(f,Ts.relativeLuminance(b>>8));if(k<h){let R=i(c,u,h),C=_r(f,Ts.relativeLuminance(R>>8));return k>C?b:R}return b}let v=i(c,u,h),_=_r(f,Ts.relativeLuminance(v>>8));if(_<h){let b=s(c,u,h),k=_r(f,Ts.relativeLuminance(b>>8));return _>k?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,k=u>>8&255,R=_r(Ts.relativeLuminance2(_,b,k),Ts.relativeLuminance2(f,g,v));for(;R<h&&(_>0||b>0||k>0);)_-=Math.max(0,Math.ceil(_*.1)),b-=Math.max(0,Math.ceil(b*.1)),k-=Math.max(0,Math.ceil(k*.1)),R=_r(Ts.relativeLuminance2(_,b,k),Ts.relativeLuminance2(f,g,v));return(_<<24|b<<16|k<<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,k=u>>8&255,R=_r(Ts.relativeLuminance2(_,b,k),Ts.relativeLuminance2(f,g,v));for(;R<h&&(_<255||b<255||k<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),R=_r(Ts.relativeLuminance2(_,b,k),Ts.relativeLuminance2(f,g,v));return(_<<24|b<<16|k<<8|255)>>>0}t.increaseLuminance=i;function a(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}t.toChannels=a})(Fo||(Fo={}));function Ao(t){let e=t.toString(16);return e.length<2?"0"+e:e}function _r(t,e){return t<e?(e+.05)/(t+.05):(t+.05)/(e+.05)}function On(t){if(!t)throw new Error("value must not be falsy");return t}function yv(t){return 57508<=t&&t<=57558}function Aj(t){return 57520<=t&&t<=57527}function jj(t){return 57344<=t&&t<=63743}function Mj(t){return 9472<=t&&t<=9631}function Tj(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 Pj(t,e,n,s){return e===1&&n>Math.ceil(s*1.5)&&t!==void 0&&t>255&&!Tj(t)&&!yv(t)&&!jj(t)}function ek(t){return yv(t)||Mj(t)}function Ij(){return{css:{canvas:Qu(),cell:Qu()},device:{canvas:Qu(),cell:Qu(),char:{width:0,height:0,left:0,top:0}}}}function Qu(){return{width:0,height:0}}function Dj(t,e,n=0){return(t-(Math.round(e)*2-n))%(Math.round(e)*2)}var ds=0,Qn=0,Ui=!1,yr=!1,Zu=!1,qs,cp=0,Oj=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,ds=0,yr=!1,Ui=!1,Zu=!1,qs=this._themeService.colors,cp=0,t.getCode()!==0&&t.extended.underlineStyle===4){let i=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));cp=e*s%(Math.round(i)*2)}if(this._decorationService.forEachDecorationAtCell(e,n,"bottom",i=>{i.backgroundColorRGB&&(Qn=i.backgroundColorRGB.rgba>>8&16777215,yr=!0),i.foregroundColorRGB&&(ds=i.foregroundColorRGB.rgba>>8&16777215,Ui=!0)}),Zu=this._selectionRenderModel.isCellSelected(this._terminal,e,n),Zu){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=Fo.blend(Qn,(this._coreBrowserService.isFocused?qs.selectionBackgroundOpaque:qs.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else Qn=(this._coreBrowserService.isFocused?qs.selectionBackgroundOpaque:qs.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(yr=!0,qs.selectionForeground&&(ds=qs.selectionForeground.rgba>>8&16777215,Ui=!0),ek(t.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)ds=(this._coreBrowserService.isFocused?qs.selectionBackgroundOpaque:qs.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:ds=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ds=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:ds=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ds=(this.result.fg&16777215)<<8|255;break;case 0:default:ds=this._themeService.colors.foreground.rgba}ds=Fo.blend(ds,(this._coreBrowserService.isFocused?qs.selectionBackgroundOpaque:qs.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Ui=!0}}this._decorationService.forEachDecorationAtCell(e,n,"top",i=>{i.backgroundColorRGB&&(Qn=i.backgroundColorRGB.rgba>>8&16777215,yr=!0),i.foregroundColorRGB&&(ds=i.foregroundColorRGB.rgba>>8&16777215,Ui=!0)}),yr&&(Zu?Qn=t.bg&-16777216&-134217729|Qn|50331648:Qn=t.bg&-16777216|Qn|50331648),Ui&&(ds=t.fg&-16777216&-67108865|ds|50331648),this.result.fg&67108864&&(yr&&!Ui&&((this.result.bg&50331648)===0?ds=this.result.fg&-134217728|qs.background.rgba>>8&16777215&16777215|50331648:ds=this.result.fg&-134217728|this.result.bg&67108863,Ui=!0),!yr&&Ui&&((this.result.fg&50331648)===0?Qn=this.result.bg&-67108864|qs.foreground.rgba>>8&16777215&16777215|50331648:Qn=this.result.bg&-67108864|this.result.fg&67108863,yr=!0)),qs=void 0,this.result.bg=yr?Qn:this.result.bg,this.result.fg=Ui?ds:this.result.fg,this.result.ext&=536870911,this.result.ext|=cp<<29&3758096384}},Bj=.5,tk=Cj||Ej?"bottom":"ideographic",$j={"▀":[{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}]},zj={"░":[[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]]},Fj={"─":{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`}},Cc={"":{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}};Cc[""]=Cc[""];Cc[""]=Cc[""];function Hj(t,e,n,s,i,a,c,u){let h=$j[e];if(h)return Uj(t,h,n,s,i,a),!0;let f=zj[e];if(f)return Wj(t,f,n,s,i,a),!0;let g=Fj[e];if(g)return qj(t,g,n,s,i,a,u),!0;let v=Cc[e];return v?(Kj(t,v,n,s,i,a,c,u),!0):!1}function Uj(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 Vb=new Map;function Wj(t,e,n,s,i,a){let c=Vb.get(e);c||(c=new Map,Vb.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 _=On(v.getContext("2d")),b=new ImageData(f,g),k,R,C,L;if(u.startsWith("#"))k=parseInt(u.slice(1,3),16),R=parseInt(u.slice(3,5),16),C=parseInt(u.slice(5,7),16),L=u.length>7&&parseInt(u.slice(7,9),16)||1;else if(u.startsWith("rgba"))[k,R,C,L]=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 T=0;T<f;T++)b.data[(S*f+T)*4]=k,b.data[(S*f+T)*4+1]=R,b.data[(S*f+T)*4+2]=C,b.data[(S*f+T)*4+3]=e[S][T]*(L*255);_.putImageData(b,0,0),h=On(t.createPattern(v,null)),c.set(u,h)}t.fillStyle=h,t.fillRect(n,s,i,a)}function qj(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],_=nk[v];if(!_){console.error(`Could not find drawing instructions for "${v}"`);continue}let b=g.substring(1).split(",");!b[0]||!b[1]||_(t,sk(b,i,a,n,s,!0,c))}t.stroke(),t.closePath()}}function Kj(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],_=nk[v];if(!_){console.error(`Could not find drawing instructions for "${v}"`);continue}let b=g.substring(1).split(",");!b[0]||!b[1]||_(t,sk(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 Yb(t,e,n=0){return Math.max(Math.min(t,e),n)}var nk={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 sk(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]=Yb(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]=Yb(Math.round(f[g]+.5)-.5,n,0)),f[g]+=i;return f}var Gb=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={}}},Xb=class{constructor(){this._data=new Gb}set(t,e,n,s,i){this._data.get(t,e)||this._data.set(t,e,new Gb),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()}},ik=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()}},Vj=class extends ik{_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())}}},Yj=class extends ik{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},Gj=!_v&&"requestIdleCallback"in window?Yj:Vj,Oa=class rk{constructor(){this.fg=0,this.bg=0,this.extended=new ok}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 rk;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}},ok=class ak{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 ak(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Xj=globalThis.performance&&typeof globalThis.performance.now=="function",Jj=class lk{static create(e){return new lk(e)}constructor(e){this._now=Xj&&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}},Cr;(t=>{t.None=()=>Pi.None;function e(B,P){return v(B,()=>{},0,void 0,!0,void 0,P)}t.defer=e;function n(B){return(P,D=null,M)=>{let $=!1,A;return A=B(j=>{if(!$)return A?A.dispose():$=!0,P.call(D,j)},null,M),$&&A.dispose(),A}}t.once=n;function s(B,P,D){return f((M,$=null,A)=>B(j=>M.call($,P(j)),null,A),D)}t.map=s;function i(B,P,D){return f((M,$=null,A)=>B(j=>{P(j),M.call($,j)},null,A),D)}t.forEach=i;function a(B,P,D){return f((M,$=null,A)=>B(j=>P(j)&&M.call($,j),null,A),D)}t.filter=a;function c(B){return B}t.signal=c;function u(...B){return(P,D=null,M)=>{let $=Xx(...B.map(A=>A(j=>P.call(D,j))));return g($,M)}}t.any=u;function h(B,P,D,M){let $=D;return s(B,A=>($=P($,A),$),M)}t.reduce=h;function f(B,P){let D,M={onWillAddFirstListener(){D=B($.fire,$)},onDidRemoveLastListener(){D==null||D.dispose()}},$=new pn(M);return P==null||P.add($),$.event}function g(B,P){return P instanceof Array?P.push(B):P&&P.add(B),B}function v(B,P,D=100,M=!1,$=!1,A,j){let N,U,I,W=0,se,me={leakWarningThreshold:A,onWillAddFirstListener(){N=B(Ie=>{W++,U=P(U,Ie),M&&!I&&(pe.fire(U),U=void 0),se=()=>{let J=U;U=void 0,I=void 0,(!M||W>1)&&pe.fire(J),W=0},typeof D=="number"?(clearTimeout(I),I=setTimeout(se,D)):I===void 0&&(I=0,queueMicrotask(se))})},onWillRemoveListener(){$&&W>0&&(se==null||se())},onDidRemoveLastListener(){se=void 0,N.dispose()}},pe=new pn(me);return j==null||j.add(pe),pe.event}t.debounce=v;function _(B,P=0,D){return t.debounce(B,(M,$)=>M?(M.push($),M):[$],P,void 0,!0,void 0,D)}t.accumulate=_;function b(B,P=(M,$)=>M===$,D){let M=!0,$;return a(B,A=>{let j=M||!P(A,$);return M=!1,$=A,j},D)}t.latch=b;function k(B,P,D){return[t.filter(B,P,D),t.filter(B,M=>!P(M),D)]}t.split=k;function R(B,P=!1,D=[],M){let $=D.slice(),A=B(U=>{$?$.push(U):N.fire(U)});M&&M.add(A);let j=()=>{$==null||$.forEach(U=>N.fire(U)),$=null},N=new pn({onWillAddFirstListener(){A||(A=B(U=>N.fire(U)),M&&M.add(A))},onDidAddFirstListener(){$&&(P?setTimeout(j):j())},onDidRemoveLastListener(){A&&A.dispose(),A=null}});return M&&M.add(N),N.event}t.buffer=R;function C(B,P){return(D,M,$)=>{let A=P(new S);return B(function(j){let N=A.evaluate(j);N!==L&&D.call(M,N)},void 0,$)}}t.chain=C;let L=Symbol("HaltChainable");class S{constructor(){this.steps=[]}map(P){return this.steps.push(P),this}forEach(P){return this.steps.push(D=>(P(D),D)),this}filter(P){return this.steps.push(D=>P(D)?D:L),this}reduce(P,D){let M=D;return this.steps.push($=>(M=P(M,$),M)),this}latch(P=(D,M)=>D===M){let D=!0,M;return this.steps.push($=>{let A=D||!P($,M);return D=!1,M=$,A?$:L}),this}evaluate(P){for(let D of this.steps)if(P=D(P),P===L)break;return P}}function T(B,P,D=M=>M){let M=(...N)=>j.fire(D(...N)),$=()=>B.on(P,M),A=()=>B.removeListener(P,M),j=new pn({onWillAddFirstListener:$,onDidRemoveLastListener:A});return j.event}t.fromNodeEventEmitter=T;function E(B,P,D=M=>M){let M=(...N)=>j.fire(D(...N)),$=()=>B.addEventListener(P,M),A=()=>B.removeEventListener(P,M),j=new pn({onWillAddFirstListener:$,onDidRemoveLastListener:A});return j.event}t.fromDOMEventEmitter=E;function H(B){return new Promise(P=>n(B)(P))}t.toPromise=H;function F(B){let P=new pn;return B.then(D=>{P.fire(D)},()=>{P.fire(void 0)}).finally(()=>{P.dispose()}),P.event}t.fromPromise=F;function X(B,P){return B(D=>P.fire(D))}t.forward=X;function V(B,P,D){return P(D),B(M=>P(M))}t.runAndSubscribe=V;class G{constructor(P,D){this._observable=P,this._counter=0,this._hasChanged=!1;let M={onWillAddFirstListener:()=>{P.addObserver(this)},onDidRemoveLastListener:()=>{P.removeObserver(this)}};this.emitter=new pn(M),D&&D.add(this.emitter)}beginUpdate(P){this._counter++}handlePossibleChange(P){}handleChange(P,D){this._hasChanged=!0}endUpdate(P){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ne(B,P){return new G(B,P).emitter.event}t.fromObservable=ne;function Y(B){return(P,D,M)=>{let $=0,A=!1,j={beginUpdate(){$++},endUpdate(){$--,$===0&&(B.reportChanges(),A&&(A=!1,P.call(D)))},handlePossibleChange(){},handleChange(){A=!0}};B.addObserver(j),B.reportChanges();let N={dispose(){B.removeObserver(j)}};return M instanceof Fa?M.add(N):Array.isArray(M)&&M.push(N),N}}t.fromObservableLight=Y})(Cr||(Cr={}));var rg=class og{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${og._idPool++}`,og.all.add(this)}start(e){this._stopWatch=new Jj,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}}};rg.all=new Set,rg._idPool=0;var Qj=rg,Zj=-1,ck=class uk{constructor(e,n,s=(uk._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 nM(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}};ck._idPool=1;var eM=ck,tM=class dk{constructor(e){this.value=e}static create(){let e=new Error;return new dk(e.stack??"")}print(){console.warn(this.value.split(`
|
|
93
|
+
`).slice(2).join(`
|
|
94
|
+
`))}},nM=class extends Error{constructor(t,e){super(t),this.name="ListenerLeakError",this.stack=e}},sM=class extends Error{constructor(t,e){super(t),this.name="ListenerRefusalError",this.stack=e}},iM=0,up=class{constructor(t){this.value=t,this.id=iM++}},rM=2,oM,pn=class{constructor(t){var e,n,s,i;this._size=0,this._options=t,this._leakageMon=(e=this._options)!=null&&e.leakWarningThreshold?new eM((t==null?void 0:t.onListenerError)??lp,((n=this._options)==null?void 0:n.leakWarningThreshold)??Zj):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Qj(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 sM(`${v}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((c=this._options)==null?void 0:c.onListenerError)||lp)(b),Pi.None}if(this._disposed)return Pi.None;e&&(t=t.bind(e));let s=new up(t),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=tM.create(),i=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof up?(this._deliveryQueue??(this._deliveryQueue=new aM),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=Rs(()=>{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*rM<=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)||lp;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 up)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}},aM=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}},Jb={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}},ql=2,Kl,Qr=class Pa{constructor(e,n,s){this._document=e,this._config=n,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new Xb,this._cacheMapCombined=new Xb,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new Oa,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=hk(e,this._config.deviceCellWidth*4+ql*2,this._config.deviceCellHeight+ql*2),this._tmpCtx=On(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 Gj;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(Pa.maxAtlasPages&&this._pages.length>=Math.max(4,Pa.maxAtlasPages)){let n=this._pages.filter(f=>f.canvas.width*2<=(Pa.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 dp(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 dp(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 Kl=e.get(n,s,i,a),Kl||(Kl=this._drawToCache(n,s,i,a,c,u),e.set(n,s,i,a,Kl)),Kl}_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 fi;let a;switch(e){case 16777216:case 33554432:a=this._getColorFromAnsiIndex(n);break;case 50331648:let c=Oa.toColorRGB(n);a=Ps.toColor(c[0],c[1],c[2]);break;case 0:default:s?a=dc.opaque(this._config.colors.foreground):a=this._config.colors.background;break}return this._config.allowTransparency||(a=dc.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=Oa.toColorRGB(c);_=Ps.toColor(b[0],b[1],b[2]);break;case 0:default:u?_=this._config.colors.background:_=this._config.colors.foreground}return this._config.allowTransparency&&(_=dc.opaque(_)),h&&(_=dc.multiplyOpacity(_,Bj)),_}_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),k=this._resolveForegroundRgba(a,c,u,h),R=Fo.ensureContrastRatio(b,k,this._config.minimumContrastRatio/(f?2:1));if(!R){v.setColor(e,i,null);return}let C=Ps.toColor(R>>24&255,R>>16&255,R>>8&255);return v.setColor(e,i,C),C}_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)+ql*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<h&&(this._tmpCanvas.width=h);let f=Math.min(this._config.deviceCellHeight+ql*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 Jb;let g=!!this._workAttributeData.isBold(),v=!!this._workAttributeData.isInverse(),_=!!this._workAttributeData.isDim(),b=!!this._workAttributeData.isItalic(),k=!!this._workAttributeData.isUnderline(),R=!!this._workAttributeData.isStrikethrough(),C=!!this._workAttributeData.isOverline(),L=this._workAttributeData.getFgColor(),S=this._workAttributeData.getFgColorMode(),T=this._workAttributeData.getBgColor(),E=this._workAttributeData.getBgColorMode();if(v){let U=L;L=T,T=U;let I=S;S=E,E=I}let H=this._getBackgroundColor(E,T,v,_);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=H.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let F=g?this._config.fontWeightBold:this._config.fontWeight,X=b?"italic":"";this._tmpCtx.font=`${X} ${F} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=tk;let V=u.length===1&&yv(u.charCodeAt(0)),G=u.length===1&&Aj(u.charCodeAt(0)),ne=this._getForegroundColor(n,E,T,s,S,L,v,_,g,ek(u.charCodeAt(0)));this._tmpCtx.fillStyle=ne.css;let Y=G?0:ql*2,B=!1;this._config.customGlyphs!==!1&&(B=Hj(this._tmpCtx,u,Y,Y,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let P=!V,D;if(typeof e=="number"?D=this._unicodeService.wcwidth(e):D=this._unicodeService.getStringCellWidth(e),k){this._tmpCtx.save();let U=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),I=U%2===1?.5:0;if(this._tmpCtx.lineWidth=U,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())P=!1,this._tmpCtx.strokeStyle=`rgb(${Oa.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{P=!1;let J=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&J<8&&(J+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(J).css}this._tmpCtx.beginPath();let W=Y,se=Math.ceil(Y+this._config.deviceCharHeight)-I-(a?U*2:0),me=se+U,pe=se+U*2,Ie=this._workAttributeData.getUnderlineVariantOffset();for(let J=0;J<D;J++){this._tmpCtx.save();let te=W+J*this._config.deviceCellWidth,ge=W+(J+1)*this._config.deviceCellWidth,Se=te+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(te,se),this._tmpCtx.lineTo(ge,se),this._tmpCtx.moveTo(te,pe),this._tmpCtx.lineTo(ge,pe);break;case 3:let Be=U<=1?pe:Math.ceil(Y+this._config.deviceCharHeight-U/2)-I,Le=U<=1?se:Math.ceil(Y+this._config.deviceCharHeight+U/2)-I,ze=new Path2D;ze.rect(te,se,this._config.deviceCellWidth,pe-se),this._tmpCtx.clip(ze),this._tmpCtx.moveTo(te-this._config.deviceCellWidth/2,me),this._tmpCtx.bezierCurveTo(te-this._config.deviceCellWidth/2,Le,te,Le,te,me),this._tmpCtx.bezierCurveTo(te,Be,Se,Be,Se,me),this._tmpCtx.bezierCurveTo(Se,Le,ge,Le,ge,me),this._tmpCtx.bezierCurveTo(ge,Be,ge+this._config.deviceCellWidth/2,Be,ge+this._config.deviceCellWidth/2,me);break;case 4:let Q=Ie===0?0:Ie>=U?U*2-Ie:U-Ie;Ie>=U||Q===0?(this._tmpCtx.setLineDash([Math.round(U),Math.round(U)]),this._tmpCtx.moveTo(te+Q,se),this._tmpCtx.lineTo(ge,se)):(this._tmpCtx.setLineDash([Math.round(U),Math.round(U)]),this._tmpCtx.moveTo(te,se),this._tmpCtx.lineTo(te+Q,se),this._tmpCtx.moveTo(te+Q+U,se),this._tmpCtx.lineTo(ge,se)),Ie=Dj(ge-te,U,Ie);break;case 5:let ve=.6,Z=.3,be=ge-te,K=Math.floor(ve*be),fe=Math.floor(Z*be),Re=be-K-fe;this._tmpCtx.setLineDash([K,fe,Re]),this._tmpCtx.moveTo(te,se),this._tmpCtx.lineTo(ge,se);break;case 1:default:this._tmpCtx.moveTo(te,se),this._tmpCtx.lineTo(ge,se);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!B&&this._config.fontSize>=12&&!this._config.allowTransparency&&u!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let J=this._tmpCtx.measureText(u);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in J&&J.actualBoundingBoxDescent>0){this._tmpCtx.save();let te=new Path2D;te.rect(W,se-Math.ceil(U/2),this._config.deviceCellWidth*D,pe-se+Math.ceil(U/2)),this._tmpCtx.clip(te),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=H.css,this._tmpCtx.strokeText(u,Y,Y+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(C){let U=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),I=U%2===1?.5:0;this._tmpCtx.lineWidth=U,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(Y,Y+I),this._tmpCtx.lineTo(Y+this._config.deviceCharWidth*D,Y+I),this._tmpCtx.stroke()}if(B||this._tmpCtx.fillText(u,Y,Y+this._config.deviceCharHeight),u==="_"&&!this._config.allowTransparency){let U=hp(this._tmpCtx.getImageData(Y,Y,this._config.deviceCellWidth,this._config.deviceCellHeight),H,ne,P);if(U)for(let I=1;I<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=H.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(u,Y,Y+this._config.deviceCharHeight-I),U=hp(this._tmpCtx.getImageData(Y,Y,this._config.deviceCellWidth,this._config.deviceCellHeight),H,ne,P),!!U);I++);}if(R){let U=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),I=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=U,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(Y,Y+Math.floor(this._config.deviceCharHeight/2)-I),this._tmpCtx.lineTo(Y+this._config.deviceCharWidth*D,Y+Math.floor(this._config.deviceCharHeight/2)-I),this._tmpCtx.stroke()}this._tmpCtx.restore();let M=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),$;if(this._config.allowTransparency?$=lM(M):$=hp(M,H,ne,P),$)return Jb;let A=this._findGlyphBoundingBox(M,this._workBoundingBox,h,G,B,Y),j,N;for(;;){if(this._activePages.length===0){let U=this._createNewPage();j=U,N=U.currentRow,N.height=A.size.y;break}j=this._activePages[this._activePages.length-1],N=j.currentRow;for(let U of this._activePages)A.size.y<=U.currentRow.height&&(j=U,N=U.currentRow);for(let U=this._activePages.length-1;U>=0;U--)for(let I of this._activePages[U].fixedRows)I.height<=N.height&&A.size.y<=I.height&&(j=this._activePages[U],N=I);if(A.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new dp(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),j=this._overflowSizePage,N=this._overflowSizePage.currentRow,N.x+A.size.x>=j.canvas.width&&(N.x=0,N.y+=N.height,N.height=0);break}if(N.y+A.size.y>=j.canvas.height||N.height>A.size.y+2){let U=!1;if(j.currentRow.y+j.currentRow.height+A.size.y>=j.canvas.height){let I;for(let W of this._activePages)if(W.currentRow.y+W.currentRow.height+A.size.y<W.canvas.height){I=W;break}if(I)j=I;else if(Pa.maxAtlasPages&&this._pages.length>=Pa.maxAtlasPages&&N.y+A.size.y<=j.canvas.height&&N.height>=A.size.y&&N.x+A.size.x<=j.canvas.width)U=!0;else{let W=this._createNewPage();j=W,N=W.currentRow,N.height=A.size.y,U=!0}}U||(j.currentRow.height>0&&j.fixedRows.push(j.currentRow),N={x:0,y:j.currentRow.y+j.currentRow.height,height:A.size.y},j.fixedRows.push(N),j.currentRow={x:0,y:N.y+N.height,height:0})}if(N.x+A.size.x<=j.canvas.width)break;N===j.currentRow?(N.x=0,N.y+=N.height,N.height=0):j.fixedRows.splice(j.fixedRows.indexOf(N),1)}return A.texturePage=this._pages.indexOf(j),A.texturePosition.x=N.x,A.texturePosition.y=N.y,A.texturePositionClipSpace.x=N.x/j.canvas.width,A.texturePositionClipSpace.y=N.y/j.canvas.height,A.sizeClipSpace.x/=j.canvas.width,A.sizeClipSpace.y/=j.canvas.height,N.height=Math.max(N.height,A.size.y),N.x+=A.size.x,j.ctx.putImageData(M,A.texturePosition.x-this._workBoundingBox.left,A.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,A.size.x,A.size.y),j.addGlyph(A),j.version++,A}_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)}}}},dp=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=hk(t,e,e),this.ctx=On(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 hp(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 lM(t){for(let e=0;e<t.data.length;e+=4)if(t.data[e+3]>0)return!1;return!0}function hk(t,e,n){let s=t.createElement("canvas");return s.width=e,s.height=n,s}function cM(t,e,n,s,i,a,c,u){let h={foreground:a.foreground,background:a.background,cursor:fi,cursorAccent:fi,selectionForeground:fi,selectionBackgroundTransparent:fi,selectionBackgroundOpaque:fi,selectionInactiveBackgroundTransparent:fi,selectionInactiveBackgroundOpaque:fi,overviewRulerBorder:fi,scrollbarSliderBackground:fi,scrollbarSliderHoverBackground:fi,scrollbarSliderActiveBackground:fi,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 Qb(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 uM(t){return(t&50331648)===16777216||(t&50331648)===33554432}var gi=[];function fk(t,e,n,s,i,a,c,u,h){let f=cM(s,i,a,c,e,n,u,h);for(let _=0;_<gi.length;_++){let b=gi[_],k=b.ownedBy.indexOf(t);if(k>=0){if(Qb(b.config,f))return b.atlas;b.ownedBy.length===1?(b.atlas.dispose(),gi.splice(_,1)):b.ownedBy.splice(k,1);break}}for(let _=0;_<gi.length;_++){let b=gi[_];if(Qb(b.config,f))return b.ownedBy.push(t),b.atlas}let g=t._core,v={atlas:new Qr(document,f,g.unicodeService),config:f,ownedBy:[t]};return gi.push(v),v.atlas}function Zb(t){for(let e=0;e<gi.length;e++){let n=gi[e].ownedBy.indexOf(t);if(n!==-1){gi[e].ownedBy.length===1?(gi[e].atlas.dispose(),gi.splice(e,1)):gi[e].ownedBy.splice(n,1);break}}}var ed=600,dM=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=ed){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=ed-(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=ed-(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})},ed)},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 e0(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 Rs(()=>s==null?void 0:s.disconnect())}function hM(t){return t>65535?(t-=65536,String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):String.fromCharCode(t)}var t0=class pk extends Oa{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ok,this.combinedData=""}static fromCharData(e){let n=new pk;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?hM(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()]}},mk=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function gk(t,e,n){let s=On(t.createProgram());if(t.attachShader(s,On(n0(t,t.VERTEX_SHADER,e))),t.attachShader(s,On(n0(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 n0(t,e,n){let s=On(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 fM(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 pM=class{constructor(t){this.texture=t,this.version=-1}},mM=`#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 gM(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 Zr=11,Na=Zr*Float32Array.BYTES_PER_ELEMENT,vM=2,Cn=0,hn,fp=0,Vl=0,_M=class extends Pi{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;Qr.maxAtlasPages===void 0&&(Qr.maxAtlasPages=Math.min(32,On(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS))),Qr.maxTextureSize=On(i.getParameter(i.MAX_TEXTURE_SIZE))),this._program=On(gk(i,mM,gM(Qr.maxAtlasPages))),this._register(Rs(()=>i.deleteProgram(this._program))),this._projectionLocation=On(i.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=On(i.getUniformLocation(this._program,"u_resolution")),this._textureLocation=On(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(Rs(()=>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(Rs(()=>i.deleteBuffer(h))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,h),i.bufferData(i.ELEMENT_ARRAY_BUFFER,u,i.STATIC_DRAW),this._attributesBuffer=On(i.createBuffer()),this._register(Rs(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,Na,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,Na,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,Na,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,Na,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,Na,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Na,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let f=new Int32Array(Qr.maxAtlasPages);for(let g=0;g<Qr.maxAtlasPages;g++)f[g]=g;i.uniform1iv(this._textureLocation,f),i.uniformMatrix4fv(this._projectionLocation,!1,mk),this._atlasTextures=[];for(let g=0;g<Qr.maxAtlasPages;g++){let v=new pM(On(i.createTexture()));this._register(Rs(()=>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(Cn=(n*this._terminal.cols+e)*Zr,s===0||s===void 0){t.fill(0,Cn,Cn+Zr-1-vM);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),fp=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==f&&hn.offset.x>fp?(Vl=hn.offset.x-fp,t[Cn]=-(hn.offset.x-Vl)+this._dimensions.device.char.left,t[Cn+1]=-hn.offset.y+this._dimensions.device.char.top,t[Cn+2]=(hn.size.x-Vl)/this._dimensions.device.canvas.width,t[Cn+3]=hn.size.y/this._dimensions.device.canvas.height,t[Cn+4]=hn.texturePage,t[Cn+5]=hn.texturePositionClipSpace.x+Vl/this._atlas.pages[hn.texturePage].canvas.width,t[Cn+6]=hn.texturePositionClipSpace.y,t[Cn+7]=hn.sizeClipSpace.x-Vl/this._atlas.pages[hn.texturePage].canvas.width,t[Cn+8]=hn.sizeClipSpace.y):(t[Cn]=-hn.offset.x+this._dimensions.device.char.left,t[Cn+1]=-hn.offset.y+this._dimensions.device.char.top,t[Cn+2]=hn.size.x/this._dimensions.device.canvas.width,t[Cn+3]=hn.size.y/this._dimensions.device.canvas.height,t[Cn+4]=hn.texturePage,t[Cn+5]=hn.texturePositionClipSpace.x,t[Cn+6]=hn.texturePositionClipSpace.y,t[Cn+7]=hn.sizeClipSpace.x,t[Cn+8]=hn.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Pj(s,h,hn.size.x,this._dimensions.device.cell.width)&&(t[Cn+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let t=this._terminal,e=t.cols*t.rows*Zr;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+=Zr}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*Zr,c=this._vertices.attributes.subarray(a,a+t.lineLengths[i]*Zr);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/Zr)}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}},yM=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 wM(){return new yM}var Id=4,_d=1,yd=2,pp=3,bM=2147483648,SM=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=wM()}resize(t,e){let n=t*e*Id;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)}},xM=`#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
|
+
}`,kM=`#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
|
+
}`,br=8,mp=br*Float32Array.BYTES_PER_ELEMENT,CM=20*br,s0=class{constructor(){this.attributes=new Float32Array(CM),this.count=0}},wr=0,i0=0,r0=0,o0=0,a0=0,l0=0,c0=0,EM=class extends Pi{constructor(t,e,n,s){super(),this._terminal=t,this._gl=e,this._dimensions=n,this._themeService=s,this._vertices=new s0,this._verticesCursor=new s0;let i=this._gl;this._program=On(gk(i,xM,kM)),this._register(Rs(()=>i.deleteProgram(this._program))),this._projectionLocation=On(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(Rs(()=>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(Rs(()=>i.deleteBuffer(h))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,h),i.bufferData(i.ELEMENT_ARRAY_BUFFER,u,i.STATIC_DRAW),this._attributesBuffer=On(i.createBuffer()),this._register(Rs(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,mp,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,mp,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,mp,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,mk),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,k;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)*Id,v=t.cells[g+_d],_=t.cells[g+yd],b=!!(_&67108864),(v!==u||_!==h&&(f||b))&&((u!==0||f&&h!==0)&&(k=s++*br,this._updateRectangle(n,k,h,u,c,a,i)),c=a,u=v,h=_,f=b);(u!==0||f&&h!==0)&&(k=s++*br,this._updateRectangle(n,k,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++*br,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++*br,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++*br,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++*br,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:wr=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:wr=(n&16777215)<<8;break;case 0:default:wr=this._themeService.colors.foreground.rgba}else switch(s&50331648){case 16777216:case 33554432:wr=this._themeService.colors.ansi[s&255].rgba;break;case 50331648:wr=(s&16777215)<<8;break;case 0:default:wr=this._themeService.colors.background.rgba}t.attributes.length<e+4&&(t.attributes=fM(t.attributes,this._terminal.rows*this._terminal.cols*br)),i0=i*this._dimensions.device.cell.width,r0=c*this._dimensions.device.cell.height,o0=(wr>>24&255)/255,a0=(wr>>16&255)/255,l0=(wr>>8&255)/255,c0=1,this._addRectangle(t.attributes,e,i0,r0,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,o0,a0,l0,c0)}_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])}},NM=class extends Pi{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(Rs(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=On(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=fk(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=tk,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}`}},RM=class extends NM{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&&uM(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()}},Oo=typeof window=="object"?window:globalThis,ag=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}};ag.INSTANCE=new ag;var vk=ag;function LM(t,e,n){typeof e=="string"&&(e=t.matchMedia(e)),e.addEventListener("change",n)}vk.INSTANCE.onDidChangeZoomLevel;vk.INSTANCE.onDidChangeFullscreen;var el=typeof navigator=="object"?navigator.userAgent:"";el.indexOf("Firefox")>=0;el.indexOf("AppleWebKit")>=0;var AM=el.indexOf("Chrome")>=0;!AM&&el.indexOf("Safari")>=0;el.indexOf("Electron/")>=0;el.indexOf("Android")>=0;var gp=!1;if(typeof Oo.matchMedia=="function"){let t=Oo.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Oo.matchMedia("(display-mode: fullscreen)");gp=t.matches,LM(Oo,t,({matches:n})=>{gp&&e.matches||(gp=n)})}var Ba="en",vp=!1,_k=!1,td,wd=Ba,u0=Ba,jM,ji,Ho=globalThis,ps,k1;typeof Ho.vscode<"u"&&typeof Ho.vscode.process<"u"?ps=Ho.vscode.process:typeof process<"u"&&typeof((k1=process==null?void 0:process.versions)==null?void 0:k1.node)=="string"&&(ps=process);var C1,MM=typeof((C1=ps==null?void 0:ps.versions)==null?void 0:C1.electron)=="string",TM=MM&&(ps==null?void 0:ps.type)==="renderer",E1;if(typeof ps=="object"){ps.platform,ps.platform,vp=ps.platform==="linux",vp&&ps.env.SNAP&&ps.env.SNAP_REVISION,ps.env.CI||ps.env.BUILD_ARTIFACTSTAGINGDIRECTORY,td=Ba,wd=Ba;let t=ps.env.VSCODE_NLS_CONFIG;if(t)try{let e=JSON.parse(t);td=e.userLocale,u0=e.osLocale,wd=e.resolvedLanguage||Ba,jM=(E1=e.languagePack)==null?void 0:E1.translationsConfigFile}catch{}_k=!0}else typeof navigator=="object"&&!TM?(ji=navigator.userAgent,ji.indexOf("Windows")>=0,ji.indexOf("Macintosh")>=0,(ji.indexOf("Macintosh")>=0||ji.indexOf("iPad")>=0||ji.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,vp=ji.indexOf("Linux")>=0,(ji==null?void 0:ji.indexOf("Mobi"))>=0,wd=globalThis._VSCODE_NLS_LANGUAGE||Ba,td=navigator.language.toLowerCase(),u0=td):console.error("Unable to resolve platform.");var d0=_k,tr=ji,Gr=wd,PM;(t=>{function e(){return Gr}t.value=e;function n(){return Gr.length===2?Gr==="en":Gr.length>=3?Gr[0]==="e"&&Gr[1]==="n"&&Gr[2]==="-":!1}t.isDefaultVariant=n;function s(){return Gr==="en"}t.isDefault=s})(PM||(PM={}));var IM=typeof Ho.postMessage=="function"&&!Ho.importScripts;(()=>{if(IM){let t=[];Ho.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}),Ho.postMessage({vscodeScheduleAsyncWork:s},"*")}}return t=>setTimeout(t)})();var DM=!!(tr&&tr.indexOf("Chrome")>=0);tr&&tr.indexOf("Firefox")>=0;!DM&&tr&&tr.indexOf("Safari")>=0;tr&&tr.indexOf("Edg/")>=0;tr&&tr.indexOf("Android")>=0;var Ra=typeof navigator=="object"?navigator:{};d0||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ra&&Ra.clipboard&&Ra.clipboard.writeText,d0||Ra&&Ra.clipboard&&Ra.clipboard.readText;var wv=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}},_p=new wv,h0=new wv,f0=new wv;new Array(230);var OM;(t=>{function e(u){return _p.keyCodeToStr(u)}t.toString=e;function n(u){return _p.strToKeyCode(u)}t.fromString=n;function s(u){return h0.keyCodeToStr(u)}t.toUserSettingsUS=s;function i(u){return f0.keyCodeToStr(u)}t.toUserSettingsGeneral=i;function a(u){return h0.strToKeyCode(u)||f0.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 _p.keyCodeToStr(u)}t.toElectronAccelerator=c})(OM||(OM={}));var yk=Object.freeze(function(t,e){let n=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(n)}}}),BM;(t=>{function e(n){return n===t.None||n===t.Cancelled||n instanceof $M?!0:!n||typeof n!="object"?!1:typeof n.isCancellationRequested=="boolean"&&typeof n.onCancellationRequested=="function"}t.isCancellationToken=e,t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Cr.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:yk})})(BM||(BM={}));var $M=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?yk:(this._emitter||(this._emitter=new pn),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},zM;(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})(zM||(zM={}));var p0=class pi{static fromArray(e){return new pi(n=>{n.emitMany(e)})}static fromPromise(e){return new pi(async n=>{n.emitMany(await e)})}static fromPromises(e){return new pi(async n=>{await Promise.all(e.map(async s=>n.emitOne(await s)))})}static merge(e){return new pi(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 Cr.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 pi(async s=>{for await(let i of e)s.emitOne(n(i))})}map(e){return pi.map(this,e)}static filter(e,n){return new pi(async s=>{for await(let i of e)n(i)&&s.emitOne(i)})}filter(e){return pi.filter(this,e)}static coalesce(e){return pi.filter(e,n=>!!n)}coalesce(){return pi.coalesce(this)}static async toPromise(e){let n=[];for await(let s of e)n.push(s);return n}toPromise(){return pi.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())}};p0.EMPTY=p0.fromArray([]);var{getWindow:FM}=(function(){let t=new Map,e={window:Oo,disposables:new Fa};t.set(Oo.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 Pi.None;let u=new Fa,h={window:c,disposables:u.add(new Fa)};return t.set(c.vscodeWindowId,h),u.add(Rs(()=>{t.delete(c.vscodeWindowId),s.fire(c)})),u.add(lg(c,UM.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:Oo},getDocument(c){return FM(c).document}}})(),HM=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 lg(t,e,n,s){return new HM(t,e,n,s)}var UM={BEFORE_UNLOAD:"beforeunload"},WM=class extends Pi{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 Wl,this._charAtlasDisposable=this._register(new Wl),this._observerDisposable=this._register(new Wl),this._model=new SM,this._workCell=new t0,this._workCell2=new t0,this._rectangleRenderer=this._register(new Wl),this._glyphRenderer=this._register(new Wl),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 Oj(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new RM(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,c,this._themeService)],this.dimensions=Ij(),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(lg(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(lg(this._canvas,"webglcontextrestored",g=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Zb(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=e0(this._canvas,this._coreBrowserService.window,(g,v)=>this._setCanvasDevicePixelDimensions(g,v)),this._register(this._coreBrowserService.onWindowChange(g=>{this._observerDisposable.value=e0(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(Rs(()=>{var g;for(let v of this._renderLayers)v.dispose();(g=this._canvas.parentElement)==null||g.removeChild(this._canvas),Zb(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 EM(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new _M(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=fk(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=Xx(Cr.forward(t.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Cr.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 dM(()=>{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,k,R,C,L,S,T,E;t=m0(t,n.rows-1,0),e=m0(e,n.rows-1,0);let H=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??"block",F=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,X=F-n.buffer.ydisp,V=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),G=-1,ne=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let Y=!1;for(a=t;a<=e;a++)for(c=a+n.buffer.ydisp,u=n.buffer.lines.get(c),this._model.lineLengths[a]=0,k=F===c,g=0,h=this._characterJoinerService.getJoinedCharacters(c),T=0;T<n.cols;T++){if(i=this._cellColorResolver.result.bg,u.loadCell(T,s),T===0&&(i=this._cellColorResolver.result.bg),f=!1,v=T>=g,_=T,h.length>0&&T===h[0][0]&&v){b=h.shift();let B=this._model.selection.isCellSelected(this._terminal,b[0],c);for(S=b[0]+1;S<b[1];S++)v&&(v=B===this._model.selection.isCellSelected(this._terminal,S,c));v&&(v=!k||V<b[0]||V>=b[1]),v?(f=!0,s=new qM(s,u.translateToString(!0,b[0],b[1]),b[1]-b[0]),_=b[1]-1):g=b[1]}if(R=s.getChars(),C=s.getCode(),S=(a*n.cols+T)*Id,this._cellColorResolver.resolve(s,T,c,this.dimensions.device.cell.width),ne&&c===F&&(T===V&&(this._model.cursor={x:V,y:X,width:s.getWidth(),style:this._coreBrowserService.isFocused?H:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},G=V+s.getWidth()-1),T>=V&&T<=G&&(this._coreBrowserService.isFocused&&H==="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)),C!==0&&(this._model.lineLengths[a]=T+1),!(this._model.cells[S]===C&&this._model.cells[S+_d]===this._cellColorResolver.result.bg&&this._model.cells[S+yd]===this._cellColorResolver.result.fg&&this._model.cells[S+pp]===this._cellColorResolver.result.ext)&&(Y=!0,R.length>1&&(C|=bM),this._model.cells[S]=C,this._model.cells[S+_d]=this._cellColorResolver.result.bg,this._model.cells[S+yd]=this._cellColorResolver.result.fg,this._model.cells[S+pp]=this._cellColorResolver.result.ext,L=s.getWidth(),this._glyphRenderer.value.updateCell(T,a,C,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,R,L,i),f)){for(s=this._workCell,T++;T<=_;T++)E=(a*n.cols+T)*Id,this._glyphRenderer.value.updateCell(T,a,0,0,0,0,Rj,0,0),this._model.cells[E]=0,this._model.cells[E+_d]=this._cellColorResolver.result.bg,this._model.cells[E+yd]=this._cellColorResolver.result.fg,this._model.cells[E+pp]=this._cellColorResolver.result.ext;T--}}Y&&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})}},qM=class extends Oa{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 m0(t,e,n=0){return Math.max(Math.min(t,e),n)}var g0="di$target",v0="di$dependencies",yp=new Map;function nr(t){if(yp.has(t))return yp.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");KM(e,n,i)};return e._id=t,yp.set(t,e),e}function KM(t,e,n){e[g0]===e?e[v0].push({id:t,index:n}):(e[v0]=[{id:t,index:n}],e[g0]=e)}nr("BufferService");nr("CoreMouseService");nr("CoreService");nr("CharsetService");nr("InstantiationService");nr("LogService");var VM=nr("OptionsService");nr("OscLinkService");nr("UnicodeService");nr("DecorationService");var YM={trace:0,debug:1,info:2,warn:3,error:4,off:5},GM="xterm.js: ",_0=class extends Pi{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=YM[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?"":GM)+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)}};_0=gj([vj(0,VM)],_0);var XM=class extends Pi{constructor(t){if(Zx&&Nj()<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 WM(t,c,u,h,n,f,s,g,this._preserveDrawingBuffer)),this._register(Cr.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Cr.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Cr.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Cr.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(Rs(()=>{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 wk="nc-terminal-renderer",ho="webgl",fo="dom";function bk(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Ec(t){const e=bk(t);try{return e&&e.getItem(wk)===fo?fo:ho}catch{return ho}}function Sk(t,e){const n=t===fo?fo:ho,s=bk(e);try{s&&s.setItem(wk,n)}catch{}return n}function JM(t){return t===fo?ho:fo}function QM(t,{preference:e,createAddon:n,onFallback:s}={}){const i=e||Ec(),a={kind:fo,dispose:()=>{}};if(i!==ho||!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:ho,dispose:h}}const ZM=Object.freeze({retryBaseMs:250,retryMaxMs:5e3,pingMs:5e3,deadMs:1e4,queuedInputBytes:4096,overlayDelayMs:1e3}),eT=(t,e)=>{const n=Number(t);return Number.isFinite(n)&&n>0?n:e};function xk(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{},n={};for(const[s,i]of Object.entries(ZM))n[s]=eT(e[s],i);return n}let cg=xk(null);function tT(t){return cg=xk(t),{...cg}}function kk(){return{...cg}}function nT(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 sT(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 iT({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:k,retryStableMs:R=5e3,onRetryScheduled:C,pingMs:L,deadMs:S,queuedInputBytes:T,onQueued:E}){const H=kk(),F=b===void 0?H.retryBaseMs:b,X=k===void 0?H.retryMaxMs:k,V=L===void 0?H.pingMs:L,G=S===void 0?H.deadMs:S,ne=T===void 0?H.queuedInputBytes:T,Y=["localhost","127.0.0.1","::1","[::1]"].includes(location.hostname);if(location.protocol!=="https:"&&!Y)throw new Error("nexuscrew: ws:// rifiutato su origine non-locale e non-TLS (apri via tunnel su localhost o servi in HTTPS)");const B=location.protocol==="https:"?"wss":"ws",P=sT(t,e),D=`${B}://${location.host}${nT(e,n,P,t)}`;let M=null,$=!1,A=!1,j=null,N=null,U=0,I=null,W=!1,se=null,me=0,pe=null;const Ie=Math.max(1,Number(ne)||4096);let J=[],te=0;const ge=()=>{if(typeof E=="function")try{E(te)}catch{}},Se=()=>{if(!M||M.readyState!==1||!J.length)return;const Z=J;J=[],te=0;for(const be of Z)try{M.send(be)}catch{}ge()},Be=()=>{se&&(clearInterval(se),se=null)},Le=Z=>{Be(),me=Date.now();const be=Math.max(1,Number(V)||5e3),K=Math.max(1,Number(G)||1e4);se=setInterval(()=>{if(M!==Z||$||A){Be();return}if(Date.now()-me>K){Be();try{Z.close(4e3,"liveness timeout")}catch{}return}if(Z.readyState===1)try{Z.send(JSON.stringify({type:"ping",t:Date.now()}))}catch{}},be),typeof se.unref=="function"&&se.unref()};let ze=u;const Q=()=>{if($||A||j)return;const Z=Math.min(X,Math.max(0,F)*2**Math.min(U++,5));typeof C=="function"&&C(Z),j=setTimeout(()=>{j=null,ve()},Z)},ve=()=>{if($||A)return;const Z=new WebSocket(D);M=Z,Z.binaryType="arraybuffer",Z.onopen=()=>{if(M!==Z||$)return;N&&clearTimeout(N);const be=Number(R),K=Number.isFinite(be)?Math.max(0,be):5e3;N=setTimeout(()=>{N=null,M===Z&&Z.readyState===1&&(U=0)},K),typeof N.unref=="function"&&N.unref();const fe={type:"attach",session:t,token:n,cols:s,rows:i,readonly:a};I&&(fe.reconnectToken=I),c!==void 0&&(fe.takeSize=c),Z.send(JSON.stringify(fe)),ze!==void 0&&Z.send(JSON.stringify({type:"focus",on:!!ze})),W&&Z.send(JSON.stringify(pe===null?{type:"resync"}:{type:"resume",seq:pe})),Se(),Le(Z)},Z.onmessage=be=>{if(!(M!==Z||$))if(me=Date.now(),typeof be.data=="string"){let K;try{K=JSON.parse(be.data)}catch{return}if(K.type==="attached"&&typeof K.reconnectToken=="string"&&K.reconnectToken&&(I=K.reconnectToken),K.type==="exit"&&(A=!0,f&&f(K.code)),K.type==="files"&&g&&g(K),K.type==="snapshot"&&v&&v(typeof K.data=="string"?K.data:""),K.type==="link"&&_&&_(K.state==="live"?"live":"reconnecting"),K.type==="resync-needed")try{Z.send(JSON.stringify({type:"resync"}))}catch{}}else{let K=new Uint8Array(be.data);try{be.data&&be.data.byteLength>=4&&(pe=new DataView(be.data).getUint32(0),K=new Uint8Array(be.data,4))}catch{}h&&h(K)}},Z.onerror=()=>{if(M===Z)try{Z.close()}catch{}},Z.onclose=be=>{Be(),!(M!==Z||$||A)&&(N&&(clearTimeout(N),N=null),![4401,4403,4404].includes(be==null?void 0:be.code)&&(W=!0,_&&_("reconnecting"),Q()))}};return ve(),{sendInput:Z=>{const be=typeof Z=="string"?new TextEncoder().encode(Z):Z;if(M&&M.readyState===1)try{return M.send(be),!0}catch{try{M.close()}catch{}}return te+be.length>Ie?!1:(J.push(be),te+=be.length,ge(),!0)},isReady:()=>!!M&&M.readyState===1,resize:(Z,be)=>{s=Z,i=be,(M==null?void 0:M.readyState)===1&&M.send(JSON.stringify({type:"resize",cols:Z,rows:be}))},action:Z=>{(M==null?void 0:M.readyState)===1&&M.send(JSON.stringify({type:"action",name:Z}))},focus:Z=>{ze=Z,(M==null?void 0:M.readyState)===1&&M.send(JSON.stringify({type:"focus",on:!!Z}))},close:()=>{if($=!0,Be(),j&&clearTimeout(j),N&&clearTimeout(N),j=null,N=null,M)try{M.close()}catch{}},get raw(){return M}}}const Ck=1e3;function rT(t,e,n=Ck){if(t==null)return!1;const s=Number(e)-Number(t);return Number.isFinite(s)?s>=Math.max(0,Number(n)||0):!1}function oT(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 aT(t){return t?`\r
|
|
152
|
+
\x1B[2m── riconnesso ──\x1B[0m\r
|
|
153
|
+
`:""}function lT(t,e){var s;if(!t||typeof((s=t.parser)==null?void 0:s.registerCsiHandler)!="function")return;const n=i=>a=>{const c=a&&a[0],u=Array.isArray(c)?c[0]:c,h=Number.isFinite(u)&&u>0?u:0;if(typeof e=="function")try{e(`\x1B[${i}${h};0$y`)}catch{}return!0};t.parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},n("?")),t.parser.registerCsiHandler({intermediates:"$",final:"p"},n(""))}function y0(t,e){try{return t.write(e),!0}catch(n){return console.error("[terminal] output scartato: eccezione del parser",n),!1}}function cT(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 ug(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 uT="\r";function dT(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 hT({isReady:t,paste:e,send:n}){return s=>{if(!s||!t())return!1;try{return e(s)===!1||!t()?!1:n(uT)!==!1}catch{return!1}}}function fT(t){return!t||typeof t!="object"?!1:!!t.shiftKey}function pT(t){return!t||typeof t!="object"||String(t.key||"").toLowerCase()!=="c"?!1:!!(t.metaKey||t.ctrlKey&&t.shiftKey)}function mT(t){return/mac|iphone|ipad/i.test(String(t||""))?"⌘C":"Ctrl+Shift+C"}const gT=450,w0=8;function b0(t,e,n,s){return Math.abs(Number(n)-Number(t))>w0||Math.abs(Number(s)-Number(e))>w0}function vT({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 _T(t){const e=t!=="mouse";return{handles:e,magnifier:e}}function yT(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 S0(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 wT({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 La({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 x0({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 bT({startLeft:t,endLeft:e,targetWidth:n=46}){return Math.abs(Number(e)-Number(t))<Number(n)}function ST({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 k=Number(e)-Number(h)-g,R=!1;k<v&&(k=Number(e)+Number(c)+Number(h),R=!0);const C=Math.max(v,Number(s)-v-g);return k>C&&(k=C),{left:b,top:k,flipped:R}}function k0(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 C0=28,xT=50;function kT({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),k=(g==="start"?Number(v.col):Number(v.col)+1)*Number(i),R=g==="start"?k-C0<0:k+C0>f;h[g]={left:Number(c)+k,top:Number(u)+(_+1)*Number(a),visible:b,flip:R}}return h}function CT({visibleRow:t,rows:e}){const n=Number(t);return n<=0?-1:n>=Number(e)-1?1:0}function ET({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 dg="(min-width:1024px) and (pointer:fine)";function Ek(){const[t,e]=w.useState(()=>window.matchMedia(dg).matches);return w.useEffect(()=>{const n=window.matchMedia(dg),s=i=>e(i.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),t}const NT=new Map([["image/png","png"],["image/jpeg","jpg"],["image/gif","gif"],["image/webp","webp"],["application/pdf","pdf"],["text/plain","txt"]]);function wp(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 E0(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 RT(t,e=0,n=Date.now()){const s=String((t==null?void 0:t.name)||"").trim();if(s)return s;const i=NT.get(String((t==null?void 0:t.type)||"").toLowerCase())||"bin";return`clipboard-${n}-${e+1}.${i}`}async function hg({files:t,token:e,session:n,node:s="",paste:i=!0,fetchImpl:a=Wn,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=_n(s?String(s).split("/"):[]);for(let _=0;_<h.length;_+=1){const b=h[_],k=RT(b,_,u);c({index:_,total:h.length,name:k,state:"uploading"});try{const R=new FormData;R.append("session",n),R.append("paste",i?"true":"false"),R.append("file",b,k);const C=await a(`${v}/files/upload`,e,{method:"POST",body:R}),L=await C.json().catch(()=>({}));if(!C.ok||L.error)throw new Error(L.error||`HTTP ${C.status}`);f.push(L.path),c({index:_,total:h.length,name:k,state:"done",path:L.path})}catch(R){const C=String((R==null?void 0:R.message)||R);g.push({name:k,message:C}),c({index:_,total:h.length,name:k,state:"error",error:C})}}return{paths:f,errors:g}}const LT=420,AT=32;function jT(t){if(!t||typeof t!="object")return!1;const e=String(t.tagName||"").toLowerCase();return e==="textarea"||e==="input"||t.isContentEditable===!0}function fg({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(jT(a)&&typeof a.blur=="function")try{a.blur(),c=!0}catch{}return{blurred:c,apiRequested:i}}function Nk(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 MT(t,e){if(!t||!t.textarea)return!1;Nk(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 TT(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<=LT&&Math.hypot(n.x-e.x,n.y-e.y)<=AT?{open:!0,next:null}:{open:!1,next:n}}const PT=24,N0=80,Rk=8,IT="\x1B[5~",DT="\x1B[6~",OT=64,BT=65;function $T(t,e,n){const s=t==="up"?OT:BT,i=a=>Math.max(1,Math.min(9999,Number.isFinite(a)?Math.round(a):1));return`\x1B[<${s};${i(e)};${i(n)}M`}function zT({alternateScreen:t=!1,readonly:e=!1,mouseTracking:n=!1}={}){return e?"scroll":n?"mouse":t?"page":"scroll"}function FT(t,e){return t==="page"?Number.isFinite(e)&&e>0?Math.max(N0,e):N0:Number.isFinite(e)&&e>0?e:PT}function HT({mode:t="scroll",accumulated:e=0,threshold:n=0}={}){const s=FT(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,Rk),u=(e>=0?1:-1)*(i%s);return{mode:t,up:e>0?c:0,down:e<0?c:0,remainder:u}}function UT(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(Rk,Number.isFinite(u)?Math.max(0,Math.floor(u)):0),c=u=>t.mode==="mouse"?{kind:"input",seq:$T(u,s,i)}:t.mode==="page"?{kind:"input",seq:u==="up"?IT:DT}:{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 gc({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:k,fontSize:R=13,selectionMode:C=!1,onSelectionModeChange:L,keyboardGesture:S="double-tap",onRendererChange:T}){const E=w.useRef(null),H=w.useRef(null),F=w.useRef(null),X=w.useRef(R);X.current=R;const V=w.useRef(a);V.current=a;const G=w.useRef(C);G.current=C;const ne=w.useRef(S);ne.current=S;const[Y,B]=w.useState(""),[P,D]=w.useState(""),[M,$]=w.useState(null),[A,j]=w.useState(null),[N,U]=w.useState(!1),[I,W]=w.useState(0),se=w.useRef(null),me=w.useRef(null),[pe,Ie]=w.useState(!1),[J,te]=w.useState(null),ge=w.useRef(null),[Se,Be]=w.useState(null),[Le,ze]=w.useState(0),[Q,ve]=w.useState(null),[Z,be]=w.useState("start"),[K,fe]=w.useState(null),[Re,Ee]=w.useState(!1),[qe,Ze]=w.useState(null),[at,Oe]=w.useState(null),_e=w.useRef(null),$e=w.useRef(null),[nt,Fe]=w.useState(!1),rt=async()=>{var ft,Pt,bt,xt;const ie=((Pt=(ft=H.current)==null?void 0:ft.term)==null?void 0:Pt.getSelection())||Y;if(!ie){D(p("copy-empty")),setTimeout(()=>D(""),1500);return}const Pe=await ug(ie);D(p(Pe?"copied":"copy-manual")),Pe&&((xt=(bt=H.current)==null?void 0:bt.term)==null||xt.clearSelection(),B(""),Ie(!1),L==null||L(!1)),setTimeout(()=>D(""),1800)},re=w.useRef(rt);re.current=rt;const ce=w.useRef({startHandleDrag:()=>{}}),O=w.useRef(null);O.current=Se,w.useEffect(()=>{const ie=E.current;ie&&(ie.dataset.selectionOrigin=at||"")},[at]),w.useEffect(()=>{const ie=H.current;ie&&ie.sock&&ie.sock.focus&&ie.sock.focus(!!a)},[a]),w.useEffect(()=>{const ie=H.current;ie&&(ie.term.options.fontSize=R,ie.fit.fit(),ie.sock.resize(ie.term.cols,ie.term.rows))},[R]),w.useEffect(()=>{var ie,Pe;(Pe=(ie=H.current)==null?void 0:ie.setKeyboardGesture)==null||Pe.call(ie,S)},[S]),w.useEffect(()=>{var Di,ar,lr,Gc,ta,na,mo,sa,dl,xi,ia;const ie=new oj({cursorBlink:!0,fontSize:X.current,scrollback:1e3,allowProposedApi:!0,theme:{background:"#0a0e0a"}}),Pe=new cj;ie.loadAddon(Pe),ie.open(E.current),Pe.fit(),mj(ie);const ft=QM(ie,{preference:Ec(),createAddon:()=>new XM,onFallback:()=>{T&&T("dom")}});F.current=ft,T&&T(ft.kind);let Pt=!1,bt=!1;const xt=ye=>Ye=>{for(const tt of Ye){const dt=Array.isArray(tt)?tt[0]:tt;dt===1006&&(Pt=ye),dt===1016&&(bt=ye)}return!1};(ar=(Di=ie.parser)==null?void 0:Di.registerCsiHandler)==null||ar.call(Di,{prefix:"?",final:"h"},xt(!0)),(Gc=(lr=ie.parser)==null?void 0:lr.registerCsiHandler)==null||Gc.call(lr,{prefix:"?",final:"l"},xt(!1)),(na=(ta=ie.parser)==null?void 0:ta.registerEscHandler)==null||na.call(ta,{final:"c"},()=>(Pt=!1,bt=!1,!1));let vt=null;lT(ie,s?null:ye=>vt&&vt(ye));const Mt=()=>{const ye=Pt&&!bt&&(ie.modes&&ie.modes.mouseTrackingMode||"none")!=="none",Ye=E.current;return Ye&&(Ye.dataset.mouseTracking=ye?"on":"off"),ye},Qt=new TextDecoder;let Dt=ne.current==="single-tap",It=null;const en=()=>{Dt=ne.current==="single-tap",Nk(ie,ne.current,Dt)},Kn=ye=>{ne.current=ye,It=null,en()},rn=()=>ne.current==="never"?!1:(Dt=!0,MT(ie));b&&(b.current=rn),en();const tn=ie.textarea,nn=()=>{ne.current==="double-tap"&&en()};tn==null||tn.addEventListener("blur",nn);let mn=!1,Wt=0;const Zt=()=>{mn=!0,Wt=Date.now()+2e3},yn=()=>{mn=!1};(mo=E.current)==null||mo.addEventListener("paste",Zt,!0),(sa=E.current)==null||sa.addEventListener("keydown",yn,!0);let Vt;try{Vt=iT({session:t,node:e,token:n,readonly:s,takeSize:i,focused:V.current,onFiles:k,cols:ie.cols,rows:ie.rows,onData:ye=>y0(ie,Qt.decode(ye)),onExit:()=>y0(ie,`\r
|
|
154
|
+
\x1B[33m[sessione finita]\x1B[0m\r
|
|
155
|
+
`),onSnapshot:ye=>{try{const Ye=ie.buffer&&ie.buffer.active,tt=oT({viewportY:Ye?Ye.viewportY:0,baseY:Ye?Ye.baseY:0},{baseY:Ye?Ye.baseY:0});ie.reset(),ie.write(ye),!tt.atBottom&&tt.line!==null&&typeof ie.scrollToLine=="function"&&ie.scrollToLine(tt.line)}catch{}},onQueued:ye=>W(ye),onLink:ye=>{if(me.current&&(clearTimeout(me.current),me.current=null),ye==="live"){const Ye=se.current!==null&&rT(se.current,Date.now());if(se.current=null,U(!1),Ye)try{ie.write(aT(!0))}catch{}return}se.current===null&&(se.current=Date.now()),me.current=setTimeout(()=>{me.current=null,U(!0)},kk().overlayDelayMs||Ck)}}),vt=ye=>Vt.sendInput(ye)}catch(ye){return ie.write(`\r
|
|
156
|
+
\x1B[31m${ye.message}\x1B[0m\r
|
|
157
|
+
`),b&&(b.current=null),tn==null||tn.removeEventListener("blur",nn),(dl=E.current)==null||dl.removeEventListener("paste",Zt,!0),(xi=E.current)==null||xi.removeEventListener("keydown",yn,!0),()=>{var Ye,tt;try{(tt=(Ye=F.current)==null?void 0:Ye.dispose)==null||tt.call(Ye)}catch{}F.current=null,ie.dispose()}}H.current={term:ie,fit:Pe,sock:Vt,setKeyboardGesture:Kn};let ln=null;const Vs=ie.onData(ye=>{if(s){ln&&(ln.ok=!1);return}const Ye=mn&&Date.now()<Wt;yn(),!ln&&!Ye&&ye.length>=1&&(f&&f.current||v&&v.current)&&(ye=cT(ye,{ctrl:!!(f&&f.current),alt:!!(v&&v.current)}),f&&(f.current=!1),v&&(v.current=!1),g&&g(!1),_&&_(!1));const tt=Vt.sendInput(ye);ln&&(ln.seen=!0,ln.ok=ln.ok&&tt)});c&&(c.current=ye=>Vt.sendInput(ye)),h&&(h.current=ye=>Vt.action(ye)),u&&(u.current=hT({isReady:()=>!s&&Vt.isReady(),paste:ye=>{const Ye={seen:!1,ok:!0};ln=Ye;try{ie.paste(ye)}catch{Ye.ok=!1}finally{ln=null}return Ye.seen&&Ye.ok},send:ye=>Vt.sendInput(ye)}));const vs=ye=>{_e.current=ye,Oe(ye)};let qt=null;const Ys=ie.onSelectionChange(()=>{const ye=ie.getSelection();ye?(B(ye),Ie(!1)):Ie(!0);const Ye=yT(ie.getSelectionPosition(),ie.cols),tt=Ye?S0(Ye.start,Ye.end,ie.cols):null;te(tt),ge.current=tt,tt||vs(null),!tt&&qt&&jr();let dt=null;if(tt&&typeof ie.buffer.active.getLine=="function"){const Rt=[];for(let wt=tt.start.row;wt<=tt.end.row;wt++){const Kt=ie.buffer.active.getLine(wt);Rt.push(Kt?Kt.translateToString():"")}dt={startRow:tt.start.row,endRow:tt.end.row,lines:Rt}}$e.current=dt,Fe(!1)}),Vn=ie.onRender(ye=>{var Ye;if((Ye=ie.hasSelection)!=null&&Ye.call(ie)){const tt=$e.current,dt=ye&&ye.start,Rt=ye&&ye.end;if(tt&&Number.isInteger(dt)&&Number.isInteger(Rt)&&typeof ie.buffer.active.getLine=="function"){const wt=Number(ie.buffer.active.viewportY)||0,Kt=Math.max(wt+dt,tt.startRow),cn=Math.min(wt+Rt,tt.endRow);for(let Pn=Kt;Pn<=cn;Pn++){const Ln=ie.buffer.active.getLine(Pn);if((Ln?Ln.translateToString():"")!==tt.lines[Pn-tt.startRow]){Fe(!0);break}}}ze(wt=>wt+1)}}),ls=ie.onScroll(()=>{var ye;(ye=ie.hasSelection)!=null&&ye.call(ie)&&ze(Ye=>Ye+1)});ie.attachCustomKeyEventHandler(ye=>(ye.ctrlKey||ye.metaKey)&&ye.key.toLowerCase()==="c"&&ie.getSelection()?(ye.type==="keydown"&&ug(ie.getSelection()),!1):!0);const St=E.current;let le=!1;const oe=async ye=>{if(!ye.length||le)return;if(s){$({error:p("settings-readonly")});return}le=!0,$({current:0,total:ye.length,name:""});const Ye=await hg({files:ye,token:n,session:t,node:e,paste:!0,onProgress:({index:tt,total:dt,name:Rt,state:wt,error:Kt})=>$({current:tt+1,total:dt,name:Rt,...wt==="error"?{error:Kt}:{}})});le=!1,Ye.errors.length?$({error:Ye.errors.map(tt=>`${tt.name}: ${tt.message}`).join(" · ")}):($({done:!0,total:Ye.paths.length}),setTimeout(()=>$(null),1600))},Me=ye=>{const Ye=ye.clipboardData;if(!wp(Ye))return;const tt=E0(Ye);tt.length&&(ye.preventDefault(),ye.stopPropagation(),oe(tt))},Ke=ye=>{wp(ye.dataTransfer)&&(ye.preventDefault(),ye.stopPropagation())},mt=ye=>{wp(ye.dataTransfer)&&(ye.preventDefault(),ye.stopPropagation(),oe(E0(ye.dataTransfer)))};St.addEventListener("paste",Me,!0),St.addEventListener("dragenter",Ke,!0),St.addEventListener("dragover",Ke,!0),St.addEventListener("drop",mt,!0);const q=24,ae=(ye,Ye)=>{const dt=(St.querySelector(".xterm-screen")||St).getBoundingClientRect(),Rt=Math.floor((ye-dt.left)/Math.max(1,dt.width)*ie.cols)+1,wt=Math.floor((Ye-dt.top)/Math.max(1,dt.height)*ie.rows)+1;return{col:Math.max(1,Math.min(ie.cols,Rt)),row:Math.max(1,Math.min(ie.rows,wt))}},Te=(ye,Ye={mode:null,remainder:0},tt=null,dt=null)=>{const Rt=E.current,wt=Rt?Rt.getBoundingClientRect().height:q,Kt=zT({alternateScreen:ie.buffer.active.type==="alternate",readonly:s,mouseTracking:Mt()}),cn=Kt==="mouse"?"mouse":tt||Kt,Pn=Ye.mode===cn?Ye.remainder+ye:ye,Ln=HT({mode:cn,accumulated:Pn,threshold:cn==="page"?wt:q});for(const bs of UT(Ln,dt))bs.kind==="input"?Vt.sendInput(bs.seq):Vt.action(bs.name);return{mode:cn,remainder:Ln.remainder}};let Ge=null,Ae=null,Ct=null,_t=null,Qe=!1,Lt=!1,Tn={mode:null,remainder:0},Xe=null,st=null,Ht=null,ke=!1;const je=750;let Je=0;const ct=()=>{Ht&&clearTimeout(Ht),Ht=null},kt=(ye,Ye)=>{const dt=(St.querySelector(".xterm-screen")||St).getBoundingClientRect(),Rt=Math.max(0,Math.min(ie.cols-1,Math.floor((ye-dt.left)/Math.max(1,dt.width)*ie.cols))),wt=Math.max(0,Math.min(ie.rows-1,Math.floor((Ye-dt.top)/Math.max(1,dt.height)*ie.rows)));return{col:Rt,row:ie.buffer.active.viewportY+wt}},Gs=()=>{const tt=(St.querySelector(".xterm-screen")||St).getBoundingClientRect().height/Math.max(1,ie.rows),dt=St.querySelector(".nc-sel-handle"),Rt=dt?dt.getBoundingClientRect().height:0;return-.3*(Rt>0?Rt:tt)},wi=(ye,Ye)=>kt(ye.clientX,ye.clientY+Ye),Jt=ye=>{const tt=(St.querySelector(".xterm-screen")||St).getBoundingClientRect(),dt=St.getBoundingClientRect(),Rt=tt.width/Math.max(1,ie.cols),wt=tt.height/Math.max(1,ie.rows),Kt=Number(ie.buffer.active.viewportY)||0,cn=Math.max(0,Math.min(ie.rows-1,ye.row-Kt));j({left:`${tt.left-dt.left+ye.col*Rt}px`,top:`${tt.top-dt.top+cn*wt}px`,width:`${Rt}px`,height:`${wt}px`})},_s=ye=>{if(Je=Date.now(),vs("touch"),ct(),ke=!1,Qe=!1,Lt||ye.touches.length!==1){Lt=!0,Qe=!0,It=null,j(null),Ge=null,Ae=null,Ct=null,_t=null;return}if(G.current){ye.preventDefault(),ye.stopPropagation();const tt=kt(ye.touches[0].clientX,ye.touches[0].clientY),dt=ie.buffer.active.getLine(tt.row),Rt=La({line:dt,col:tt.col,side:"start",cols:ie.cols}),wt=x0({line:dt,col:Rt,cols:ie.cols});st={row:tt.row,col:wt.start};const Kt={row:tt.row,col:wt.end};ie.clearSelection(),vs("touch"),Ee(!0),be("end"),ie.select(wt.start,tt.row,wt.end-wt.start+1),Jt(Kt);return}Ge=ye.touches[0].clientY,Ae=ye.touches[0].clientX,Ct=Ae,_t=Ge,Tn={mode:null,remainder:0},Xe=null;const Ye={x:Ae,y:Ge};Ht=setTimeout(()=>{var cn;Ht=null,ke=!0,Qe=!0,It=null,G.current=!0,L==null||L(!0);const tt=kt(Ye.x,Ye.y),dt=ie.buffer.active.getLine(tt.row),Rt=La({line:dt,col:tt.col,side:"start",cols:ie.cols}),wt=x0({line:dt,col:Rt,cols:ie.cols});st={row:tt.row,col:wt.start};const Kt={row:tt.row,col:wt.end};ie.clearSelection(),vs("touch"),Ee(!0),be("end"),ie.select(wt.start,tt.row,wt.end-wt.start+1),Jt(Kt);try{(cn=navigator.vibrate)==null||cn.call(navigator,10)}catch{}Ge=null,Ae=null,Xe=null,Tn={mode:null,remainder:0}},gT)},Ot=ye=>{if(ke&&st&&ye.touches.length===1){ye.preventDefault(),ye.stopPropagation();const dt=kt(ye.touches[0].clientX,ye.touches[0].clientY),Rt=st.row*ie.cols+st.col,wt=dt.row*ie.cols+dt.col,Kt=Rt<=wt?"end":"start",cn=ie.buffer.active.getLine(dt.row),Pn=La({line:cn,col:dt.col,side:Kt,cols:ie.cols}),Ln={row:dt.row,col:Pn},bs=Ln.row*ie.cols+Ln.col,ii=Rt<=bs?st:Ln;be(Kt),ie.select(ii.col,ii.row,Math.abs(bs-Rt)+1),Jt(Ln);return}if(G.current&&st&&ye.touches.length===1){ye.preventDefault(),ye.stopPropagation();const dt=kt(ye.touches[0].clientX,ye.touches[0].clientY),Rt=st.row*ie.cols+st.col,wt=dt.row*ie.cols+dt.col,Kt=Rt<=wt?"end":"start",cn=ie.buffer.active.getLine(dt.row),Pn=La({line:cn,col:dt.col,side:Kt,cols:ie.cols}),Ln={row:dt.row,col:Pn},bs=Ln.row*ie.cols+Ln.col,ii=Rt<=bs?st:Ln;be(Kt),ie.select(ii.col,ii.row,Math.abs(bs-Rt)+1),Jt(Ln);return}if(Ge===null||ye.touches.length!==1)return;ye.preventDefault(),ye.stopPropagation();const Ye=ye.touches[0];if(b0(Ct,_t,Ye.clientX,Ye.clientY)&&(Qe=!0,It=null,Ht&&ct()),Xe===null&&(Math.abs(Ye.clientY-Ge)>8||Math.abs(Ye.clientX-Ae)>8)&&(Xe=Math.abs(Ye.clientY-Ge)>Math.abs(Ye.clientX-Ae)),!Xe)return;const tt=Ye.clientY-Ge;Ge=Ye.clientY,Tn=Te(tt,Tn,"scroll",ae(Ye.clientX,Ye.clientY))},Os=()=>{ct(),Ge=null,Ae=null,Ct=null,_t=null,st=null,ke=!1,Qe=!1,Lt=!1,j(null),Ee(!1),Tn={mode:null,remainder:0},Je=Date.now()},po=ye=>{if(Lt){It=null,ct(),(!ye.touches||ye.touches.length===0)&&Os();return}const Ye=ye.changedTouches&&ye.changedTouches[0];if(!Qe&&!ke&&!G.current&&Ye){const tt={at:Date.now(),x:Ye.clientX,y:Ye.clientY},dt=TT(ne.current,It,tt);It=dt.next,dt.open&&rn()}Os()},sr=()=>{It=null,Os()};let Gt={mode:null,remainder:0};const il=ye=>{ye.preventDefault(),ye.stopPropagation(),Gt=Te(-ye.deltaY,Gt,"scroll",ae(ye.clientX,ye.clientY))};St.addEventListener("touchstart",_s,{passive:!1}),St.addEventListener("touchmove",Ot,{passive:!1,capture:!0}),St.addEventListener("touchend",po,{passive:!0}),St.addEventListener("touchcancel",sr,{passive:!0});const rl=()=>{typeof window.matchMedia=="function"&&window.matchMedia(dg).matches||!G.current&&ne.current==="double-tap"&&rn()};St.addEventListener("dblclick",rl);const Qo=ye=>{(G.current||ke)&&(ye.preventDefault(),ye.stopPropagation())};St.addEventListener("contextmenu",Qo,!0),St.addEventListener("wheel",il,{passive:!1,capture:!0});let Xs=null;const ol=ye=>{Date.now()-Je>=je&&vs("mouse"),fT(ye)&&(ye.preventDefault(),ye.stopPropagation(),Xs={cell:kt(ye.clientX,ye.clientY),clientX:ye.clientX,clientY:ye.clientY,extendFrom:ge.current,dragged:!1})},al=ye=>{var Kt;if(!Xs){(Kt=ie.hasSelection)!=null&&Kt.call(ie)&&Mt()&&(ye.preventDefault(),ye.stopPropagation());return}if(ye.preventDefault(),ye.stopPropagation(),!Xs.dragged&&!b0(Xs.clientX,Xs.clientY,ye.clientX,ye.clientY))return;Xs.dragged=!0;const Ye=Xs.cell,tt=kt(ye.clientX,ye.clientY),dt=Ye.row*ie.cols+Ye.col,Rt=tt.row*ie.cols+tt.col,wt=dt<=Rt?Ye:tt;ie.select(wt.col,wt.row,Math.abs(Rt-dt)+1)},Zo=ye=>{if(!Xs)return;ye.stopPropagation();const{cell:Ye,extendFrom:tt,dragged:dt}=Xs;if(Xs=null,dt||!tt)return;const Rt=vT({range:tt,cell:Ye,cols:ie.cols});if(!Rt.moved)return;const wt=Rt[Rt.moved],Kt=ie.buffer.active.getLine(wt.row);wt.col=La({line:Kt,col:wt.col,side:Rt.moved,cols:ie.cols});const cn=k0({start:Rt.start,end:Rt.end},ie.cols);ie.select(cn.col,cn.row,cn.length)};St.addEventListener("mousedown",ol,!0),St.addEventListener("mousemove",al,!0),St.addEventListener("mouseup",Zo,!0);let ir=null,ys={x:0,y:0,type:"touch"};const Js=()=>{ir&&(clearInterval(ir),ir=null)},bi=(ye,Ye,tt)=>{if(!qt||!qt.fixed)return;const dt=qt.fixed,Rt=tt==="mouse"?kt(ye,Ye):wi({clientX:ye,clientY:Ye},Gs()),wt=ie.buffer.active.getLine(Rt.row),Kt={row:Rt.row,col:La({line:wt,col:Rt.col,side:qt.which,cols:ie.cols})},cn=Math.max(0,Number(ie.buffer.active.baseY||0)+ie.rows-1),Pn=wT({moving:Kt,fixed:dt,which:qt.which,cols:ie.cols,maxRow:cn}),Ln=k0(S0(Pn,dt,ie.cols),ie.cols);ie.select(Ln.col,Ln.row,Ln.length);const bs=Number(ie.buffer.active.viewportY)||0,ii=CT({visibleRow:Pn.row-bs,rows:ie.rows});Js(),!(ii===0||ie.buffer.active.type==="alternate")&&(ir=setInterval(()=>{const go=Number(ie.buffer.active.viewportY)||0;if(ie.scrollLines(ii),(Number(ie.buffer.active.viewportY)||0)===go){Js();return}bi(ys.x-qt.offsetX,ys.y-qt.offsetY,ys.type)},130))},rr=ye=>{qt&&(ye.preventDefault(),ys={x:ye.clientX,y:ye.clientY,type:ye.pointerType||ys.type},bi(ye.clientX-qt.offsetX,ye.clientY-qt.offsetY,ys.type))},jr=()=>{qt=null,Js(),ve(null),window.removeEventListener("pointermove",rr),window.removeEventListener("pointerup",Ls),window.removeEventListener("pointercancel",Ls)},Ls=()=>jr();ce.current={startHandleDrag:(ye,Ye)=>{if(!ie.getSelectionPosition())return;Ye.preventDefault(),Ye.stopPropagation();const tt=O.current&&O.current[ye],dt=St.getBoundingClientRect();qt={which:ye,offsetX:tt?Ye.clientX-(dt.left+tt.left):0,offsetY:tt?Ye.clientY-(dt.top+tt.top):0,fixed:ge.current?ye==="start"?ge.current.end:ge.current.start:null},ys={x:Ye.clientX,y:Ye.clientY,type:Ye.pointerType||"touch"},ve(ye),be(ye),window.addEventListener("pointermove",rr),window.addEventListener("pointerup",Ls),window.addEventListener("pointercancel",Ls)}};const Yc=ye=>{!pT(ye)||!(H.current&&H.current.term&&H.current.term.getSelection())||(ye.preventDefault(),ye.stopPropagation(),re.current&&re.current())};St.addEventListener("keydown",Yc,!0);const or=()=>{Pe.fit(),Vt.resize(ie.cols,ie.rows)};window.addEventListener("resize",or);const ws=window.visualViewport;let ll=ws&&Number(ws.height);const cl=()=>{const ye=ws&&Number(ws.height);Dt&&ne.current==="double-tap"&&Number.isFinite(ll)&&Number.isFinite(ye)&&ye>ll+80&&en(),ll=ye,or()};ws&&(ws.addEventListener("resize",cl),ws.addEventListener("scroll",or));const Yn=typeof navigator<"u"?navigator.virtualKeyboard:null,ul=()=>{var ye;Dt&&ne.current==="double-tap"&&Number(((ye=Yn==null?void 0:Yn.boundingRect)==null?void 0:ye.height)||0)===0&&en()};(ia=Yn==null?void 0:Yn.addEventListener)==null||ia.call(Yn,"geometrychange",ul);let ea=null,Si=0;return typeof ResizeObserver<"u"&&(ea=new ResizeObserver(()=>{Si&&cancelAnimationFrame(Si),Si=requestAnimationFrame(or)}),ea.observe(St)),()=>{var ye,Ye,tt;H.current=null,b&&(b.current=null),me.current&&(clearTimeout(me.current),me.current=null),c&&(c.current=()=>!1),u&&(u.current=()=>!1),h&&(h.current=()=>!1),Vs.dispose(),Ys.dispose(),Vn.dispose(),ls.dispose(),Js(),window.removeEventListener("pointermove",rr),window.removeEventListener("pointerup",Ls),window.removeEventListener("pointercancel",Ls),ce.current={startHandleDrag:()=>{}},St.removeEventListener("touchstart",_s),St.removeEventListener("touchmove",Ot,{capture:!0}),St.removeEventListener("touchend",po),St.removeEventListener("touchcancel",sr),St.removeEventListener("dblclick",rl),St.removeEventListener("contextmenu",Qo,!0),ct(),St.removeEventListener("wheel",il,{capture:!0}),St.removeEventListener("mousedown",ol,!0),St.removeEventListener("mousemove",al,!0),St.removeEventListener("mouseup",Zo,!0),St.removeEventListener("keydown",Yc,!0),St.removeEventListener("paste",Me,!0),St.removeEventListener("dragenter",Ke,!0),St.removeEventListener("dragover",Ke,!0),St.removeEventListener("drop",mt,!0),window.removeEventListener("resize",or),ws&&(ws.removeEventListener("resize",cl),ws.removeEventListener("scroll",or)),(ye=Yn==null?void 0:Yn.removeEventListener)==null||ye.call(Yn,"geometrychange",ul),tn==null||tn.removeEventListener("blur",nn),(Ye=E.current)==null||Ye.removeEventListener("paste",Zt,!0),(tt=E.current)==null||tt.removeEventListener("keydown",yn,!0),ea&&ea.disconnect(),Si&&cancelAnimationFrame(Si),Vt.close(),ie.dispose()}},[t,e,n,s,i,c,u,h,f,g,k]),w.useEffect(()=>{const ie=E.current,Pe=H.current?H.current.term:null;if(!ie||!Pe||!J){Be(null),fe(null),Ze(null);return}const Pt=(ie.querySelector(".xterm-screen")||ie).getBoundingClientRect(),bt=ie.getBoundingClientRect(),xt=Pt.width/Math.max(1,Pe.cols),vt=Pt.height/Math.max(1,Pe.rows),Mt=kT({range:J,viewportY:Number(Pe.buffer.active.viewportY)||0,rows:Pe.rows,cols:Pe.cols,cellWidth:xt,cellHeight:vt,screenLeft:Pt.left-bt.left,screenTop:Pt.top-bt.top});Be(Mt);let Qt=null;const Dt=J[Z==="end"?"end":"start"].row;typeof Pe.buffer.active.getLine=="function"&&(Qt=Pe.buffer.active.getLine(Number(Dt)));const It=Math.max(16,Math.round(vt*2)),en=Qt?{...ET({range:J,side:Z,line:Qt,cols:Pe.cols}),fontSize:It}:null;fe(en);const Kn=Q!==null||Re,rn=Mt[Z==="end"?"end":"start"];if(!Kn||!en||!rn||!rn.visible){Ze(null);return}const tn=(en.before+en.sel+en.after).length,nn=xt*(It/Math.max(1,vt)),mn=Math.min(bt.width-8,Math.round(tn*nn)+16),Wt=Math.round(It*1.25)+12;Ze(ST({anchorLeft:rn.left,anchorTop:rn.top,hostWidth:bt.width,hostHeight:bt.height,bubbleWidth:mn,bubbleHeight:Wt}))},[J,Le,Z,Q,Re]);const de=_T(at),we=w.useRef({}),We=(ie,Pe)=>{if(Q!==ie)return we.current[ie]={flip:Pe,ts:0},Pe;const ft=we.current[ie]||{flip:Pe,ts:0};if(ft.flip===Pe)return we.current[ie]=ft,Pe;const Pt=Date.now();return Pt-ft.ts<xT?ft.flip:(we.current[ie]={flip:Pe,ts:Pt},Pe)};return l.jsxs("div",{className:`nc-terminal${C?" selecting":""}`,children:[l.jsx("div",{className:"nc-terminal-host",ref:E}),N&&l.jsxs("div",{className:"nc-terminal-link-overlay",children:["riconnessione…",I>0?` (${I} byte in coda)`:""]}),A&&l.jsx("div",{className:"nc-touch-selection-caret",style:A,"aria-hidden":"true"}),J&&Se&&de.handles&&["start","end"].map(ie=>Se[ie].visible&&l.jsx("div",{className:`nc-sel-handle ${ie}${Q===ie?" dragging":""}${We(ie,Se[ie].flip)?" flip":""}${bT({startLeft:Se.start.left,endLeft:Se.end.left})?" tight":""}`,style:{left:`${Se[ie].left}px`,top:`${Se[ie].top}px`},onPointerDown:Pe=>ce.current.startHandleDrag(ie,Pe),"aria-hidden":"true"},`nc-sel-handle-${ie}`)),J&&K&&de.magnifier&&qe&&l.jsx("div",{className:`nc-zoom-bubble${qe.flipped?" flipped":""}`,style:{left:`${qe.left}px`,top:`${qe.top}px`},"aria-hidden":"true",children:l.jsxs("pre",{className:"nc-zoom-line",style:{fontSize:`${K.fontSize}px`},children:[l.jsx("span",{children:K.before}),l.jsx("span",{className:"nc-zoom-sel",children:K.sel}),l.jsx("span",{children:K.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))}),(Y||C)&&l.jsxs("div",{className:"nc-selection-tools",children:[Y?l.jsx("button",{type:"button",onClick:rt,children:P||`${p("copy")} · ${mT(typeof navigator<"u"?navigator.userAgent:"")}`}):l.jsx("span",{children:p("select-drag")}),Y&&pe&&l.jsx("span",{className:"nc-selection-held",children:p("selection-held")}),Y&&!pe&&nt&&l.jsx("span",{className:"nc-selection-changed",children:p("selection-changed")}),l.jsx("button",{type:"button",onClick:()=>{var ie,Pe;(Pe=(ie=H.current)==null?void 0:ie.term)==null||Pe.clearSelection(),B(""),Ie(!1),L==null||L(!1)},children:p("cancel")}),P===p("copy-manual")&&l.jsx("textarea",{readOnly:!0,value:Y,onFocus:ie=>ie.target.select()})]})]})}let Lk=new Set;function WT(t){Lk=new Set(Array.isArray(t)?t.filter(e=>typeof e=="string"):[])}function qT(t){return Array.isArray(t)&&t.some(e=>Lk.has(e))}function Nc(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 KT=6901,VT="allow-scripts allow-forms allow-popups allow-modals allow-downloads allow-pointer-lock";function bv({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=qT(_)?VT:null,k=w.useRef(0),R=w.useCallback(async()=>{if(!t||!i||!e){h("none");return}const P=k.current+=1;h("requesting");const D=new AbortController,M=setTimeout(()=>D.abort(),c);try{const $=await MN(i,_,t,{signal:D.signal});if(clearTimeout(M),P!==k.current)return;if($.ok){let A="/";try{A=new URL(e).pathname||"/"}catch{}const j=s?`http://127.0.0.1:${s}`:_n(_);g(`${j}/panel/${encodeURIComponent(t)}${A}?ticket=${encodeURIComponent($.ticket)}`),h("ready")}else h($.cause)}catch($){if(clearTimeout(M),P!==k.current)return;h($&&$.name==="AbortError"?"timeout":"unreachable")}},[t,e,_,s,i,c]),C=w.useCallback(()=>{h(P=>P==="ready"?"loaded":P)},[]),L=w.useCallback(()=>{h(P=>P==="ready"||P==="loaded"?"frame-error":P)},[]),S=w.useRef(null),T=w.useCallback(P=>{P&&(S.current=P,P.onload=C,P.onerror=L)},[C,L]);w.useEffect(()=>{R()},[R]);const H=w.useMemo(()=>{try{return Number(new URL(e).port)===KT}catch{return!1}},[e])&&_.length===0,[F,X]=w.useState(!1),[V,G]=w.useState("");w.useEffect(()=>{const P=D=>{const M=S.current;if(!M||!M.contentWindow||D.source!==M.contentWindow)return;let $=null;try{$=new URL(f,window.location.href).origin}catch{return}!$||D.origin!==$||!D.data||D.data.type!=="nc-panel-unreachable"||h(A=>A==="ready"||A==="loaded"?"unreachable":A)};return window.addEventListener("message",P),()=>window.removeEventListener("message",P)},[f]);const ne=w.useCallback(async()=>{if(!i||F)return;X(!0),G("");let P=!1;try{const D=await z1(i,!0);D&&D.ok===!1&&(G(D.error||"comando fallito"),P=!0)}catch(D){G(String(D&&D.message||D)),P=!0}X(!1),P||R()},[i,F,R]),Y=(P,D=!0,M=null)=>l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsx("span",{children:p(P)}),D&&l.jsxs("span",{className:"nc-cellpanel-actions",children:[M,l.jsx("button",{type:"button",title:p("panel-retry"),onClick:()=>R(),children:p("panel-retry")})]})]}),B=H?l.jsx("button",{type:"button",disabled:F,onClick:ne,children:p("panel-start-desktop")}):null;return u==="none"||u==="no-panel"?Y("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"?Y("panel-not-granted",!1):u==="node-refused"?Y("panel-node-refused",!1):u==="unauthorized"?Y("panel-unauthorized",!1):u==="denied"?Y("panel-denied"):u==="timeout"?Y("panel-timeout"):u==="unreachable"?l.jsxs("div",{className:"nc-cellpanel nc-cellpanel-msg",role:"status",children:[l.jsxs("span",{children:[p("panel-unreachable"),V?` — ${V}`:""]}),l.jsxs("span",{className:"nc-cellpanel-actions",children:[B,l.jsx("button",{type:"button",title:p("panel-retry"),onClick:()=>R(),children:p("panel-retry")})]})]}):u==="frame-error"?Y("panel-frame-error",!0,B):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:T,className:"nc-cellpanel nc-cellpanel-frame","data-frame-state":u,src:f,title:a||p("panel"),allowFullScreen:!0,...b?{sandbox:b}:{}})]})}const YT=1800*1e3;function pg(t,e,n=Date.now()){const s=Number(e);if(!Number.isFinite(s)||s<=0)return"";const i=n-s;if(i<0||i>YT)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 mg(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 Sv({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=V=>c&&c(V),v=w.useRef(()=>{}),_=w.useRef(()=>!1),b=w.useRef(()=>{}),k=w.useRef(!1),[R,C]=w.useState(!1),[L,S]=w.useState(""),[T,E]=w.useState(!1),H=!!(s&&s.cell&&s.cell===t.cellName),F=async()=>{E(!0);const V=await nh({action:H?"remove":"use",cellId:t.cellName,route:t.route||[],token:e,api:{getLiveHost:G=>Qd(e,G),designateHostCell:(G,ne,Y)=>Zd(e,G,ne,Y),clearHostCell:(G,ne)=>eh(e,G,ne)}});E(!1),S(p(V.messageKey).replace("{cell}",V.hostCell||t.cellName)),V.ok&&i&&i({route:t.route||[],hostCell:V.hostCell,revision:V.revision})},X=[["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:X.map(([V,G])=>l.jsx("button",{type:"button",role:"tab","aria-selected":a===V,className:`nc-peek-sorgente${a===V?" attiva":""}`,onClick:()=>g(V),children:G},V))}),f&&l.jsxs("div",{className:"nc-peek-host",children:[l.jsx("button",{type:"button",className:"nc-peek-host-btn",disabled:T,onClick:F,children:p(H?"live-host-action-remove":"live-host-action-use")}),L&&l.jsx("div",{className:"nc-peek-notice",role:"status",children:L})]}),a==="stream"?l.jsx("div",{className:"nc-peek-stream",children:l.jsx(gc,{session:t.session,node:t.node||void 0,token:e,readonly:h,takeSize:!1,focused:!0,sendRef:v,composerRef:_,actionRef:b,ctrlRef:k,setCtrlArmed:C,fontSize:u},`peek:${t.key}`)}):a==="panel"?l.jsx(bv,{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")}),[pg(p,t.activity),mg(p,t.telemetry)].filter(Boolean).join(" · ")&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:[pg(p,t.activity),mg(p,t.telemetry)].filter(Boolean).join(" · ")})]})]})}function Ak({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(sx,{title:t.cellName,subtitle:[t.nodeLabel,t.subtitle].filter(Boolean).join(" · "),onClose:i,children:l.jsx(Sv,{row:t,token:e,panelPort:s,liveHost:a,onLiveHostApplied:c,source:u,onSourceChange:h})})}const Rc="nc_order_journal_v1",GT=50,bp="__corrupt",XT=200,JT=200,QT=["reason","key","position","source","target","note"],ZT=["before","after","visible"],jk=t=>String(t).slice(0,JT),eP=t=>Array.isArray(t)?t.slice(0,XT).map(jk):void 0,lh=t=>{try{return t||globalThis.localStorage}catch{return null}};function tP(t){const e={t:Date.now()};for(const n of QT)t[n]!==void 0&&t[n]!==null&&(e[n]=jk(t[n]));for(const n of ZT){const s=eP(t[n]);s&&(e[n]=s)}return e}function xv(t,e,n){const s=lh(n);if(!s||e===null||e===void 0)return!1;try{if(s.getItem(t+bp)===e)return!1;s.setItem(t+bp,e)}catch{return!1}return t!==Rc&&Gi({reason:"corrupt-preserved",key:t,note:`${String(e).length} caratteri conservati in ${t}${bp}`},s),!0}function gg(t){const e=lh(t);if(!e)return[];let n=null;try{n=e.getItem(Rc)}catch{return[]}if(n===null)return[];try{const s=JSON.parse(n);if(Array.isArray(s))return s}catch{}return xv(Rc,n,e),[]}function Gi(t,e){const n=lh(e);if(!(!n||!t))try{const s=[...gg(n),tP(t)].slice(-GT);n.setItem(Rc,JSON.stringify(s))}catch{}}function nP(t){const e=lh(t);if(e)try{e.removeItem(Rc)}catch{}}function Ar(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 xv(t,a,i),n()}function _i(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{xv(t,i,s)}return s.setItem(t,JSON.stringify(e)),null}catch(i){return i instanceof Error?i:new Error(String(i))}}const sP=["all","pinned","active","off","technical"],Vo="nc_sidebar_views_v1",Yo="nc_sidebar_order_v1";function Mk(t){return sP.includes(t)?t:"all"}function iP(t,e=[],n="all"){const s=Mk(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 rP(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 hc(t=globalThis.localStorage){return Ar(Yo,{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 Ti(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function oP(t,e=globalThis.localStorage){return _i(Yo,t,{storage:e}),t}function aP(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=Ti(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 bd(t=globalThis.localStorage){return Ar(Vo,{storage:t,fallback:()=>({}),parse:e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0})}function vg(t,e){var n,s;return{open:((n=t==null?void 0:t[e])==null?void 0:n.open)!==!1,filter:Mk((s=t==null?void 0:t[e])==null?void 0:s.filter)}}function lP(t,e=globalThis.localStorage){return _i(Vo,t,{storage:e}),t}function R0(t,e=""){const n=String(e||"").trim().toLocaleLowerCase();return n?[t.label,t.key,t.searchText].filter(Boolean).join(" ").toLocaleLowerCase().includes(n):!0}function lo(t=[],e=[],n="all",s=[]){return[...t].filter(i=>iP(i,e,n)).sort((i,a)=>rP(i,a,e,s))}function $n(){return[w.useSyncExternalStore(B5,Nd,Nd),O5]}function Dd({cell:t,token:e,route:n=[],onConfirm:s,onClose:i}){var $,A;$n();const a=!!(t&&t.active),c=Array.isArray(n)?n.join("/"):"",[u,h]=w.useState([]),[f,g]=w.useState(!1);w.useEffect(()=>{let j=!0;return(async()=>{if(e)try{const N=await Ja(e,c?c.split("/"):[]);if(!j)return;if(g(N.provider==="builtin"&&(N.capabilities||[]).includes("edit")),N.provider==="builtin"&&(N.capabilities||[]).includes("definitions")){const U=await Xd(e,c?c.split("/"):[]);if(!j)return;const I=new Map((N.engines||[]).map(W=>[W.id,W]));h((U.engines||[]).map(W=>{var se,me,pe,Ie,J,te,ge;return{id:W.id,label:W.label||W.id,client:((se=W.managed)==null?void 0:se.client)||"",models:[...new Set([...((me=I.get(W.id))==null?void 0:me.models)||[],...((pe=W.managedInfo)==null?void 0:pe.models)||[]])].filter(Boolean),defaultModel:((Ie=W.managed)==null?void 0:Ie.model)||((J=W.managedInfo)==null?void 0:J.defaultModel)||"",policyDefault:((te=W.managed)==null?void 0:te.permissionPolicy)||((ge=W.managed)!=null&&ge.client&&W.managed.client==="claude"?"unsafe":"standard")}}))}}catch{}})(),()=>{j=!1}},[e,c]);const v=(t==null?void 0:t.engine)||(($=u[0])==null?void 0:$.id)||"",_=j=>(t==null?void 0:t.models)&&t.models[j]||"",b=j=>{const N=(t==null?void 0:t.permissionPolicies)&&t.permissionPolicies[j];if(N==="standard"||N==="unsafe")return N;const U=u.find(I=>I.id===j);return U?U.policyDefault:"standard"},[k,R]=w.useState(v),[C,L]=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:((A=t==null?void 0:t.permissionPolicies)==null?void 0:A[t==null?void 0:t.engine])||"",[T,E]=w.useState(S),[H,F]=w.useState((t==null?void 0:t.boot)??!0),[X,V]=w.useState(!1),[G,ne]=w.useState(null);w.useEffect(()=>{u.length&&(R(j=>j||v),L(j=>j||_((t==null?void 0:t.engine)||v)||""),E(j=>j==="standard"||j==="unsafe"?j:b((t==null?void 0:t.engine)||v)))},[u.length]);const Y=w.useMemo(()=>u.find(j=>j.id===k)||null,[u,k]),B=!!(Y&&["claude","codex","codex-vl","agy","kimi"].includes(Y.client)),P=(Y==null?void 0:Y.client)==="shell";function D(j){R(j);const N=u.find(U=>U.id===j);L(_(j)||(N==null?void 0:N.defaultModel)||""),E(b(j))}async function M(j){j.preventDefault(),V(!0),ne(null);try{if(a)await s({action:"down",boot:H});else{const N=T==="standard"||T==="unsafe"?T:(Y==null?void 0:Y.policyDefault)||"standard";await s({action:"up",...f?{engine:k,model:C||"",...B?{permissionPolicy:N}:(Y==null?void 0:Y.client)==="pi"?{permissionPolicy:"standard"}:{}}:{},boot:H})}i()}catch(N){ne(String(N&&N.message||N)),V(!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:j=>j.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:H,onChange:j=>F(j.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:k,onChange:j=>D(j.target.value),children:u.map(j=>l.jsx("option",{value:j.id,children:j.label},j.id))})]}),!P&&l.jsxs("label",{className:"nc-field",children:[p("model"),l.jsx("input",{value:C,list:"nc-launch-models",placeholder:p("model-default"),onChange:j=>L(j.target.value)}),l.jsx("datalist",{id:"nc-launch-models",children:((Y==null?void 0:Y.models)||[]).map(j=>l.jsx("option",{value:j},j))})]}),B?l.jsxs("label",{className:"nc-field",children:[p("permissions"),l.jsxs("select",{value:T,onChange:j=>E(j.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")}),B&&T==="unsafe"&&l.jsx("small",{className:"nc-err",children:p("fleet-unsafe-warning")}),l.jsx("small",{className:"nc-note",children:p(P?"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:H,onChange:j=>F(j.target.checked)}),p("boot-persist")]})]}),G&&l.jsx("div",{className:"nc-err",children:G}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:i,children:p("cancel")}),l.jsx("button",{type:"submit",className:"nc-btn primary",disabled:X,children:p(X?a?"power-stopping":"power-starting":a?"power-off":"save-and-start")})]})]})})}const L0=/^[a-z0-9-]{1,32}$/;function Lc(t,e){const n=Array.isArray(t)?t:[];return n.length?`${n.map(encodeURIComponent).join("/")}:${e}`:String(e)}function cP(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 _g(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 Yl(t,e,n){if(!t)return{};const s=yg(t);return!fc(t,s)||s!=="stale"?{}:{cells:_g(t,e,n,!0),fleetState:"stale",fleetAvailable:!1,cellsPreserved:!0}}function yg(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 fc(t,e){return(e==="available"||e==="stale")&&Array.isArray(t==null?void 0:t.cells)}function A0(t,e){const n=t?e&&e.at:e&&e.lastGoodAt;return Number.isFinite(n)?n:null}function j0({nodes:t,topology:e,remote:n,down:s,fleet:i,aliases:a,pendingReads:c,previousGroups:u}={}){var k,R,C,L;const h=[],f=new Set,g=new Set,v=(S,T)=>!!(c&&(c.has(S)||c.has(`${S}#${T}`))),_=(S,T,E)=>Array.isArray(u)?u.find(H=>H.name===T&&H.instanceId===E&&(Array.isArray(H.route)?H.route.join("/"):"")===S):null;function b(S,T){const E=_(S,T.name,T.instanceId),H=v(S,"sessions"),F=v(S,"fleet"),X=(n==null?void 0:n[S])||(H&&E?{sessions:E.sessionsAvailable?E.sessions:void 0,at:E.verifiedAt,lastGoodAt:E.verifiedAt,...E.sessionsAvailable===!1&&E.cause?{cause:E.cause}:{}}:null),V=(i==null?void 0:i[S])||(F&&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(H||F)&&(T.checking=!0,T.sessionsPending=H,T.fleetPending=F),{r:X,f:V,previous:E,pending:H||F,rereading:E&&(H||F)&&!(n!=null&&n[S])&&!(i!=null&&i[S])}}for(const S of Array.isArray(t)?t:[]){if(!S||typeof S.name!="string"||!L0.test(S.name)||S.direction==="inbound"&&S.shared!==!0)continue;const T=[S.name],E=S.name;f.add(E);const H=((k=S.tunnel)==null?void 0:k.status)||"unknown",F=H==="up",X={name:S.name,label:S.label||S.name,originalLabel:S.label||S.name,alias:null,route:T,direct:!0,instanceId:S.nodeId||null,shared:S.shared===!0,stale:S.stale===!0,tunnelStatus:H,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({...X,status:"needs-repair",downSince:s&&s[E]||null,...Yl(i&&(i[E]||i[S.name]),T,E)});continue}if(((R=S.health)==null?void 0:R.auth)==="failed"||H==="degraded"&&((C=S.health)==null?void 0:C.status)==="degraded"){h.push({...X,status:"needs-repair",downSince:s&&s[E]||null,...Yl(i&&(i[E]||i[S.name]),T,E)});continue}if(H==="passive"||((L=S.health)==null?void 0:L.status)==="passive"){h.push({...X,status:"passive",downSince:null,...Yl(i&&(i[E]||i[S.name]),T,E)});continue}if(!F){h.push({...X,status:"down",downSince:s&&s[E]||null,...Yl(i&&(i[E]||i[S.name]),T,E)});continue}const{r:V,f:G,previous:ne,pending:Y,rereading:B}=b(E,X);if(B){h.push({...ne,checking:!0,sessionsPending:X.sessionsPending,fleetPending:X.fleetPending});continue}const P=!!(V&&!V.error&&Array.isArray(V.sessions)),D=yg(G),M=D==="available"&&fc(G,D),$=fc(G,D);if(Y&&!V&&!G){h.push({...X,status:(ne==null?void 0:ne.status)||"pending",pendingRead:!0,verifiedAt:(ne==null?void 0:ne.verifiedAt)??null});continue}if(!P&&!$){h.push({...X,status:Y?(ne==null?void 0:ne.status)||"pending":"unreachable",cause:V&&V.cause||null});continue}const A=(P?V.sessions:[]).filter(U=>U&&typeof U.name=="string"&&U.name).map(U=>({...U,node:E,route:T,key:`${E}:${U.name}`})),j=_g(G,T,E),N=new Set(j.map(U=>U.tmuxSession).filter(Boolean));h.push({...X,status:"up",sessions:A,cells:j,unmanaged:A.filter(U=>!N.has(U.name)),fleetAvailable:M,fleetState:D,...G!=null&&G.cellsPreserved?{cellsPreserved:!0}:{},...V!=null&&V.cause||G!=null&&G.cause?{cause:(V==null?void 0:V.cause)||(G==null?void 0:G.cause)}:{},capabilities:G&&G.capabilities||[],engines:G&&G.engines||[],fleetProvider:G&&G.provider||null,sessionsAvailable:P,inventoryPartial:!P,verifiedAt:A0(P,V)})}for(const S of Array.isArray(e)?e:[]){if(!S||!Array.isArray(S.route)||S.route.length<1||S.route.some(N=>!L0.test(N)))continue;const T=S.route.join("/");if(f.has(T)||S.instanceId&&g.has(S.instanceId))continue;S.instanceId&&g.add(S.instanceId);const E=S.label||S.route.join(" › "),H=S.instanceId&&a&&typeof a[S.instanceId]=="string"?a[S.instanceId]:null,F={name:S.name,label:H||E,originalLabel:E,alias:H,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({...F,status:"offline",downSince:s&&s[T]||S.lastSeen||null,...Yl(i&&i[T],S.route,T)});continue}const{r:X,f:V,previous:G,pending:ne,rereading:Y}=b(T,F);if(Y){h.push({...G,checking:!0,sessionsPending:F.sessionsPending,fleetPending:F.fleetPending});continue}const B=!!(X&&!X.error&&Array.isArray(X.sessions)),P=yg(V),D=P==="available"&&fc(V,P),M=fc(V,P);if(ne&&!X&&!V){h.push({...F,status:(G==null?void 0:G.status)||"pending",pendingRead:!0,verifiedAt:(G==null?void 0:G.verifiedAt)??null});continue}if(!B&&!M){h.push({...F,status:ne?(G==null?void 0:G.status)||"pending":"unreachable",downSince:s&&s[T]||null,cause:X&&X.cause||null});continue}const $=(B?X.sessions:[]).filter(N=>N&&typeof N.name=="string"&&N.name).map(N=>({...N,node:T,route:S.route,key:`${T}:${N.name}`})),A=_g(V,S.route,T),j=new Set(A.map(N=>N.tmuxSession).filter(Boolean));h.push({...F,status:"up",sessions:$,cells:A,unmanaged:$.filter(N=>!j.has(N.name)),fleetAvailable:D,fleetState:P,...V!=null&&V.cellsPreserved?{cellsPreserved:!0}:{},...X!=null&&X.cause||V!=null&&V.cause?{cause:(X==null?void 0:X.cause)||(V==null?void 0:V.cause)}:{},capabilities:V&&V.capabilities||[],engines:V&&V.engines||[],fleetProvider:V&&V.provider||null,lastSeen:S.lastSeen||null,sessionsAvailable:B,inventoryPartial:!B,verifiedAt:A0(B,X)})}return h.sort((S,T)=>S.label.localeCompare(T.label))}const wg="nc_route_alias_v1",uP="nexuscrew-roster-preferences",M0="nc_pins",dP=/^[a-f0-9]{16,64}$/;let kv=new Map;const hP=t=>Array.isArray(t==null?void 0:t.route)&&t.route.length?t.route.join("/"):String((t==null?void 0:t.name)||"");function Sp(t,e=kv){if(t==="local"||typeof t!="string")return t;const n=e.get(t);return n?`id:${n}`:t}const T0=(t,e,n)=>typeof t=="string"&&t.startsWith(`${e}:`)?`${n}:${t.slice(e.length+1)}`:t,P0=t=>[...new Set(t)];function xp(t,e){return Ar(t,{storage:e,fallback:()=>({}),parse:n=>n&&typeof n=="object"&&!Array.isArray(n)?n:void 0})}function Aa(t,e=kv){const n={...t||{}};for(const[s,i]of e)t&&t[`id:${i}`]!==void 0&&(n[s]=t[`id:${i}`]);return n}function fP(t,{storage:e=globalThis.localStorage}={}){const n=new Map,s=new Map;for(const R of Array.isArray(t)?t:[]){const C=String((R==null?void 0:R.instanceId)||""),L=hP(R);if(!(dP.test(C)&&L)||n.has(L))continue;n.set(L,C);const S=R.status==="up"&&R.stale!==!0;(!s.has(C)||S&&!s.get(C).up)&&s.set(C,{name:L,up:S})}if(kv=n,!n.size)return!1;const i=xp(wg,e);let a=xp(Yo,e),c=xp(Vo,e),u=Ar(M0,{storage:e,fallback:()=>[],parse:R=>Array.isArray(R)?R:void 0});const h={...i},f={...a},g={...c};let v=[...u];const _={aliases:!1,orders:!1,views:!1,pins:!1};for(const[R,{name:C}]of s){const L=`id:${R}`,S=typeof i[R]=="string"?i[R]:"",T=S&&S!==C&&(!n.has(S)||n.get(S)===R)?S:"";T&&(v=P0([...v,...u.filter(E=>E.startsWith(`${T}:`)).map(E=>T0(E,T,C))]),_.pins=_.pins||v.length!==u.length);for(const[E,H,F]of[[a,f,"orders"],[c,g,"views"]]){const X=E[L]!==void 0?E[L]:T&&E[T]!==void 0?E[T]:E[C];if(X===void 0)continue;let V=X;F==="orders"&&Array.isArray(V)&&(V=P0(V.map(G=>T?T0(G,T,C):G))),JSON.stringify(H[L])!==JSON.stringify(V)&&(H[L]=V,_[F]=!0)}i[R]!==C&&(h[R]=C,_.aliases=!0),T&&Gi({reason:"route-renamed",key:R,note:`${T} -> ${C}`})}const b=[];_.pins&&b.push(_i(M0,v,{storage:e})),_.orders&&b.push(_i(Yo,f,{storage:e})),_.views&&b.push(_i(Vo,g,{storage:e})),_.aliases&&b.push(_i(wg,h,{storage:e}));const k=Object.values(_).some(Boolean);if(k)try{window.dispatchEvent(new Event(uP))}catch{}return k&&b.every(R=>!R)}const Tk="nc_last_roster_v1",pP=64,mP=["cell","tmuxSession","engine","model","label","boot"],Pk=t=>Ar(Tk,{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={...Pk(n)};!Array.isArray(e)||!e.length?delete s[t]:s[t]={at:Date.now(),cells:e.slice(0,pP).filter(i=>i&&typeof i.cell=="string").map(i=>Object.fromEntries(mP.filter(a=>i[a]!==void 0&&i[a]!==null).map(a=>[a,i[a]])))},_i(Tk,s,{storage:n})}function Cv(t,e=globalThis.localStorage){const n=t?Pk(e)[t]:null;return!n||!Array.isArray(n.cells)?[]:n.cells.map(s=>({...s,tmux:!1,active:!1,preserved:!0,degraded:!1}))}function Ik(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 gP(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 Dk(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 vP=/fleet\.json/;function ch({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}:vP.test(n)?{kind:"stale"}:{kind:"disabled",reason:n||null}}const Ok={baseMs:4e3,capMs:6e4},Bk="peer-assente",$k="peer-nega",zk="rotta-inesistente";function kp(t){const e=t&&t.status;return e===403?$k:e===404?zk:Bk}function _P(t,{baseMs:e,capMs:n}=Ok){return!Number.isFinite(t)||t<1?0:Math.min(e*2**(t-1),n)}function I0(t,e,n){const s=t&&t[e];return!s||!(s.failures>=1)?!0:n>=s.nextAtMs}function D0(t,e,n,s,i=Ok){const c=(t&&t[e]||{failures:0}).failures+1;return{...t,[e]:{failures:c,cause:n,nextAtMs:s+_P(c,i)}}}function O0(t,e){if(!t||!(e in t))return t;const n={...t};return delete n[e],n}const yP=4e3,Ev=600*1e3,Fk="nc-sticky-owners-v1";function wP(){try{const t=localStorage.getItem(Fk);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 bP(t){try{localStorage.setItem(Fk,JSON.stringify(t))}catch{}}function nd(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>Ev?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 Hk(t,e=!0,n=0){const[s,i]=w.useState([]),[a,c]=w.useState(null),u=w.useRef([]),h=w.useRef({}),f=w.useRef({}),g=w.useRef({remote:{},fleet:{}}),v=w.useRef(null),_=w.useRef(null),b=w.useRef(new Map),k=w.useRef(new Map),R=w.useRef(new Set),C=w.useRef(th()),L=w.useRef(null);return w.useEffect(()=>{if(!e||!t){i([]),c(null);return}let S=!0;const T=v.current!==null&&v.current!==t;v.current!==t&&(v.current=t,f.current={},g.current={remote:{},fleet:{}},b.current.clear(),k.current.clear(),R.current.clear(),h.current={},u.current=[],i([]));const E={instanceId:"",nodes:new Map,topology:new Map},H=T?null:wP();if(H){E.instanceId=H.instanceId||"";for(const V of H.nodes)E.nodes.set(V.name,{data:V,missingSince:null});for(const V of H.topology)E.topology.set(V.route.join("/"),{data:V,missingSince:null})}async function F(){const V=C.current,G=Date.now(),ne=V.begin();if(ne===null)return;const Y=new AbortController;L.current=Y;const B={timeoutMs:L1,signal:Y.signal},P=()=>S&&V.isCurrent(ne);let D=[],M=[],$={},A="",j=!1,N=!1,U="pending",I="pending";const W={},se={},me=new Set,pe=new Set,Ie=new Set;let J=new Map;const te=[],ge=()=>{J=new Map([...M.filter(Oe=>Array.isArray(Oe.route)).map(Oe=>[Oe.route.join("/"),Oe.instanceId]),...D.map(Oe=>[Oe.name,Oe.nodeId])].filter(([,Oe])=>typeof Oe=="string"&&Oe))},Se=Oe=>{const _e=J.get(Oe),$e=_e?Cv(`id:${_e}`):[];return $e.length?{available:!1,cells:$e,fleetState:"stale"}:null},Be=()=>{if(!P()||!A)return!1;const Oe=[],_e=Date.now();for(const[rt,re]of k.current){if(_e-re.at>Ev){k.current.delete(rt);continue}const ce=rt.slice(3),O=b.current.get(ce);if(re.ownerInstanceId!=null&&O!==void 0&&O!==re.ownerInstanceId){k.current.delete(rt);continue}const de=R.current.has(rt.slice(3)),we=re.round!==ne||re.identityUnknown===!0||de;for(const We of re.peers)Oe.push({...We,stale:we})}const $e=u.current,nt=j0({nodes:D,topology:M,remote:W,fleet:se,aliases:$,down:h.current,pendingReads:me,previousGroups:$e});h.current=cP(h.current,nt,Math.floor(Date.now()/1e3));const Fe=[...j0({nodes:D,topology:M,remote:W,fleet:se,aliases:$,down:h.current,pendingReads:me,previousGroups:u.current}),...gP(Oe)];return fP(Fe),u.current=Fe,c(t),i(Fe),!0};let Le=[],ze=[];const Q=()=>{var Oe;if(P()&&A){j?nd(E.nodes,!0,Le,_e=>_e&&_e.name,G):U==="error"&&nd(E.nodes,!1,Le,_e=>_e&&_e.name,G),N?nd(E.topology,!0,ze,_e=>Array.isArray(_e&&_e.route)?_e.route.join("/"):"",G):I==="error"&&nd(E.topology,!1,ze,_e=>Array.isArray(_e&&_e.route)?_e.route.join("/"):"",G),D=[...E.nodes.values()].map(_e=>_e.data),M=[...E.topology.values()].map(_e=>_e.data),ge();for(const[_e,$e]of J){const nt=b.current.get(_e);nt&&nt!==$e&&(delete g.current.remote[_e],delete g.current.fleet[_e],delete f.current[_e],delete f.current[`vl:${_e}`],delete h.current[_e],k.current.delete(`vl:${_e}`)),b.current.set(_e,$e)}for(const _e of b.current.keys())if(!J.has(_e)){const $e=k.current.get(`vl:${_e}`);$e&&($e.identityUnknown=!0)}R.current=new Set(M.filter(_e=>!_e.stale&&Array.isArray(_e.route)&&_e.route.length>0&&!J.has(_e.route.join("/"))).map(_e=>_e.route.join("/")));for(const _e of D){if(((Oe=_e.tunnel)==null?void 0:Oe.status)==="up")continue;const $e=g.current.fleet[_e.name];$e&&!se[_e.name]&&(se[_e.name]={...$e,available:!1,fleetState:"stale"})}for(const _e of M){if(!_e.stale||!Array.isArray(_e.route)||!_e.route.length)continue;const $e=_e.route.join("/"),nt=g.current.fleet[$e];nt&&!se[$e]&&(se[$e]={...nt,available:!1,fleetState:"stale"})}(j||N)&&bP({instanceId:E.instanceId,savedAt:G,nodes:[...E.nodes.values()].map(_e=>_e.data),topology:[...E.topology.values()].map(_e=>_e.data)}),Re(),Be()}},ve=(Oe,_e)=>{P()&&(U=Oe?"success":"error",j=Oe,Le=Oe?_e:[],Q())},Z=(Oe,_e)=>{P()&&(I=Oe?"success":"error",N=Oe,ze=Oe?_e:[],Q())},be=Oe=>{P()&&(A=Oe&&typeof Oe.instanceId=="string"?Oe.instanceId:"",A&&(E.instanceId!==A||_.current!==A)?(E.instanceId!==A&&(E.nodes.clear(),E.topology.clear()),u.current=[],h.current={},f.current={},g.current={remote:{},fleet:{}},b.current.clear(),k.current.clear(),R.current.clear()):A&&(E.instanceId=A),_.current=A||null,E.instanceId=A,Q())};function K(){const Oe=[{instanceId:A||null,route:[],label:null},...Dk({nodes:M},A)];for(const _e of Oe){const $e=`${_e.instanceId}:${_e.route.join("/")}`;if(Ie.has($e))continue;Ie.add($e);const nt=`vl:${_e.route.join("/")}`;te.push((async()=>{if(I0(f.current,nt,G))try{const Fe=await B1(t,_e.route,{signal:Y.signal});if(!P())return;const rt=b.current.get(_e.route.join("/"));if(rt!==void 0&&rt!==_e.instanceId||R.current.has(_e.route.join("/")))return;f.current=O0(f.current,nt);const re=[];for(const ce of Fe.nodes||[]){const O=Ik(ce,_e);O&&re.push(O)}k.current.set(nt,{peers:re,ownerInstanceId:_e.instanceId??null,at:G,round:ne}),Be()}catch(Fe){if(!P())return;const rt=b.current.get(_e.route.join("/"));if(rt!==void 0&&rt!==_e.instanceId||R.current.has(_e.route.join("/")))return;f.current=D0(f.current,nt,kp(Fe),G)}})())}}async function fe(Oe){const _e=Oe.join("/"),$e=g.current.remote[_e]||null;if(!I0(f.current,_e,G)){me.delete(`${_e}#sessions`),me.delete(`${_e}#fleet`);const rt=f.current[_e];W[_e]={error:"unreachable",cause:rt&&rt.cause||null,lastGoodAt:$e?$e.at:null};const re=g.current.fleet[_e]||Se(_e);re&&(se[_e]={...re,available:!1,fleetState:"stale"});return}me.add(`${_e}#sessions`),me.add(`${_e}#fleet`);const nt=(async()=>{let rt=!1;try{const re=await nv(t,Oe,B);if(!P())return;rt=!0,W[_e]={...re,at:G},g.current.remote[_e]={payload:re,at:G}}catch(re){if(!P())return;W[_e]={error:"unreachable",cause:kp(re),lastGoodAt:$e?$e.at:null}}finally{me.delete(`${_e}#sessions`)}f.current=rt?O0(f.current,_e):D0(f.current,_e,W[_e].cause,G),Be()})(),Fe=(async()=>{const rt=g.current.fleet[_e]||Se(_e);try{const re=await Ja(t,Oe,B);if(!P())return;const ce=ch({fs:re});ce.kind==="data"?(se[_e]={...re,available:!0,cells:ce.cells,fleetState:"available"},J.get(_e)&&Ka(`id:${J.get(_e)}`,ce.cells)):ce.kind==="disabled"?(se[_e]={...re,available:!1,cells:[],fleetState:"disabled"},J.get(_e)&&Ka(`id:${J.get(_e)}`,[])):se[_e]={...rt||{},available:!1,cells:Array.isArray(rt==null?void 0:rt.cells)?rt.cells:[],fleetState:"stale",...re!=null&&re.reason?{reason:re.reason}:{}},g.current.fleet[_e]=se[_e]}catch(re){if(!P())return;se[_e]={...rt||{},available:!1,cells:Array.isArray(rt==null?void 0:rt.cells)?rt.cells:[],fleetState:"stale",cause:kp(re)},g.current.fleet[_e]=se[_e]}me.delete(`${_e}#fleet`),Be()})();await Promise.allSettled([nt,Fe])}function Re(){var $e,nt;if(!P()||!A)return;K();const Oe=new Set(D.map(Fe=>Fe.name)),_e=Fe=>{const rt=Fe.join("/");pe.has(rt)||(pe.add(rt),te.push(fe(Fe)))};for(const Fe of D)j&&!Fe.stale&&(($e=Fe.tunnel)==null?void 0:$e.status)==="up"&&(Fe.nodeId||Fe.paired!==!1)&&(Fe.direction!=="inbound"||Fe.shared===!0)?_e([Fe.name]):U==="pending"&&!Fe.stale&&((nt=Fe.tunnel)==null?void 0:nt.status)==="up"&&(me.add(`${Fe.name}#sessions`),me.add(`${Fe.name}#fleet`));for(const Fe of M)if(!Fe.stale&&Array.isArray(Fe.route)&&Fe.route.length>0&&!(Fe.route.length===1&&Oe.has(Fe.route[0]))){const rt=Fe.route.join("/");N?_e(Fe.route):I==="pending"&&(me.add(`${rt}#sessions`),me.add(`${rt}#fleet`))}}const Ee=KN(t,B).then(Oe=>{ve(!0,Array.isArray(Oe.nodes)?Oe.nodes:[])},()=>{ve(!1,[])}),qe=$1(t,B).then(Oe=>{Z(!0,Array.isArray(Oe.nodes)?Oe.nodes:[])},()=>{Z(!1,[])}),Ze=ZN(t,B).then(Oe=>{P()&&($=Oe&&typeof Oe.aliasesByInstanceId=="object"?Oe.aliasesByInstanceId:{},Be())},()=>{}),at=Bc(t,[],B).then(Oe=>{be(Oe)},()=>{});try{await Promise.allSettled([Ee,qe,Ze,at]),await Promise.allSettled(te)}finally{V.isCurrent(ne)&&V.end(ne)}}F();const X=setInterval(F,yP);return()=>{S=!1,clearInterval(X),C.current.reset(),L.current&&L.current.abort()}},[t,e,n]),{groups:s,hasLoaded:e&&!!t&&a===t}}function Nv(t,e=!0,n=0){return Hk(t,e,n).groups}const B0=52,$0=14;function Vi({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 L,S,T,E;const C=u.current;(S=(L=C==null?void 0:C.over)==null?void 0:L.classList)==null||S.remove("nc-roster-over"),(E=(T=C==null?void 0:C.source)==null?void 0:T.classList)==null||E.remove("nc-roster-dragging"),h.current&&cancelAnimationFrame(h.current),h.current=0},_=(C=!1)=>{const L=u.current;if(!L)return;const S=L.target;v(),u.current=null,g(!1);try{L.handle.releasePointerCapture(L.pointerId)}catch{}C&&S&&S!==e&&a(e,S)&&s(e,S)},b=(C,L)=>{var V,G,ne,Y,B,P,D,M,$;const S=u.current;if(!S)return;S.x=C,S.y=L;const T=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",E=(G=(V=document.elementFromPoint(C,L))==null?void 0:V.closest)==null?void 0:G.call(V,T),H=c==="node"?(ne=E==null?void 0:E.dataset)==null?void 0:ne.nodeOrderKey:(Y=E==null?void 0:E.dataset)==null?void 0:Y.rosterKey,X=(c==="node"||((B=E==null?void 0:E.dataset)==null?void 0:B.position)===t)&&H&&H!==e&&a(e,H);S.over!==(X?E:null)&&((D=(P=S.over)==null?void 0:P.classList)==null||D.remove("nc-roster-over"),S.over=X?E:null,($=(M=S.over)==null?void 0:M.classList)==null||$.add("nc-roster-over")),S.target=X?H:null},k=()=>{const C=u.current;if(!C){h.current=0;return}const L=C.container;if(L){const S=L.getBoundingClientRect(),T=C.y<S.top+B0?-$0:C.y>S.bottom-B0?$0:0;T&&(L.scrollTop+=T,b(C.x,C.y))}h.current=requestAnimationFrame(k)};w.useEffect(()=>{const C=S=>{S.key==="Escape"&&u.current&&(S.preventDefault(),_(!1))},L=()=>_(!1);return window.addEventListener("keydown",C),window.addEventListener("blur",L),()=>{window.removeEventListener("keydown",C),window.removeEventListener("blur",L),v(),u.current=null}},[e,t,c]);const R=C=>{var E;if(C.pointerType==="mouse"&&C.button!==0)return;C.preventDefault(),C.stopPropagation(),C.currentTarget.focus({preventScroll:!0});const L=c==="node"?"[data-node-order-key]":"[data-roster-key][data-position]",S=C.currentTarget.closest(L),T=C.currentTarget.closest(".nc-side-scroll, .nc-home-scroll, .nc-cell-switcher-list");u.current={pointerId:C.pointerId,handle:C.currentTarget,source:S,container:T,target:null,over:null,x:C.clientX,y:C.clientY},(E=S==null?void 0:S.classList)==null||E.add("nc-roster-dragging");try{C.currentTarget.setPointerCapture(C.pointerId)}catch{}g(!0),h.current=requestAnimationFrame(k)};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:C=>{C.preventDefault(),C.stopPropagation()},onDragStart:C=>C.preventDefault(),onKeyDown:C=>{C.key!=="ArrowUp"&&C.key!=="ArrowDown"||(C.preventDefault(),C.stopPropagation(),i(C.key==="ArrowUp"?-1:1))},onPointerDown:R,onPointerMove:C=>{!u.current||C.pointerId!==u.current.pointerId||(C.preventDefault(),C.stopPropagation(),b(C.clientX,C.clientY))},onPointerUp:C=>{!u.current||C.pointerId!==u.current.pointerId||(C.preventDefault(),C.stopPropagation(),_(!0))},onPointerCancel:()=>_(!1),onLostPointerCapture:()=>{u.current&&_(!1)},children:"↕"})}const Uk="nc_pins";function eo(){return Ar(Uk,{fallback:()=>[],parse:t=>Array.isArray(t)?t:void 0})}function Rv(t){return _i(Uk,t)}function SP(t,e){const n=t.includes(e)?t.filter(s=>s!==e):[...t,e];return{next:n,error:Rv(n)}}function z0(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:Rv(n)}}function xP(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),Rv(s),s}function kP(t,e,n){const s=t.indexOf(e);return[s===-1?1e9:s,-(n||0)]}function CP(t,e){return t[0]-e[0]||t[1]-e[1]}const bg="nexuscrew-roster-preferences",EP=new Set(["nc_pins",Yo,Vo,wg]),ja=()=>{try{window.dispatchEvent(new Event(bg))}catch{}},NP=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Cp=t=>e=>NP(e,t)?e:t;function Lv(){const[t,e]=w.useState(eo),[n,s]=w.useState(bd),[i,a]=w.useState(hc),[c,u]=w.useState(null),[h,f]=w.useState(null);w.useEffect(()=>{if(!h)return;const T=setTimeout(()=>f(null),8e3);return()=>clearTimeout(T)},[h]),w.useEffect(()=>{const T=E=>{E&&E.type==="storage"&&E.key&&!EP.has(E.key)||(e(Cp(eo())),a(Cp(hc())),s(Cp(bd())))};return window.addEventListener("storage",T),window.addEventListener(bg,T),()=>{window.removeEventListener("storage",T),window.removeEventListener(bg,T)}},[]);const g=T=>{const E=eo(),H=SP(E,T);e(H.next),Gi({reason:H.error?"pin-write-failed":"pin",key:T,before:E,after:H.next,note:H.error?String(H.error.message||H.error):void 0}),ja()},v=T=>{const E=eo(),H=z0(E,T);return e(H.next),u(H.error?{key:T,message:H.error.message||String(H.error)}:null),Gi({reason:H.error?"unpin-write-failed":"unpin",key:T,before:E,after:H.next}),ja(),H.error},_=()=>{if(!c)return;const T=z0(eo(),c.key);e(T.next),u(T.error?{...c,message:T.error.message||String(T.error)}:null),ja()},b=()=>u(null),k=T=>vg(Aa(n),T),R=(T,E)=>{const H=bd(),F=Sp(T),X=lP({...H,[F]:{...vg(Aa(H),T),...E}});s(X),ja()},C=(T,E)=>t.includes(T)===t.includes(E);function L(T,E,H,F){var j,N;const X=(j=F.find(U=>U.partial))==null?void 0:j.partial;if(X){f({reason:X,position:T,at:Date.now()}),Gi({reason:"reorder-blocked",position:Sp(T),source:E,target:H,note:X});return}f(null);const V=eo(),G=V.includes(E),ne=V.includes(H);if(G!==ne)return;if(G){const U=xP(V,E,H);e(U),Gi({reason:"move-pin",source:E,target:H,before:V,after:U}),ja();return}const Y=hc(),B=Sp(T),P=Aa(Y),D=((N=F.find(U=>U.key===E))==null?void 0:N.technical)===!0,M=lo(F,V,D?"technical":"all",Ti(P,T)).map(U=>U.key),$=aP({...Y,[B]:Ti(P,T)},B,E,H,M),A={...Y,[B]:$[B]};oP(A),Gi({reason:"move",position:B,source:E,target:H,before:Ti(P,T),after:$[B],visible:M}),a(A),ja()}function S(T,E,H,F){var D;if(F.some(M=>M.partial)){L(T,E,E,F);return}const X=eo(),V=Aa(hc()),G=((D=F.find(M=>M.key===E))==null?void 0:D.technical)===!0,ne=X.includes(E),Y=lo(F,X,G?"technical":"all",Ti(V,T)).map(M=>M.key).filter(M=>X.includes(M)===ne),B=Y.indexOf(E),P=Y[B+H];B>=0&&P&&L(T,E,P,F)}return{pins:t,views:Aa(n),orders:Aa(i),togglePin:g,removePin:v,pinError:c,retryPinPersist:_,clearPinError:b,reorderBlocked:h,viewFor:k,updateView:R,canMoveRoster:C,moveRoster:L,stepRoster:S}}const uh="nc_node_order_v1",RP=/^[a-f0-9]{16,64}$/;function Bo(t){if(RP.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 Sg(t=globalThis.localStorage){return Ar(uh,{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 LP(t,e=globalThis.localStorage){return _i(uh,t,{storage:e}),t}function F0(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(Bo(s.group))?n.get(Bo(s.group)):Number.MAX_SAFE_INTEGER,c=n.has(Bo(i.group))?n.get(Bo(i.group)):Number.MAX_SAFE_INTEGER;return a-c||s.index-i.index}).map(({group:s})=>s)}function AP(t,e,n,s=[]){if(!e||!n||e===n)return t;const i=s.map(Bo).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 xg="nexuscrew-node-preferences";function jP(){try{window.dispatchEvent(new Event(xg))}catch{}}function dh(){const[t,e]=w.useState(Sg);w.useEffect(()=>{const a=()=>e(Sg());return window.addEventListener("storage",a),window.addEventListener(xg,a),()=>{window.removeEventListener("storage",a),window.removeEventListener(xg,a)}},[]);const n=a=>F0(a,t),s=(a,c,u)=>e(h=>{const f=AP(h,a,c,u);return LP(f),jP(),f});return{order:t,groupsFor:n,moveNode:s,stepNode:(a,c,u)=>{const h=F0(u,t).map(Bo),f=h.indexOf(a),g=h[f+c];f>=0&&g&&s(a,g,u)},nodeKey:Bo}}function Wk({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 hh({item:t,pins:e,hostByRoute:n,route:s}){const i=(n||{})[Ns(s)]||{},a=Rd({hostCell:i.hostCell??null,threadStatus:i.threadStatus,pins:e,item:t}),c=$5(a);return{state:a,live:!!c,favorite:a==="favorite",filled:a!=="none",titleKey:c||"pin",action:a===V1?"removePin":"addPin"}}async function Av({view:t,itemKey:e,togglePin:n,removePin:s}){return t.action==="removePin"?(s(e),{ok:!0}):(n(e),{ok:!0})}function ro({item:t,cellName:e,route:n=[],pins:s=[],hostByRoute:i={}}={}){const a=hh({item:t,pins:s,hostByRoute:i,route:n}),c=(i||{})[Ns(n)]||{};return{pinned:a.favorite,isLive:!!c.hostCell&&c.hostCell===e}}function jv({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 qk({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 Kk({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 Vk({anchorRect:t,items:e,busy:n,onClose:s}){const i=w.useRef(null);Kk({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(qk,{items:e,busy:n,onRun:c=>{c.run(),s()}})})}function Mv({cellName:t,items:e,busy:n,onClose:s}){const i=w.useRef(null);return Kk({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(qk,{items:e,busy:n,onRun:a=>{a.run(),s()}})]})})}function oo(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 Yk(t){const e=t||{};return!(e.sessionsAvailable===!1||typeof e.status=="string"&&e.status!=="up")}function Xi(t){return t.status==="up"&&!Yk(t)?p("node-sessions-unverified"):t.status==="passive"?p("node-passive"):t.status==="down"?t.downSince?p("tunnel-down-since").replace("{t}",oo(t.downSince)):p("tunnel-down"):t.status==="unreachable"?t.cause===$k?p("peer-cause-nega"):t.cause===zk?p("peer-cause-rotta"):t.cause===Bk?p("peer-cause-assente"):p("node-unreachable"):t.status==="offline"?t.lastSeen?p("node-offline-seen").replace("{t}",oo(t.lastSeen)):p("node-offline"):t.status==="needs-repair"?p("node-needs-repair"):""}function Gk(t,{passive:e=null}={}){return t?t.status==="passive"?e:t.status==="healthy"?"on":"warn":null}function Od(t){return t&&(t.detail||t.status)||""}const MP="restrict,port-forwarding,permitopen=";function TP(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(MP);return s<0?{note:e,line:""}:{note:e.slice(0,s).replace(/[:\s]+$/,""),line:e.slice(s).trim()}}function Bd(t,e,n=globalThis.localStorage){if(!(t!=null&&t.outbox)||t.outbox.count<1)return!1;const s=Number(n.getItem(A1(e))||0);return t.outbox.latest>s}function Tv(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 Xk(t,e){return[...new Set([t.engine,t.model,t.key,e.preview,t.preview,e.status].filter(Boolean).map(String))].join(" ")}function Jk({sessionsOk:t=!0,fleetStale:e=!1,cellCount:n=0}={}){return t?e&&!n?"fleet":null:"sessions"}function Pv(t,e,n,s=globalThis.localStorage,{autorevole:i=!0,fleetStale:a=!1}={}){const c=Jk({sessionsOk:i,fleetStale:a,cellCount:Array.isArray(t)?t.length:0});return Qk([...(Array.isArray(t)?t:[]).map(u=>{const h=n.get(u.tmuxSession)||{},f=Lc([],u.tmuxSession),g=Tv(u,h,{autorevole:i});return{type:"cell",value:u,key:f,label:u.cell,live:!!u.tmux,fresh:Bd(h,f,s),activity:h.activity||0,working:g.working,stato:g.stato,subtitle:g.subtitle,searchText:Xk(u,h)}}),...(Array.isArray(e)?e:[]).map(u=>{const h=Lc([],u.name);return{type:"session",value:u,key:h,label:u.name,live:!0,technical:u.technical===!0,fresh:Bd(u,h,s),activity:u.activity||0,searchText:`${u.preview||""} ${u.cmd||""}`}})],c)}const Qk=(t,e)=>e?t.map(n=>({...n,partial:e})):t;function vc(t,e=globalThis.localStorage){const n=t||{},s=Array.isArray(n.route)?n.route:[],i=Yk(n),a=new Map((n.sessions||[]).map(h=>[h.name,h])),c=[...(n.cells||[]).map(h=>{const f=a.get(h.tmuxSession)||{},g=Lc(s,h.tmuxSession||h.cell),v=Tv(h,f,{autorevole:i});return{type:"cell",value:h,key:g,label:h.cell,live:!!h.tmux&&!h.preserved,fresh:Bd(f,g,e),activity:f.activity||h.activity||0,working:v.working,stato:v.stato,subtitle:v.subtitle,searchText:Xk(h,f)}}),...(n.unmanaged||[]).map(h=>{const f=Lc(s,h.name);return{type:"session",value:h,key:f,label:h.name,live:!0,technical:h.technical===!0,fresh:Bd(h,f,e),activity:h.activity||0,searchText:`${h.preview||""} ${h.cmd||""}`}})],u=Jk({sessionsOk:n.sessionsAvailable!==!1,fleetStale:n.fleetState==="stale",cellCount:(n.cells||[]).length});return{route:s,rawItems:Qk(c,u)}}const fh=9,kg=.2,PP=/^[a-z0-9-]{1,32}(?:\/[a-z0-9-]{1,32}){0,3}$/,Va=/^[a-f0-9]{16,64}$/,Cg=t=>PP.test(t)&&new Set(t.split("/")).size===t.split("/").length;function Nr(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!Cg(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"&&Va.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"&&Cg(t.node)?{session:t.session,node:t.node,...e?{ownerId:e}:{}}:null}return null}function zt(t){const e=Nr(t);return e?e.node?`${e.node}:${e.session}`:e.session:""}const Zk=9,eC=24,vi=11,tC=t=>{const e=Number(t);return e>=Zk&&e<=eC?e:vi};function co(){return{columns:[]}}function gs(t){return t.columns.flatMap(e=>e.tiles.map(n=>zt(n)))}function IP(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(zt(i.tiles[s]));return e}const Ii=t=>({columns:t.columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))});function Ac(t,e,n,s){const i=Nr(e);if(!i||gs(t).includes(zt(i))||gs(t).length>=fh)return t;const a=Ii(t),c={session:i.session,height:1,fontSize:vi,...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 nC(t,e){const n=zt(e);if(!n||gs(t).includes(n)||gs(t).length>=fh)return t;const s=gs(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 Ac(t,e,{col:g,row:t.columns[g].tiles.length})}const a=[...IP(t),n],c=new Map(t.columns.flatMap(g=>g.tiles.map(v=>[zt(v),v]))),u=Nr(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 _=Nr(g);if(!_)return;const b=c.get(g)||(g===n?u:{})||{},k={session:_.session,height:b.height||1,fontSize:b.fontSize||vi};_.node&&(k.node=_.node),b.ownerId&&(k.ownerId=b.ownerId),b.unavailable===!0&&(k.unavailable=!0),b.stale===!0&&(k.stale=!0),f[v%i].tiles.push(k)}),{columns:f.filter(g=>g.tiles.length)}}function sC(t,e){const n=Nr(e);if(!n)return t;const s=zt(n);if(!s||gs(t).includes(s)||gs(t).length>=fh)return t;const i=e&&typeof e=="object"?e:{},a={height:Math.max(kg,Number(i.height)||1),fontSize:tC(i.fontSize),...n.ownerId?{ownerId:n.ownerId}:{}};if(!t.columns.length)return Ac(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 Ac(t,n,{col:c,row:t.columns[c].tiles.length},a)}function jc(t,e){const n=zt(e),s=Ii(t);for(const i of s.columns)i.tiles=i.tiles.filter(a=>zt(a)!==n);return s.columns=s.columns.filter(i=>i.tiles.length>0),s}function DP(t,e,n){const s=zt(e);if(!gs(t).includes(s))return t;const i=t.columns.flatMap(a=>a.tiles).find(a=>zt(a)===s);return Ac(jc(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 OP(t,e){if(!(e instanceof Map)||e.size===0)return t;let n=!1;const s=Ii(t);for(const i of s.columns)for(const a of i.tiles){const c=e.get(zt(a));if(!c)continue;const u=Nr(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?Mi(s):t}const iC=120,rC=60,pc=[1/3,.5,2/3],Eg=16;function oC(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 pc)if(Math.abs(a-c)*e<=Eg){a=c;break}}return a}function H0(t,e,n,s,i={}){const a=Ii(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:oC(s,g,i.minPx??iC,i.snap!==!1);return c.width=f*v,u.width=f*(1-v),a}function U0(t,e,n,s,i,a={}){const c=Ii(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((k,R)=>k+(Number(R.height)||1),0),v=(Number(h.height)||1)+(Number(f.height)||1),_=(Number(s)||0)*(v/(g||1)),b=a.half===!0?.5:oC(i,_,a.minPx??rC,a.snap!==!1);return h.height=v*b,f.height=v*(1-b),c}function BP(t,e,n){if(!e||!n||e===n)return t;const s=Ii(t);let i=null,a=null;for(const f of s.columns)for(let g=0;g<f.tiles.length;g+=1){const v=zt(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 Uc=6,Wc=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 Iv(t,e){for(const n of t.columns)for(let s=0;s<n.tiles.length;s+=1)if(zt(n.tiles[s])===e)return{tile:n.tiles[s]};return null}function $P(t,e,n){const s=Ii(t),i=zt(e);if(FP(s).length>=Uc)return t;const a=Iv(s,i);return!a||a.tile.float?t:(a.tile.float=Wc(n||{}),s)}function zP(t,e){const n=Ii(t),s=Iv(n,zt(e));return!s||!s.tile.float?t:(delete s.tile.float,n)}function W0(t,e,n){const s=Ii(t),i=Iv(s,zt(e));return!i||!i.tile.float?t:(i.tile.float=Wc(n),s)}function FP(t){return t.columns.flatMap(e=>e.tiles).filter(e=>e.float).map(e=>zt(e))}function $d(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 aC=["x","y","w","h","fontSize"],Ng=(t,e)=>Math.abs((Number(t)||0)-(Number(e)||0))<1e-9,lC=(t,e)=>aC.every(n=>Ng(t[n],e[n]));function HP(t,e,n){if(!t)return n;const s={...n};for(const i of aC)Ng(n[i],t[i])&&!Ng(e[i],t[i])&&(s[i]=e[i]);return{...s,...Wc(s)}}function UP(t,e,n){const s=h=>new Map((Array.isArray(h)?h:[]).map(f=>[zt(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)&&lC(f,i.get(h))||u.push(a.has(h)?HP(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,Uc)}function WP(t,e,n,s,i){const a=_=>Array.isArray(_.floating)?_.floating:[],c=(_,b)=>a(_).some(k=>zt(k)===b)?"float":gs(_.grid).includes(b)?"grid":"",u=(_,b)=>_.columns.flatMap(k=>k.tiles).find(k=>zt(k)===b),h=new Set([...a(n),...a(s),...a(i)].map(_=>zt(_)).filter(Boolean));let f=t,g=Array.isArray(e)?e:[];const v=(_,b)=>a(_).find(k=>zt(k)===b);for(const _ of h){const b=c(i,_),k=c(n,_),C=b!==k||b==="float"&&!lC(v(i,_),v(n,_))?b:c(s,_);if(C!=="grid"&&gs(f).includes(_)&&(f=jc(f,_)),C!=="float"&&(g=g.filter(L=>zt(L)!==_)),C==="grid"&&!gs(f).includes(_)){const L=u(s.grid,_)||u(i.grid,_)||u(n.grid,_);L&&(f=sC(f,L))}if(C==="float"&&!g.some(L=>zt(L)===_)){const L=[s,i,n].map(S=>a(S).find(T=>zt(T)===_)).find(Boolean);L&&(g=[...g,L])}}return{grid:f,floating:g.slice(0,Uc)}}function qP(t,e){const n=s=>{const{grid:i,floating:a}=$d(s||co());return JSON.stringify({g:i.columns.map(c=>[c.width,c.tiles.map(u=>[zt(u),u.ownerId||"",u.height,u.fontSize])]),f:a.map(c=>[zt(c),c.ownerId||"",c.x,c.y,c.w,c.h,c.fontSize])})};return n(t)===n(e)}function Rg(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=zt(i);if(!a||gs(n).includes(a))continue;const c=Ii(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||vi,float:Wc(s)};i.node&&(h.node=i.node),i.ownerId&&(h.ownerId=i.ownerId),c.columns[u].tiles.push(h),n=c}return n}function KP(t,e,n,s){if(!(t.columns[e]&&t.columns[e].tiles[n]))return t;const a=Ii(t),c=a.columns[e].tiles[n],u=Number(c.fontSize)||vi;return c.fontSize=Math.max(Zk,Math.min(eC,u+(Number(s)||0))),a}function VP(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 Mi(t){if(!t||!Array.isArray(t.columns))return co();const e=t.columns.map(a=>({width:Math.max(kg,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"&&Cg(c.node)).filter(c=>c.ownerId==null||typeof c.ownerId=="string"&&Va.test(c.ownerId)).map(c=>{const u={session:c.session,height:Math.max(kg,Number(c.height)||1),fontSize:tC(c.fontSize)};return c.node!=null&&(u.node=c.node),c.ownerId!=null&&(u.ownerId=c.ownerId),c.float&&(u.float=Wc(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=zt(c);return n.has(u)||(c.float?i>=Uc:s>=fh)?!1:(n.add(u),c.float?i+=1:s+=1,!0)});return{columns:e.filter(a=>a.tiles.length>0)}}function YP(t,e){let n=Mi(t);const s=Mi(e),i=new Map;for(const c of s.columns)for(const u of c.tiles)i.set(zt(u),u);for(const c of n.columns)for(let u=0;u<c.tiles.length;u+=1){const h=zt(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=>zt(h)).sort().join("|");a.has(u)||a.set(u,c.width)}for(const c of n.columns){const u=c.tiles.map(f=>zt(f)).sort().join("|"),h=a.get(u);h!=null&&(c.width=h)}for(const[c,u]of i)gs(n).includes(c)||(n=sC(n,u));return n}const cC=/^[a-z0-9-]{1,32}$/,GP=/^[A-Za-z0-9._-]{1,32}$/,XP=/^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/,JP=320;function Lg(t){return typeof t=="string"&&cC.test(t)}const QP=64;function Ya(t){if(typeof t!="string")return!1;const e=t.trim();return e.length>0&&e.length<=QP&&!/[\x00-\x1f\x7f]/.test(e)}function uo(t){return String(t??"").normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32).replace(/-+$/g,"")||"node"}function uC(t){if(typeof t!="string"||!t||t.length>JP||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:GP.test(t.slice(0,e))&&XP.test(t.slice(e+1))}function q0(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 ZP({name:t,ssh:e,sshPort:n,remotePort:s}={}){const i=typeof t=="string"?t.trim():t,a=typeof e=="string"?e.trim():e;if(!Lg(i))return{ok:!1,error:"err-node-name"};if(!uC(a))return{ok:!1,error:"err-ssh"};const c=q0(n);if(c===void 0)return{ok:!1,error:"err-ssh-port"};const u=q0(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 eI(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 Ag(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?eI(t.since,e):null}}const tI=new Set(["v","instanceId","port","label","invite"]),nI=new Set(["v","instanceId","port","label","invite","name","ssh","sshPort"]);function sI(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 iI(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(sI(e))}catch{return{ok:!1}}if(!n||typeof n!="object"||Array.isArray(n))return{ok:!1};const s=n.v===1?tI:n.v===2?nI: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"||!cC.test(n.name))return{ok:!1};a.name=n.name}if(n.ssh!==void 0){if(!uC(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 rI(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?uo(e.label):"")),i("ssh",e.ssh),e.sshPort!==void 0&&i("sshPort",String(e.sshPort))),s}const oI=["KIMI_AUTH_ACTION_REQUIRED","CLIENT_INTERACTION_REQUIRED"],aI=["kimi-code-consent-yes","kimi-code-config-custom-api-key","kimi-cli-login","client-terminal-dialog"];function lI(t){const e=t&&typeof t=="object"?t.actionRequired:null;if(e&&typeof e=="object"&&oI.includes(e.code)&&aI.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 cI(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 Dv({token:t,powerCell:e,payload:n,onNotice:s,fleetApi:i}){const a=i||{fleetUp:TN,fleetDown:M1},{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=lI(h);f&&s(f.text)}else await a.fleetDown(t,{cell:c,boot:!!n.boot},u);return}catch(h){const f=cI(h,n.action);if(f)return s(f.text),{benign:f.code};throw h}}const uI=1e4;function dC(){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),uI))},[]);return w.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]),{notice:t,showActionNotice:s}}let jg={sessions:[],cells:[],nodeGroups:[],localNodeId:"",localFresh:!1,refreshedAt:0};function dI(){return jg}function hI(t={}){return jg={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},jg}const Ma=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function fI({onPick:t,token:e,onSettings:n,onOpenVlSession:s,hostByRoute:i={},onDesignateCell:a,onClearHostCell:c,panelPort:u=0,nodePanelPorts:h=null}){const[f,g]=$n(),v=Nv(e),[_,b]=w.useState(null),[k,R]=w.useState(null),[C,L]=w.useState(!0),[S,T]=w.useState(""),[E,H]=w.useState(""),[F,X]=w.useState({bind:"127.0.0.1",port:""}),[V,G]=w.useState(""),[ne,Y]=w.useState([]),[B,P]=w.useState([]),[D,M]=w.useState(!1),[$,A]=w.useState(null),[j,N]=w.useState({}),[U,I]=w.useState(new Set),[W,se]=w.useState(null),{notice:me,showActionNotice:pe}=dC(),[Ie,J]=w.useState(null),[te,ge]=w.useState(null),[Se,Be]=w.useState(!1),[Le,ze]=w.useState(null),[Q,ve]=w.useState(null),[Z,be]=w.useState("preview"),[K,fe]=w.useState(!1),{pins:Re,orders:Ee,togglePin:qe,removePin:Ze,pinError:at,reorderBlocked:Oe,retryPinPersist:_e,clearPinError:$e,viewFor:nt,updateView:Fe,canMoveRoster:rt,moveRoster:re,stepRoster:ce}=Lv(),O=le=>i[Ns(le)]||{},{groupsFor:de,moveNode:we,stepNode:We,nodeKey:ie}=dh(),Pe=de(v);w.useEffect(()=>{hI({sessions:_||[],cells:ne,nodeGroups:v,localNodeId:V})},[_,ne,v,V]),w.useEffect(()=>{const le=new Map;for(const oe of ne)le.set(Ma(oe.cell),!!oe.boot);for(const oe of v){const Me=oe.route||[oe.name];for(const Ke of oe.cells||[])le.set(Ma(Ke.cell,Me),!!Ke.boot)}N(oe=>{let Me=!1;const Ke={...oe};for(const[mt,q]of Object.entries(oe))le.has(mt)&&le.get(mt)===q&&(delete Ke[mt],Me=!0);return Me?Ke:oe})},[ne,v]);function ft(){ic([],e)}w.useEffect(()=>{const oe=wc(e,[],Me=>{if(!Me)return;const Ke=Me.sessionsError?null:Me.sessionsJson;Ke&&!Ke.error?(R(null),b(Ke.sessions||[]),L(!0)):Ke?(R(Ke.error),b([]),L(!1)):(R(String(Me.sessionsError)),b([]),L(!1));const mt=ch({fs:Me.fs,error:Me.fleetError});mt.kind==="data"?(Ka("local",mt.cells),Y(mt.cells),P(mt.capabilities),M(!1),A(null)):mt.kind==="stale"?(Y(q=>q.length?q:Cv("local")),M(!0),A(null)):(Y([]),Ka("local",[]),P([]),M(!1),A(mt.reason||""))});return Wn("/api/config",e).then(Me=>Me.json()).then(Me=>{H(Me.version||""),X({bind:Me.bind||"127.0.0.1",port:Me.port||""}),G(Va.test(String(Me.instanceId||""))?Me.instanceId:"")}).catch(()=>{}),oe},[e]);async function Pt(){if(!F.port)return;const le=`http://${F.bind}:${F.port}/#token=${e}`;try{await navigator.clipboard.writeText(le)}catch{}}function bt(le,oe,Me){const Ke=Ma(le,oe);N(mt=>({...mt,[Ke]:!!Me}))}function xt(le,oe=[]){const Me=Ma(le.cell,oe);return Object.prototype.hasOwnProperty.call(j,Me)?j[Me]:!!le.boot}async function vt(le,oe,Me=[],Ke){const mt=Ma(oe.cell,Me),q=typeof Ke=="boolean"?Ke:!xt(oe,Me);bt(oe.cell,Me,q),I(ae=>new Set(ae).add(mt));try{await T1(e,{cell:oe.cell,enabled:q},Me),Me.length||Y(ae=>ae.map(Te=>Te.cell===oe.cell?{...Te,boot:q}:Te))}catch(ae){N(Te=>{const Ge={...Te};return delete Ge[mt],Ge}),R(String((ae==null?void 0:ae.message)||ae))}finally{I(ae=>{const Te=new Set(ae);return Te.delete(mt),Te})}}const Mt=(le,oe,Me)=>({onToggleLive:async()=>{const Ke=ro({item:le,cellName:oe.cell,route:Me,pins:Re,hostByRoute:i});Be(!0);const mt=await nh({action:Ke.isLive?"remove":"use",cellId:oe.cell,route:Me,token:e});Be(!1),ze({messageKey:mt.messageKey,ok:mt.ok,cell:mt.hostCell||oe.cell})},onTogglePin:()=>Av({view:hh({item:le,pins:Re,hostByRoute:i,route:Me}),itemKey:le.key,togglePin:qe,removePin:Ze}),onToggleBoot:Ke=>vt(null,oe,Me,Ke),onWatchLive:()=>{be("stream"),ve(le.key)}});async function Qt(le){if(!W)return;let oe=null;try{oe=await Dv({token:e,powerCell:W,payload:le,onNotice:pe})}catch(Me){throw pe(String(Me&&Me.message||Me)),Me}if(!oe){const{cell:Me}=W,Ke=Array.isArray(W.route)?W.route:[];le.action==="up"?bt(Me,Ke,!!le.boot):le.boot&&bt(Me,Ke,!1)}ft()}const Dt=w.useMemo(()=>{if(!W)return null;const le=(Array.isArray(W.route)?W.route:[]).join("/"),Me=[...ne,...v.flatMap(Ke=>(Ke.cells||[]).map(mt=>({...mt,route:Ke.route||[Ke.name]})))].find(Ke=>Ke.cell===W.cell&&(Array.isArray(Ke.route)?Ke.route.join("/"):"")===le);return Me?{...W,active:!!Me.active}:W},[W,ne,v]);async function It(le,oe=[]){try{await ev(e,le,oe)}catch{return}ft()}async function en(le,oe,Me=[]){try{await D1(e,le,oe,Me)}catch{return}ft()}async function Kn(le){if(!(!(le!=null&&le.direct)||Ie)){J(le.name);try{await sv(e,le.name,le.tunnelStatus==="up"?"down":"up")}catch{}J(null)}}async function rn(le){if(!(le!=null&&le.direct))return;const oe=window.prompt(p("rename-node-prompt"),le.label||le.name);if(oe===null)return;const Me=String(oe).trim();if(!Ya(Me)){window.alert(p("rename-node-invalid"));return}try{await F1(e,le.name,Me)}catch(Ke){window.alert(String((Ke==null?void 0:Ke.message)||Ke))}}const tn=w.useMemo(()=>new Map((_||[]).map(le=>[le.name,le])),[_]),nn=w.useMemo(()=>new Set(ne.map(le=>le.tmuxSession)),[ne]),mn=w.useMemo(()=>(_||[]).filter(le=>!nn.has(le.name)),[_,nn]),Wt=w.useMemo(()=>Pv(ne,mn,tn,void 0,{autorevole:C,fleetStale:D}),[ne,mn,tn,C,D]),Zt=w.useMemo(()=>{const le=new Map;for(const oe of Wt)oe.type==="cell"&&le.set(oe.key,{item:oe,route:[],nodeLabel:"",sessions:_||[],cells:ne});for(const oe of Pe){const Me=Array.isArray(oe.route)?oe.route:[];if(!Me.length||oe.kind==="vl")continue;const{rawItems:Ke}=vc(oe);for(const mt of Ke)mt.type==="cell"&&le.set(mt.key,{item:mt,route:Me,nodeLabel:oe.label||oe.name||"",sessions:oe.sessions||[],cells:oe.cells||[]})}return le},[Wt,Pe,_,ne]),yn=w.useMemo(()=>{if(!Q)return null;const le=Zt.get(Q);if(!le)return null;const oe=le.item.value,Me=(le.sessions||[]).find(Ke=>Ke.name===oe.tmuxSession)||{};return{row:{key:le.item.key,cellName:oe.cell,subtitle:le.item.subtitle||"",nodeLabel:le.nodeLabel,node:le.route.length?le.route.join("/"):"",session:oe.tmuxSession,route:le.route,panelUrl:oe.panelUrl||"",telemetry:Me.telemetry||null,preview:Me.preview||oe.preview||"",activity:Me.activity||oe.activity||0},cells:le.cells||[]}},[Q,Zt]),Vt=nt("local"),ln=w.useMemo(()=>lo(Wt,Re,Vt.filter,Ti(Ee,"local")).filter(le=>R0(le,S)),[Wt,Re,Vt.filter,S,Ee]),Vs=Pe.reduce((le,oe)=>le+(oe.cells||[]).length+(oe.unmanaged||[]).filter(Me=>!Me.technical).length,0),vs=lo(Wt,Re,"all",Ti(Ee,"local")).length+Vs,qt=Wt.filter(le=>le.live).length+Pe.reduce((le,oe)=>le+vc(oe).rawItems.filter(Me=>Me.live).length,0),Ys=(_||[]).filter(le=>le.attached).length+Pe.reduce((le,oe)=>le+(oe.sessions||[]).filter(Me=>Me.attached).length,0),Vn=Math.min(Ys,qt),ls=F.port?`${F.bind}:${F.port}`:F.bind;function St(le,oe=null,Me=Wt){var Ct,_t;const Ke=Array.isArray(oe==null?void 0:oe.route)?oe.route:[],mt=Ke.join("/"),q=mt||"local",ae=Ke.length?oe==null?void 0:oe.instanceId:V,Te=(Qe,Lt)=>t({session:Qe,...mt?{node:mt}:{},...Va.test(String(ae||""))?{ownerId:ae}:{},...typeof Lt=="string"&&Lt?{cellName:Lt}:{}}),Ge=rt;if(le.type==="cell"){const Qe=le.value,Lt=O(Ke),Tn=Rd({hostCell:Lt.hostCell??null,threadStatus:Lt.threadStatus,pins:Re,item:le}),Xe=Ke.length?((oe==null?void 0:oe.sessions)||[]).find(Jt=>Jt.name===Qe.tmuxSession):tn.get(Qe.tmuxSession),st=vm(Tn,Lt.hostLease??null),Ht=Qe.degraded?p("cell-degraded"):le.subtitle||(Qe.tmux?p("cell-idle"):p("cell-off")),ke=st?`${Ht} · ${p(st)}`:Ht,je=Ke.length===0||((oe==null?void 0:oe.capabilities)||[]).includes(Qe.active?"down":"up"),Je=Ke.length===0?B.includes("boot"):((oe==null?void 0:oe.capabilities)||[]).includes("boot"),ct=xt(Qe,Ke),kt=ro({item:le,cellName:Qe.cell,route:Ke,pins:Re,hostByRoute:i}),Gs=!!te&&te.itemKey===le.key,wi=`${p("cell-actions-open")}: ${Qe.cell}`;return l.jsxs("div",{className:"nc-mcard","data-roster-key":le.key,"data-position":q,children:[K&&l.jsx(Vi,{position:q,itemKey:le.key,label:Qe.cell,canMove:Ge,onMove:(Jt,_s)=>re(q,Jt,_s,Me),onStep:Jt=>ce(q,le.key,Jt,Me)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Qe.tmux&&Te(Qe.tmuxSession,Qe.cell),title:ke,"aria-label":`${Qe.cell}, ${ke}`,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}),kt.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:oo(le.activity)}):null,le.fresh&&((Ct=Xe==null?void 0:Xe.outbox)==null?void 0:Ct.count)>0&&l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Xe.outbox.count}),l.jsx("button",{type:"button",className:`nc-act cellmenu${Gs?" on":""}`,title:wi,"aria-label":wi,"aria-haspopup":"menu","aria-expanded":Gs?"true":"false",onClick:()=>ge({itemKey:le.key,item:le,cell:Qe,route:Ke,canBoot:Je}),children:"⋯"}),je&&l.jsx("button",{className:`nc-act power${Qe.tmux?" on":""}${Qe.degraded?" warn":""}`,onClick:()=>se(Ke.length?{...Qe,boot:ct,route:Ke,availableEngines:(oe==null?void 0:oe.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 Ae=le.value;return l.jsxs("div",{className:"nc-mcard","data-roster-key":le.key,"data-position":q,children:[l.jsx(Vi,{position:q,itemKey:le.key,label:Ae.name,canMove:Ge,onMove:(Qe,Lt)=>re(q,Qe,Lt,Me),onStep:Qe=>ce(q,le.key,Qe,Me)}),l.jsxs("button",{className:"nc-mcard-main",onClick:()=>Te(Ae.name),children:[l.jsx("span",{className:Ae.attached?"dot on":"dot"}),l.jsxs("span",{className:"nc-mcard-text",children:[l.jsx("b",{children:Ae.name}),l.jsx("small",{children:Ae.preview?Ae.preview:Ae.cmd?Ae.cmd:p("windows").replace("{n}",String(Ae.windows||0))})]})]}),le.activity?l.jsx("span",{className:"nc-rel",children:oo(le.activity)}):null,le.fresh&&((_t=Ae.outbox)==null?void 0:_t.count)>0&&l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Ae.outbox.count}),l.jsx("button",{className:`nc-act pin${Re.includes(le.key)?" on":""}`,"aria-label":`${p("pin")} ${Ae.name}`,title:p("pin"),onClick:()=>qe(le.key),children:Re.includes(le.key)?"★":"☆"}),l.jsx("button",{className:`nc-act 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:()=>en(Ae.name,!Ae.technical,Ke),children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),"aria-label":`${p("terminate")} ${Ae.name}`,onClick:()=>{window.confirm(p("terminate-confirm").replace("{name}",Ae.name))&&It(Ae.name,Ke)},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")," · ",qt," ",p("sessions"),Vn>0&&` · ${Vn} attached`]}),l.jsxs("span",{className:"nc-head-actions",children:[l.jsx("button",{className:`nc-refresh${K?" on":""}`,onClick:()=>fe(le=>!le),"aria-pressed":K,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:ft,title:p("refresh"),children:l.jsx(Tt,{name:"refresh",size:18})})]})]}),l.jsxs("main",{className:"nc-home-scroll",children:[l.jsx(pI,{view:Wa({liveHost:i[Ns([])],cells:ne}),notice:Le}),l.jsx(Wk,{pinError:at,onRetry:_e,onDismiss:$e}),vs>8&&l.jsx("input",{className:"nc-filter",type:"search",placeholder:p("filter-placeholder"),"aria-label":p("filter-placeholder"),value:S,onChange:le=>T(le.target.value)}),k&&l.jsx("div",{className:"nc-err",children:k}),me&&l.jsx("div",{className:"nc-notice",role:"status",children:me}),D&&l.jsx("div",{className:"nc-set-hint nc-fleet-stale",role:"status",children:p("fleet-stale")}),Oe&&l.jsxs("div",{className:"nc-set-hint nc-reorder-blocked",role:"status",children:[p("reorder-blocked")," (",Oe.reason,")"]}),$!==null&&l.jsxs("div",{className:"nc-set-hint nc-fleet-off",role:"status",children:[p("fleet-off"),$?` (${$})`:""]}),l.jsxs("section",{className:"nc-group","data-position":"local",children:[l.jsx(Ep,{label:p("position-local"),count:ln.length,state:Vt,dotClass:"on",onToggle:()=>Fe("local",{open:!Vt.open}),onFilter:le=>Fe("local",{filter:le})}),Vt.open&&ln.map(le=>St(le,null,Wt)),Vt.open&&_===null&&l.jsx("div",{className:"nc-empty",children:p("loading-fleet")}),Vt.open&&_!==null&&ln.length===0&&!k&&l.jsx("div",{className:"nc-empty",children:S?p("no-match").replace("{q}",S):p("no-sessions-short")})]}),Pe.map(le=>{const oe=Gk(le.health,{passive:"warn"}),Me=le.fleetState==="stale"?p("fleet-stale"):le.fleetState==="disabled"?p("fleet-off"):"",Ke=le.fleetState==="stale"?"warn":oe||(le.status==="up"?"on":le.status==="passive"?"":"warn"),mt=[le.health?Od(le.health):Xi(le),Me].filter(Boolean).join(" · "),ae=(le.route&&le.route.length?le.route:[le.name]).join("/"),Te=nt(ae);if(le.kind==="vl")return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":ae,"data-node-order-key":ie(le),children:[l.jsx(Ep,{label:le.label||le.name,count:le.sessions.length,state:Te,dotClass:Ke,dotTitle:mt,detail:Xi(le),onToggle:()=>Fe(ae,{open:!Te.open}),onFilter:Qe=>Fe(ae,{filter:Qe})}),le.status==="up"&&Te.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"&&Te.open&&le.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]},`nodo-vl-${ae}-${le.name}`);const{rawItems:Ge}=vc(le),Ae=lo(Ge,Re,Te.filter,Ti(Ee,ae)).filter(Qe=>R0(Qe,S)),Ct=le.direct&&le.health&&le.health.managed!==!1?l.jsx("button",{type:"button",className:`nc-act power${le.tunnelStatus==="up"?" on":""}`,disabled:Ie===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:()=>Kn(le),children:l.jsx(Tt,{name:"power",size:15})}):null,_t=l.jsxs("span",{className:"nc-node-actions",children:[l.jsx(Vi,{scope:"node",position:"nodes",itemKey:ie(le),label:le.label||le.name,onMove:(Qe,Lt)=>we(Qe,Lt,v),onStep:Qe=>We(ie(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:()=>rn(le),children:"✎"}),Ct]});return l.jsxs("section",{className:"nc-group nc-node-order-wrap","data-position":ae,"data-node-order-key":ie(le),children:[l.jsx(Ep,{label:le.label||le.name,count:Ae.length,state:Te,dotClass:Ke,dotTitle:mt,detail:le.status==="up"?[Xi(le),Me].filter(Boolean).join(" · "):le.health&&Od(le.health)||Xi(le),onToggle:()=>Fe(ae,{open:!Te.open}),onFilter:Qe=>Fe(ae,{filter:Qe}),onRename:le.direct?()=>rn(le):null,action:_t}),le.status==="up"&&Te.open&&Ae.map(Qe=>St(Qe,le,Ge)),le.status==="up"&&Te.open&&Ae.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:[ls," · ",p("ssh-only")]})]}),l.jsx("span",{className:"nc-lang",onClick:le=>le.stopPropagation(),children:K1.map((le,oe)=>l.jsxs("span",{children:[oe>0&&" · ",l.jsx("button",{className:`nc-lang-btn${f===le?" on":""}`,onClick:()=>g(le),title:le,children:le.toUpperCase()})]},le))})]})]}),Dt&&l.jsx(Dd,{cell:Dt,token:e,route:Array.isArray(Dt.route)?Dt.route:[],onConfirm:Qt,onClose:()=>se(null)}),yn&&l.jsx(Ak,{row:yn.row,token:e,initialSource:Z,panelPort:Nc(yn.row.route||[],h,u),liveHost:Wa({liveHost:i[Ns(yn.row.route||[])],cells:yn.cells}),onClose:()=>{ve(null),be("preview")}}),te&&(()=>{const{item:le,cell:oe,route:Me=[],canBoot:Ke}=te,mt=ro({item:le,cellName:oe.cell,route:Me,pins:Re,hostByRoute:i}),q=jv({...mt,canBoot:Ke,boot:xt(oe,Me),alive:!!oe.tmux,handlers:Mt(le,oe,Me)});return l.jsx(Mv,{cellName:oe.cell,items:q,busy:Se||U.has(Ma(oe.cell,Me)),onClose:()=>ge(null)})})()]})}function pI({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 ${ov(t||{})}`,"aria-hidden":"true"}),l.jsx("span",{className:"nc-m-live-testo",children:n?t.cell:s}),l.jsx(tx,{view:t}),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 Ep({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 K0="",an="\x1B",mI=[{label:"↑",seq:an+"[A"},{label:"↓",seq:an+"[B"},{label:"PGUP",seq:an+"[5~"},{label:"PGDN",seq:an+"[6~"}],gI=new Set([an+"[A",an+"[B",an+"[C",an+"[D",an+"[5~",an+"[6~"]),vI=350,_I=55;function yI({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:k="full",onKeyboardKeep:R}){const[C,L]=w.useState(!1),[S,T]=w.useState(!1),[E,H]=w.useState(!1),F=k==="compact"&&!E,X=w.useRef({delay:null,interval:null}),V=w.useRef(()=>{}),G=()=>{const I=X.current;I.delay!==null&&clearTimeout(I.delay),I.interval!==null&&clearInterval(I.interval),I.delay=null,I.interval=null};V.current=G,w.useEffect(()=>{const I=()=>{document.visibilityState==="hidden"&&V.current()},W=()=>V.current();return window.addEventListener("blur",W),document.addEventListener("visibilitychange",I),()=>{window.removeEventListener("blur",W),document.removeEventListener("visibilitychange",I),V.current()}},[]),w.useEffect(()=>{k!=="compact"&&H(!1)},[k]);const ne=I=>{i?(t(an+I),c&&c()):t(I)},Y=(I,{keepOpen:W}={})=>{_&&!W&&fg(),W&&R&&R(),I()},B=(I,W={})=>({onPointerDown:se=>{se.preventDefault(),Y(I,W)},onClick:se=>{se.detail===0&&Y(I,W)}}),P=(I,W={})=>({onPointerDown:se=>{se.preventDefault(),G(),Y(I,W),!i&&(X.current.delay=setTimeout(()=>{X.current.delay=null,I(),X.current.interval=setInterval(I,_I)},vI))},onPointerUp:G,onPointerLeave:G,onPointerCancel:G,onLostPointerCapture:G,onTouchCancel:G,onClick:se=>{se.detail===0&&Y(I,W)}}),D=(I,W,se)=>l.jsx("button",{type:"button",...gI.has(W)&&!se?P(()=>ne(W)):B(()=>{ne(W),se&&se()}),children:I},I),M=(I,W)=>l.jsx("button",{type:"button",...B(()=>{e(W),T(!1)}),children:I},I),$=g?l.jsx("button",{type:"button","aria-label":p("fleet-cells"),title:p("fleet-cells"),"aria-expanded":v,...B(g),children:"◫"},"cells"):l.jsx("button",{type:"button",...B(()=>{u&&u()}),children:"⌨"},"kbd"),A=b&&l.jsx("button",{type:"button",className:"nc-enter-key","aria-label":"ENTER",title:"ENTER",...B(()=>ne("\r")),children:l.jsx(Tt,{name:"enter",size:24})}),j=S&&l.jsxs("div",{className:"nc-keymenu",children:[M("←WIN","prev-window"),M("WIN→","next-window"),M("⬅PANE","pane-left"),M("PANE➡","pane-right"),D("SCROLL",K0+"[",()=>{L(!0),T(!1)}),l.jsx("button",{type:"button",className:h?"armed":"",...B(()=>{f==null||f(!h),T(!1)}),children:"SELECT"}),D("⌃C","",()=>T(!1)),D("DETACH",K0+"d",()=>T(!1))]});if(C)return l.jsxs("div",{className:"nc-keybar copy",children:[l.jsx("span",{className:"tag",children:"copy-mode"}),mI.map(I=>D(I.label,I.seq)),D("ESCI (q)","q",()=>L(!1))]});if(F)return l.jsxs("div",{className:"nc-keybar termux",children:[j,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"),...B(()=>H(!0)),children:l.jsx(Tt,{name:"chevronUp",size:20})},"expand"),$,l.jsx("button",{type:"button",className:S?"armed":"",...B(()=>T(I=>!I)),children:"☰"},"menu"),D("↑",an+"[A"),D("↓",an+"[B"),D("←",an+"[D"),D("→",an+"[C"),D("PGUP",an+"[5~"),D("PGDN",an+"[6~")]})}),A]})]});const N=k==="compact"&&E,U=N&&l.jsx("button",{type:"button",className:"nc-retract-key","aria-label":p("keybar-retract"),title:p("retract"),...B(()=>H(!1)),children:l.jsx(Tt,{name:"chevronDown",size:20})});return l.jsxs("div",{className:`nc-keybar termux${N?" expanded":""}`,children:[j,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:[D("ESC",an),l.jsx("button",{type:"button",className:S?"armed":"",...B(()=>T(I=>!I)),children:"☰"},"menu"),D("/","/"),D("—","-"),D("HOME",an+"[H"),D("↑",an+"[A"),D("END",an+"[F"),D("PGUP",an+"[5~")]}),l.jsxs("div",{className:"row",children:[D("⇥"," "),$,l.jsx("button",{type:"button",className:n?"armed":"",...B(()=>{s&&s()},{keepOpen:!0}),children:"CTRL"},"ctrl"),l.jsx("button",{type:"button",className:i?"armed":"",...B(()=>{a&&a()},{keepOpen:!0}),children:"ALT"},"alt"),D("←",an+"[D"),D("↓",an+"[B"),D("→",an+"[C"),D("PGDN",an+"[6~")]})]}),A]})]})}const wI=t=>t>1048576?`${(t/1048576).toFixed(1)}M`:t>1024?`${(t/1024).toFixed(0)}K`:`${t}B`;function Mg({session:t,node:e,token:n,filesEvent:s,onClose:i}){$n();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 L=await(await Wn(`${a}/files?session=${encodeURIComponent(t)}`,n)).json();if(L.error){_(L.error);return}g(L);const S=L.outbox[0]?L.outbox[0].mtime:0;localStorage.setItem(A1(c),String(S))}catch(C){_(String(C))}}w.useEffect(()=>{b()},[t,e]),w.useEffect(()=>{s&&s.session===t&&b()},[s]);async function k(C){const L=await Wn(`${a}/files/download?session=${encodeURIComponent(t)}&box=${u}&name=${encodeURIComponent(C)}`,n);if(!L.ok){const H=await L.json().catch(()=>({}));_(H.error?`errore: ${H.error}`:"errore download");return}const S=await L.blob(),T=URL.createObjectURL(S),E=document.createElement("a");E.href=T,E.download=C,E.click(),URL.revokeObjectURL(T)}async function R(C){const L=await Wn(`${a}/files?session=${encodeURIComponent(t)}&box=${u}&name=${encodeURIComponent(C)}`,n,{method:"DELETE"});if(!L.ok){const S=await L.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(C=>l.jsxs("li",{children:[l.jsx("span",{className:"name",children:C.name}),l.jsx("small",{children:wI(C.size)}),l.jsx("button",{type:"button",onClick:()=>k(C.name),title:p("files-download"),"aria-label":`${p("files-download")} ${C.name}`,children:l.jsx(Tt,{name:"download",size:18})}),l.jsx("button",{onClick:()=>R(C.name),title:p("delete"),"aria-label":`${p("delete")} ${C.name}`,children:l.jsx(Tt,{name:"trash",size:18})})]},C.name)),f[u].length===0&&l.jsx("li",{className:"empty",children:p("empty-files")})]})]})}const ph="nc_composer_v1",Tg="nc-composer-reset",bI=50,hC=256*1024,fC=512*1024,SI=768*1024,V0=2*1024*1024,pC=720*60*60*1e3,Pg=1;function mC(t){const e=Number(t);return Number.isFinite(e)&&e>0?e:0}function Ov(t){if(t!==void 0)return t;try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function zd(){return{version:Pg,cells:{}}}function gC(t){const e=[];for(const s of Array.isArray(t)?t:[]){const i=typeof s=="string"?s:s&&s.text,a=mC(typeof s=="string"?0:s&&s.at);if(!(typeof i!="string"||!i||i.length>hC)&&!(e.length&&e[e.length-1].text===i)&&(e.push({text:i,at:a}),e.length>=bI))break}let n=0;return e.filter(s=>n+s.text.length>SI?!1:(n+=s.text.length,!0))}function Fd(t){if(!t||typeof t!="object")return null;const e=typeof t.draft=="string"&&t.draft.length<=fC?t.draft:"",n=gC(t.history),s=mC(t.updatedAt),i=t.expanded===!0;return!e&&!n.length&&!i?null:{draft:e,history:n,expanded:i,updatedAt:s}}function xI(t){let e;try{e=typeof t=="string"?JSON.parse(t):t}catch{return zd()}if(!e||typeof e!="object"||e.version!==Pg||!e.cells||typeof e.cells!="object")return zd();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=Fd(i);a&&(n[s]=a)}return{version:Pg,cells:n}}function vC(t){const e=Ov(t);if(!e)return zd();try{return xI(e.getItem(ph))}catch{return zd()}}function Y0(t){try{return JSON.stringify(t).length}catch{return 1/0}}function kI(t,e,n){for(const[s,i]of Object.entries(t.cells))s!==n&&i.updatedAt>0&&e-i.updatedAt>pC&&delete t.cells[s]}function _C(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(;Y0(t)>V0;){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 _C(t,e)){if(Y0(t)<=V0)break;delete t.cells[n]}}function yC(t,e,n){const s=Ov(t);if(!s)return!1;CI(e,n);const i=()=>(s.setItem(ph,JSON.stringify(e)),!0);try{return i()}catch{for(const c of _C(e,n)){delete e.cells[c];try{return i()}catch{}}return!1}}function qc(t,e,n,s){const i=vC(e);kI(i,n,t);const a=Fd(i.cells[t])||{draft:"",history:[],expanded:!1,updatedAt:0},c=s({...a,history:[...a.history]}),u=Fd(c);return u?i.cells[t]={...u,updatedAt:n}:delete i.cells[t],{ok:yC(e,i,t),cell:i.cells[t]||{draft:"",history:[],expanded:!1,updatedAt:n}}}function EI({ownerId:t,node:e,session:n}){const s=String(n||"");if(!s)return"";const i=Va.test(String(t||""))?String(t):e?`route:${String(e)}`:"local";return`${encodeURIComponent(i)}:${encodeURIComponent(s)}`}function Gl(t,e,n=Date.now()){if(!t)return{draft:"",history:[],expanded:!1,updatedAt:0};const s=vC(e),i=Fd(s.cells[t]);return!i||i.updatedAt>0&&n-i.updatedAt>pC?(s.cells[t]&&(delete s.cells[t],yC(e,s,"")),{draft:"",history:[],expanded:!1,updatedAt:0}):{...i,history:[...i.history]}}function G0(t,e,n,s=Date.now()){const i=String(e||"");return!t||i.length>fC?!1:qc(t,n,s,a=>({...a,draft:i})).ok}function X0(t,e,n=Date.now()){return t?qc(t,e,n,s=>({...s,draft:""})).ok:!1}function NI(t,e,n,s=Date.now()){return t?qc(t,n,s,i=>({...i,expanded:!!e})).ok:!1}function RI(t,e,n,s=Date.now()){const i=String(e||"");return!t||!i||i.length>hC?!1:qc(t,n,s,a=>{const c=a.history.filter(u=>u.text!==i);return c.unshift({text:i,at:s}),{...a,history:gC(c)}}).ok}function LI(t,e,n=Date.now()){return t?qc(t,e,n,s=>({...s,history:[]})).ok:!1}function AI(t){const e=Ov(t);if(!e)return!1;try{return e.removeItem(ph),!0}catch{return!1}}const jI=300;function MI(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function TI({ownerId:t,node:e,session:n,storage:s=MI()}){const i=w.useMemo(()=>EI({ownerId:t,node:e,session:n}),[t,e,n]),a=w.useMemo(()=>Gl(i,s),[]),[c,u]=w.useState(a.draft),[h,f]=w.useState(a.expanded),[g,v]=w.useState(a.history),[_,b]=w.useState(-1),k=w.useRef(i),R=w.useRef(a.draft),C=w.useRef(null),L=w.useRef(a.updatedAt||0),S=w.useRef(a.draft),T=w.useCallback(()=>{C.current&&clearTimeout(C.current),C.current=null},[]),E=w.useCallback(()=>{T(),G0(k.current,R.current,s)},[T,s]),H=w.useCallback(()=>{T(),C.current=setTimeout(()=>{C.current=null,G0(k.current,R.current,s)},jI)},[T,s]),F=w.useCallback(D=>{const M=String(typeof D=="function"?D(R.current):D||"");R.current=M,L.current=Date.now(),S.current=M,b(-1),u(M),H()},[H]),X=w.useCallback((D,M)=>{T(),R.current=D,L.current=Date.now(),u(D),b(M),H()},[T,H]),V=w.useCallback(()=>{if(!g.length)return!1;const D=Math.min(_+1,g.length-1);return _<0&&(S.current=R.current),X(g[D].text,D),!0},[X,g,_]),G=w.useCallback(()=>{if(_<0)return!1;const D=_-1;return X(D<0?S.current:g[D].text,D),!0},[X,g,_]),ne=w.useCallback(D=>{S.current=R.current;const M=g.findIndex($=>$.text===D);X(String(D||""),M)},[X,g]),Y=w.useCallback(()=>{f(D=>{const M=!D;return NI(k.current,M,s),M})},[s]),B=w.useCallback((D,M,$)=>{if(!D)return;if(RI(D,$,s),!(k.current===D)){Gl(D,s).draft===M&&X0(D,s);return}v(Gl(D,s).history),S.current="",b(-1),R.current===M?(T(),R.current="",L.current=Date.now(),u(""),X0(D,s)):H()},[T,H,s]),P=w.useCallback(()=>{LI(k.current,s),v([]),b(-1),S.current=R.current},[s]);return w.useEffect(()=>{if(k.current===i)return;E(),k.current=i;const D=Gl(i,s);R.current=D.draft,L.current=D.updatedAt||0,S.current=D.draft,u(D.draft),f(D.expanded),v(D.history),b(-1)},[i,E,s]),w.useEffect(()=>{const D=()=>E(),M=()=>{document.visibilityState==="hidden"&&E()};return window.addEventListener("pagehide",D),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("pagehide",D),document.removeEventListener("visibilitychange",M),E()}},[E]),w.useEffect(()=>{const D=()=>{T(),R.current="",L.current=0,S.current="",u(""),f(!1),v([]),b(-1)},M=A=>{if(A.key!==ph)return;if(A.newValue==null){D();return}const j=Gl(k.current,s);j.updatedAt<L.current||(T(),R.current=j.draft,L.current=j.updatedAt,S.current=j.draft,u(j.draft),f(j.expanded),v(j.history),b(-1))},$=()=>D();return window.addEventListener("storage",M),window.addEventListener(Tg,$),()=>{window.removeEventListener("storage",M),window.removeEventListener(Tg,$)}},[T,s]),{cellKey:i,text:c,setText:F,expanded:h,toggleExpanded:Y,history:g,historyCursor:_,recallPrevious:V,recallNext:G,selectHistory:ne,confirmSubmitted:B,clearHistory:P,flush:E}}function wC({submitText:t,token:e,session:n,node:s,ownerId:i,readonly:a=!1,keepKeyboardClosedOnVoice:c=!0}){$n();const u=s?`/api/route/${String(s).split("/").map(encodeURIComponent).join("/")}/_`:"/api",{cellKey:h,text:f,setText:g,expanded:v,toggleExpanded:_,history:b,historyCursor:k,recallPrevious:R,recallNext:C,selectHistory:L,confirmSubmitted:S,clearHistory:T,flush:E}=TI({ownerId:i,node:s,session:n}),[H,F]=w.useState(!1),[X,V]=w.useState(""),[G,ne]=w.useState(""),[Y,B]=w.useState(!1),P=w.useRef(null),D=w.useRef(null),M=w.useRef(null),[$,A]=w.useState(!1),[j,N]=w.useState({left:0,bottom:0}),[U,I]=w.useState(!1),[W,se]=w.useState(!1),me=w.useRef(null),pe=w.useRef(null),Ie=w.useRef(null),J=w.useRef(null),te=w.useRef(null),ge=w.useRef(null),Se=w.useRef(null),Be=w.useRef(null),Le=w.useRef(!1),[ze,Q]=w.useState(!1),[ve,Z]=w.useState({left:0,bottom:0,width:320}),be=w.useRef(`nc-attach-${Math.random().toString(36).slice(2,8)}`);w.useEffect(()=>{let ce=!1;if(s){B(!1);return}return Wn(`${u}/voice/status`,e).then(O=>O.json()).then(O=>{ce||B(!!O.serverSttConfigured)}).catch(()=>{ce||B(!1)}),()=>{ce=!0}},[e,u]);const fe=!!(typeof window<"u"&&(window.SpeechRecognition||window.webkitSpeechRecognition)||Y);async function Re(){const ce=M.current&&typeof M.current.value=="string"?M.current.value:f;fg(),ce!==f&&g(ce);const O=ce,de=dT(O);if(!de||W)return;if(a){V(p("settings-readonly"));return}se(!0),V("");let we=!1;try{we=!!await t(de)}catch{we=!1}we?S(h,O,de):V(p("composer-send-failed")),se(!1)}function Ee(){const ce=me.current&&me.current.getBoundingClientRect();ce&&N({left:Math.max(6,Math.min(ce.left,window.innerWidth-186)),bottom:window.innerHeight-ce.top+6}),A(!0)}function qe(ce){A(!1),ce&&me.current&&me.current.focus()}function Ze(){const ce=Ie.current&&Ie.current.getBoundingClientRect();if(ce){const O=Math.max(220,Math.min(360,window.innerWidth-12));Z({left:Math.max(6,Math.min(ce.right-O,window.innerWidth-O-6)),bottom:window.innerHeight-ce.top+6,width:O})}Q(!0)}function at(ce){Q(!1),ce&&Ie.current&&Ie.current.focus()}w.useEffect(()=>{if(!$)return;const ce=de=>{de.key==="Escape"&&qe(!0)},O=de=>{const we=pe.current&&pe.current.contains(de.target),We=me.current&&me.current.contains(de.target);!we&&!We&&qe(!1)};return document.addEventListener("keydown",ce),document.addEventListener("pointerdown",O),()=>{document.removeEventListener("keydown",ce),document.removeEventListener("pointerdown",O)}},[$]),w.useEffect(()=>{if(!ze)return;const ce=de=>{de.key==="Escape"&&at(!0)},O=de=>{const we=J.current&&J.current.contains(de.target),We=Ie.current&&Ie.current.contains(de.target);!we&&!We&&at(!1)};return document.addEventListener("keydown",ce),document.addEventListener("pointerdown",O),()=>{document.removeEventListener("keydown",ce),document.removeEventListener("pointerdown",O)}},[ze]);function Oe(ce){if(!(ce.isComposing||Le.current||ce.altKey||ce.ctrlKey||ce.metaKey)){if(ce.key==="ArrowUp"&&ce.currentTarget.selectionStart===0&&ce.currentTarget.selectionEnd===0){R()&&ce.preventDefault();return}ce.key==="ArrowDown"&&k>=0&&ce.currentTarget.selectionStart===f.length&&ce.currentTarget.selectionEnd===f.length&&C()&&ce.preventDefault()}}function _e(ce){qe(!1),ce.current&&ce.current.click()}async function $e(ce){if(!ce.length||!n)return;I(!0),V("");const{paths:O,errors:de}=await hg({files:ce,token:e,session:n,node:s,paste:!1});de.length&&V(de.map(we=>`${we.name}: ${we.message}`).join(" · ")),O.length&&g(we=>we+(we&&!we.endsWith(" ")?" ":"")+O.join(" ")),I(!1)}async function nt(ce){var we;if(!ce.length||!n)return;I(!0),V(""),ne("");const{paths:O,errors:de}=await hg({files:ce,token:e,session:n,node:s,paste:!1});if(de.length&&V(de.map(We=>`${We.name}: ${We.message}`).join(" · ")),O.length){ne(p("attach-inbox-done").replace("{n}",String(O.length)));try{(we=navigator.vibrate)==null||we.call(navigator,10)}catch{}setTimeout(()=>ne(""),2500)}I(!1)}function Fe(){P.current&&P.current.stop(),D.current&&D.current.stop(),F(!1)}async function rt(){V("");const ce=window.SpeechRecognition||window.webkitSpeechRecognition;if(ce){const O=new ce;O.lang="it-IT",O.continuous=!1,O.interimResults=!0;const de=f?`${f} `:"";O.onresult=we=>{const We=Array.from(we.results).map(ie=>ie[0].transcript).join("");g(de+We)},O.onend=()=>F(!1),O.onerror=we=>{V(`voice: ${we.error||"errore"}`),F(!1)},P.current=O,O.start(),F(!0);return}try{const O=await navigator.mediaDevices.getUserMedia({audio:!0}),de=new MediaRecorder(O),we=[];de.ondataavailable=We=>we.push(We.data),de.onstop=async()=>{O.getTracks().forEach(We=>We.stop()),F(!1),V("trascrivo…");try{const We=new Blob(we,{type:de.mimeType||"audio/webm"}),Pe=await(await Wn(`${u}/voice/transcribe`,e,{method:"POST",headers:{"content-type":"application/octet-stream"},body:We})).json();Pe.error?V(Pe.error):(V(""),g(ft=>ft+(ft?" ":"")+(Pe.text||"")))}catch(We){V(String(We))}},D.current={stop:()=>de.state!=="inactive"&&de.stop()},de.start(),F(!0)}catch{V("microfono non disponibile"),F(!1)}}function re(){c&&fg(),H?Fe():rt()}return l.jsxs("div",{className:"nc-composer",children:[X&&l.jsx("div",{className:"nc-composer-err",children:X}),G&&l.jsx("div",{className:"nc-composer-info",children:G}),l.jsxs("div",{className:"nc-composer-row",children:[n&&l.jsx("button",{ref:me,className:U?"attach busy":"attach",disabled:U,onClick:()=>$?qe(!1):Ee(),title:p(U?"attach-uploading":"attach"),"aria-label":p("attach"),"aria-haspopup":"menu","aria-expanded":$,"aria-controls":be.current,children:l.jsx(Tt,{name:"attach",size:22})}),$&&l.jsxs("div",{ref:pe,id:be.current,role:"menu",className:"nc-attach-menu",style:{left:j.left,bottom:j.bottom},children:[l.jsxs("button",{role:"menuitem",onClick:()=>_e(te),children:[l.jsx(Tt,{name:"file",size:18})," ",p("attach-file")]}),l.jsxs("button",{role:"menuitem",onClick:()=>_e(ge),children:[l.jsx(Tt,{name:"camera",size:18})," ",p("attach-camera")]}),l.jsxs("button",{role:"menuitem",onClick:()=>_e(Se),children:[l.jsx(Tt,{name:"image",size:18})," ",p("attach-gallery")]}),l.jsxs("button",{role:"menuitem",onClick:()=>_e(Be),children:[l.jsx(Tt,{name:"folder",size:18})," ",p("attach-inbox")]})]}),l.jsx("button",{ref:Ie,type:"button",className:"history",onPointerDown:ce=>ce.preventDefault(),onClick:()=>ze?at(!1):Ze(),title:p("composer-history-tools"),"aria-label":p("composer-history-tools"),"aria-haspopup":"menu","aria-expanded":ze,children:l.jsx(Tt,{name:"history",size:21})}),ze&&l.jsxs("div",{ref:J,role:"menu",className:"nc-composer-history-menu",style:{left:ve.left,bottom:ve.bottom,width:ve.width},children:[l.jsxs("button",{role:"menuitem",className:"nc-composer-history-action",onPointerDown:ce=>ce.preventDefault(),onClick:()=>{_(),at(!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((ce,O)=>l.jsxs("button",{type:"button",role:"menuitem",className:"nc-composer-history-entry",onPointerDown:de=>de.preventDefault(),onClick:()=>{L(ce.text),at(!1)},children:[l.jsx("span",{children:ce.text.replace(/\s+/g," ").slice(0,180)}),ce.at>0&&l.jsx("small",{children:new Date(ce.at).toLocaleString()})]},`${ce.at}:${O}`)),b.length>0&&l.jsx("button",{type:"button",role:"menuitem",className:"nc-composer-history-clear",onPointerDown:ce=>ce.preventDefault(),onClick:()=>{T(),at(!1)},children:p("composer-history-clear")})]}),l.jsx("input",{ref:te,type:"file",multiple:!0,hidden:!0,onChange:ce=>{$e(Array.from(ce.target.files||[])),ce.target.value=""}}),l.jsx("input",{ref:ge,type:"file",accept:"image/*",capture:"environment",hidden:!0,onChange:ce=>{$e(Array.from(ce.target.files||[])),ce.target.value=""}}),l.jsx("input",{ref:Se,type:"file",accept:"image/*,video/*",multiple:!0,hidden:!0,onChange:ce=>{$e(Array.from(ce.target.files||[])),ce.target.value=""}}),l.jsx("input",{ref:Be,type:"file",multiple:!0,hidden:!0,onChange:ce=>{nt(Array.from(ce.target.files||[])),ce.target.value=""}}),l.jsx("textarea",{ref:M,className:v?"expanded":"",rows:v?8:2,value:f,placeholder:p("composer-placeholder"),onChange:ce=>g(ce.target.value),onKeyDown:Oe,onCompositionStart:()=>{Le.current=!0},onCompositionEnd:()=>{Le.current=!1},onBlur:E}),fe&&l.jsx("button",{type:"button",className:H?"mic on":"mic",title:p("voice"),"aria-label":p("voice"),onPointerDown:ce=>{ce.preventDefault(),re()},onClick:ce=>{ce.detail===0&&re()},children:l.jsx(Tt,{name:"mic",size:22})}),l.jsx("button",{type:"button",className:"go",disabled:W,onPointerDown:ce=>ce.preventDefault(),onClick:Re,title:p("send"),children:l.jsx(Tt,{name:"enter",size:22})})]})]})}const J0=460,PI=320;function II({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 k=R=>{R.key==="Escape"&&f()};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[f]);const _=s?Math.max(8,Math.min(s.right+10,window.innerWidth-J0-8)):void 0,b=s?Math.max(8,Math.min(s.top-6,window.innerHeight-PI-8)):void 0;return l.jsxs("div",{className:"nc-peekcloud",style:{left:_,top:b,width:J0},"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(Sv,{row:t,token:e,panelPort:n,liveHost:i,onLiveHostApplied:a,source:c,onSourceChange:u})]})}function Np(t){return String(t||"?").replace(/^[^a-zA-Z0-9]+/,"").charAt(0).toUpperCase()||"?"}const DI=180,OI=480,Xl=(t,e=[])=>`${e.length?e.join("/"):"local"}:${t}`;function BI({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:k,localNodeId:R,fleetCapabilities:C=[],fleetStale:L=!1,fleetOff:S=null,bootSettlement:T=null,localVerified:E=!0,hostByRoute:H={},onDesignateCell:F,onClearHostCell:X,onBootSettlementApplied:V,onOpenVlSession:G,token:ne="",onPeekOpen:Y,overlayOpen:B=!1,width:P=240,collapsed:D=!1,onResize:M,onToggleCollapse:$}){const[A,j]=$n(),{pins:N,orders:U,togglePin:I,removePin:W,pinError:se,reorderBlocked:me,retryPinPersist:pe,clearPinError:Ie,viewFor:J,updateView:te,canMoveRoster:ge,moveRoster:Se,stepRoster:Be}=Lv(),{groupsFor:Le,moveNode:ze,stepNode:Q,nodeKey:ve}=dh(),Z=q=>H[Ns(q)]||{},be=new Set((e||[]).map(q=>q.tmuxSession)),K=new Map((t||[]).map(q=>[q.name,q])),fe=(q,ae)=>kP(N,q,ae),Re=CP,Ee=[...e||[]].sort((q,ae)=>Re(fe(q.tmuxSession,(K.get(q.tmuxSession)||{}).activity),fe(ae.tmuxSession,(K.get(ae.tmuxSession)||{}).activity))),qe=(t||[]).filter(q=>!be.has(q.name)).sort((q,ae)=>Re(fe(q.name,q.activity),fe(ae.name,ae.activity))||q.name.localeCompare(ae.name)),Ze=new Set(n||[]),[at,Oe]=w.useState(null),[_e,$e]=w.useState("preview"),[nt,Fe]=w.useState(null),rt=w.useRef(null),re=w.useRef(null),ce=w.useRef(null);w.useEffect(()=>{ce.current=at},[at]),w.useEffect(()=>()=>{clearTimeout(rt.current),clearTimeout(re.current)},[]);const[O,de]=w.useState(null),[we,We]=w.useState(null),[ie,Pe]=w.useState(!1),[ft,Pt]=w.useState(null),bt=(q,ae,Te=[],Ge="",Ae=null)=>{const _t=(Te.length===0?K.get(ae.tmuxSession):(Ae||[]).find(Qe=>Qe&&Qe.name===ae.tmuxSession))||{};return{key:q.key,cellName:ae.cell,subtitle:q.subtitle||"",nodeLabel:Ge,node:Te.length?Te.join("/"):"",session:ae.tmuxSession,route:Te,panelUrl:ae.panelUrl||"",telemetry:_t.telemetry||null,preview:_t.preview||ae.preview||"",activity:_t.activity||ae.activity||0}},xt=(q,ae,Te=[],Ge="",Ae="preview")=>Ct=>{Ct&&Ct.stopPropagation(),Fe(null),$e(Ae),Oe(q.key),typeof Y=="function"&&Y()},vt=(q,ae,Te)=>{Te&&(clearTimeout(re.current),clearTimeout(rt.current),rt.current=setTimeout(()=>{ce.current||Fe({itemKey:q.key,routeKey:ae||"",anchorRect:Te.getBoundingClientRect(),source:"stream"})},300))},Mt=()=>{clearTimeout(rt.current),clearTimeout(re.current),re.current=setTimeout(()=>Fe(null),150)},Qt=()=>clearTimeout(re.current),Dt=()=>Fe(null),It=(q,ae,Te,Ge,Ae)=>{if(O&&O.itemKey===q){de(null);return}de({itemKey:q,routeKey:ae||"",canBoot:!!Ge,preserved:!!Ae}),We(Te?Te.getBoundingClientRect():null)};w.useEffect(()=>{B&&(Oe(null),$e("preview"))},[B]);const en=Pv(Ee,qe,K,void 0,{autorevole:E,fleetStale:L}),Kn=lo(en,N,J("local").filter,Ti(U,"local")),tn=Le(s||[]).map(q=>{const ae=(q.route&&q.route.length?q.route:[q.name]).join("/"),Te=J(ae);if(q.kind==="vl")return{g:q,nodeRoute:ae,groupView:Te,rawItems:[],items:[]};const{rawItems:Ge}=vc(q),Ae=lo(Ge,N,Te.filter,Ti(U,ae));return{g:q,nodeRoute:ae,groupView:Te,rawItems:Ge,items:Ae}}),nn=[...Kn,...tn.flatMap(({items:q,nodeRoute:ae,g:Te})=>(q||[]).map(Ge=>({...Ge,nodeRoute:ae,nodeLabel:Te.label||Te.name})))].filter(q=>q.type==="cell"),mn=at?nn.find(q=>q.key===at):null,Wt=()=>{if(!nt)return null;const q=nn.find(Ae=>Ae.key===nt.itemKey);if(!q)return null;const ae=q.value,Te=q.nodeRoute?s.find(Ae=>(Ae.route||[Ae.name]).join("/")===q.nodeRoute)||{}:null,Ge=q.nodeRoute?Te.route||[q.nodeRoute]:[];return l.jsx(II,{row:bt(q,ae,Ge,q.nodeLabel||"",Te&&Te.sessions),token:ne,anchorRect:nt.anchorRect,source:nt.source,onSourceChange:Ae=>Fe(Ct=>Ct&&{...Ct,source:Ae}),onExpand:Ae=>{Fe(null),$e(Ae),Oe(q.key),typeof Y=="function"&&Y()},onClose:Dt,onMouseEnter:Qt,onMouseLeave:Mt})},Zt=(q,ae,Te)=>i&&i({session:q,...ae?{node:ae}:{},...Va.test(String(Te||""))?{ownerId:Te}:{}}),yn=async q=>{if(!(q!=null&&q.direct)||!_)return;const ae=window.prompt(p("rename-node-prompt"),q.label||q.name);if(ae!==null)try{await _(q,ae)||window.alert(p("rename-node-invalid"))}catch(Te){window.alert(String((Te==null?void 0:Te.message)||Te))}},[Vt,ln]=w.useState({}),[Vs,vs]=w.useState(new Set);w.useEffect(()=>{const q=new Map;for(const ae of e||[])q.set(Xl(ae.cell),!!ae.boot);for(const ae of s||[]){const Te=ae.route||[ae.name];for(const Ge of ae.cells||[])q.set(Xl(Ge.cell,Te),!!Ge.boot)}ln(ae=>{let Te=!1;const Ge={...ae};for(const[Ae,Ct]of Object.entries(ae))q.has(Ae)&&q.get(Ae)===Ct&&(delete Ge[Ae],Te=!0);return Te?Ge:ae})},[e,s]),w.useEffect(()=>{if(!(T!=null&&T.cell))return;const q=Array.isArray(T.route)?T.route:[],ae=Xl(T.cell,q);ln(Te=>({...Te,[ae]:!!T.enabled})),V&&V(T.id)},[T,V]);const qt=(q,ae=[])=>{const Te=Xl(q.cell,ae);return Object.prototype.hasOwnProperty.call(Vt,Te)?Vt[Te]:!!q.boot},Ys=async(q,ae,Te=[],Ge)=>{if(!u)return;const Ae=Xl(ae.cell,Te),Ct=typeof Ge=="boolean"?Ge:!qt(ae,Te);ln(_t=>({..._t,[Ae]:Ct})),vs(_t=>new Set(_t).add(Ae));try{await u(ae.cell,Ct,Te)}catch(_t){ln(Qe=>{const Lt={...Qe};return delete Lt[Ae],Lt}),k&&k(_t)}finally{vs(_t=>{const Qe=new Set(_t);return Qe.delete(Ae),Qe})}},Vn=(q,ae,Te)=>({onToggleLive:async()=>{const Ge=ro({item:q,cellName:ae.cell,route:Te,pins:N,hostByRoute:H});Pe(!0);const Ae=await nh({action:Ge.isLive?"remove":"use",cellId:ae.cell,route:Te,token:ne});Pe(!1),Pt({messageKey:Ae.messageKey,ok:Ae.ok,cell:Ae.hostCell||ae.cell})},onTogglePin:()=>Av({view:hh({item:q,pins:N,hostByRoute:H,route:Te}),itemKey:q.key,togglePin:I,removePin:W}),onToggleBoot:Ge=>Ys(null,ae,Te,Ge),onWatchLive:()=>{Fe(null),$e("stream"),Oe(q.key),typeof Y=="function"&&Y()}}),[ls,St]=w.useState(null),le=(q,ae)=>{const Te=q.currentTarget.getBoundingClientRect();St({text:ae,y:Te.top+Te.height/2})},oe=()=>St(null),Me=w.useRef(null);w.useEffect(()=>()=>{Me.current&&Me.current()},[]);function Ke(q){q.preventDefault(),q.stopPropagation();const ae=q.clientX,Te=P,Ge=Ct=>{const _t=Math.max(DI,Math.min(OI,Te+(Ct.clientX-ae)));M&&M(_t)},Ae=()=>{window.removeEventListener("pointermove",Ge),window.removeEventListener("pointerup",Ae),window.removeEventListener("pointercancel",Ae),window.removeEventListener("blur",Ae),Me.current=null};window.addEventListener("pointermove",Ge),window.addEventListener("pointerup",Ae),window.addEventListener("pointercancel",Ae),window.addEventListener("blur",Ae),Me.current=Ae}const mt=D?{width:48,flex:"0 0 48px"}:{width:P,flex:`0 0 ${P}px`};return D?l.jsxs("aside",{className:"nc-sidebar mini",style:mt,children:[l.jsx("div",{className:"nc-side-head mini",children:l.jsx("button",{className:"nc-collapse-btn",onClick:$,title:p("expand"),children:"⟩"})}),l.jsx("button",{className:"nc-side-gear mini",onClick:()=>b&&b("nodes",!1),title:p("settings"),onMouseEnter:q=>le(q,p("settings")),onMouseLeave:oe,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:[J("local").open&&Kn.map(q=>q.type==="cell"?(()=>{const ae=q.value,Te=ae.degraded?"warn":ae.tmux?"on":"",Ge=!!ae.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${Ze.has(ae.tmuxSession)?" active":""}`,onMouseEnter:Ae=>{Ge?vt(q,"",Ae.currentTarget):le(Ae,`${ae.cell}: ${q.subtitle}`)},onMouseLeave:()=>{Ge?Mt():oe()},draggable:Ge,onDragStart:Ge?Ae=>Ae.dataTransfer.setData("text/nc-session",ae.tmuxSession):void 0,onClick:Ge?()=>{Fe(null),a&&a(ae.tmuxSession)}:()=>c&&c(ae),onDoubleClick:Ge?()=>Zt(ae.tmuxSession,"",R):void 0,children:l.jsx("span",{className:`nc-dot ${Te}${q.working?" working":""}`})},q.key)})():(()=>{const ae=q.value;return l.jsx("button",{type:"button",className:`nc-mini-init${Ze.has(ae.name)?" active":""}`,onMouseEnter:Te=>le(Te,ae.name),onMouseLeave:oe,draggable:!0,onDragStart:Te=>Te.dataTransfer.setData("text/nc-session",ae.name),onClick:()=>a&&a(ae.name),onDoubleClick:()=>Zt(ae.name,"",R),children:Np(ae.name)},q.key)})()),tn.flatMap(({g:q,nodeRoute:ae,groupView:Te,items:Ge})=>q.kind==="vl"?q.status==="up"&&q.sessions.length?q.sessions.map(Ae=>l.jsx("button",{type:"button",className:"nc-mini-init",onMouseEnter:Ct=>le(Ct,`${q.label||ae}: ${Ae.name}`),onMouseLeave:oe,onClick:()=>G&&G(q.peer),children:Np(Ae.name)},Ae.key)):[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Ae=>le(Ae,`${q.label||q.name}: ${Xi(q)||p("no-sessions-short")}`),onMouseLeave:oe,children:l.jsx("span",{className:`nc-dot${q.status==="up"?" on":" warn"}`})},`nodo-vl-${ae}-${q.name}`)]:q.status==="up"?Te.open?Ge.map(Ae=>Ae.type==="cell"?(()=>{const Ct=Ae.value,_t=!!Ct.tmux;return l.jsx("button",{type:"button",className:`nc-mini-dot${Ze.has(Ae.key)?" active":""}`,onMouseEnter:Qe=>{_t?vt(Ae,ae,Qe.currentTarget):le(Qe,`${q.label||ae}: ${Ct.cell} · ${Ae.subtitle}`)},onMouseLeave:()=>{_t?Mt():oe()},draggable:_t,onDragStart:_t?Qe=>Qe.dataTransfer.setData("text/nc-session",Ae.key):void 0,onClick:_t?()=>{Fe(null),a&&a(Ae.key)}:()=>c&&c({...Ct,route:q.route,availableEngines:q.engines||[]}),onDoubleClick:_t?()=>Zt(Ct.tmuxSession,ae,q.instanceId):void 0,children:l.jsx("span",{className:`nc-dot ${Ct.degraded?"warn":_t?`on${Ae.working?" working":""}`:""}`})},Ae.key)})():(()=>{const Ct=Ae.value;return l.jsx("button",{type:"button",className:`nc-mini-init${Ze.has(Ae.key)?" active":""}`,onMouseEnter:_t=>le(_t,`${q.label||ae}: ${Ct.name}`),onMouseLeave:oe,draggable:!0,onDragStart:_t=>_t.dataTransfer.setData("text/nc-session",Ae.key),onClick:()=>a&&a(Ae.key),onDoubleClick:()=>Zt(Ct.name,ae,q.instanceId),children:Np(Ct.name)},Ae.key)})()):[]:[l.jsx("button",{type:"button",className:"nc-mini-dot",onMouseEnter:Ae=>le(Ae,`${q.label||(q.route||[q.name]).join(" › ")}: ${Xi(q)}`),onMouseLeave:oe,children:l.jsx("span",{className:`nc-dot${q.status==="passive"?"":" warn"}`})},`nodo-${(q.route||[q.name]).join("/")}`)])]})}),Wt(),ls&&l.jsx("div",{className:"nc-mini-tip",style:{top:ls.y},children:ls.text})]}):l.jsxs("aside",{className:"nc-sidebar",style:mt,children:[l.jsx("div",{className:"nc-side-live-host",children:l.jsx($I,{view:Wa({liveHost:H[Ns([])],cells:e}),notice:ft})}),l.jsxs("div",{className:"nc-side-head",children:[l.jsx("button",{className:"nc-collapse-btn",onClick:$,title:p("collapse"),children:"⟨"}),l.jsx("span",{className:"nc-side-title",children:p("fleet")}),me&&l.jsx("span",{className:"nc-side-fleet-stale",role:"status",title:p("reorder-blocked"),"aria-label":p("reorder-blocked"),children:"⇅"}),L&&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(Wk,{pinError:se,onRetry:pe,onDismiss:Ie}),l.jsxs("div",{className:"nc-side-scroll",children:[l.jsx(zI,{label:p("position-local"),count:Kn.length,state:J("local"),onToggle:()=>te("local",{open:!J("local").open}),onFilter:q=>te("local",{filter:q})}),J("local").open&&l.jsxs("div",{className:"nc-side-group",children:[Kn.map(q=>q.type==="cell"?(()=>{var Tn;const ae=q.value,Te=Z([]),Ge=Rd({hostCell:Te.hostCell??null,threadStatus:Te.threadStatus,pins:N,item:q}),Ae=ae.degraded?"warn":ae.tmux?"on":"",Ct=vm(Ge,Te.hostLease??null),_t=ae.degraded?p("cell-degraded"):q.subtitle||(ae.tmux?p("cell-idle"):p("cell-off")),Qe=Ct?`${_t} · ${p(Ct)}`:_t,Lt=!!ae.tmux;return l.jsxs("div",{"data-roster-key":q.key,"data-position":"local",className:`nc-cell${Lt?" live":""}${Ze.has(ae.tmuxSession)?" active":""}`,title:`${ae.cell} · ${q.subtitle}${Qe===q.subtitle?"":` · ${Qe}`}`,"aria-label":`${ae.cell}, ${q.subtitle}${Qe===q.subtitle?"":`, ${Qe}`}`,draggable:Lt,onDragStart:Lt?Xe=>Xe.dataTransfer.setData("text/nc-session",ae.tmuxSession):void 0,onClick:Lt?()=>a&&a(ae.tmuxSession):void 0,onDoubleClick:Lt?()=>Zt(ae.tmuxSession,"",R):void 0,children:[l.jsx(Vi,{position:"local",itemKey:q.key,label:ae.cell,canMove:ge,onMove:(Xe,st)=>Se("local",Xe,st,en),onStep:Xe=>Be("local",q.key,Xe,en)}),Lt?l.jsx("button",{type:"button",className:"nc-side-peek",title:p("cell-peek"),"aria-label":`${p("cell-peek")}: ${ae.cell}`,onClick:xt(q,ae,[],""),onMouseEnter:Xe=>vt(q,"",Xe.currentTarget),onMouseLeave:Mt,children:l.jsx("span",{className:`nc-dot ${Ae}${q.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${Ae}${q.working?" working":""}`}),l.jsxs("span",{className:"nc-cell-main",children:[l.jsxs("b",{title:ae.cell,children:[ae.cell,ro({item:q,cellName:ae.cell,route:[],pins:N,hostByRoute:H}).isLive&&l.jsx("span",{className:"nc-live-bollino",children:"LIVE"})]}),l.jsx("small",{title:q.subtitle,children:q.subtitle})]}),q.activity?l.jsx("span",{className:"nc-rel",children:oo(q.activity)}):null,q.fresh&&((Tn=(K.get(ae.tmuxSession)||{}).outbox)==null?void 0:Tn.count)>0?l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:K.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":O&&O.itemKey===q.key?"true":"false",onClick:Xe=>{Xe.stopPropagation(),It(q.key,"",Xe.currentTarget,C.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:Xe=>{Xe.stopPropagation(),c&&c({...ae,boot:qt(ae)})},title:ae.active?p("power-off"):p("power-on"),children:l.jsx(Tt,{name:"power",size:14})})]},q.key)})():(()=>{var Te;const ae=q.value;return l.jsxs("div",{"data-roster-key":q.key,"data-position":"local",className:`nc-side-card${Ze.has(ae.name)?" active":""}`,draggable:!0,onDragStart:Ge=>Ge.dataTransfer.setData("text/nc-session",ae.name),onClick:()=>a&&a(ae.name),onDoubleClick:()=>Zt(ae.name,"",R),children:[l.jsx(Vi,{position:"local",itemKey:q.key,label:ae.name,canMove:ge,onMove:(Ge,Ae)=>Se("local",Ge,Ae,en),onStep:Ge=>Be("local",q.key,Ge,en)}),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)),((Te=ae.outbox)==null?void 0:Te.count)>0?` · 📦${ae.outbox.count}`:""]})]}),ae.activity?l.jsx("span",{className:"nc-rel",children:oo(ae.activity)}):null,l.jsx("button",{className:`nc-pin${N.includes(q.key)?" on":""}`,title:p("pin"),onClick:Ge=>{Ge.stopPropagation(),I(q.key)},children:N.includes(q.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:Ge=>{Ge.stopPropagation(),g&&g(ae.name,!ae.technical,[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:Ge=>{Ge.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",ae.name))&&f&&f(ae.name)},children:"⋯"})]},q.key)})()),Kn.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]}),tn.map(({g:q,nodeRoute:ae,groupView:Te,rawItems:Ge,items:Ae})=>{const Ct=Gk(q.health),_t=q.fleetState==="stale"?p("fleet-stale"):q.fleetState==="disabled"?p("fleet-off"):"",Qe=q.fleetState==="stale"?"warn":Ct||(q.status==="up"?"on":q.status==="passive"?"":"warn"),Lt=[q.health?Od(q.health):"",_t].filter(Boolean).join(" · "),Tn=q.status==="up"?[p("node-sessions").replace("{n}",String(Ae.length)),_t].filter(Boolean).join(" · "):q.health&&Od(q.health)||Xi(q);if(q.kind==="vl"){const Xe=Xi(q)||[p("node-sessions").replace("{n}",String(q.sessions.length)),_t].filter(Boolean).join(" · ");return l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":ve(q),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onClick:()=>te(ae,{open:!Te.open}),onKeyDown:st=>{(st.key==="Enter"||st.key===" ")&&(st.preventDefault(),te(ae,{open:!Te.open}))},children:[l.jsx(Vi,{scope:"node",position:"nodes",itemKey:ve(q),label:q.label||q.name,onMove:(st,Ht)=>ze(st,Ht,s||[]),onStep:st=>Q(ve(q),st,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:Te.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${Qe}`,title:Lt}),l.jsxs("span",{className:"nc-node-main",children:[l.jsx("b",{children:q.label||q.name}),l.jsx("small",{title:Xe,children:Xe})]})]}),q.status==="up"&&Te.open&&l.jsxs("div",{className:"nc-side-group",children:[q.sessions.map(st=>l.jsxs("div",{className:"nc-side-card nc-vl-session-row",role:"button",tabIndex:0,onClick:()=>G&&G(q.peer),onKeyDown:Ht=>{(Ht.key==="Enter"||Ht.key===" ")&&(Ht.preventDefault(),G&&G(q.peer))},children:[l.jsx("span",{className:"nc-dot on"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:st.name}),l.jsx("small",{children:p("vl-events-title")})]})]},st.key)),q.sessions.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-vl-${ae}-${q.name}`)}return l.jsxs("div",{className:"nc-node-order-wrap","data-node-order-key":ve(q),children:[l.jsxs("div",{className:"nc-side-group-title nc-node-title",role:"button",tabIndex:0,onContextMenu:q.direct&&_?Xe=>{Xe.preventDefault(),yn(q)}:void 0,onClick:()=>te(ae,{open:!Te.open}),onKeyDown:Xe=>{(Xe.key==="Enter"||Xe.key===" ")&&(Xe.preventDefault(),te(ae,{open:!Te.open}))},children:[l.jsx(Vi,{scope:"node",position:"nodes",itemKey:ve(q),label:q.label||q.name,onMove:(Xe,st)=>ze(Xe,st,s||[]),onStep:Xe=>Q(ve(q),Xe,s||[])}),l.jsx("span",{className:"nc-node-chevron",children:Te.open?"⌄":"›"}),l.jsx("span",{className:`nc-dot ${Qe}`,title:Lt}),l.jsxs("span",{className:"nc-node-main",children:[l.jsx("b",{children:q.label||q.name}),l.jsx("small",{title:Tn,children:Tn})]}),q.direct&&_&&l.jsx("button",{type:"button",className:"nc-node-rename",title:p("rename-node"),"aria-label":`${p("rename-node")} ${q.label||q.name}`,onClick:Xe=>{Xe.stopPropagation(),yn(q)},children:"✎"}),q.direct&&q.health&&q.health.managed!==!1&&l.jsx("button",{type:"button",className:`nc-power${q.tunnelStatus==="up"?" on":""}`,title:q.tunnelStatus==="up"?p("power-off"):p("power-on"),onClick:Xe=>{Xe.stopPropagation(),h&&h(q)},children:l.jsx(Tt,{name:"power",size:14})}),l.jsxs("select",{className:"nc-node-filter",value:Te.filter,title:p(`view-${Te.filter}`),onClick:Xe=>Xe.stopPropagation(),onChange:Xe=>te(ae,{filter:Xe.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")})]})]}),(q.status==="up"||q.cellsPreserved)&&Te.open&&l.jsxs("div",{className:"nc-side-group",children:[Ae.map(Xe=>Xe.type==="cell"?(()=>{var _s;const st=Xe.value,Ht=q.route||[q.name],ke=Z(Ht),je=Rd({hostCell:ke.hostCell??null,threadStatus:ke.threadStatus,pins:N,item:Xe}),Je=vm(je,ke.hostLease??null),ct=!!st.tmux&&!q.cellsPreserved,kt=st.degraded?"warn":st.tmux&&!q.cellsPreserved?"on":"",Gs=(q.sessions||[]).find(Ot=>Ot&&Ot.name===st.tmuxSession)||null,wi=q.cellsPreserved?`${p("fleet-stale")}`:Xe.subtitle||(st.tmux?p("cell-idle"):p("cell-off")),Jt=Je?`${wi} · ${p(Je)}`:wi;return l.jsxs("div",{"data-roster-key":Xe.key,"data-position":ae,className:`nc-side-card nc-cell${ct?" live":""}${q.cellsPreserved?" preserved":""}${Ze.has(st.key)?" active":""}`,title:Jt,draggable:ct,onDragStart:ct?Ot=>Ot.dataTransfer.setData("text/nc-session",st.key):void 0,onClick:ct?()=>a&&a(st.key):void 0,onDoubleClick:ct?()=>Zt(st.tmuxSession,ae,q.instanceId):void 0,children:[l.jsx(Vi,{position:ae,itemKey:Xe.key,label:st.cell,canMove:ge,onMove:(Ot,Os)=>Se(ae,Ot,Os,Ge),onStep:Ot=>Be(ae,Xe.key,Ot,Ge)}),ct?l.jsx("button",{type:"button",className:"nc-side-peek",title:p("cell-peek"),"aria-label":`${p("cell-peek")}: ${st.cell}`,onClick:xt(Xe,st,q.route||[q.name],q.label||q.name),onMouseEnter:Ot=>vt(Xe,ae,Ot.currentTarget),onMouseLeave:Mt,children:l.jsx("span",{className:`nc-dot ${kt}${Xe.working?" working":""}`})}):l.jsx("span",{className:`nc-dot ${kt}${Xe.working?" working":""}`}),l.jsxs("span",{className:"nc-card-main",children:[l.jsxs("b",{children:[st.cell,ro({item:Xe,cellName:st.cell,route:Ht,pins:N,hostByRoute:H}).isLive&&l.jsx("span",{className:"nc-live-bollino",children:"LIVE"})]}),l.jsx("small",{title:Xe.subtitle,children:Xe.subtitle})]}),Xe.activity?l.jsx("span",{className:"nc-rel",children:oo(Xe.activity)}):null,Xe.fresh&&((_s=(Gs||{}).outbox)==null?void 0:_s.count)>0?l.jsx("span",{className:"nc-badge",title:p("new-files-outbox"),children:Gs.outbox.count}):null,l.jsx("button",{type:"button",className:"nc-cellmenu",title:`${p("cell-actions-open")}: ${st.cell}`,"aria-label":`${p("cell-actions-open")}: ${st.cell}`,"aria-haspopup":"menu","aria-expanded":O&&O.itemKey===Xe.key?"true":"false",onClick:Ot=>{Ot.stopPropagation(),It(Xe.key,ae,Ot.currentTarget,u&&(q.capabilities||[]).includes("boot"),!!q.cellsPreserved)},children:l.jsx("span",{"aria-hidden":"true",children:"⋯"})}),(q.capabilities||[]).includes(st.active?"down":"up")&&l.jsx("button",{className:`nc-power${st.active?" on":""}${st.degraded?" warn":""}`,onClick:Ot=>{Ot.stopPropagation(),c&&c({...st,boot:qt(st,q.route||[]),route:q.route,availableEngines:q.engines||[]})},title:st.active?p("power-off"):p("power-on"),children:l.jsx(Tt,{name:"power",size:14})})]},Xe.key)})():(()=>{const st=Xe.value;return l.jsxs("div",{"data-roster-key":Xe.key,"data-position":ae,className:`nc-side-card${Ze.has(st.key)?" active":""}`,draggable:!0,onDragStart:Ht=>Ht.dataTransfer.setData("text/nc-session",st.key),onClick:()=>a&&a(st.key),onDoubleClick:()=>Zt(st.name,st.node||ae,q.instanceId),children:[l.jsx(Vi,{position:ae,itemKey:Xe.key,label:st.name,canMove:ge,onMove:(Ht,ke)=>Se(ae,Ht,ke,Ge),onStep:Ht=>Be(ae,Xe.key,Ht,Ge)}),l.jsx("span",{className:st.attached?"nc-dot on":"nc-dot"}),l.jsxs("span",{className:"nc-card-main",children:[l.jsx("b",{children:st.name}),l.jsx("small",{children:st.preview?st.preview:st.cmd?st.cmd:p("windows").replace("{n}",String(st.windows||0))})]}),st.activity?l.jsx("span",{className:"nc-rel",children:oo(st.activity)}):null,l.jsx("button",{className:`nc-pin${N.includes(Xe.key)?" on":""}`,title:p("pin"),onClick:Ht=>{Ht.stopPropagation(),I(Xe.key)},children:N.includes(Xe.key)?"★":"☆"}),l.jsx("button",{className:`nc-technical${st.technical?" on":""}`,title:st.technical?p("mark-normal"):p("mark-technical"),"aria-label":`${st.technical?p("mark-normal"):p("mark-technical")} ${st.name}`,onClick:Ht=>{Ht.stopPropagation(),g&&g(st.name,!st.technical,q.route||[])},children:"T"}),l.jsx("button",{className:"nc-menu",title:p("terminate"),onClick:Ht=>{Ht.stopPropagation(),window.confirm(p("terminate-confirm").replace("{name}",st.name))&&f&&f(st.name,q.route)},children:"⋯"})]},Xe.key)})()),Ae.length===0&&l.jsx("div",{className:"nc-empty",children:p("no-sessions-short")})]})]},`nodo-${(q.route||[q.name]).join("/")}`)})]}),l.jsx("div",{className:"nc-side-lang",children:K1.map((q,ae)=>l.jsxs("span",{children:[ae>0&&" · ",l.jsx("button",{className:`nc-lang-btn${A===q?" on":""}`,onClick:()=>j(q),title:q,children:q.toUpperCase()})]},q))}),l.jsx("div",{className:"nc-side-resize",onPointerDown:Ke,title:""}),mn&&(()=>{const q=mn.value,ae=mn.nodeRoute?s.find(Ge=>(Ge.route||[Ge.name]).join("/")===mn.nodeRoute)||{}:null,Te=mn.nodeRoute?ae.route||[mn.nodeRoute]:[];return l.jsx(Ak,{row:bt(mn,q,Te,mn.nodeLabel||"",ae&&ae.sessions),token:ne,initialSource:_e,onClose:()=>{Oe(null),$e("preview")}})})(),Wt(),O&&(()=>{const q=nn.find(Qe=>Qe.key===O.itemKey);if(!q)return null;const ae=q.value,Te=O.routeKey?s.find(Qe=>(Qe.route||[Qe.name]).join("/")===O.routeKey)||{}:null,Ge=O.routeKey?Te.route||[O.routeKey]:[],Ae=O.preserved?!1:!!ae.tmux,Ct=ro({item:q,cellName:ae.cell,route:Ge,pins:N,hostByRoute:H}),_t=jv({...Ct,canBoot:O.canBoot,boot:qt(ae,Ge),alive:Ae,handlers:Vn(q,ae,Ge)});return l.jsx(Vk,{anchorRect:we,items:_t,busy:ie,onClose:()=>de(null)})})()]})}function $I({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 ${ov(t||{})}`,"aria-hidden":"true"}),l.jsx("span",{className:"nc-live-strip-testo",children:n?t.cell:s}),l.jsx(tx,{view:t}),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 zI({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.jsxs("span",{className:"nc-node-main",children:[l.jsx("b",{children:t}),l.jsx("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 hs={PRESENTE:"presente-verificata",ASSENTE:"assente-verificata",IGNOTA:"ignota"},Rp={OK:"ok",NON_DISPONIBILE:"non-disponibile",RIMOSSO:"rimosso"},sd={LETTURA_NON_VERIFICABILE:"lettura-non-verificabile",OWNER_NON_DISPONIBILE:"owner-non-disponibile",OWNER_RIMOSSO:"owner-rimosso",LOCALE_NON_VERIFICATO:"lettura-locale-non-verificata"},Q0={RITORNO:"ritorno-dopo-assenza",IDENTITA:"identita-cambiata"},FI=6e4;function HI(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 Z0(t){const e=t&&t.created;return Number.isFinite(e)&&e>0?e:null}function UI({tileKey:t,node:e,nodeGroups:n,sessionsAlive:s,localVerified:i=!0,localIdentita:a=null,lastVerifiedAt:c=null,nowMs:u=0}={}){const h=HI(e,n);let f,g=Rp.OK,v=null,_=null;if(!e)i?!s||s.has(t)?(f=hs.PRESENTE,_=Z0({created:a})):f=hs.ASSENTE:(f=hs.IGNOTA,v=sd.LOCALE_NON_VERIFICATO);else if(!h)f=hs.IGNOTA,g=Rp.RIMOSSO,v=sd.OWNER_RIMOSSO;else if(h.status!=="up")f=hs.IGNOTA,g=Rp.NON_DISPONIBILE,v=h.cause||sd.OWNER_NON_DISPONIBILE;else if(h.inventoryPartial===!0)f=hs.IGNOTA,v=sd.LETTURA_NON_VERIFICABILE;else if(!s||s.has(t)){f=hs.PRESENTE;const k=Array.isArray(h.sessions)?h.sessions.find(R=>R&&R.key===t):null;_=Z0(k)}else f=hs.ASSENTE;const b=f===hs.IGNOTA&&Number.isFinite(c)&&Number.isFinite(u)&&u-c>FI;return{presenza:f,owner:g,causa:v,identita:f===hs.PRESENTE?_:null,verificata:f!==hs.IGNOTA,oltreIlTetto:b}}function bC(){return{presenza:null,identita:null}}function WI(t,e){const n=t&&typeof t=="object"?t:bC();if(!e||e.presenza===hs.IGNOTA)return{runtime:{presenza:n.presenza,identita:n.identita},generazione:0,motivo:null};const s=e.presenza===hs.PRESENTE;let i=null;return s&&(n.presenza===hs.ASSENTE?i=Q0.RITORNO:n.presenza===hs.PRESENTE&&n.identita!==null&&e.identita!==null&&n.identita!==e.identita&&(i=Q0.IDENTITA)),{runtime:{presenza:e.presenza,identita:s?e.identita===void 0?null:e.identita:null},generazione:i?1:0,motivo:i}}const Bv="nc_input_preferences_v1",Lp="nc-input-preferences",SC=Object.freeze(["double-tap","single-tap","never"]),xC=Object.freeze(["full","compact"]);function qI(){try{return typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)").matches:!1}catch{return!1}}const Sr=Object.freeze({terminalKeyboardGesture:"double-tap",keybarKeepsKeyboardClosed:!0,voiceKeepsKeyboardClosed:!0,showKeybarEnter:!0,keybarLayout:"full",showComposer:qI()});function $v(t){const e=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return{terminalKeyboardGesture:SC.includes(e.terminalKeyboardGesture)?e.terminalKeyboardGesture:Sr.terminalKeyboardGesture,keybarKeepsKeyboardClosed:typeof e.keybarKeepsKeyboardClosed=="boolean"?e.keybarKeepsKeyboardClosed:Sr.keybarKeepsKeyboardClosed,voiceKeepsKeyboardClosed:typeof e.voiceKeepsKeyboardClosed=="boolean"?e.voiceKeepsKeyboardClosed:Sr.voiceKeepsKeyboardClosed,showKeybarEnter:typeof e.showKeybarEnter=="boolean"?e.showKeybarEnter:Sr.showKeybarEnter,keybarLayout:xC.includes(e.keybarLayout)?e.keybarLayout:Sr.keybarLayout,showComposer:typeof e.showComposer=="boolean"?e.showComposer:Sr.showComposer}}function kC(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function eS(t=kC()){if(!t)return{...Sr};try{return $v(JSON.parse(t.getItem(Bv)||"null"))}catch{return{...Sr}}}function KI(t,e=kC()){const n=$v(t);if(e)try{e.setItem(Bv,JSON.stringify(n))}catch{}return n}function zv(){const[t,e]=w.useState(eS);w.useEffect(()=>{const s=i=>{if((i==null?void 0:i.type)==="storage"&&i.key!==Bv&&i.key!==null)return;const a=i!=null&&i.detail?$v(i.detail):eS();e(a)};return window.addEventListener(Lp,s),window.addEventListener("storage",s),()=>{window.removeEventListener(Lp,s),window.removeEventListener("storage",s)}},[]);const n=w.useCallback(s=>{e(i=>{const a=KI({...i,...s||{}});return window.dispatchEvent(new CustomEvent(Lp,{detail:a})),a})},[]);return[t,n]}function VI({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:k,onReattach:R,onToggleMinimize:C,onFloatDragStart:L,alive:S=!0,sessionAlive:T=S,available:E=!0,stale:H=!1,presence:F=null,fontSize:X=vi,onZoom:V,decks:G=[],currentDeck:ne,onSendToDeck:Y,panelUrl:B="",panelCellId:P="",panelPort:D=0}){const[M]=zv(),$=s||t,A=w.useRef(()=>{}),j=w.useRef(()=>!1),N=w.useRef(()=>{}),U=w.useRef(!1),[I,W]=w.useState(!1),[se,me]=w.useState(!1),[pe,Ie]=w.useState(!1),[J,te]=w.useState(!1),[ge,Se]=w.useState(null),[Be,Le]=w.useState(0),ze=w.useRef(bC()),Q=e?`${e}:${t}`:t,ve=G.filter(K=>K.id!==ne&&K.available!==!1),Z=F?F.presenza:T?hs.PRESENTE:hs.ASSENTE,be=F?F.identita??null:null;return w.useEffect(()=>{const K=WI(ze.current,{presenza:Z,identita:be});ze.current=K.runtime,K.generazione&&Le(fe=>fe+K.generazione)},[Z,be]),l.jsxs("div",{className:`nc-tile${c?" focused":""}`,onMouseDown:()=>u&&u(Q),children:[l.jsxs("div",{className:`nc-tile-head${v?" nc-float-head":""}`,draggable:!v,onPointerDown:v&&L?K=>{K.target&&K.target.closest&&K.target.closest(".nc-tile-actions")||L(K)}:void 0,onDragStart:K=>{v||(K.dataTransfer.setData("text/nc-session",Q),K.dataTransfer.effectAllowed="move",g&&g(Q))},children:[l.jsxs("button",{className:"nc-tile-name",onClick:()=>u&&u(Q),title:e?`${$} · ${e}`:$,children:[l.jsx("span",{className:S?"nc-dot on":"nc-dot"}),l.jsx("b",{children:$})]}),l.jsxs("span",{className:"nc-tile-actions",children:[v?l.jsxs(l.Fragment,{children:[R&&l.jsx("button",{className:"nc-tile-float-btn",onClick:()=>R(Q),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"})]})}),C&&l.jsx("button",{onClick:()=>C(Q),title:p(_?"tile-restore":"tile-minimize"),"aria-label":p(_?"tile-restore":"tile-minimize"),children:"–"})]}):l.jsxs(l.Fragment,{children:[V&&l.jsx("button",{onClick:()=>V(-1),title:p("zoom-out"),"aria-label":p("zoom-out"),children:l.jsx(Tt,{name:"zoomOut",size:14})}),V&&l.jsx("button",{onClick:()=>V(1),title:p("zoom-in"),"aria-label":p("zoom-in"),children:l.jsx(Tt,{name:"zoomIn",size:14})}),Y&&ve.length>0&&l.jsxs("select",{className:"nc-tile-deck",title:p("send-to-deck"),value:"",onMouseDown:K=>K.stopPropagation(),onChange:K=>{const fe=K.target.value;fe&&Y(Q,fe),K.target.value=""},children:[l.jsx("option",{value:"",children:p("send-to-deck")}),ve.map(K=>l.jsxs("option",{value:K.id,children:[K.ownerLabel," · ",K.name]},K.id))]}),l.jsx("button",{onClick:()=>me(K=>!K),title:p("composer"),children:"⌨"}),l.jsx("button",{onClick:()=>Ie(K=>!K),title:p("files"),children:"📁"}),B&&l.jsx("button",{onClick:()=>te(K=>!K),title:p("panel"),"aria-pressed":J,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&&k&&l.jsx("button",{className:"nc-tile-float-btn",onClick:()=>k(Q),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(Q),title:p("close"),"aria-label":p("close"),children:"✕"})]})]}),l.jsxs("div",{className:"nc-tile-body",children:[F&&F.oltreIlTetto===!0&&l.jsx("div",{className:"nc-tile-unverified",role:"status","data-causa":F.causa||"",children:p("tile-unverified")}),l.jsx(gc,{session:t,node:e,token:i,readonly:a,takeSize:b,focused:c,sendRef:A,composerRef:j,actionRef:N,ctrlRef:U,setCtrlArmed:W,onFiles:Se,fontSize:X,keyboardGesture:M.terminalKeyboardGesture},`${Q}:${Be}`),!E&&l.jsx("div",{className:"nc-tile-unavailable",title:p("deck-owner-unavailable"),children:p("deck-owner-reconnecting")}),E&&H&&l.jsx("div",{className:"nc-tile-stale",title:p("deck-owner-stale"),children:p("deck-owner-stale")}),E&&pe&&l.jsx("div",{className:"nc-tile-files",onMouseDown:K=>K.stopPropagation(),children:l.jsx(Mg,{session:t,node:e,token:i,filesEvent:ge,onClose:()=>Ie(!1)})})]}),E&&se&&l.jsx("div",{className:"nc-tile-composer",onMouseDown:K=>K.stopPropagation(),children:l.jsx(wC,{submitText:K=>j.current(K),token:i,session:t,node:e,ownerId:n,readonly:a,keepKeyboardClosedOnVoice:M.voiceKeepsKeyboardClosed})}),E&&J&&B&&P&&l.jsx(sx,{title:$,onClose:()=>te(!1),children:l.jsx(bv,{cellId:P,panelUrl:B,route:e?e.split("/"):[],panelPort:D,token:i,title:$})})]})}function Ig({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 Mc({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=Ig({session:c,node:n,ownerId:s,cells:i,nodeGroups:a});return u&&u.cell?u.cell:c}const tS=.22,nS=.3,CC=(t,e)=>Array.from((t==null?void 0:t.types)||[]).includes(e),Ap=t=>CC(t,"text/nc-session"),sS=t=>{var e;return CC(t,"Files")||(((e=t==null?void 0:t.files)==null?void 0:e.length)||0)>0};function YI(t,e){return t&&Array.isArray(e)?e.find(n=>Array.isArray(n==null?void 0:n.route)&&n.route.join("/")===t):null}function GI(t,e,n){const s=(t-n.left)/(n.width||1),i=(e-n.top)/(n.height||1);return s<tS?"left":s>1-tS?"right":i>=nS&&i<=1-nS?"center":i<.5?"top":"bottom"}const XI=[["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 JI({active:t}){return l.jsx("div",{className:"nc-drop-zones","data-testid":"nc-drop-zones","aria-hidden":"true",children:XI.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 jp(t,e){for(const n of t.columns)for(const s of n.tiles)if(zt(s)===e)return s.float||null;return null}function iS(t,e){for(const n of t.columns)for(const s of n.tiles)if(zt(s)===e)return s.fontSize||null;return null}function QI({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:k,cells:R=[],nodeGroups:C=[],panelPort:L=0,nodePanelPorts:S={}}){$n();const T=Date.now(),[E,H]=w.useState(null),[F,X]=w.useState(null),V=w.useRef(null);V.current=F;const[G,ne]=w.useState({z:{},next:1,focus:null,mini:{}}),[Y,B]=w.useState(null),P=w.useRef(null);P.current=Y;const D=w.useRef(null),M=w.useRef([]),$=w.useRef(null);function A(K,fe,Re){const Ee=()=>{window.removeEventListener("pointermove",K),window.removeEventListener("pointerup",qe),window.removeEventListener("pointercancel",Ze),window.removeEventListener("blur",Ze)},qe=()=>{Ee(),$.current=null,fe&&fe()},Ze=()=>{Ee(),$.current=null,Re&&Re()};window.addEventListener("pointermove",K),window.addEventListener("pointerup",qe),window.addEventListener("pointercancel",Ze),window.addEventListener("blur",Ze),$.current=Ze}w.useEffect(()=>()=>{$.current&&$.current()},[]),w.useEffect(()=>{if(!E&&!Y)return;const K=fe=>{fe.key==="Escape"&&(H(null),Y&&$.current&&$.current())};return window.addEventListener("keydown",K),()=>{window.removeEventListener("keydown",K)}},[E,Y]),w.useEffect(()=>{const K=()=>H(null);return window.addEventListener("dragend",K),window.addEventListener("drop",K),()=>{window.removeEventListener("dragend",K),window.removeEventListener("drop",K)}},[]);const j=t.columns.length,N=t.columns.flatMap(K=>K.tiles).filter(K=>K.float).map(K=>zt(K)),U=K=>!!K&&K.tiles.length>0&&K.tiles.every(fe=>fe.float),I=K=>E&&E.col===K&&E.row===void 0,W=!!E&&E.col===j,se=(K,fe)=>E&&E.col===K&&E.row===fe&&E.quadrant?` drop-${E.quadrant}`:"";function me(K){var qe;if(K.preventDefault(),sS(K.dataTransfer)){H(null);return}const fe=K.dataTransfer.getData("text/nc-session"),Re=E;if(H(null),!fe||!Re)return;if(Re.quadrant==="center"){const Ze=zt(((qe=t.columns[Re.col])==null?void 0:qe.tiles[Re.row])||{});Ze&&Ze!==fe&&e(BP(t,fe,Ze));return}let Ee;if(Re.quadrant){if(Ee=VP(t,Re.col,Re.row,Re.quadrant),!Ee)return}else Ee={col:Re.col};e(gs(t).includes(fe)?DP(t,fe,Ee):Ac(t,fe,Ee))}function pe(K,fe){var ce,O,de;K.preventDefault(),K.stopPropagation();try{K.currentTarget.setPointerCapture&&K.pointerId!=null&&K.currentTarget.setPointerCapture(K.pointerId)}catch{}const Re=D.current&&D.current.clientWidth||0,Ee=D.current?D.current.getBoundingClientRect():null,qe=Ee?Ee.left:0,Ze=M.current[fe]?M.current[fe].getBoundingClientRect():null,at=M.current[fe+1]?M.current[fe+1].getBoundingClientRect():null,Oe=Ze&&at&&at.right>Ze.left?Ze.left-(Ee?Ee.left:0):0,_e=Number.isFinite(K.clientX)?K.clientX:0,$e=t.columns[fe].width+(((ce=t.columns[fe+1])==null?void 0:ce.width)||0),nt=t.columns.reduce((we,We)=>we+We.width,0),Fe=Ze&&at&&at.right>Ze.left?at.right-Ze.left:Re*($e/(nt||1)),rt=Math.min(iC,Fe/2),re=we=>{const We=(Number.isFinite(we.clientX)?we.clientX:_e)-qe;let ie=Math.max(rt,Math.min(Fe-rt,We-Oe)),Pe=!1;if(!we.altKey){for(const ft of pc)if(Math.abs(ie-ft*Fe)<=Eg){ie=ft*Fe,Pe=!0;break}}return{border:ie,snapped:Pe,alt:we.altKey===!0}};X({kind:"col",ci:fe,coupleLeft:Oe,couplePx:Fe,live:re(K),pxOther:D.current&&D.current.clientHeight||0,fsA:((O=t.columns[fe].tiles[0])==null?void 0:O.fontSize)||vi,fsB:((de=t.columns[fe+1].tiles[0])==null?void 0:de.fontSize)||vi}),A(we=>X(We=>We&&{...We,live:re(we)}),()=>{var ie,Pe;const we=V.current,We=((ie=we==null?void 0:we.live)==null?void 0:ie.border)??Fe/2;X(null),e(H0(t,fe,Re,We,{snap:!((Pe=we==null?void 0:we.live)!=null&&Pe.alt)})),k&&k()},()=>X(null))}function Ie(K){const fe=D.current&&D.current.clientWidth||0;e(H0(t,K,fe,Number.NaN,{snap:!0,half:!0})),k&&k()}function J(K,fe,Re){var ie;K.preventDefault(),K.stopPropagation();try{K.currentTarget.setPointerCapture&&K.pointerId!=null&&K.currentTarget.setPointerCapture(K.pointerId)}catch{}const Ee=M.current[fe],qe=Ee&&Ee.clientHeight||D.current&&D.current.clientHeight||0,Ze=D.current?D.current.getBoundingClientRect():null,at=Ze?Ze.top:0,Oe=Ee?Ee.getBoundingClientRect():null,_e=Oe?Oe.left-(Ze?Ze.left:0):0,$e=Oe&&Oe.width>0?Oe.width:Ee&&Ee.clientWidth||0,nt=Number.isFinite(K.clientY)?K.clientY:0,Fe=t.columns[fe].tiles,rt=Fe[Re].height+(((ie=Fe[Re+1])==null?void 0:ie.height)||0),re=Fe.reduce((Pe,ft)=>Pe+ft.height,0),ce=Fe.slice(0,Re).reduce((Pe,ft)=>Pe+ft.height,0),O=(Oe&&Oe.height>0?Oe.top-at:0)+qe*(ce/(re||1)),de=(Oe&&Oe.height>0,qe*(rt/(re||1))),we=Math.min(rC,de/2),We=Pe=>{const ft=(Number.isFinite(Pe.clientY)?Pe.clientY:nt)-at;let Pt=Math.max(we,Math.min(de-we,ft-O)),bt=!1;if(!Pe.altKey){for(const xt of pc)if(Math.abs(Pt-xt*de)<=Eg){Pt=xt*de,bt=!0;break}}return{border:Pt,snapped:bt,alt:Pe.altKey===!0}};X({kind:"row",ci:fe,ri:Re,coupleTop:O,couplePx:de,colLeft:_e,colWidth:$e,live:We(K),pxOther:Ee&&Ee.clientWidth||D.current&&D.current.clientWidth||0,fsA:Fe[Re].fontSize||vi,fsB:Fe[Re+1].fontSize||vi}),A(Pe=>X(ft=>ft&&{...ft,live:We(Pe)}),()=>{var Pt,bt;const Pe=V.current,ft=((Pt=Pe==null?void 0:Pe.live)==null?void 0:Pt.border)??de/2;X(null),e(U0(t,fe,Re,qe,ft,{snap:!((bt=Pe==null?void 0:Pe.live)!=null&&bt.alt)})),k&&k()},()=>X(null))}function te(K,fe){const Re=M.current[K],Ee=Re&&Re.clientHeight||D.current&&D.current.clientHeight||0;e(U0(t,K,fe,Ee,Number.NaN,{snap:!0,half:!0})),k&&k()}function ge(K){e(jc(t,K))}const Se={x:.45,y:.12,w:.42,h:.6},Be=8;function Le(K){ne(fe=>({...fe,z:{...fe.z,[K]:fe.next},next:fe.next+1,focus:K})),c&&c(K)}function ze(K){ne(fe=>({...fe,mini:{...fe.mini,[K]:!fe.mini[K]}}))}function Q(K){N.length>=Uc||e($P(t,K,Se))}function ve(K,fe){const Re=[0,1];let Ee=!1,qe=K;for(const Ze of[...Re,...fe])if(Math.abs(K-Ze)<=Be/window.innerWidth){qe=Ze,Ee=!0;break}return{v:Math.max(0,Math.min(1,qe)),snapped:Ee}}function Z(K,fe){K.preventDefault(),K.stopPropagation();try{K.currentTarget.setPointerCapture&&K.pointerId!=null&&K.currentTarget.setPointerCapture(K.pointerId)}catch{}const Re=jp(t,fe);if(!Re)return;const Ee=Number.isFinite(K.clientX)?K.clientX:0,qe=Number.isFinite(K.clientY)?K.clientY:0,Ze=N.filter($e=>$e!==fe).map($e=>jp(t,$e)).filter(Boolean),at=Ze.flatMap($e=>[$e.x,$e.x+$e.w]),Oe=Ze.flatMap($e=>[$e.y,$e.y+$e.h]),_e=$e=>{const nt=(Number.isFinite($e.clientX)?$e.clientX:Ee)-Ee,Fe=(Number.isFinite($e.clientY)?$e.clientY:qe)-qe,rt=ve(Re.x+nt/Math.max(1,window.innerWidth),at),re=ve(Re.y+Fe/Math.max(1,window.innerHeight),Oe);return{x:rt.v,y:re.v,w:Re.w,h:Re.h,snappedX:rt.snapped,snappedY:re.snapped}};B({key:fe,kind:"move",live:_e(K)}),A($e=>B(nt=>nt&&{...nt,live:_e($e)}),()=>{var nt;const $e=(nt=P.current)==null?void 0:nt.live;B(null),$e&&e(W0(t,fe,$e))},()=>B(null))}function be(K,fe,Re){K.preventDefault(),K.stopPropagation();try{K.currentTarget.setPointerCapture&&K.pointerId!=null&&K.currentTarget.setPointerCapture(K.pointerId)}catch{}const Ee=jp(t,fe);if(!Ee)return;const qe=Number.isFinite(K.clientX)?K.clientX:0,Ze=Number.isFinite(K.clientY)?K.clientY:0,at=Math.max(1,window.innerWidth),Oe=Math.max(1,window.innerHeight);iS(t,fe);const _e=$e=>{const nt=((Number.isFinite($e.clientX)?$e.clientX:qe)-qe)/at,Fe=((Number.isFinite($e.clientY)?$e.clientY:Ze)-Ze)/Oe;let{x:rt,y:re,w:ce,h:O}=Ee;return Re.includes("e")&&(ce=Ee.w+nt),Re.includes("s")&&(O=Ee.h+Fe),Re.includes("w")&&(rt=Ee.x+nt,ce=Ee.w-nt),Re.includes("n")&&(re=Ee.y+Fe,O=Ee.h-Fe),ce=Math.max(.05,Math.min(1-rt,ce)),O=Math.max(.05,Math.min(1-re,O)),{x:rt,y:re,w:ce,h:O}};B({key:fe,kind:"resize",dir:Re,live:_e(K),badge:!0}),A($e=>B(nt=>nt&&{...nt,live:_e($e)}),()=>{var nt;const $e=(nt=P.current)==null?void 0:nt.live;B(null),$e&&e(W0(t,fe,$e)),k&&k()},()=>B(null))}return l.jsxs("div",{className:`nc-grid${F||Y?" gesturing":""}`,ref:D,onDragOver:K=>{if(sS(K.dataTransfer)){K.preventDefault(),H(null);return}Ap(K.dataTransfer)&&(K.preventDefault(),E&&E.col===j||H({col:j}))},onDrop:me,onDragLeave:K=>{const fe=K.relatedTarget;(!fe||!(D.current&&D.current.contains(fe)))&&H(null)},children:[t.columns.flatMap((K,fe)=>{const Re=[];return Re.push(l.jsx("div",{className:`nc-col${I(fe)?" drop-newcol":""}${U(K)?" nc-col-emptyfloat":""}`,ref:Ee=>{M.current[fe]=Ee},style:{flexGrow:U(K)?0:K.width,flexBasis:0},onDragOver:Ee=>{Ap(Ee.dataTransfer)&&(Ee.preventDefault(),Ee.stopPropagation(),E&&E.col===fe&&E.row===void 0||H({col:fe}))},children:K.tiles.flatMap((Ee,qe)=>{const Ze=[],at=zt(Ee),Oe=YI(Ee.node,C),_e=UI({tileKey:at,node:Ee.node,nodeGroups:C,sessionsAlive:i,localVerified:h,localIdentita:f?f.get(at):null,lastVerifiedAt:Ee.node?(Oe==null?void 0:Oe.verifiedAt)??null:g,nowMs:T}),$e=Ee.unavailable!==!0&&(Ee.node?(Oe==null?void 0:Oe.status)==="up":_e.owner==="ok"),nt=Ee.unavailable!==!0&&_e.presenza!=="assente-verificata",Fe=Ig({session:Ee.session,node:Ee.node,ownerId:Ee.ownerId,cells:R,nodeGroups:C}),rt=Mc({session:Ee.session,cell:Fe,node:Ee.node,ownerId:Ee.ownerId,cells:R,nodeGroups:C}),re=typeof(Fe==null?void 0:Fe.panelUrl)=="string"?Fe.panelUrl.trim():"",ce=typeof(Fe==null?void 0:Fe.cell)=="string"?Fe.cell:"",O=Ee.float||null,de=!!(O&&G.mini[at]);return Ze.push(l.jsxs("div",{className:`nc-tile-slot${se(fe,qe)}${E&&E.from===at?" nc-tile-source":""}${O?" nc-float":""}${de?" nc-float-mini":""}`,style:O?{position:"fixed",left:`${O.x*100}%`,top:`${O.y*100}%`,width:`${O.w*100}%`,height:de?"auto":`${O.h*100}%`,zIndex:20+(G.z[at]||0)}:{flexGrow:Ee.height,flexBasis:0},onPointerDown:O?()=>Le(at):void 0,onDragOver:we=>{if(!Ap(we.dataTransfer))return;if(O){we.stopPropagation();return}we.preventDefault(),we.stopPropagation();const We=GI(we.clientX,we.clientY,we.currentTarget.getBoundingClientRect());E&&E.col===fe&&E.row===qe&&E.quadrant===We||H({col:fe,row:qe,quadrant:We,from:E==null?void 0:E.from,ghost:{x:we.clientX,y:we.clientY}})},children:[l.jsx(VI,{session:Ee.session,node:Ee.node,ownerId:Ee.ownerId,cellName:rt,token:n,readonly:s,focused:a===at,onFocus:c,onClose:ge,onOpenSingle:u,floating:!!O,minimized:de,takeSize:!!O,onDetach:O?void 0:Q,onReattach:O?we=>e(zP(t,we)):void 0,onToggleMinimize:O?ze:void 0,onFloatDragStart:O?we=>Z(we,at):void 0,onDragTileStart:O?void 0:we=>H(We=>We?{...We,from:we}:{from:we}),available:Ee.unavailable!==!0,stale:Ee.stale===!0,alive:$e,sessionAlive:nt,presence:_e,fontSize:Ee.fontSize,onZoom:we=>e(KP(t,fe,qe,we)),decks:v,currentDeck:_,onSendToDeck:b,panelUrl:re,panelCellId:ce,panelPort:Nc(Ee.node?Ee.node.split("/"):[],S,L)}),!O&&E&&E.col===fe&&E.row===qe&&E.quadrant&&l.jsx(JI,{active:E.quadrant}),O&&!de&&["n","s","e","w","se"].map(we=>l.jsx("div",{className:`nc-float-rz ${we}`,"data-testid":`float-resize-${we}`,onPointerDown:We=>be(We,at,we)},`rz-${we}`))]},at)),qe<K.tiles.length-1&&Ze.push(l.jsx("div",{className:`nc-divider-h${F&&F.kind==="row"&&F.ci===fe&&F.ri===qe?" dragging":""}`,title:p("grid-resize-rows"),onPointerDown:we=>J(we,fe,qe),onDoubleClick:()=>te(fe,qe)},`h${qe}`)),Ze})},`c${fe}`)),fe<j-1&&!U(K)&&!U(t.columns[fe+1])&&Re.push(l.jsx("div",{className:`nc-divider-v${F&&F.kind==="col"&&F.ci===fe?" dragging":""}`,title:p("grid-resize-cols"),onPointerDown:Ee=>pe(Ee,fe),onDoubleClick:()=>Ie(fe)},`v${fe}`)),Re}),F&&l.jsx("div",{className:`nc-gesture-shield ${F.kind==="col"?"col":"row"}`,"data-testid":"nc-gesture-shield"}),F&&F.kind==="col"&&pc.map(K=>l.jsx("div",{className:"nc-gesture-ghost v",style:{left:F.coupleLeft+K*F.couplePx}},`ghost-v-${K}`)),F&&F.kind==="row"&&pc.map(K=>l.jsx("div",{className:"nc-gesture-ghost h",style:{top:F.coupleTop+K*F.couplePx,left:F.colLeft,width:F.colWidth}},`ghost-h-${K}`)),F&&F.kind==="col"&&l.jsx("div",{className:`nc-gesture-guide v${F.live.snapped?" snap":""}`,"data-testid":"nc-gesture-guide",style:{left:F.coupleLeft+F.live.border}}),F&&F.kind==="row"&&l.jsx("div",{className:`nc-gesture-guide h${F.live.snapped?" snap":""}`,"data-testid":"nc-gesture-guide",style:{top:F.coupleTop+F.live.border,left:F.colLeft,width:F.colWidth}}),F&&l.jsx("div",{className:"nc-gesture-badge","data-testid":"nc-gesture-badge",style:F.kind==="col"?{left:F.coupleLeft+F.live.border,top:"50%"}:{top:F.coupleTop+F.live.border,left:"50%"},children:[F.fsA,F.fsB].map((K,fe)=>{const Re=fe===0?F.live.border:F.couplePx-F.live.border,Ee=Math.max(1,K*.6),qe=Math.max(1,K*1.2),Ze=F.kind==="col"?`${Math.round(Re/Ee)}×${Math.round(F.pxOther/qe)}`:`${Math.round(F.pxOther/Ee)}×${Math.round(Re/qe)}`;return l.jsx("span",{className:"nc-gesture-chip",children:Ze},fe)})}),Y&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`nc-gesture-shield ${Y.kind==="resize"?"row":"col"}`,"data-testid":"nc-gesture-shield"}),Y.live.snappedX&&l.jsx("div",{className:"nc-float-snap v",style:{left:`${Y.live.x*100}%`}}),Y.live.snappedY&&l.jsx("div",{className:"nc-float-snap h",style:{top:`${Y.live.y*100}%`}}),Y.kind==="resize"&&(()=>{const K=iS(t,Y.key)||vi,fe=Math.max(1,K*.6),Re=Math.max(1,K*1.2);return l.jsx("div",{className:"nc-gesture-badge","data-testid":"nc-gesture-badge",style:{left:`${(Y.live.x+Y.live.w/2)*100}%`,top:`${(Y.live.y+Y.live.h)*100}%`},children:l.jsx("span",{className:"nc-gesture-chip",children:`${Math.round(Y.live.w*window.innerWidth/fe)}×${Math.round(Y.live.h*window.innerHeight/Re)}`})})})()]}),E&&E.from&&E.ghost&&(()=>{const K=t.columns.flatMap(Re=>Re.tiles).find(Re=>zt(Re)===E.from),fe=K?Mc({session:K.session,node:K.node,ownerId:K.ownerId,cells:R,nodeGroups:C,cell:Ig({session:K.session,node:K.node,ownerId:K.ownerId,cells:R,nodeGroups:C})}):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:fe})]}),l.jsx("div",{className:"nc-drag-ghost-body"})]})})(),W&&l.jsx("div",{className:"nc-drop-line-v nc-drop-line-end"}),j===0&&l.jsx("div",{className:"nc-grid-empty",children:p("grid-empty")})]})}const Yi="local",Ks=/^[a-f0-9]{16,64}$/,EC=3,Ia=new Map,to=new Map,rS=128;function ZI(t){const e=new Set;for(const n of Array.isArray(t)?t:[])!n||!Ks.test(String(n.instanceId||""))||!Array.isArray(n.route)||(e.add(n.instanceId),to.set(n.instanceId,[...n.route]),Ia.set(n.instanceId,0));for(const n of[...to.keys()]){if(e.has(n))continue;const s=(Ia.get(n)||0)+1;Ia.set(n,s),s>EC+32&&(Ia.delete(n),to.delete(n))}if(to.size>rS)for(const n of[...to.keys()].slice(0,to.size-rS))Ia.delete(n),to.delete(n)}function Uo(t,e){return`${t&&Ks.test(t)?t:Yi}:${e}`}function Kc(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!==Yi&&!Ks.test(s)||!/^[a-z0-9-]{1,32}$/.test(i)?null:{ownerId:s===Yi?null:s,name:i}}function Tc(t){return Array.isArray(t)&&t.length?t.join("/"):""}function Fv(t){return{columns:Mi(t).columns.map(e=>({width:e.width,tiles:e.tiles.map(n=>({...n}))}))}}function eD(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&Ks.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(Tc(n.route),n.instanceId);return e}function tD(t){const e=new Map;for(const n of Array.isArray(t)?t:[])n&&Ks.test(String(n.instanceId||""))&&Array.isArray(n.route)&&e.set(n.instanceId,[...n.route]);return e}function Dg(t,e,n=[]){const s=Fv(t),i=eD(n);for(const a of s.columns)for(const c of a.tiles)c.ownerId||(!c.node&&Ks.test(String(e||""))?c.ownerId=e:c.node&&i.has(c.node)&&(c.ownerId=i.get(c.node)));return s}function Jl(t,e){const n=Kc(t);return!n||!n.ownerId||!e||n.ownerId!==e?t:Uo(null,n.name)}function Ha(t,e,n=[]){const s=Fv(t),i=new Map,a=new Set;for(const c of n)c&&Ks.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=Tc(i.get(u.ownerId)),delete u.unavailable,a.has(u.ownerId)?u.stale=!0:delete u.stale;else{const h=Ia.get(u.ownerId),f=to.get(u.ownerId);f&&h!==void 0&&h<EC?(u.node=Tc(f),delete u.unavailable,u.stale=!0):(u.unavailable=!0,delete u.stale)}return s}function Ql(t,e,n=[]){const s=Fv(t),i=tD(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=Tc(i.get(c.ownerId))));return s}function NC(t,e,n=[]){const s=Nr(t);if(!s)return null;if(s.ownerId)return s;if(!s.node)return{...s,...Ks.test(String(e||""))?{ownerId:e}:{}};const i=n.find(a=>Tc(a&&a.route)===s.node);return{...s,...i&&Ks.test(String(i.instanceId||""))?{ownerId:i.instanceId}:{}}}const nD=/^[a-z0-9-]{1,32}$/,si="main",RC="nc_decks",LC="nc_deck_order_v1",AC=24;function oS(t){return typeof t!="string"?"":t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,32).replace(/-+$/,"")}function Ga(t){return typeof t=="string"&&nD.test(t)}function sD(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/?$/);if(e){let n;try{n=decodeURIComponent(e[1])}catch{n=e[1]}return Ga(n)?n:si}return si}function iD(t){const e=String(t||"").match(/^\/deck\/([^/]+)\/([^/]+)\/?$/);if(e){let s,i;try{s=decodeURIComponent(e[1]),i=decodeURIComponent(e[2])}catch{return{id:Uo(null,si),ownerId:null,name:si}}if(Ks.test(s)&&Ga(i))return{id:Uo(s,i),ownerId:s,name:i}}const n=sD(t);return{id:Uo(null,n),ownerId:null,name:n}}function Mp(t,e){const n=typeof t=="object"&&t?{ownerId:t.ownerId||null,name:t.name}:Kc(t)||{ownerId:null,name:t},s=Ga(n.name)?n.name:si,i=n.ownerId?`/deck/${encodeURIComponent(n.ownerId)}/${encodeURIComponent(s)}`:s===si?"/":`/deck/${encodeURIComponent(s)}`;return e?`${i}#token=${encodeURIComponent(e)}`:i}function jC(t){return t===si?"nc_grid_v1":`nc_grid_v1__${t}`}function MC(t){const e=[si];if(Array.isArray(t)){for(const n of t)if(Ga(n)&&n!==si&&!e.includes(n)&&e.push(n),e.length>=AC)break}return e}function tl(){return typeof localStorage<"u"?localStorage:null}function rD(){const t=tl();if(!t)return[si];try{return MC(JSON.parse(t.getItem(RC)||"null"))}catch{return[si]}}function oD(t){const e=tl();if(e)try{e.setItem(RC,JSON.stringify(MC(t)))}catch{}}function Vc(t){return t==="local"||Ks.test(String(t||""))}function mh(t,e){const n=Kc(t);return!!n&&(n.ownerId||"local")===e}function Zi(t){if(!t||typeof t!="object"||Array.isArray(t))return{};const e={};for(const[n,s]of Object.entries(t).slice(0,64)){if(!Vc(n)||!Array.isArray(s))continue;const i=[...new Set(s.filter(a=>typeof a=="string"&&a.length<=100&&mh(a,n)))].slice(0,AC);i.length&&(e[n]=i)}return e}function Zl(t=tl()){if(!t)return{};try{return Zi(JSON.parse(t.getItem(LC)||"null"))}catch{return{}}}function Tp(t,e=tl()){const n=Zi(t);if(e)try{e.setItem(LC,JSON.stringify(n))}catch{}return n}function gh(t,e){return Array.isArray(t==null?void 0:t[e])?t[e]:[]}function aD(t,e,n,s,i=[]){if(!Vc(e)||n===s)return Zi(t);const a=[...new Set(i.filter(v=>mh(v,e)))];if(!a.includes(n)||!a.includes(s))return Zi(t);const c=gh(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),Zi({...t,[e]:u})}function lD(t,e,n,s){if(!Vc(e)||!mh(s,e))return Zi(t);const i=gh(t,e);return i.includes(n)?Zi({...t,[e]:i.map(a=>a===n?s:a)}):Zi(t)}function cD(t,e,n){return Vc(e)?Zi({...t,[e]:gh(t,e).filter(s=>s!==n)}):Zi(t)}function Pp(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)||"");!Vc(f)||!mh(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=gh(e,h),v=new Map(g.map((_,b)=>[_,b]));f.sort((_,b)=>{const k=v.has(_.id)?v.get(_.id):Number.MAX_SAFE_INTEGER,R=v.has(b.id)?v.get(b.id):Number.MAX_SAFE_INTEGER;return k-R}),u.push(...f)}return u}function Og(t){const e=tl();if(!e)return null;try{return JSON.parse(e.getItem(jC(t))||"null")}catch{return null}}function uD(t,e){const n=tl();if(n)try{n.setItem(jC(t),JSON.stringify(e))}catch{}}const Hv="nc_deckbar_collapsed_v1",TC=64;function Uv(t){return t===Yi||Ks.test(String(t||""))}function Wv(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>=TC)break;if(Uv(s)){if(i===!0)e[s]=!0;else if(i===!1)e[s]=!1;else continue;n+=1}}return e}function PC(t,e){return Uv(e)&&Object.prototype.hasOwnProperty.call(t||{},e)?t[e]===!0:!0}function dD(t,e){const n=Wv(t);return Uv(e)&&(!Object.prototype.hasOwnProperty.call(n,e)&&Object.keys(n).length>=TC&&delete n[Object.keys(n)[0]],n[e]=!PC(n,e)),n}function IC(){return typeof localStorage<"u"?localStorage:null}function aS(t=IC()){if(!t)return{};try{return Wv(JSON.parse(t.getItem(Hv)||"null"))}catch{return{}}}function hD(t,e=IC()){const n=Wv(t);if(e)try{e.setItem(Hv,JSON.stringify(n))}catch{}return n}function fD(){const[t,e]=w.useState(aS);w.useEffect(()=>{const i=a=>{(a.key===Hv||a.key===null)&&e(aS())};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]);const n=w.useCallback(i=>PC(t,i),[t]),s=w.useCallback(i=>{e(a=>hD(dD(a,i)))},[]);return{collapsed:t,isCollapsed:n,toggle:s}}const qv="nc_deck_presence_v1",lS=3e4,pD=18e4,DC=1e4,OC=32,mD=/^[A-Za-z0-9_-]{1,64}$/,gD=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),cS="working",vD="on",_D="neutral",yD="warn";function Kv(t){return typeof t=="string"&&mD.test(t)&&!gD.has(t)}function BC(t){return typeof t=="string"&&Kc(t)!==null}function Vv(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}function Xa(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>=OC)break;Kv(s)&&(!i||typeof i!="object"||BC(i.deckId)&&Vv(i.ts)&&(e[s]={deckId:i.deckId,ts:i.ts,focus:i.focus===!0,visible:i.visible===!0},n+=1))}return e}function $C(t,e){const n=Xa(t);if(!Vv(e))return n;const s={};for(const[i,a]of Object.entries(n)){const c=a.visible?lS:pD,u=e-c;a.ts>=u&&a.ts<=e+lS&&(s[i]=a)}return s}function uS(t,e,n,s){if(!Kv(e)||!Vv(s))return Xa(t);const i=$C(t,s);if(!BC(n==null?void 0:n.deckId))return i;if(!Object.prototype.hasOwnProperty.call(i,e)&&Object.keys(i).length>=OC){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},Xa(i)}function wD(t,e){const n=Xa(t);if(!Kv(e))return n;const s={...n};return delete s[e],s}function bD(t,e){const n=$C(t,e),s={};for(const i of Object.values(n)){const a=i.focus&&i.visible?cS:vD;s[i.deckId]!==cS&&(s[i.deckId]=a)}return s}function zC(){return typeof localStorage<"u"?localStorage:null}function id(t=zC()){if(!t)return{};try{return Xa(JSON.parse(t.getItem(qv)||"null"))}catch{return{}}}function Ip(t,e=zC()){const n=Xa(t);if(e)try{e.setItem(qv,JSON.stringify(n))}catch{}return n}const SD=Math.min(DC,5e3);function xD(){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 kD=xD();function dS(){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(kD).current,i=w.useRef(t);i.current=t;const[a,c]=w.useState(()=>({map:{},now:Date.now()})),u=w.useCallback(()=>{c({map:id(),now:Date.now()})},[]);w.useEffect(()=>{if(!e)return;const g=()=>{const C=Date.now(),L=uS(id(),s,{deckId:i.current,...dS()},C);return Ip(L),{map:L,now:C}},v=()=>c(g());v();const _=setInterval(g,DC),b=setInterval(u,SD),k=v,R=C=>{(C.key===qv||C.key===null)&&u()};return window.addEventListener("focus",k),window.addEventListener("blur",k),typeof document<"u"&&document.addEventListener("visibilitychange",k),window.addEventListener("storage",R),()=>{clearInterval(_),clearInterval(b),window.removeEventListener("focus",k),window.removeEventListener("blur",k),typeof document<"u"&&document.removeEventListener("visibilitychange",k),window.removeEventListener("storage",R);try{Ip(wD(id(),s))}catch{}}},[e,s,u]),w.useEffect(()=>{if(!e)return;const g=Date.now(),v=uS(id(),s,{deckId:t,...dS()},g);Ip(v),c({map:v,now:g})},[t,e,s]);const h=w.useMemo(()=>e?bD(a.map,a.now):{},[e,a]);return{dotFor:w.useCallback((g,v=!1)=>e?v?yD:h[g]||_D:null,[h,e]),windowId:s}}const hS=52,fS=18;function ED({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 R,C,L,S;const k=a.current;(C=(R=k==null?void 0:k.over)==null?void 0:R.classList)==null||C.remove("nc-deck-over"),(S=(L=k==null?void 0:k.source)==null?void 0:L.classList)==null||S.remove("nc-deck-dragging"),c.current&&cancelAnimationFrame(c.current),c.current=0},g=(k=!1)=>{const R=a.current;if(!R)return;const C=R.target;f(),a.current=null,h(!1);try{R.handle.releasePointerCapture(R.pointerId)}catch{}k&&C&&C!==e&&s(e,C)},v=(k,R)=>{var E,H,F,X,V,G,ne,Y;const C=a.current;if(!C)return;C.x=k,C.y=R;const L=(H=(E=document.elementFromPoint(k,R))==null?void 0:E.closest)==null?void 0:H.call(E,"[data-deck-id][data-owner-key]"),S=(F=L==null?void 0:L.dataset)==null?void 0:F.deckId,T=((X=L==null?void 0:L.dataset)==null?void 0:X.ownerKey)===t&&S&&S!==e;C.over!==(T?L:null)&&((G=(V=C.over)==null?void 0:V.classList)==null||G.remove("nc-deck-over"),C.over=T?L:null,(Y=(ne=C.over)==null?void 0:ne.classList)==null||Y.add("nc-deck-over")),C.target=T?S:null},_=()=>{var C,L;const k=a.current;if(!k){c.current=0;return}const R=(L=(C=k.container)==null?void 0:C.getBoundingClientRect)==null?void 0:L.call(C);if(R){const S=k.x<R.left+hS?-fS:k.x>R.right-hS?fS:0;S&&(k.container.scrollLeft+=S,v(k.x,k.y))}c.current=requestAnimationFrame(_)};w.useEffect(()=>{const k=C=>{C.key==="Escape"&&a.current&&(C.preventDefault(),g(!1))},R=()=>g(!1);return window.addEventListener("keydown",k),window.addEventListener("blur",R),()=>{window.removeEventListener("keydown",k),window.removeEventListener("blur",R),f(),a.current=null}},[e,t]);const b=k=>{var L;if(k.pointerType==="mouse"&&k.button!==0)return;k.preventDefault(),k.stopPropagation(),k.currentTarget.focus({preventScroll:!0});const R=k.currentTarget.closest("[data-deck-id][data-owner-key]"),C=k.currentTarget.closest(".nc-deckbar");a.current={pointerId:k.pointerId,handle:k.currentTarget,source:R,container:C,target:null,over:null,x:k.clientX,y:k.clientY},(L=R==null?void 0:R.classList)==null||L.add("nc-deck-dragging");try{k.currentTarget.setPointerCapture(k.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:k=>{k.preventDefault(),k.stopPropagation()},onDragStart:k=>k.preventDefault(),onKeyDown:k=>{k.key!=="ArrowLeft"&&k.key!=="ArrowRight"||(k.preventDefault(),k.stopPropagation(),i(k.key==="ArrowLeft"?-1:1))},onPointerDown:b,onPointerMove:k=>{!a.current||k.pointerId!==a.current.pointerId||(k.preventDefault(),k.stopPropagation(),v(k.clientX,k.clientY))},onPointerUp:k=>{!a.current||k.pointerId!==a.current.pointerId||(k.preventDefault(),k.stopPropagation(),g(!0))},onPointerCancel:()=>g(!1),onLostPointerCapture:()=>{a.current&&g(!1)},children:"↔"})}function ND({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}){$n();const{isCollapsed:k,toggle:R}=fD(),{dotFor:C}=CD(e),[L,S]=w.useState(null),[T,E]=w.useState(""),[H,F]=w.useState(!1),[X,V]=w.useState(""),[G,ne]=w.useState(""),Y=oS(T),B=Ga(Y),P=[];for(const j of t){const N=j.local?"local":j.ownerId;let U=P.find(I=>I.key===N);U||(U={key:N,label:j.ownerLabel||(j.local?"Local":N),local:!!j.local,decks:[]},P.push(U)),U.decks.push(j)}const D=async()=>{if(B){F(!0),V("");try{n&&await n(Y,L),E(""),S(null)}catch(j){V(String(j.message||j))}F(!1)}},M=j=>{ne(""),c&&c(j.id)||ne(j.id)},$=async j=>{if(!(j.id===e||!u||H||j.available===!1)){F(!0),V("");try{await u(j.id)}catch(N){V(String((N==null?void 0:N.message)||N))}F(!1)}},A=(j,N,U)=>{const I=j.decks.findIndex(se=>se.id===N.id),W=j.decks[I+U];I>=0&&W&&a&&!H&&a(N.id,W.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:P.map(j=>{const N=k(j.key),U=`nc-deck-content-${j.key}`,I=j.local?"Local":j.label,W=j.decks.some(pe=>pe.id===e),se=(j.decks.find(pe=>pe.id===e)||{}).name,me=p(j.decks.length===1?"owner-deck-count-one":"owner-deck-count-many").replace("{count}",j.decks.length);return l.jsxs("span",{className:`nc-deck-owner-group${N?" collapsed":""}`,"data-owner-key":j.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}",I),onClick:()=>{!N&&L===j.key&&(E(""),S(null)),R(j.key)},children:[l.jsx("span",{className:"nc-deck-owner-caret","aria-hidden":"true",children:N?"▸":"▾"}),l.jsx("span",{className:"nc-deck-owner",children:I})]}),N&&l.jsxs("span",{className:"nc-deck-summary",title:me,children:[l.jsx("span",{className:"nc-deck-summary-count",children:j.decks.length}),W&&l.jsxs("span",{className:"nc-deck-summary-current",children:["• ",se]})]}),l.jsxs("span",{id:U,className:"nc-deck-owner-content",hidden:N,children:[j.decks.map(pe=>{const Ie=C(pe.id,pe.available===!1);return l.jsxs("span",{"data-deck-id":pe.id,"data-owner-key":j.key,className:`nc-deck-chip${pe.id===e?" current":""}${pe.available===!1?" offline":""}`,children:[Ie&&l.jsx(RD,{state:Ie}),l.jsx(ED,{ownerKey:j.key,deckId:pe.id,label:`${j.label} · ${pe.name}`,onMove:(J,te)=>{a&&!H&&a(J,te)},onStep:J=>A(j,pe,J)}),l.jsxs("button",{className:"nc-deck-open",title:pe.available===!1?`${pe.ownerLabel} offline${pe.refreshFailedAt?" · aggiornamento in ritardo":""}`:pe.id===e?p("deck-current"):`${pe.ownerLabel} · ${pe.name}`,disabled:H||pe.available===!1,onClick:()=>$(pe),children:[pe.name,pe.id===e?" •":""]}),pe.available!==!1&&pe.stale===!0&&pe.refreshFailedAt?l.jsx("span",{className:"nc-deck-stale",title:`${pe.ownerLabel} · ${p("deck-stale")}`,children:p("deck-stale-badge")}):null,l.jsx("button",{className:"nc-deck-mini",disabled:pe.available===!1,title:p("detach-deck"),onClick:()=>M(pe),children:"↗"}),pe.name!==si&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"nc-deck-mini",disabled:pe.available===!1,title:p("rename-deck"),onClick:()=>{const J=(typeof window<"u"?window.prompt(p("rename-deck"),pe.name):"")||"",te=oS(J);Ga(te)&&te!==pe.name&&s&&s(pe.id,te).catch(ge=>V(String(ge.message||ge)))},children:"✎"}),l.jsx("button",{className:"nc-deck-mini nc-deck-del",disabled:pe.available===!1,title:p("delete-deck"),onClick:()=>{(typeof window>"u"||window.confirm(p("delete-deck-confirm").replace("{name}",`${pe.ownerLabel} · ${pe.name}`)))&&i&&i(pe.id).catch(J=>V(String(J.message||J)))},children:"✕"})]})]},pe.id)}),L===j.key?l.jsxs("span",{className:"nc-deck-add",children:[l.jsx("input",{autoFocus:!0,className:B||!T?"":"invalid",placeholder:p("deck-name"),value:T,onChange:pe=>E(pe.target.value),onKeyDown:pe=>{pe.key==="Enter"&&D(),pe.key==="Escape"&&(E(""),S(null))}}),T&&B&&Y!==T&&l.jsxs("span",{className:"nc-deck-slug",children:["→ ",Y]}),l.jsx("button",{className:"nc-deck-ok",disabled:!B||H,onClick:D,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:H||j.decks.every(pe=>pe.available===!1),title:`${p("new-deck")} · ${j.label}`,onClick:()=>{E(""),S(j.key)},children:["+ ",p("new")]})]})]},j.key)})}),l.jsx("span",{className:`nc-deck-state ${h}`,title:p("deck-autosave"),children:p(h==="saving"?"saving":h==="saved"?"saved":"deck-autosave")}),(X||f)&&l.jsx("span",{className:"nc-deck-error",children:X||f}),_&&b&&l.jsx("button",{className:"nc-deck-reload",onClick:b,children:p("reload")}),G&&l.jsx("button",{className:"nc-deck-fallback",onClick:()=>c&&c(G),children:p("popup-blocked")})]})}function RD({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 Ta={},Dp,pS;function LD(){return pS||(pS=1,Dp=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Dp}var Op={},Xr={},mS;function Xo(){if(mS)return Xr;mS=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 Xr.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},Xr.getSymbolTotalCodewords=function(s){return e[s]},Xr.getBCHDigit=function(n){let s=0;for(;n!==0;)s++,n>>>=1;return s},Xr.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');t=s},Xr.isKanjiModeEnabled=function(){return typeof t<"u"},Xr.toSJIS=function(s){return t(s)},Xr}var Bp={},gS;function Yv(){return gS||(gS=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}}})(Bp)),Bp}var $p,vS;function AD(){if(vS)return $p;vS=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++}},$p=t,$p}var zp,_S;function jD(){if(_S)return zp;_S=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]},zp=t,zp}var Fp={},yS;function MD(){return yS||(yS=1,(function(t){const e=Xo().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}})(Fp)),Fp}var Hp={},wS;function TD(){if(wS)return Hp;wS=1;const t=Xo().getSymbolSize,e=7;return Hp.getPositions=function(s){const i=t(s);return[[0,0],[i-e,0],[0,i-e]]},Hp}var Up={},bS;function PD(){return bS||(bS=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}})(Up)),Up}var rd={},SS;function FC(){if(SS)return rd;SS=1;const t=Yv(),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 rd.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}},rd.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}},rd}var Wp={},ec={},xS;function ID(){if(xS)return ec;xS=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]})(),ec.log=function(s){if(s<1)throw new Error("log("+s+")");return e[s]},ec.exp=function(s){return t[s]},ec.mul=function(s,i){return s===0||i===0?0:t[e[s]+e[i]]},ec}var kS;function DD(){return kS||(kS=1,(function(t){const e=ID();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}})(Wp)),Wp}var qp,CS;function OD(){if(CS)return qp;CS=1;const t=DD();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},qp=e,qp}var Kp={},Vp={},Yp={},ES;function HC(){return ES||(ES=1,Yp.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),Yp}var Wi={},NS;function UC(){if(NS)return Wi;NS=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
|
+
]))+`;Wi.KANJI=new RegExp(n,"g"),Wi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Wi.BYTE=new RegExp(s,"g"),Wi.NUMERIC=new RegExp(t,"g"),Wi.ALPHANUMERIC=new RegExp(e,"g");const i=new RegExp("^"+n+"$"),a=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Wi.testKanji=function(h){return i.test(h)},Wi.testNumeric=function(h){return a.test(h)},Wi.testAlphanumeric=function(h){return c.test(h)},Wi}var RS;function Jo(){return RS||(RS=1,(function(t){const e=HC(),n=UC();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}}})(Vp)),Vp}var LS;function BD(){return LS||(LS=1,(function(t){const e=Xo(),n=FC(),s=Yv(),i=Jo(),a=HC(),c=7973,u=e.getBCHDigit(c);function h(_,b,k){for(let R=1;R<=40;R++)if(b<=t.getCapacity(R,k,_))return R}function f(_,b){return i.getCharCountIndicator(_,b)+4}function g(_,b){let k=0;return _.forEach(function(R){const C=f(R.mode,b);k+=C+R.getBitsLength()}),k}function v(_,b){for(let k=1;k<=40;k++)if(g(_,k)<=t.getCapacity(k,b,i.MIXED))return k}t.from=function(b,k){return a.isValid(b)?parseInt(b,10):k},t.getCapacity=function(b,k,R){if(!a.isValid(b))throw new Error("Invalid QR Code version");typeof R>"u"&&(R=i.BYTE);const C=e.getSymbolTotalCodewords(b),L=n.getTotalCodewordsCount(b,k),S=(C-L)*8;if(R===i.MIXED)return S;const T=S-f(R,b);switch(R){case i.NUMERIC:return Math.floor(T/10*3);case i.ALPHANUMERIC:return Math.floor(T/11*2);case i.KANJI:return Math.floor(T/13);case i.BYTE:default:return Math.floor(T/8)}},t.getBestVersionForData=function(b,k){let R;const C=s.from(k,s.M);if(Array.isArray(b)){if(b.length>1)return v(b,C);if(b.length===0)return 1;R=b[0]}else R=b;return h(R.mode,R.getLength(),C)},t.getEncodedBits=function(b){if(!a.isValid(b)||b<7)throw new Error("Invalid QR Code version");let k=b<<12;for(;e.getBCHDigit(k)-u>=0;)k^=c<<e.getBCHDigit(k)-u;return b<<12|k}})(Kp)),Kp}var Gp={},AS;function $D(){if(AS)return Gp;AS=1;const t=Xo(),e=1335,n=21522,s=t.getBCHDigit(e);return Gp.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},Gp}var Xp={},Jp,jS;function zD(){if(jS)return Jp;jS=1;const t=Jo();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))},Jp=e,Jp}var Qp,MS;function FD(){if(MS)return Qp;MS=1;const t=Jo(),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)},Qp=n,Qp}var Zp,TS;function HD(){if(TS)return Zp;TS=1;const t=Jo();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)},Zp=e,Zp}var em,PS;function UD(){if(PS)return em;PS=1;const t=Jo(),e=Xo();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)}},em=n,em}var tm={exports:{}},IS;function WD(){return IS||(IS=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,k,R,C;!u.empty();){h=u.pop(),f=h.value,v=h.cost,_=n[f]||{};for(g in _)_.hasOwnProperty(g)&&(b=_[g],k=v+b,R=c[g],C=typeof c[g]>"u",(C||R>k)&&(c[g]=k,u.push(g,k),a[g]=f))}if(typeof i<"u"&&typeof c[i]>"u"){var L=["Could not find a path from ",s," to ",i,"."].join("");throw new Error(L)}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})(tm)),tm.exports}var DS;function qD(){return DS||(DS=1,(function(t){const e=Jo(),n=zD(),s=FD(),i=HD(),a=UD(),c=UC(),u=Xo(),h=WD();function f(L){return unescape(encodeURIComponent(L)).length}function g(L,S,T){const E=[];let H;for(;(H=L.exec(T))!==null;)E.push({data:H[0],index:H.index,mode:S,length:H[0].length});return E}function v(L){const S=g(c.NUMERIC,e.NUMERIC,L),T=g(c.ALPHANUMERIC,e.ALPHANUMERIC,L);let E,H;return u.isKanjiModeEnabled()?(E=g(c.BYTE,e.BYTE,L),H=g(c.KANJI,e.KANJI,L)):(E=g(c.BYTE_KANJI,e.BYTE,L),H=[]),S.concat(T,E,H).sort(function(X,V){return X.index-V.index}).map(function(X){return{data:X.data,mode:X.mode,length:X.length}})}function _(L,S){switch(S){case e.NUMERIC:return n.getBitsLength(L);case e.ALPHANUMERIC:return s.getBitsLength(L);case e.KANJI:return a.getBitsLength(L);case e.BYTE:return i.getBitsLength(L)}}function b(L){return L.reduce(function(S,T){const E=S.length-1>=0?S[S.length-1]:null;return E&&E.mode===T.mode?(S[S.length-1].data+=T.data,S):(S.push(T),S)},[])}function k(L){const S=[];for(let T=0;T<L.length;T++){const E=L[T];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 R(L,S){const T={},E={start:{}};let H=["start"];for(let F=0;F<L.length;F++){const X=L[F],V=[];for(let G=0;G<X.length;G++){const ne=X[G],Y=""+F+G;V.push(Y),T[Y]={node:ne,lastCount:0},E[Y]={};for(let B=0;B<H.length;B++){const P=H[B];T[P]&&T[P].node.mode===ne.mode?(E[P][Y]=_(T[P].lastCount+ne.length,ne.mode)-_(T[P].lastCount,ne.mode),T[P].lastCount+=ne.length):(T[P]&&(T[P].lastCount=ne.length),E[P][Y]=_(ne.length,ne.mode)+4+e.getCharCountIndicator(ne.mode,S))}}H=V}for(let F=0;F<H.length;F++)E[H[F]].end=0;return{map:E,table:T}}function C(L,S){let T;const E=e.getBestModeForData(L);if(T=e.from(S,E),T!==e.BYTE&&T.bit<E.bit)throw new Error('"'+L+'" cannot be encoded with mode '+e.toString(T)+`.
|
|
160
|
+
Suggested mode is: `+e.toString(E));switch(T===e.KANJI&&!u.isKanjiModeEnabled()&&(T=e.BYTE),T){case e.NUMERIC:return new n(L);case e.ALPHANUMERIC:return new s(L);case e.KANJI:return new a(L);case e.BYTE:return new i(L)}}t.fromArray=function(S){return S.reduce(function(T,E){return typeof E=="string"?T.push(C(E,null)):E.data&&T.push(C(E.data,E.mode)),T},[])},t.fromString=function(S,T){const E=v(S,u.isKanjiModeEnabled()),H=k(E),F=R(H,T),X=h.find_path(F.map,"start","end"),V=[];for(let G=1;G<X.length-1;G++)V.push(F.table[X[G]].node);return t.fromArray(b(V))},t.rawSplit=function(S){return t.fromArray(v(S,u.isKanjiModeEnabled()))}})(Xp)),Xp}var OS;function KD(){if(OS)return Op;OS=1;const t=Xo(),e=Yv(),n=AD(),s=jD(),i=MD(),a=TD(),c=PD(),u=FC(),h=OD(),f=BD(),g=$D(),v=Jo(),_=qD();function b(F,X){const V=F.size,G=a.getPositions(X);for(let ne=0;ne<G.length;ne++){const Y=G[ne][0],B=G[ne][1];for(let P=-1;P<=7;P++)if(!(Y+P<=-1||V<=Y+P))for(let D=-1;D<=7;D++)B+D<=-1||V<=B+D||(P>=0&&P<=6&&(D===0||D===6)||D>=0&&D<=6&&(P===0||P===6)||P>=2&&P<=4&&D>=2&&D<=4?F.set(Y+P,B+D,!0,!0):F.set(Y+P,B+D,!1,!0))}}function k(F){const X=F.size;for(let V=8;V<X-8;V++){const G=V%2===0;F.set(V,6,G,!0),F.set(6,V,G,!0)}}function R(F,X){const V=i.getPositions(X);for(let G=0;G<V.length;G++){const ne=V[G][0],Y=V[G][1];for(let B=-2;B<=2;B++)for(let P=-2;P<=2;P++)B===-2||B===2||P===-2||P===2||B===0&&P===0?F.set(ne+B,Y+P,!0,!0):F.set(ne+B,Y+P,!1,!0)}}function C(F,X){const V=F.size,G=f.getEncodedBits(X);let ne,Y,B;for(let P=0;P<18;P++)ne=Math.floor(P/3),Y=P%3+V-8-3,B=(G>>P&1)===1,F.set(ne,Y,B,!0),F.set(Y,ne,B,!0)}function L(F,X,V){const G=F.size,ne=g.getEncodedBits(X,V);let Y,B;for(Y=0;Y<15;Y++)B=(ne>>Y&1)===1,Y<6?F.set(Y,8,B,!0):Y<8?F.set(Y+1,8,B,!0):F.set(G-15+Y,8,B,!0),Y<8?F.set(8,G-Y-1,B,!0):Y<9?F.set(8,15-Y-1+1,B,!0):F.set(8,15-Y-1,B,!0);F.set(G-8,8,1,!0)}function S(F,X){const V=F.size;let G=-1,ne=V-1,Y=7,B=0;for(let P=V-1;P>0;P-=2)for(P===6&&P--;;){for(let D=0;D<2;D++)if(!F.isReserved(ne,P-D)){let M=!1;B<X.length&&(M=(X[B]>>>Y&1)===1),F.set(ne,P-D,M),Y--,Y===-1&&(B++,Y=7)}if(ne+=G,ne<0||V<=ne){ne-=G,G=-G;break}}}function T(F,X,V){const G=new n;V.forEach(function(D){G.put(D.mode.bit,4),G.put(D.getLength(),v.getCharCountIndicator(D.mode,F)),D.write(G)});const ne=t.getSymbolTotalCodewords(F),Y=u.getTotalCodewordsCount(F,X),B=(ne-Y)*8;for(G.getLengthInBits()+4<=B&&G.put(0,4);G.getLengthInBits()%8!==0;)G.putBit(0);const P=(B-G.getLengthInBits())/8;for(let D=0;D<P;D++)G.put(D%2?17:236,8);return E(G,F,X)}function E(F,X,V){const G=t.getSymbolTotalCodewords(X),ne=u.getTotalCodewordsCount(X,V),Y=G-ne,B=u.getBlocksCount(X,V),P=G%B,D=B-P,M=Math.floor(G/B),$=Math.floor(Y/B),A=$+1,j=M-$,N=new h(j);let U=0;const I=new Array(B),W=new Array(B);let se=0;const me=new Uint8Array(F.buffer);for(let ge=0;ge<B;ge++){const Se=ge<D?$:A;I[ge]=me.slice(U,U+Se),W[ge]=N.encode(I[ge]),U+=Se,se=Math.max(se,Se)}const pe=new Uint8Array(G);let Ie=0,J,te;for(J=0;J<se;J++)for(te=0;te<B;te++)J<I[te].length&&(pe[Ie++]=I[te][J]);for(J=0;J<j;J++)for(te=0;te<B;te++)pe[Ie++]=W[te][J];return pe}function H(F,X,V,G){let ne;if(Array.isArray(F))ne=_.fromArray(F);else if(typeof F=="string"){let M=X;if(!M){const $=_.rawSplit(F);M=f.getBestVersionForData($,V)}ne=_.fromString(F,M||40)}else throw new Error("Invalid data");const Y=f.getBestVersionForData(ne,V);if(!Y)throw new Error("The amount of data is too big to be stored in a QR Code");if(!X)X=Y;else if(X<Y)throw new Error(`
|
|
161
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
162
|
+
Minimum version required to store current data is: `+Y+`.
|
|
163
|
+
`);const B=T(X,V,ne),P=t.getSymbolSize(X),D=new s(P);return b(D,X),k(D),R(D,X),L(D,V,0),X>=7&&C(D,X),S(D,B),isNaN(G)&&(G=c.getBestMask(D,L.bind(null,D,V))),c.applyMask(G,D),L(D,V,G),{modules:D,version:X,errorCorrectionLevel:V,maskPattern:G,segments:ne}}return Op.create=function(X,V){if(typeof X>"u"||X==="")throw new Error("No input text");let G=e.M,ne,Y;return typeof V<"u"&&(G=e.from(V.errorCorrectionLevel,e.M),ne=f.from(V.version),Y=c.from(V.maskPattern),V.toSJISFunc&&t.setToSJISFunction(V.toSJISFunc)),H(X,ne,G,Y)},Op}var nm={},sm={},BS;function WC(){return BS||(BS=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 k=(_*f+b)*4,R=a.color.light;if(_>=g&&b>=g&&_<f-g&&b<f-g){const C=Math.floor((_-g)/h),L=Math.floor((b-g)/h);R=v[u[C*c+L]?1:0]}s[k++]=R.r,s[k++]=R.g,s[k++]=R.b,s[k]=R.a}}})(sm)),sm}var $S;function VD(){return $S||($S=1,(function(t){const e=WC();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)}})(nm)),nm}var im={},zS;function YD(){if(zS)return im;zS=1;const t=WC();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 im.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)+'"/>',k='viewBox="0 0 '+v+" "+v+'"',C='<svg xmlns="http://www.w3.org/2000/svg" '+(h.width?'width="'+h.width+'" height="'+h.width+'" ':"")+k+' shape-rendering="crispEdges">'+_+b+`</svg>
|
|
164
|
+
`;return typeof u=="function"&&u(null,C),C},im}var FS;function GD(){if(FS)return Ta;FS=1;const t=LD(),e=KD(),n=VD(),s=YD();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,k){try{const R=e.create(u,h);b(a(R,c,h))}catch(R){k(R)}})}try{const b=e.create(u,h);f(null,a(b,c,h))}catch(b){f(b)}}return Ta.create=e.create,Ta.toCanvas=i.bind(null,n.render),Ta.toDataURL=i.bind(null,n.renderToDataURL),Ta.toString=i.bind(null,function(a,c,u){return s.render(a,u)}),Ta}var XD=GD();const JD=Qg(XD);function HS(t){return typeof t=="string"?t.trim():t&&typeof t=="object"&&typeof t.data=="string"?t.data.trim():""}function QD(t){const e=String(t||"").trim();if(!e)return{kind:"empty"};const n=iI(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 ZD(t,e,n=new Set,s=!1){if(!e||!e.ok)return t;const i=rI(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 US(t,e,n=new Set,s=!1){const i=String(e||"").trim(),a=QD(i);let c={...t,pairingUrl:i};return(a.kind==="complete"||a.kind==="partial")&&(c={...ZD(c,a.decoded,n,s),pairingUrl:i}),{classification:a,form:c}}function Sd(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=uo(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 e3(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||Sd(a,n)||s||"").trim();return c&&(i.localName=c),i}function t3(){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 n3=["validation","conflict","ssh-start","ssh-ready","join","tunnel-final","confirm","health"];function s3(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 i3="modulepreload",r3=function(t){return"/"+t},WS={},o3=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=r3(f),f in WS)return;WS[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":i3,g||(_.as="script"),_.crossOrigin="",_.href=f,h&&_.setAttribute("nonce",h),document.head.appendChild(_),g)return new Promise((b,k)=>{_.addEventListener("load",b),_.addEventListener("error",()=>k(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 Bt{constructor(e,n,s,i,a){this._legacyCanvasSize=Bt.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=Bt.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 Bt.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"),Bt._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"),Bt._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(),Bt._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?Bt._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&&(Bt._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||Bt.createQrEngine(),Bt._loadImage(e)]),[i,g]=Bt._drawToCanvas(f,u,i,a);let v;if(s instanceof Worker){let _=s;n||Bt._postWorkerMessageSync(_,"inversionMode","both"),v=await new Promise((b,k)=>{let R,C,L,S=-1;C=E=>{E.data.id===S&&(_.removeEventListener("message",C),_.removeEventListener("error",L),clearTimeout(R),E.data.data!==null?b({data:E.data.data,cornerPoints:Bt._convertPoints(E.data.cornerPoints,u)}):k(Bt.NO_QR_CODE_FOUND))},L=E=>{_.removeEventListener("message",C),_.removeEventListener("error",L),clearTimeout(R),k("Scanner error: "+(E?E.message||E:"Unknown Error"))},_.addEventListener("message",C),_.addEventListener("error",L),R=setTimeout(()=>L("timeout"),1e4);let T=g.getImageData(0,0,i.width,i.height);S=Bt._postWorkerMessageSync(_,"decode",T,[T.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 Bt.NO_QR_CODE_FOUND;return{data:_.rawValue,cornerPoints:Bt._convertPoints(_.cornerPoints,u)}}catch(b){if(_=b.message||b,/not implemented|service unavailable/.test(_))return Bt._disableBarcodeDetector=!0,Bt.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 Bt.scanImage(e,{qrEngine:s,canvas:i,disallowCanvasResizing:a});return h?g:g.data}finally{n||Bt._postWorkerMessage(s,"close")}}setGrayscaleWeights(e,n,s,i=!0){Bt._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:n,blue:s,useIntegerApproximation:i})}setInversionMode(e){Bt._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=()=>o3(()=>import("./qr-scanner-worker.min-D85Z9gVD.js"),[]).then(s=>s.createWorker()),!(!Bt._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[k,R]=h.objectPosition.split(" ").map((L,S)=>{const T=parseFloat(L);return L.endsWith("%")?(S?a-b:i-_)*T/100:T});h=this._scanRegion.width||n,v=this._scanRegion.height||s,f=this._scanRegion.x||0;var C=this._scanRegion.y||0;g=this.$overlay.style,g.width=`${h/n*_}px`,g.height=`${v/s*b}px`,g.top=`${u+R+C/s*b}px`,s=/scaleX\(-1\)/.test(e.style.transform),g.left=`${c+(s?i-k-_:k)+(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 Bt.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(i){if(!this._active)return;this._onDecodeError(i)}!Bt._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=Bt.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!==Bt.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 Bt._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 Bt._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 Bt._postWorkerMessageSync(await e,n,s,i)}static _postWorkerMessageSync(e,n,s,i){if(!(e instanceof Worker))return-1;let a=Bt._workerMessageId++;return e.postMessage({id:a,type:n,data:s},i),a}}Bt.DEFAULT_CANVAS_SIZE=400;Bt.NO_QR_CODE_FOUND="No QR code found";Bt._disableBarcodeDetector=!1;Bt._workerMessageId=0;function a3({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 Bt.hasCamera()}catch{v=!1}if(!v){c(p("qr-no-camera"));return}if(h||!f)return;const _=new Bt(f,b=>{const k=HS(b);k&&g(k)},{returnDetailedScanResult:!0,preferredCamera:"environment",calculateScanRegion:b=>{const k=b.videoWidth||640,R=b.videoHeight||480,C=Math.max(1,Math.round(Math.min(k,R)*.92));return{x:Math.round((k-C)/2),y:Math.round((R-C)/2),width:C,height:C,downScaledWidth:600,downScaledHeight:600}},highlightScanRegion:!0,highlightCodeOutline:!0});s.current=_;try{await _.start()}catch(b){if(h)return;const k=b&&b.name||"";c(p(k==="NotAllowedError"||k==="SecurityError"?"qr-permission":k==="NotFoundError"||k==="OverconstrainedError"||k==="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 k of b.getTracks())try{k.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 Bt.scanImage(f,{returnDetailedScanResult:!0}),v=HS(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 Gv({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 ug(t))},children:p(n?"pair-authkeys-copied":"pair-authkeys-copy")})]}):null}const qS=()=>({name:"",label:"",ssh:"",sshPort:"",pairingUrl:"",localLabel:"",localName:""});function qC({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(qS),[v,_]=w.useState(!1),[b,k]=w.useState(!1),[R,C]=w.useState("idle"),[L,S]=w.useState(null),[T,E]=w.useState(""),[H,F]=w.useState(null),[X,V]=w.useState(!1),[G,ne]=w.useState(!1),Y=w.useRef(t3()),B=w.useRef(new Set),P=R==="busy",D=Sd(f.localLabel||s,i)||a,M=G?f.localName:D;w.useEffect(()=>(h&&h(P),()=>{h&&h(!1)}),[P,h]);const $=async W=>{const se=String(W.pairingUrl||"").trim();if(Y.current.start(se)){C("busy"),S(null),E("");try{const me=await JN(t,e3({...W,localName:G?W.localName:Sd(W.localLabel||s,i)||a},{deviceDefault:s,localNodeId:i,localNameDefault:a}));C("ok"),_(!1),g(qS()),F(me&&me.authorizedKeys?{line:me.authorizedKeys,note:me.authorizedKeysNote||""}:null),B.current=new Set,V(!1),ne(!1),Y.current.finish(),u&&await u(me)}catch(me){const pe=s3(me);S(pe),C("idle"),Y.current.finish(),pe.code==="peer-name-conflict"&&Lg(pe.suggestedName)&&(ne(!0),B.current.add("localName"),g(Ie=>({...Ie,localName:pe.suggestedName}))),(pe.stage==="validation"||pe.stage==="conflict"||pe.stage==="ssh-start"||pe.stage==="ssh-ready"||String(pe.code||"").startsWith("ssh-"))&&_(!0)}}},A=(W,se=!0)=>{const{classification:me,form:pe}=US(f,W,B.current,X),Ie=pe.pairingUrl;if(S(null),E(""),R==="ok"&&C("idle"),g(pe),me.kind==="invalid"){S({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(me.kind==="partial"){_(!0),E(me.missing.includes("ssh")?p("pair-missing-ssh"):p("pair-missing-name"));return}me.kind==="complete"&&se&&!c&&Y.current.canAuto(Ie)&&$(pe)};w.useEffect(()=>{e&&A(e,n)},[]);const j=()=>{const W=String(f.pairingUrl||"").trim(),{classification:se,form:me}=US(f,W,B.current,X);if(g(me),E(""),S(null),se.kind==="empty"){S({stage:"validation",message:p("pairing-required"),retryable:!0});return}if(se.kind==="invalid"){S({stage:"validation",code:"bad-link",message:p("pair-invalid-link"),hint:p("pair-invalid-hint"),retryable:!0});return}if(!me.ssh||!me.name){_(!0),E(me.ssh?p("pair-missing-name"):p("pair-missing-ssh"));return}if(me.label&&!Ya(me.label)){S({stage:"validation",message:p("err-label"),retryable:!0});return}if(me.localLabel&&!Ya(me.localLabel)){S({stage:"validation",message:p("err-label"),retryable:!0});return}const pe=G?me.localName:Sd(me.localLabel||s,i)||a;if(!Lg(pe)||pe==="localhost"){_(!0),S({stage:"validation",code:"bad-local-name",message:p("err-local-name"),retryable:!0});return}Y.current.reset(W),$(me)},N=async()=>{try{if(!navigator.clipboard||typeof navigator.clipboard.readText!="function")throw new Error("unsupported");const W=await navigator.clipboard.readText();W&&W.trim()?A(W):E(p("pair-clipboard-empty"))}catch{E(p("pair-clipboard-denied"))}},U=(W,se)=>{B.current.add(W),g(me=>({...me,[W]:se}))},I=L&&L.stage&&(n3.includes(L.stage)||L.stage==="internal")?p(`pair-stage-${L.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||P,onChange:W=>{g({...f,pairingUrl:W.target.value}),S(null),E("")},onPaste:W=>{const se=W.clipboardData&&W.clipboardData.getData("text")||"";se.trim()&&(W.preventDefault(),A(se))},onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),j())}}),l.jsxs("div",{className:"nc-pair-actions",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||P,onClick:N,children:p("pair-paste-btn")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||P,onClick:()=>k(!0),children:p("scan-qr")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:c||P,title:c?p("settings-readonly"):"",onClick:j,children:p("test-and-connect")})]}),l.jsxs("div",{className:"nc-pair-status","aria-live":"polite",children:[P&&l.jsx("div",{className:"nc-pair-progress",children:p("pair-progress")}),R==="ok"&&l.jsx("div",{className:"nc-set-test ok",children:p("node-connected")}),R==="ok"&&H&&l.jsx(Gv,{line:H.line,note:H.note}),T&&l.jsx("div",{className:"nc-set-hint nc-pair-notice",children:T}),L&&l.jsxs("div",{className:"nc-err",role:"alert",children:[l.jsx("b",{children:I})," — ",L.message,L.hint&&l.jsx("div",{className:"nc-pair-hint",children:L.hint}),L.retryable&&l.jsx("div",{children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:c||P,onClick:j,children:p("pair-retry")})})]})]}),l.jsxs("button",{type:"button",className:"nc-btn ghost nc-pair-advanced-toggle",disabled:P,onClick:()=>_(W=>!W),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||P,onChange:W=>{B.current.add("label"),g(se=>({...se,label:W.target.value,name:X?se.name:uo(W.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||P,onChange:W=>{V(!0),B.current.add("name"),g(se=>({...se,name:W.target.value?uo(W.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||P,onChange:W=>{B.current.add("ssh"),U("ssh",W.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||P,onChange:W=>U("sshPort",W.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||P,onChange:W=>U("localLabel",W.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:D||"nexuscrew-5bd6",value:M,disabled:c||P,onChange:W=>{ne(!0),B.current.add("localName"),g(se=>({...se,localName:W.target.value?uo(W.target.value):""}))}}),l.jsx("small",{className:"nc-set-hint",children:p("local-route-name-hint")})]})]}),b&&l.jsx(a3,{onResult:W=>{k(!1),A(W)},onClose:()=>k(!1)})]})}const Ki={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 Xv(t){if(!t||typeof t!="object")return{key:Ki.down,up:!1};if(t.kind==="vl")return t.online?{key:Ki.vlOnline,up:!0}:{key:Ki.vlOffline,up:!1};if(t.kind==="transitive"){const n=t.stale===!0;return{key:n?Ki.routedStale:Ki.routed,up:!n,routed:!0}}const e=t.tunnel&&t.tunnel.status;return e==="up"?{key:Ki.up,up:!0}:e==="passive"?{key:Ki.passive,up:!1,passive:!0}:{key:Ki.down,up:!1}}function KC(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 l3(t){const n=t.health&&typeof t.health.detail=="string"&&t.health.detail.trim()||p(t.online?Ki.vlOnline:Ki.vlOffline);return t.ownerLabel?`${t.ownerLabel} · ${n}`:n}function c3(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"?l3(t):e,reach:Xv(t),exposure:KC(t),routed:n,routeLabel:n&&Array.isArray(t.route)?t.route.join(" › "):null}}function u3(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 d3(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 h3(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 f3(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 p3(t,{readonly:e=!1,busy:n=!1}={}){if(!t||typeof t!="object")return[];const s=t.actions&&typeof t.actions=="object"?t.actions:{},i=Xv(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 VC(t){const e=t&&typeof t.cellVisibility=="string"?t.cellVisibility:"all";return["all","none","selected"].includes(e)?e:"all"}function m3(t,e){if(VC(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 g3(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 v3(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 _3(t,e,{readonly:n=!1,busy:s=!1}={}){const i=u3(t);return i?{identity:i,reach:Xv(t),authority:d3(t),exposure:KC(t),grants:h3(t,e),cellScope:VC(t),actions:p3(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 y3=Object.freeze(["cellVisibility","eventsAccess","nodeEventsAccess","askReplyAccess","filesReadAccess","liveHostAccess","panelAccess","peerOperatorAccess"]),w3=Object.freeze(["admin","user","nexushost"]),b3=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 S3(t,e,n=!1){const s=b3[e];if(!s)return[];const i=t&&typeof t=="object"?t:{},a=y3.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 YC="nc_push_local_v1",KS=Object.freeze({enabled:!0});function GC(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled!==!1}}function Jv(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function XC(t=Jv()){if(!t)return{...KS};try{return GC(JSON.parse(t.getItem(YC)||"null"))}catch{return{...KS}}}function x3(t,e=Jv()){const n=GC(t);if(e)try{e.setItem(YC,JSON.stringify(n))}catch{}return n}function k3(t=Jv()){return XC(t).enabled===!1}function Qv(){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 JC(){if(!Qv())return"unsupported";if(Notification.permission==="denied")return"denied";try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?"subscribed":"idle"}catch{return"idle"}}async function QC(t){if(!Qv())throw new Error("push-unsupported");if(k3())throw new Error("push-disabled-local");if(await Notification.requestPermission()!=="granted")throw new Error("push-denied");const n=await Wn("/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 Wn("/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 VS(t){if(!Qv())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 Wn("/api/push/subscribe",t,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}return!0}const E3=new Set(["update_candidate"]),YS=4096,N3=new Set(["prompt"]),GS={logs:{limit:50}};function R3(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||E3.has(i)||N3.has(i)||n.has(i)||(n.add(i),s.push(i));return s}function XS(t){return!!(t&&t.kind==="vl"&&Array.isArray(t.capabilities)&&t.capabilities.includes("prompt"))}function L3(t){return GS[t]?{...GS[t]}:{}}function A3(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 j3({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 jo({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 M3({node:t,nodes:e,token:n,readonly:s,refresh:i,onClose:a,peerAccessRevision:c=null}){var re,ce;$n();const[u,h]=w.useState(null),[f,g]=w.useState(null),[v,_]=w.useState(null),[b,k]=w.useState(null),[R,C]=w.useState(!1),[L,S]=w.useState(""),[T,E]=w.useState(!1),[H,F]=w.useState(null),[X,V]=w.useState(!1),[G,ne]=w.useState(""),[Y,B]=w.useState(!1),[P,D]=w.useState(null),[M,$]=w.useState(!1),[A,j]=w.useState(""),[N,U]=w.useState(null),I=w.useMemo(()=>_3(t,e,{readonly:s,busy:!!u}),[t,e,s,u]);if(!I)return null;const{identity:W,reach:se,authority:me,exposure:pe,grants:Ie,actions:J,canEditVisibility:te,canEditCellScope:ge,cellScope:Se}=I,Be=v3(t),Le=W.routed?{up:se.up,since:null}:Ag(t.tunnel,Date.now()),ze=async(O,de)=>{g(null),h(O);try{await de()}catch(we){g(String(we&&we.message||we))}h(null)},Q=O=>{if(O==="edit"){k({label:t.label||t.name,ssh:t.ssh||"",sshPort:t.sshPort?String(t.sshPort):"",autostart:t.autostart===!0,visibility:t.visibility||"network"});return}if(O==="remove"){C(!0);return}ze(`${t.name}:${O}`,async()=>{const de=await sv(n,t.name,O);O==="test"&&_(de),await i()})},ve=(O,de=L3(O))=>ze(`${t.nodeId}:${O}`,async()=>{const we=await zw(n,t.nodeId,O,de,t.route||[]);D({id:we.id,kind:O,submittedAt:Date.now()}),await i()}),Z=()=>{const O=A.trim().slice(0,YS);O&&ze(`${t.nodeId}:prompt`,async()=>{const de=await zw(n,t.nodeId,"prompt",{text:O},t.route||[]);D({id:de.id,kind:"prompt",submittedAt:Date.now()}),j(""),$(!1),await i()})},be=()=>{if(!Ya(b.label)){g(p("err-label"));return}const O=W.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 ze(`${t.name}:edit`,async()=>{await Yf(n,t.name,O),k(null),await i()})},K=(O,de)=>ze(`${t.name}:visibility`,async()=>{await s5(n,t.name,O,de),await i()}),fe=te&&t.visibility==="selected"?f3(t,e,L):[],Re=(O,de)=>ze(`${t.name}:cell-scope`,async()=>{await Yf(n,t.name,O==="selected"?{cellVisibility:O,cells:Array.isArray(de)?de:t.cells||[]}:{cellVisibility:O}),await i()}),Ee=O=>ze(`${t.name}:access`,async()=>{try{if(await Yf(n,t.name,{accessRole:O,accessRevision:c}),O==="admin"&&typeof Notification<"u"&&Notification.permission==="granted")try{await JC()==="idle"&&await QC(n)}catch{}U(null),await i()}catch(de){if(de&&de.status===409)g(p("peer-access-conflict")),await i();else throw de}}),qe=async({retry:O=!1}={})=>{if(O&&X)V(!1);else if(H!==null||X)return;try{const de=await Xd(n);F(Array.isArray(de&&de.cells)?de.cells:[])}catch{V(!0)}};w.useEffect(()=>{ge&&Se==="selected"&&H===null&&qe()},[ge,Se,H]);const Ze=m3(t,H),at=Se==="selected"?g3(t,H,G):[],Oe=l.jsxs("span",{className:`nc-set-tunnel${se.up?" up":""}`,children:[p(se.key),Le.since?` · ${Le.since}`:""]}),_e=t.kind==="vl",$e=_e?R3(t):[],nt=_e?A3(t,P):null,Fe=O=>{const de=`vl-cmd-${O}`,we=p(de);return we===de?O:we},rt=_e?[...$e.map(O=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u||s,title:s?p("settings-readonly"):void 0,onClick:()=>ve(O),children:Fe(O)},O)),...XS(t)?[l.jsx("button",{type:"button",className:`nc-btn ghost${M?" on":""}`,disabled:!!u||s,title:s?p("settings-readonly"):void 0,onClick:()=>$(O=>!O),children:Fe("prompt")},"prompt")]:[]]:J.map(O=>l.jsx("button",{type:"button",className:`nc-btn ${O.danger?"danger":"ghost"}`,disabled:O.disabled,title:O.disabled&&s?p("settings-readonly"):void 0,onClick:()=>Q(O.action),children:O.action==="remove"?l.jsxs(l.Fragment,{children:[l.jsx(Tt,{name:"trash",size:14})," ",p(O.key)]}):p(O.key)},O.action));return l.jsxs(j3,{title:W.title,subtitle:W.name,status:Oe,footer:rt,onClose:a,children:[l.jsxs(jo,{title:p("node-detail-reach"),children:[l.jsxs("dl",{className:"nc-detail-facts",children:[W.route&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-route")}),l.jsx("dd",{children:W.route.join(" › ")})]}),W.ssh&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-ssh")}),l.jsxs("dd",{children:[W.ssh,t.sshPort?`:${t.sshPort}`:""]})]}),W.transport&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-transport")}),l.jsx("dd",{children:W.transport})]}),_e&&t.ownerLabel&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:p("node-detail-owner")}),l.jsx("dd",{children:t.ownerLabel})]})]}),((re=t.health)==null?void 0:re.detail)&&l.jsx("div",{className:`nc-set-test${_e?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 O=TP(t.health);return O?O.line?l.jsx(Gv,{line:O.line,note:O.note}):l.jsx("small",{className:"nc-set-hint",children:O.note}):null})(),v&&l.jsxs("div",{className:`nc-set-test${v.ok?" ok":" ko"}`,children:[v.result,v.detail?` — ${v.detail}`:""]})]}),_e&&l.jsxs(jo,{title:p("node-detail-command"),children:[$e.length===0&&!XS(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:A,maxLength:YS,placeholder:p("vl-prompt-placeholder"),"aria-label":p("vl-prompt-placeholder"),disabled:!!u||s,onChange:O=>j(O.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:!!u||s||!A.trim(),onClick:Z,children:p("vl-prompt-send")})]}),nt&&l.jsxs("div",{className:`nc-set-test${nt.phase==="done"?nt.status==="ok"?" ok":" ko":""}`,children:[nt.kind&&`${Fe(nt.kind)}: `,nt.phase==="submitted"&&p("vl-cmd-phase-submitted"),nt.phase==="inflight"&&p("vl-cmd-phase-inflight"),nt.phase==="done"&&p(nt.status==="ok"?"vl-cmd-phase-done-ok":"vl-cmd-phase-done-error"),nt.phase==="done"&&((ce=nt.result)!=null&&ce.detail)?` — ${nt.result.detail}`:""]})]}),l.jsxs(jo,{title:p("node-detail-authority"),children:[l.jsx("div",{className:"nc-set-info",children:p(me.key)}),me.grants.length===0&&l.jsx("small",{className:"nc-set-hint",children:p(ge?"authority-no-grants":"authority-no-grants-elsewhere")})]}),l.jsxs(jo,{title:p("node-detail-network-view"),children:[l.jsx("div",{className:"nc-set-info",children:p(_e?pe.key:pe.shared?"peer-shared":"peer-private")}),te&&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:O=>K(O.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:[Ie.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("node-grant-none")}),Ie.map(O=>l.jsxs("div",{className:`nc-detail-grant${O.known?"":" unknown"}`,children:[l.jsxs("span",{children:[O.label,O.known?"":` — ${p("node-grant-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>K("selected",(t.selected||[]).filter(de=>de!==O.id)),children:p("node-grant-remove")})]},O.id)),!T&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>{E(!0),S("")},children:p("node-grant-add")}),T&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:L,placeholder:p("node-grant-search"),disabled:s||!!u,onChange:O=>S(O.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[fe.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("node-grant-no-candidates")}),fe.map(O=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await K("selected",[...t.selected||[],O.id]),E(!1),S("")},children:O.label},O.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{E(!1),S("")},children:p("cancel")})]})]})]})]}),ge&&l.jsxs(jo,{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:Se,"aria-label":p("cell-scope"),disabled:s||!!u,onChange:O=>{O.target.value==="selected"&&qe(),Re(O.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")})]})}),Se==="selected"&&Ze.length>0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-reset-warning")}),X&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-list-unavailable")}),Se==="selected"&&l.jsxs("div",{className:"nc-detail-grants",children:[Ze.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-none-granted")}),Ze.map(O=>l.jsxs("div",{className:`nc-detail-grant${O.known?"":" unknown"}`,children:[l.jsxs("span",{children:[O.label,O.known?"":` — ${p("cell-scope-unknown")}`]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:()=>Re("selected",(t.cells||[]).filter(de=>de!==O.id)),children:p("node-grant-remove")})]},O.id)),!Y&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await qe({retry:!0}),B(!0),ne("")},children:p("cell-scope-add")}),Y&&l.jsxs("div",{className:"nc-detail-picker",children:[l.jsx("input",{value:G,placeholder:p("cell-scope-search"),disabled:s||!!u,onChange:O=>ne(O.target.value)}),l.jsxs("div",{className:"nc-detail-picker-list",children:[at.length===0&&l.jsx("small",{className:"nc-set-hint",children:p("cell-scope-no-candidates")}),at.map(O=>l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:s||!!u,onClick:async()=>{await Re("selected",[...t.cells||[],O.id]),B(!1),ne("")},children:O.label},O.id))]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>{B(!1),ne("")},children:p("cancel")})]})]})]}),Be&&c!=null&&!_e&&l.jsxs(jo,{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-${Be.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:O=>U(O.target.value||null),children:[l.jsx("option",{value:"",children:p("peer-access-preset-none")}),w3.map(O=>l.jsx("option",{value:O,children:p(`access-label-${O}`)},O))]})}),N&&(()=>{const O=S3(Be.grants,N,t.eventsReceive),de=O.filter(we=>we.changed).length;return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-access-matrix",role:"table","aria-label":p("peer-access-matrix"),children:O.map(we=>l.jsxs("div",{role:"row",className:`nc-access-row${we.changed?" changed":""}`,children:[l.jsx("span",{role:"rowheader",children:p(`access-grant-${we.key}`)}),l.jsx("span",{children:p(`access-value-${we.current===!0?"yes":we.current===!1?"no":String(we.current)}`)}),l.jsx("span",{"aria-hidden":"true",children:"→"}),l.jsx("span",{children:p(`access-value-${we.next===!0?"yes":we.next===!1?"no":String(we.next)}`)})]},we.key))}),l.jsx("small",{className:"nc-set-hint",children:p(de===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:()=>Ee(N),children:p("peer-access-apply")})]})})()]}),b&&l.jsxs(jo,{title:p("edit"),children:[l.jsxs("label",{className:"nc-field",children:[p("node-display-label"),l.jsx("input",{value:b.label,disabled:!!u,onChange:O=>k({...b,label:O.target.value})})]}),W.inbound?l.jsxs("label",{className:"nc-field",children:[p("peer-visibility"),l.jsxs("select",{value:b.visibility,disabled:!!u,onChange:O=>k({...b,visibility:O.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:O=>k({...b,ssh:O.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:O=>k({...b,sshPort:O.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:O=>k({...b,autostart:O.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:be,children:p("save")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>k(null),children:p("cancel")})]})]}),R&&l.jsxs("div",{className:"nc-set-confirm",children:[l.jsx("b",{children:p("node-remove-confirm").replace("{name}",W.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:()=>ze(`${t.name}:remove`,async()=>{await t5(n,t.name),C(!1),await i(),a&&a()}),children:p("delete")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:!!u,onClick:()=>C(!1),children:p("cancel")})]})]}),f&&l.jsx("div",{className:"nc-err",children:f})]})}function T3(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 Bg="nexuscrew.fleet",ZC=3,P3="nexuscrew.cells",eE=/^[A-Za-z0-9._-]{1,32}$/,vh=/^[a-z0-9._-]{1,32}$/,tE=/^[A-Za-z_][A-Za-z0-9_]{0,63}$/,nE=new Set(["standard","unsafe"]),I3=4096,D3=4096,Hd=256,sE=8192,O3=4096,B3=32,$3=64,od=100,z3=128,F3=new Set(["format","version","exportedAt","cells","engines","models"]),H3=new Set(["id","cwdRel","engine","boot","model","models","permissionPolicies","commands","systemPrompt","prompt","label","mcp"]),U3=new Set(["id","cwd","engine","boot","model","models","permissionPolicies","systemPrompt","prompt"]);function Io(t){if(typeof t!="string"||t.length>D3)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 W3=new Set(["id","label","rc","managed","command","args","envKeys","model","promptMode","promptFlag","panelUrl"]),q3=new Set(["client","provider","credentialProfile","model","permissionPolicy","displayName","protocol","baseUrl","envKey","providerId"]),K3=new Set(["127.0.0.1","localhost","[::1]"]);function Zv(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:"||!K3.has(e.hostname))}function xr(t,e){return typeof t=="string"&&t.length<=e&&!/[\x00-\x1f\x7f]/.test(t)}function e_(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 _c(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(!vh.test(i)||!e(a))return null;s[i]=a}return s}function iE(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(u=>!H3.has(u))||!eE.test(String(t.id||""))||typeof t.cwdRel!="string")return null;const e=Io(t.cwdRel);if(e===null||!vh.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>Hd)||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>sE)return null;const s=_c(t.models,u=>typeof u=="string"&&!!u&&u.length<=Hd),i=_c(t.permissionPolicies,u=>nE.has(u)),a=_c(t.commands,u=>xr(u,O3)&&!e_(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(!xr(t.label,$3)||!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 V3(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(a=>!U3.has(a))||!eE.test(String(t.id||""))||typeof t.cwd!="string"||!t.cwd||t.cwd.length>I3||!vh.test(String(t.engine||""))||t.boot!==void 0&&typeof t.boot!="boolean"||t.model!==void 0&&(typeof t.model!="string"||t.model.length>Hd)||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>sE)return null;const n=_c(t.models,a=>typeof a=="string"&&!!a&&a.length<=Hd),s=_c(t.permissionPolicies,a=>nE.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 Y3(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(n=>!q3.has(n)))return null;const e={};for(const[n,s]of Object.entries(t)){if(typeof s!="string"||!xr(s,n==="baseUrl"?512:128)||e_(s))return null;e[n]=s}return!e.client||!e.provider||e.envKey&&!tE.test(e.envKey)?null:e}function rE(t){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(s=>!W3.has(s))||!vh.test(String(t.id||""))||!xr(t.label||t.id,64)||t.rc!==void 0&&typeof t.rc!="boolean"||t.panelUrl!==void 0&&!Zv(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=Y3(t.managed);return!s||["command","args","envKeys","model","promptMode","promptFlag"].some(i=>t[i]!==void 0)?null:(e.managed=s,e)}if(!xr(t.command,512)||!t.command.startsWith("/")||!Array.isArray(t.args)||t.args.length>32||t.args.some(s=>!xr(s,1024)||e_(s))||t.promptMode!=="flag"&&t.promptMode!=="send-keys"||t.promptMode==="flag"&&(!xr(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")||!xr(t.model.flag,32)||/\s/.test(t.model.flag)||!xr(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=>!tE.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 oE(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=rE(e);return n||null}function G3(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 X3(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 _=iE({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 _=oE(v);_&&f.push(_)}const g=G3(a,n,u);return{format:Bg,version:ZC,exportedAt:i.toISOString(),cells:h,engines:f,...g.length?{models:g}:{}}}function J3(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)===P3&&(e==null?void 0:e.version)===1,s=(e==null?void 0:e.format)===Bg&&(e==null?void 0:e.version)===2,i=(e==null?void 0:e.format)===Bg&&(e==null?void 0:e.version)===ZC,a=n||s,c=s||i;if(c&&Array.isArray(e.engines)&&e.engines.length>od)return{ok:!1,error:"invalid-format",detail:`${e.engines.length} engine dichiarati, cap ${od}; riduci gli engine a ${od} o meno`,cells:[],engines:[]};if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(_=>!F3.has(_))||!n&&!s&&!i||!Array.isArray(e.cells)||e.cells.length>B3||c&&(!Array.isArray(e.engines)||e.engines.length>od))return{ok:!1,error:"invalid-format",cells:[],engines:[]};const u=[],h=new Set;for(const _ of e.cells){const b=a?V3(_):iE(_);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=rE(_);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>z3)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 k=new Set(["id","engine","label","contextWindow","maxTokens","reasoning"]);if(Object.keys(b).some(S=>!k.has(S)))return{ok:!1,error:"invalid-model",cells:[],engines:[]};const R=typeof b.id=="string"?b.id.trim():"",C=typeof b.engine=="string"?b.engine.trim():"";if(!R||!C)return{ok:!1,error:"invalid-model",cells:[],engines:[]};const L=`${C}::${R}`;if(_.has(L))return{ok:!1,error:"duplicate-model",cells:[],engines:[]};_.add(L),v.push({...b,id:R,engine:C})}}return{ok:!0,cells:u,engines:f,models:v,legacy:a,exportedAt:typeof e.exportedAt=="string"?e.exportedAt:""}}function Q3(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 Z3=()=>({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:""}),JS=(t="")=>({id:"",cwd:"",engine:t,boot:!1,label:"",model:"",prompt:"",commands:{},command:"",panelUrl:""}),aE=t=>t==="claude"?"unsafe":"standard",Pc=(t,e)=>t.find(n=>n.client===e.client&&n.provider===e.provider&&(n.credentialProfile||"")===(e.credentialProfile||"")),e6=(t,e)=>{var n;return((n=Pc(t,e))==null?void 0:n.label)||`${e.client} · ${e.provider}`};function t6(t){var e,n,s,i,a,c,u,h,f,g,v,_,b,k,R;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)||aE((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:((k=t.model)==null?void 0:k.flag)||"",modelValue:((R=t.model)==null?void 0:R.value)||"",envRows:(t.envKeys||[]).map(C=>({key:C,value:"",configured:!0,remove:!1})),credentialValue:"",credentialReveal:!1,allowMissingCredential:!1,panelUrl:t.panelUrl||""}}function QS(t,e,n){const s=(e.panelUrl||"").trim();return n?s&&(t.panelUrl=s):t.panelUrl=s||null,t}function n6(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||aE(t.client)};t.credentialProfile&&(i.credentialProfile=t.credentialProfile),t.credentialSourcePolicy&&t.credentialSourcePolicy!=="auto"&&(i.credentialSourcePolicy=t.credentialSourcePolicy);const a=Pc(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}),QS({...e?{id:t.id}:{},label:t.label||e6(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]))),QS(s,t,e)}function Jr({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 C;if(_.key==="Escape"){_.preventDefault(),(C=c.current)==null||C.call(c);return}if(_.key!=="Tab")return;const b=f();if(!b.length){_.preventDefault(),h==null||h.focus();return}const k=b[0],R=b[b.length-1];_.shiftKey&&document.activeElement===k?(_.preventDefault(),R.focus()):!_.shiftKey&&document.activeElement===R&&(_.preventDefault(),k.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 rm({token:t,targets:e=[],readonly:n=!1,onPower:s,onImport:i}){const[a,c]=w.useState([]),[u,h]=w.useState(0);w.useEffect(()=>{let C=!0;async function L(){const T=[{route:[],label:p("local")}].concat((e||[]).map(H=>({route:Array.isArray(H.route)?H.route:[],label:H.label||(H.route||[]).join(" › ")}))),E=await Promise.all(T.map(async H=>{const F={...H,available:!1,readonly:!1,capabilities:[],provider:null,cells:[],unmanaged:[],err:""};try{const X=await Ja(t,H.route);F.available=!!X.available,F.capabilities=X.capabilities||[],F.provider=X.provider||null,F.cells=(X.cells||[]).map(V=>({...V,route:H.route}));try{F.readonly=!!(await Bc(t,H.route)).readonlyDefault}catch{}try{const V=await nv(t,H.route),G=new Set(F.cells.map(ne=>ne.tmuxSession).filter(Boolean));F.unmanaged=(V.sessions||[]).filter(ne=>ne&&!G.has(ne.name))}catch{}}catch(X){F.err=String(X&&X.message||X)}return F}));C&&c(E)}L();const S=setInterval(L,6e3);return()=>{C=!1,clearInterval(S)}},[t,e,u]);const f=(C,L)=>Array.isArray(C.capabilities)&&C.capabilities.includes(L)&&!n&&!C.readonly,g=()=>h(C=>C+1),v=(C,L)=>{s&&s({...C,route:L})},_=(C,L)=>{s&&s({...C,route:L})},b=async(C,L)=>{try{await nc(t,C.cell,L)}catch{}g()},k=async(C,L)=>{if(window.confirm(p("fleet-remove-cell").replace("{id}",C.cell))){try{await I1(t,C.cell,!0,L)}catch{}g()}},R=async(C,L)=>{if(window.confirm(p("terminate-confirm").replace("{name}",C.name))){try{await ev(t,C.name,L)}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(C=>{const L=C.route.length?C.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 ${C.available?"on":"warn"}`}),l.jsx("b",{children:C.label}),l.jsx("small",{children:C.available?`${C.cells.length} ${p("fleet-cells")} · ${C.unmanaged.length} ${p("fleet-tmux")}`:C.err||p("fleet-not-available")})]}),C.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(C,"down")&&l.jsx("button",{className:"nc-btn ghost",title:p("power-off"),onClick:()=>_(S,C.route),children:p("stop")}),!S.active&&f(C,"up")&&l.jsx("button",{className:"nc-btn ghost",title:p("power-on"),onClick:()=>v(S,C.route),children:p("start")}),f(C,"restart")&&S.active&&l.jsx("button",{className:"nc-btn ghost",title:p("restart"),onClick:()=>b(S,C.route),children:p("restart")}),f(C,"remove")&&l.jsx("button",{className:"nc-btn danger",title:p("delete"),onClick:()=>k(S,C.route),children:"×"})]})]},`${L}:${S.cell}`)),C.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(C,"import")&&i&&l.jsx("button",{className:"nc-btn ghost",title:p("import-as-cell"),onClick:()=>i(S,C.route),children:p("import-as-cell")}),l.jsx("button",{className:"nc-btn danger",title:p("terminate"),onClick:()=>R(S,C.route),children:"×"})]})]},`${L}:u:${S.name}`)),C.available&&C.cells.length===0&&C.unmanaged.length===0&&l.jsx("div",{className:"nc-empty",children:p("fleet-inventory-empty")})]},L)})]})}function s6({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($=>$.id))),[b,k]=w.useState(()=>new Set(e.map($=>$.id))),[R,C]=w.useState([]),[L,S]=w.useState([]),[T,E]=w.useState(""),H=new Set(e.map($=>$.id)),F=new Set(t.map($=>$.id)),X=($,A)=>$(j=>{const N=new Set(j);return N.has(A)?N.delete(A):N.add(A),N}),V=()=>{const $=X3(t,v,e,b,new Date,n);if($.ok===!1){E(p(`fleet-backup-${$.error}`));return}const A=t.filter(W=>v.has(W.id)).length,j=e.filter(W=>b.has(W.id)).length;if($.cells.length!==A){E(p("fleet-backup-invalid-cell"));return}if($.engines.length!==j){E(p("fleet-backup-invalid-engine"));return}if(!$.cells.length&&!$.engines.length){E(p("fleet-backup-select-one"));return}const N=new Blob([`${JSON.stringify($,null,2)}
|
|
167
|
+
`],{type:"application/json"}),U=URL.createObjectURL(N),I=document.createElement("a");I.href=U,I.download=`nexuscrew-fleet-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(I),I.click(),I.remove(),setTimeout(()=>URL.revokeObjectURL(U),0),E("")},G=async $=>{if(E(""),C([]),S([]),!!$){if($.size>1024*1024){E(p("fleet-backup-too-large"));return}try{const A=J3(await $.text());if(!A.ok){E(p(`fleet-backup-${A.error}`));return}g(Array.isArray(A.models)?A.models:[]);const j=new Set(A.engines.map(N=>N.id));S(A.engines.map(N=>({engine:N,exists:H.has(N.id),selected:!H.has(N.id)}))),C(A.cells.map(N=>{const U=H.has(N.engine)||j.has(N.engine),I=F.has(N.id);return{cell:N,engine:U?N.engine:"",selected:U&&!I,exists:I}}))}catch(A){E(String(A.message||A))}}},ne=($,A)=>C(j=>j.map((N,U)=>U===$?{...N,...A}:N)),Y=($,A)=>S(j=>j.map((N,U)=>U===$?{...N,...A}:N)),B=new Set([...H,...L.filter($=>$.selected).map($=>$.engine.id)]),P=R.filter($=>$.selected&&$.engine&&B.has($.engine)),D=L.filter($=>$.selected),M=[...new Map([...e.map($=>[$.id,$.label||$.id]),...L.filter($=>$.selected).map($=>[$.engine.id,$.engine.label||$.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($=>$.id))),k(new Set(e.map($=>$.id)))},children:p("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{_(new Set),k(new Set)},children:p("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[l.jsx("b",{children:p("fleet-engines")}),e.map($=>{var A;return l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:b.has($.id),onChange:()=>X(k,$.id)}),l.jsxs("span",{children:[l.jsx("b",{children:$.label||$.id}),l.jsxs("small",{children:[$.id,(A=$.envKeys)!=null&&A.length?` · ${$.envKeys.length} ${p("fleet-backup-env-names")}`:""]})]})]},$.id)}),l.jsx("b",{children:p("fleet-cells")}),t.map($=>l.jsxs("label",{className:"nc-check nc-backup-row",children:[l.jsx("input",{type:"checkbox",checked:v.has($.id),onChange:()=>X(_,$.id)}),l.jsxs("span",{children:[l.jsx("b",{children:$.id}),l.jsxs("small",{children:[$.engine," · ",p("fleet-system-prompt")," ",($.prompt||"").length," ",p("characters")]})]})]},$.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:V,children:p("fleet-backup-download")})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",accept:"application/json,.json",disabled:s,onChange:$=>G($.target.files&&$.target.files[0])}),l.jsx("small",{children:p("fleet-backup-import-help")}),!!(R.length||L.length)&&l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{S($=>$.map(A=>({...A,selected:!0}))),C($=>$.map(A=>({...A,selected:!!A.engine})))},children:p("select-all")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:()=>{S($=>$.map(A=>({...A,selected:!1}))),C($=>$.map(A=>({...A,selected:!1})))},children:p("select-none")})]}),l.jsxs("div",{className:"nc-backup-list",children:[!!L.length&&l.jsx("b",{children:p("fleet-engines")}),L.map(($,A)=>{var j;return l.jsx("div",{className:"nc-backup-import-row",children:l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:$.selected,onChange:N=>Y(A,{selected:N.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:$.engine.label||$.engine.id}),l.jsxs("small",{children:[$.engine.id," · ",$.exists?p("fleet-backup-overwrite"):p("fleet-backup-new"),(j=$.engine.envKeys)!=null&&j.length?` · ${p("fleet-backup-env-values-required")}`:""]})]})]})},$.engine.id)}),!!R.length&&l.jsx("b",{children:p("fleet-cells")}),R.map(($,A)=>l.jsxs("div",{className:"nc-backup-import-row",children:[l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:$.selected,disabled:!$.engine||!B.has($.engine),onChange:j=>ne(A,{selected:j.target.checked})}),l.jsxs("span",{children:[l.jsx("b",{children:$.cell.id}),l.jsxs("small",{children:[$.exists?p("fleet-backup-overwrite"):p("fleet-backup-new")," · ",p("fleet-system-prompt")," ",$.cell.systemPrompt.length," ",p("characters")]})]})]}),l.jsxs("select",{value:$.engine,onChange:j=>ne(A,{engine:j.target.value,selected:!!j.target.value}),children:[l.jsx("option",{value:"",children:p("fleet-backup-engine-missing")}),M.map(([j,N])=>l.jsx("option",{value:j,children:N},j))]})]},$.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||!P.length&&!D.length,onClick:()=>a({engineRows:L,cellRows:R,models:f}),children:p("fleet-backup-restore")})]})]}),T&&l.jsx("div",{className:"nc-err",children:T})]})}function i6({state:t,setState:e,busy:n,onSave:s,catalog:i}){var L;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=Pc(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",k=!!(g!=null&&g.credentialEnv)||a.credentialProfile==="a"||a.credentialProfile==="p",R=!!v&&t.mode==="new"&&(g==null?void 0:g.authConfigured)!==!0&&!a.credentialValue&&!a.allowMissingCredential,C=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=>C(i.find(T=>T.client===S.target.value&&T.default)||i.find(T=>T.client===S.target.value)),children:h.map(([S,T])=>l.jsx("option",{value:S,children:T},S))}),l.jsx("select",{value:((L=Pc(i,a))==null?void 0:L.id)||"",disabled:t.mode!=="new",onChange:S=>C(i.find(T=>T.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,T,E)=>S&&E.indexOf(S)===T).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")}),k&&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,T)=>l.jsxs("div",{className:"nc-fleet-env",children:[l.jsx("input",{value:S.key,disabled:S.configured,placeholder:"ENV_KEY",onChange:E=>{const H=u.slice();H[T]={...S,key:E.target.value},c({envRows:H})}}),l.jsx("input",{type:"password",value:S.value,placeholder:S.configured?"•••••• (unchanged)":"value",onChange:E=>{const H=u.slice();H[T]={...S,value:E.target.value},c({envRows:H})}}),l.jsx("button",{className:"nc-btn danger",onClick:()=>c({envRows:u.filter((E,H)=>H!==T)}),children:"×"})]},`${S.key}-${T}`)),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&&!Zv(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||R||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 r6({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,_=C=>e({...t,form:{...v,...C}}),b=/^[^\x00-\x1f\x7f]{1,128}$/.test(v.id||""),k=!!(v.id||"").trim()&&!!(v.engine||"").trim()&&b,R=async()=>{h(null),g(!0);try{h(await i(v.engine,v.id))}catch(C){h({outcome:"unverified",detail:String(C&&C.message||C)})}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:C=>{h(null),_({engine:C.target.value})},children:[l.jsx("option",{value:"",children:"—"}),a.map(C=>l.jsx("option",{value:C.id,children:C.label?`${C.id} · ${C.label}`:C.id},C.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:C=>{h(null),_({id:C.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:C=>_({contextWindow:C.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:C=>_({maxTokens:C.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:C=>_({reasoning:C.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||!k,onClick:R,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||!k,onClick:()=>s(v),children:p("save")})]})]})}function o6({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 D,M,$;const[_,b]=w.useState(null),[k,R]=w.useState(""),C=a.form,L=A=>c({...a,form:{...C,...A}}),S=u.find(A=>A.id===C.engine),T=((D=S==null?void 0:S.managed)==null?void 0:D.client)==="shell",E=((M=S==null?void 0:S.managed)==null?void 0:M.client)||"",H=(($=f.find(A=>A.client===E))==null?void 0:$.mcpManaged)!==!1,F=A=>{var U,I,W,se;const j=u.find(me=>me.id===A),N={...C.commands||{}};((U=S==null?void 0:S.managed)==null?void 0:U.client)==="shell"&&(C.command?N[C.engine]=C.command:delete N[C.engine]),L({engine:A,model:((I=C.models)==null?void 0:I[A])||((W=j==null?void 0:j.managed)==null?void 0:W.model)||((se=j==null?void 0:j.model)==null?void 0:se.value)||"",commands:N,command:N[A]||""})},X=A=>{const j={...C.commands||{}};A?j[C.engine]=A:delete j[C.engine],L({command:A,commands:j})},V=T&&/[|&;<>()`$*?{}\[\]~]/.test(C.command||""),G=[...new Set([...h||[],...Array.isArray(C.mcp)?C.mcp:[]])].sort(),ne=Array.isArray(C.mcp)?C.mcp.length?"some":"none":"all",Y=A=>{var j;return L({mcp:A==="all"?void 0:A==="none"?[]:(j=C.mcp)!=null&&j.length?C.mcp:[...G]})},B=A=>{const j=Array.isArray(C.mcp)?C.mcp:[];L({mcp:j.includes(A)?j.filter(N=>N!==A):[...j,A].sort()})},P=async A=>{try{const j=await tv(t,A,e);b(j),L({cwd:j.path}),R("")}catch(j){R(String(j.message||j))}};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")} ${C.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:A=>{i(A.target.value),L({engine:""})},children:[l.jsx("option",{value:"",children:p("local")}),n.map(A=>l.jsxs("option",{value:A.route.join("/"),disabled:A.status&&A.status!=="up",children:[A.label,A.status&&A.status!=="up"?` · ${p("node-offline")}`:""]},A.route.join("/")))]})]}),l.jsx("input",{value:C.id,disabled:a.mode!=="new",placeholder:"id",onChange:A=>L({id:A.target.value})}),l.jsx("input",{value:C.label||"",maxLength:64,placeholder:p("fleet-cell-label"),onChange:A=>L({label:A.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:C.cwd,placeholder:p("cwd"),onChange:A=>L({cwd:A.target.value})}),l.jsx("button",{className:"nc-btn ghost",onClick:()=>_?b(null):P(C.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:()=>P(_.parent),children:["↑ ",p("fs-parent")]}),(_.dirs||[]).map(A=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>P(`${_.path.replace(/\/$/,"")}/${A}`),children:["📁 ",A]},A))]})]}),k&&l.jsx("div",{className:"nc-err",children:k}),l.jsx("select",{value:C.engine,onChange:A=>F(A.target.value),children:u.map(A=>l.jsx("option",{value:A.id,children:A.label},A.id))}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!C.boot,onChange:A=>L({boot:A.target.checked})})," ",p("fleet-boot")]}),l.jsx("input",{value:C.panelUrl||"",maxLength:512,placeholder:p("fleet-panel-url"),onChange:A=>L({panelUrl:A.target.value})}),l.jsx("small",{children:p("fleet-panel-url-help")}),C.panelUrl&&!Zv(C.panelUrl)&&l.jsx("small",{className:"nc-err",children:p("fleet-panel-url-invalid")}),T?l.jsxs(l.Fragment,{children:[l.jsx("input",{value:C.command||"",maxLength:4096,placeholder:p("fleet-shell-command-placeholder"),onChange:A=>X(A.target.value)}),l.jsx("small",{children:C.command?p("fleet-shell-command-help"):p("fleet-shell-interactive")}),V&&l.jsx("small",{className:"nc-note",children:p("fleet-shell-command-metachar")})]}):l.jsxs(l.Fragment,{children:[l.jsx("input",{value:C.model||"",list:"nc-cell-models",placeholder:p("fleet-model-override"),onChange:A=>L({model:A.target.value})}),l.jsx("datalist",{id:"nc-cell-models",children:((S==null?void 0:S.availableModels)||[]).map(A=>l.jsx("option",{value:A},A))}),l.jsx("textarea",{value:C.prompt||"",placeholder:p("cell-prompt"),onChange:A=>L({prompt:A.target.value})}),l.jsx("small",{children:p("cell-prompt-help")}),l.jsxs("label",{className:"nc-field",children:[p("cell-mcp"),l.jsxs("select",{value:ne,onChange:A=>Y(A.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")})]})]}),!H&&l.jsx("small",{className:"nc-note",children:p("cell-mcp-inert")}),ne==="some"&&l.jsx("div",{className:"nc-fleet-mcp-list",children:G.map(A=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:(C.mcp||[]).includes(A),onChange:()=>B(A)})," ",A]},A))}),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||!C.id||!C.cwd||!C.engine,onClick:v,children:p("save")})]})]})}function ZS({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 L=!0;return Xd(t,_?_.split("/"):[]).then(S=>{L&&(f(S.engines||[]),v(""))}).catch(S=>{L&&(f([]),v(String(S.message||S)))}),()=>{L=!1}},[t,_]);const b=n.form,k=L=>s({...n,form:{...b,...L}}),R=async L=>{try{const S=await tv(t,L,e);u(S),k({cwd:S.path})}catch{}},C=!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:L=>k({id:L.target.value})}),l.jsxs("div",{className:"nc-fleet-pair",children:[l.jsx("input",{value:b.cwd,placeholder:p("cwd"),onChange:L=>k({cwd:L.target.value})}),l.jsx("button",{className:"nc-btn ghost",type:"button",onClick:()=>c?u(null):R(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:()=>R(c.parent),children:["↑ ",p("fs-parent")]}),(c.dirs||[]).map(L=>l.jsxs("button",{className:"nc-fs-item",onClick:()=>R(`${c.path.replace(/\/$/,"")}/${L}`),children:["📁 ",L]},L))]})]}),l.jsxs("select",{value:b.engine,onChange:L=>k({engine:L.target.value}),children:[l.jsx("option",{value:"",children:p("import-engine-required")}),h.map(L=>l.jsx("option",{value:L.id,children:L.label},L.id))]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:!!b.boot,onChange:L=>k({boot:L.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(C?"import-as-cell":"save")})]})]})}function ad(t){const e=Io(t);return e===null?`~/${t}`:e?`~/${e}`:"~"}function a6(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 l6({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(""),k=typeof(n==null?void 0:n.cwdSuggestion)=="string"&&Io(n.cwdSuggestion)!==null?Io(n.cwdSuggestion):null,[R,C]=w.useState(k),L=n==null?void 0:n.id,S=s||g,T=async G=>{const ne=Io(G);if(ne===null){f({rel:"",dirs:[],loading:!1,err:p("fleet-cwd-repair-invalid")});return}f({rel:ne,dirs:[],loading:!0,err:""});try{const Y=await tv(t,ne,e),B=a6(Y);f({rel:B,dirs:Array.isArray(Y.dirs)?Y.dirs:[],loading:!1,err:""})}catch(Y){f({rel:ne,dirs:[],loading:!1,err:String(Y&&Y.message||Y)})}},E=G=>{if(!h)return;const ne=h.rel?`${h.rel}/${G}`:G;T(ne)},H=()=>{h!=null&&h.rel&&T(h.rel.split("/").slice(0,-1).join("/"))},F=()=>{h&&(u(h.rel||""),f(null),b(""),C(null))},X=()=>{R!==null&&(u(R),C(null),b(""))},V=async()=>{if(S)return;const G=Io(c);if(G===null){b(p("fleet-cwd-repair-invalid"));return}const ne=ad(G);let Y=!0;try{Y=window.confirm(p("fleet-cwd-repair-confirm").replace("{id}",String(L||"")).replace("{path}",ne))}catch{Y=!1}if(Y){v(!0),b(""),C(null);try{const B=await P1(t,L,{cwdRel:G},e);i==null||i(B)}catch(B){const P=B&&B.data||{};if(P.code==="unportable-cwd"){b(p("fleet-cwd-repair-unportable"));const D=Array.isArray(P.cells)?P.cells.find($=>$&&$.id===L):null,M=D&&typeof D.suggestion=="string"?D.suggestion:null;M!==null&&Io(M)!==null&&C(M)}else b(String(B&&B.message||B))}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(L||""))}),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:G=>u(G.target.value)}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:S,onClick:()=>h?f(null):T(""),children:p(h?"close":"fleet-cwd-repair-browse")})]})]}),l.jsx("div",{className:"nc-cwd-preview",children:p("fleet-cwd-repair-preview").replace("{path}",ad(c))}),h&&l.jsxs("div",{className:"nc-fs",children:[l.jsx("div",{className:"nc-fs-path",children:ad(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:H,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(G=>l.jsxs("button",{type:"button",className:"nc-fs-item",onClick:()=>E(G),children:["📁 ",G]},G))]}),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:F,children:p("fleet-cwd-repair-use-current")})})]}),_&&l.jsx("div",{className:"nc-err",role:"alert",children:_}),R!==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:X,children:p("fleet-cwd-repair-use-suggestion").replace("{path}",ad(R))})]}),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:V,children:g?"…":p("save")})]})]})}function c6({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,k]=w.useState(null),[R,C]=w.useState({}),[L,S]=w.useState(null),[T,E]=w.useState(!1),[H,F]=w.useState(""),[X,V]=w.useState(""),[G,ne]=w.useState(i),[Y,B]=w.useState(!1),[P,D]=w.useState(null),[M,$]=w.useState(null),[A,j]=w.useState(null),[N,U]=w.useState(!1),[I,W]=w.useState([]),[se,me]=w.useState(null),[pe,Ie]=w.useState("manage"),J=w.useRef(!1),te=G?G.split("/"):[],ge=w.useCallback(async()=>{try{const re=await Ja(t,te);h(re);try{const ce=await Bc(t,te);B(!!ce.readonlyDefault)}catch{B(!1)}if(re.provider==="builtin"&&(re.capabilities||[]).includes("definitions")){const ce=await Xd(t,te),O=new Map((re.engines||[]).map(de=>[de.id,de]));if(ce.engines=(ce.engines||[]).map(de=>{var we;return{...de,availableModels:((we=O.get(de.id))==null?void 0:we.models)||[]}}),c(ce),(re.capabilities||[]).includes("credentials"))try{W((await PN(t,te)).credentials||[])}catch{W([])}else W([])}F("")}catch(re){F(String(re.message||re))}finally{g(!0)}},[t,G]);w.useEffect(()=>{document.visibilityState!=="hidden"&&ge()},[ge]),T3(ge,5e3);const Se=new Set((u.cells||[]).filter(re=>re.active).map(re=>re.cell)),Be=u.provider==="builtin"&&(u.capabilities||[]).includes("edit"),Le=(u.capabilities||[]).includes("restore");w.useEffect(()=>{!s||J.current||!Be||!a.engines.length||(J.current=!0,S({mode:"new",form:JS(a.engines[0].id)}))},[s,Be,a.engines]);const ze=async re=>{E(!0),F(""),V("");try{await re(),await ge()}catch(ce){F(String(ce.message||ce))}E(!1)},Q=async(re,ce)=>{const O=await FN(t,re,ce,te);return C(de=>({...de,[`${re}::${ce}`]:O})),O},ve=re=>ze(async()=>{const ce={id:String(re.id||"").trim(),engine:String(re.engine||"").trim()};for(const O of["contextWindow","maxTokens"]){const de=String(re[O]||"").trim();de&&(ce[O]=Number(de))}re.reasoning===!0&&(ce.reasoning=!0),await $N(t,ce,te),k(null),await ge()}),Z=()=>ze(async()=>{var xt;const re=v.mode==="new",ce=v.form,O=a.managedCatalog||[],de=ce.kind==="managed"?Pc(O,ce):null,we=typeof(de==null?void 0:de.credentialEnv)=="string"?de.credentialEnv:"",We=we&&ce.credentialValue||"",ie=n6(ce,re,O);!re&&v.form.kind==="custom"&&!v.form.modelFlag&&(ie.model=null),!re&&v.form.kind==="custom"&&v.form.promptMode!=="flag"&&(ie.promptFlag=null);let Pe;if(re)Pe=await DN(t,ie,te);else{const vt=v.original,Mt=new Set(v.form.envRows.filter(It=>!It.remove).map(It=>It.key)),Qt=(vt.envKeys||[]).filter(It=>!Mt.has(It)),Dt=Object.fromEntries(v.form.envRows.filter(It=>!It.remove&&It.key&&(!It.configured||It.value!=="")).map(It=>[It.key,It.value]));Pe=await ON(t,vt.id,ie,v.form.kind==="custom"?{set:Dt,remove:Qt}:void 0,te)}let ft=null;if(we&&We)try{ft=await $w(t,we,We,te),W(ft.credentials||[])}catch{throw await ge(),re&&_({mode:"edit",original:{...ie,id:ce.id},form:{...ce,credentialReveal:!1}}),new Error(p(re?"fleet-key-partial-create":"fleet-key-partial-edit"))}await ge(),_(null),V(p("fleet-saved"));const Pt=((xt=((ft==null?void 0:ft.credentials)||[]).find(vt=>vt.envKey===we))==null?void 0:xt.activeCells)||[],bt=[...new Set([...(Pe==null?void 0:Pe.activeCells)||[],...Pt])];if(bt.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",bt.join(", "))))for(const vt of bt)await nc(t,vt,te)}),be=()=>ze(async()=>{var Pt,bt,xt,vt,Mt,Qt;const re=L.mode==="new",ce=L.form,O={...re?{id:ce.id}:{},cwd:ce.cwd,engine:ce.engine,boot:!!ce.boot},de={...ce.commands||{}},we=a.engines.find(Dt=>Dt.id===ce.engine);((Pt=we==null?void 0:we.managed)==null?void 0:Pt.client)==="shell"&&typeof ce.command=="string"&&ce.command.length?de[ce.engine]=ce.command:((bt=we==null?void 0:we.managed)==null?void 0:bt.client)==="shell"&&delete de[ce.engine],(Object.keys(de).length||!re)&&(O.commands=de);const We=(ce.label||"").trim();re?We&&(O.label=We):O.label=We||null;const ie=(ce.panelUrl||"").trim();re?ie&&(O.panelUrl=ie):O.panelUrl=ie||null,re?Array.isArray(ce.mcp)&&(O.mcp=ce.mcp):O.mcp=Array.isArray(ce.mcp)?ce.mcp:null,re?(((xt=we==null?void 0:we.managed)==null?void 0:xt.client)!=="shell"&&ce.model&&(O.model=ce.model),((vt=we==null?void 0:we.managed)==null?void 0:vt.client)!=="shell"&&ce.prompt&&(O.prompt=ce.prompt)):(O.model=((Mt=we==null?void 0:we.managed)==null?void 0:Mt.client)==="shell"?null:ce.model||null,((Qt=we==null?void 0:we.managed)==null?void 0:Qt.client)!=="shell"&&(O.prompt=ce.prompt||null));const Pe=re?await HN(t,O,te):await P1(t,L.original.id,O,te),ft=re?ce.id:L.original.id;S(null),V(p("fleet-saved")),!re&&(Pe!=null&&Pe.active)&&window.confirm(p("fleet-restart-confirm").replace("{cells}",ft))&&await nc(t,ft,te)}),K=e||Y,fe=u.capabilities||[],Re=te.length>0&&K,Ee=re=>I.find(ce=>{var O;return(O=ce.engines)==null?void 0:O.includes(re.id)})||null,qe=()=>ze(async()=>{var O;const re=await $w(t,se.envKey,se.value,te);W(re.credentials||[]),me(null),V(p("fleet-credential-saved"));const ce=((O=(re.credentials||[]).find(de=>de.envKey===se.envKey))==null?void 0:O.activeCells)||[];if(ce.length&&window.confirm(p("fleet-restart-confirm").replace("{cells}",ce.join(", "))))for(const de of ce)await nc(t,de,te)}),Ze=re=>ze(async()=>{if(!window.confirm(p("fleet-credential-remove-confirm").replace("{key}",re.envKey)))return;const ce=await IN(t,re.envKey,te);W(ce.credentials||[]),V(p("fleet-credential-removed"))}),at=re=>D({...re,route:Array.isArray(re==null?void 0:re.route)?re.route:te}),Oe=async re=>{if(!P)return;const ce={...P,cell:P.cell||P.id};try{await Dv({token:t,powerCell:ce,payload:re,onNotice:V})}catch(O){throw F(String(O&&O.message||O)),O}},_e=(re,ce)=>{F(""),$({mode:"new",route:Array.isArray(ce)?ce:te,form:{tmuxSession:re.name,id:"",engine:"",cwd:"",boot:!1},err:""})},$e=()=>ze(async()=>{const re=M.form;if(!re.engine){$({...M,err:p("import-engine-required")});return}await UN(t,{tmuxSession:re.tmuxSession,id:re.id||void 0,engine:re.engine,cwd:re.cwd||void 0,boot:!!re.boot},re.route||te),$(null),V(p("fleet-saved"))}),nt=({engineRows:re=[],cellRows:ce=[],models:O=[]})=>ze(async()=>{const de=re.filter(vt=>vt.selected),we=de.map(vt=>oE(vt.engine));if(we.some(vt=>!vt))throw new Error(p("fleet-backup-invalid-engine"));const We=de.filter(vt=>vt.exists).map(vt=>vt.engine.id);if(We.length&&!window.confirm(p("fleet-backup-confirm-engine-overwrite").replace("{engines}",We.join(", "))))return;const ie=[...new Set([...a.engines.map(vt=>vt.id),...we.map(vt=>vt.id)])],Pe=[];for(const vt of ce.filter(Mt=>Mt.selected)){const Mt=Q3(vt.cell,vt.engine,ie);if(!Mt)throw new Error(`${vt.cell.id}: ${p("fleet-backup-engine-missing")}`);Pe.push(Mt)}const ft=ce.filter(vt=>vt.selected&&vt.exists).map(vt=>vt.cell.id);if(ft.length&&!window.confirm(p("fleet-backup-confirm-overwrite").replace("{cells}",ft.join(", "))))return;const Pt=we.length?await qN(t,we,We.length>0,te,O):{needsRestart:[]},bt=Pe.length?await WN(t,Pe,te):{needsRestart:[]},xt=[...new Set([...Pt.needsRestart||[],...bt.needsRestart||[]])];U(!1),V(`${p("fleet-backup-restored").replace("{n}",String(Pe.length))}${we.length?` · ${we.length} ${p("fleet-engines").toLowerCase()}`:""}${xt.length?` · ${p("fleet-backup-needs-restart").replace("{cells}",xt.join(", "))}`:""}`)}),Fe=l.jsxs("label",{className:"nc-field",children:[p("location"),l.jsxs("select",{value:G,onChange:re=>{ne(re.target.value),_(null),S(null),F(""),V(""),B(!1),g(!1),h({available:!1,capabilities:[]}),c({engines:[],cells:[],managedCatalog:[]}),W([]),me(null)},children:[l.jsx("option",{value:"",children:p("local")}),n.map(re=>l.jsxs("option",{value:re.route.join("/"),disabled:re.status&&re.status!=="up",children:[re.label,re.status&&re.status!=="up"?` · ${p("node-offline")}`:""]},re.route.join("/")))]})]}),rt=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":pe==="manage",className:`nc-set-tabbtn${pe==="manage"?" on":""}`,onClick:()=>Ie("manage"),children:p("fleet-manage-location")}),l.jsx("button",{type:"button",role:"tab","aria-selected":pe==="overview",className:`nc-set-tabbtn${pe==="overview"?" on":""}`,onClick:()=>Ie("overview"),children:p("fleet-network-overview")})]});return f?Be?l.jsxs("div",{className:"nc-set-tab nc-fleet-editor",children:[rt,pe==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(rm,{token:t,targets:n,readonly:e,onPower:at,onImport:_e})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-manage-help")}),Fe,l.jsxs("div",{className:"nc-set-row nc-fleet-backup-actions",children:[l.jsx("button",{className:"nc-btn ghost",disabled:K||T,onClick:()=>{F(""),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:K||T||!a.engines.length,onClick:()=>{var re;F(""),S({mode:"new",form:JS((re=a.engines[0])==null?void 0:re.id)})},children:["+ ",p("add")]})})]}),a.cells.map(re=>{const ce=Se.has(re.id),O=re.needsRepair===!0;return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:re.id}),re.label?l.jsxs("small",{className:"nc-fleet-label",children:[" ",re.label]}):null,l.jsxs("small",{children:[re.engine," · ",O?l.jsx("span",{className:"nc-fleet-tag nc-fleet-tag-warn",children:p("fleet-cwd-needs-repair")}):re.cwd,ce?` · ${p("service-active")}`:` · ${p("cell-off")}`]})]}),l.jsxs("span",{children:[ce&&fe.includes("down")&&l.jsx("button",{className:"nc-btn ghost",disabled:K||T,onClick:()=>ze(()=>M1(t,{cell:re.id},te)),children:p("stop")}),!ce&&fe.includes("up")&&l.jsx("button",{className:"nc-btn primary",disabled:K||T,onClick:()=>at({cell:re.id,id:re.id,engine:re.engine,model:re.model,models:re.models,permissionPolicies:re.permissionPolicies,active:!1,boot:re.boot}),children:p("start")}),ce&&fe.includes("restart")&&l.jsx("button",{className:"nc-btn ghost",disabled:K||T,onClick:()=>ze(()=>nc(t,re.id,te)),children:p("restart")}),O?l.jsx("button",{className:"nc-btn ghost",disabled:K||T,onClick:()=>{F(""),j(re)},children:p("fleet-cwd-repair")}):l.jsx("button",{className:"nc-btn ghost",disabled:K||T,onClick:()=>{var de;F(""),S({mode:"edit",original:re,form:{...re,commands:{...re.commands||{}},command:((de=re.commands)==null?void 0:de[re.engine])||""}})},children:p("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:K||T,onClick:()=>ze(async()=>{window.confirm(p("fleet-remove-cell").replace("{id}",re.id))&&await I1(t,re.id,!0,te)}),children:"×"})]})]},re.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:K||T,onClick:()=>{F(""),_({mode:"new",form:Z3()})},children:["+ ",p("add")]})]}),a.engines.map(re=>{var O,de;const ce=Ee(re);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:re.label}),l.jsx("small",{children:re.managed?`${re.id} · ${re.managed.client} / ${re.managed.provider} · ${(O=re.managedInfo)!=null&&O.configured?p("fleet-ready"):((de=re.managedInfo)==null?void 0:de.reason)||p("fleet-not-ready")}`:`${re.id} · ${re.command}`}),ce&&l.jsxs("small",{children:[ce.envKey," · ",p(`fleet-credential-source-${ce.source||"missing"}`)]})]}),l.jsxs("span",{children:[ce&&l.jsx("button",{className:"nc-btn ghost",disabled:K||T,onClick:()=>{F(""),me({envKey:ce.envKey,value:""})},children:ce.configured?p("fleet-credential-change"):p("fleet-credential-set")}),(ce==null?void 0:ce.source)==="local"&&l.jsx("button",{className:"nc-btn danger",disabled:K||T,onClick:()=>Ze(ce),children:p("fleet-credential-forget")}),l.jsx("button",{className:"nc-btn ghost",disabled:K||T,onClick:()=>{F(""),_({mode:"edit",original:re,form:t6(re)})},children:p("edit")}),l.jsx("button",{className:"nc-btn danger",disabled:K||T,onClick:()=>ze(async()=>{window.confirm(p("fleet-remove-engine").replace("{id}",re.id))&&await BN(t,re.id,te)}),children:"×"})]})]},re.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:K||T,onClick:()=>{F(""),k({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(re=>{const ce=`${re.engine}::${re.id}`,O=R[ce],de=(a.engines||[]).some(we=>we.managed&&we.managed.model===re.id);return l.jsxs("div",{className:"nc-fleet-item",children:[l.jsxs("span",{children:[l.jsx("b",{children:re.id}),l.jsxs("small",{children:[re.engine,re.contextWindow?` · ${re.contextWindow}`:"",de?` · ${p("model-in-use")}`:""]}),O&&l.jsxs("small",{className:`nc-model-test ${O.outcome}`,children:[p(`model-test-${O.outcome}`),O.outcome==="ok"&&Number.isInteger(O.latencyMs)?` · ${O.latencyMs}ms`:""]})]}),l.jsxs("span",{children:[fe.includes("model-test")&&l.jsx("button",{className:"nc-btn ghost",disabled:T||Re,onClick:()=>ze(()=>Q(re.engine,re.id)),children:p("model-test")}),l.jsx("button",{className:"nc-btn danger",disabled:K||T,onClick:()=>ze(()=>zN(t,re.id,re.engine,te)),children:"×"})]})]},ce)})]}),b&&l.jsx(Jr,{onClose:()=>k(null),label:p("fleet-models"),error:H,children:l.jsx(r6,{state:b,setState:k,busy:T,onSave:ve,onTest:Q,profiles:a.managedCatalog||[],canTest:fe.includes("model-test")&&!Re})}),v&&l.jsx(Jr,{onClose:()=>_(null),label:p("fleet-new-engine"),error:H,children:l.jsx(i6,{state:v,setState:_,busy:T,onSave:Z,catalog:a.managedCatalog||[]})}),L&&l.jsx(Jr,{onClose:()=>S(null),label:p("fleet-new-cell"),error:H,children:l.jsx(o6,{token:t,route:te,targets:n,location:G,setLocation:ne,state:L,setState:S,engines:a.engines,mcpServers:a.mcpServers||[],managedCatalog:a.managedCatalog||[],busy:T,onSave:be})}),A&&l.jsx(Jr,{onClose:()=>j(null),label:p("fleet-cwd-repair-title").replace("{id}",A.id),error:"",children:l.jsx(l6,{token:t,route:te,cell:A,busy:T,onSaved:async()=>{j(null),V(p("fleet-cwd-repaired")),await ge()},onClose:()=>j(null)})}),X&&l.jsx("div",{className:"nc-set-note",children:X}),H&&l.jsx("div",{className:"nc-err",children:H}),N&&l.jsx(Jr,{onClose:()=>U(!1),label:p("fleet-backup"),error:H,children:l.jsx(s6,{cells:a.cells,engines:a.engines,models:a.models||[],busy:T,canRestore:Le,onRestore:nt,onClose:()=>U(!1)})}),se&&l.jsx(Jr,{onClose:()=>me(null),label:p("fleet-credential-title"),error:H,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:[se.envKey,l.jsx("input",{type:"password",autoComplete:"off",spellCheck:"false",autoCapitalize:"none",value:se.value,onChange:re=>me({...se,value:re.target.value})})]}),l.jsxs("div",{className:"nc-sheet-actions",children:[l.jsx("button",{className:"nc-btn ghost",onClick:()=>me(null),children:p("cancel")}),l.jsx("button",{className:"nc-btn primary",disabled:T||!se.value,onClick:qe,children:p("save")})]})]})}),M&&l.jsx(Jr,{onClose:()=>$(null),label:p("import-as-cell"),error:H,children:l.jsx(ZS,{token:t,route:M.route||te,state:M,setState:$,busy:T,onSave:$e})}),P&&l.jsx(Dd,{cell:P,token:t,route:Array.isArray(P.route)?P.route:te,onConfirm:async re=>{try{await Oe(re)}finally{ge()}},onClose:()=>D(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[rt,pe==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(rm,{token:t,targets:n,readonly:e,onPower:at,onImport:_e})]}):l.jsxs(l.Fragment,{children:[Fe,l.jsxs("div",{className:"nc-set-info",children:[p(H?"fleet-editor-load-error":"fleet-editor-unavailable"),!H&&u.reason?` ${u.reason}`:""]})]}),H&&l.jsx("div",{className:"nc-err",children:H}),M&&l.jsx(Jr,{onClose:()=>$(null),label:p("import-as-cell"),error:H,children:l.jsx(ZS,{token:t,route:M.route||te,state:M,setState:$,busy:T,onSave:$e})}),P&&l.jsx(Dd,{cell:P,token:t,route:Array.isArray(P.route)?P.route:te,onConfirm:async re=>{try{await Oe(re)}finally{ge()}},onClose:()=>D(null)})]}):l.jsxs("div",{className:"nc-set-tab",children:[rt,pe==="overview"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-set-info",children:p("fleet-overview-help")}),l.jsx(rm,{token:t,targets:n,readonly:e,onPower:at,onImport:_e})]}):l.jsxs(l.Fragment,{children:[Fe,l.jsx("div",{className:"nc-set-info",children:p("fleet-editor-loading")})]})]})}const lE="nc_bar_files_button",cE="nc_bar_keyboard_button",uE="nc_bar_panel_button";function t_(t,e){try{const n=localStorage.getItem(t);if(n==="on")return!0;if(n==="off")return!1}catch{}return e}function n_(t,e){try{localStorage.setItem(t,e?"on":"off")}catch{}}function dE(){return t_(lE,!0)}function hE(t){n_(lE,t)}function fE(){return t_(cE,!0)}function u6(t){n_(cE,t)}function pE(){return t_(uE,!1)}function d6(t){n_(uE,t)}const s_="nc_notification_speech_v1",ld="nc-notification-speech",$g="nc-notification-speech-preview",h6=320,f6=2,p6=3e4,m6=1e4,g6=6e4,v6=64,e1=Object.freeze({enabled:!1}),_6=Object.freeze({it:"it-IT",en:"en-US",es:"es-ES"}),y6=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"])}),i_=new WeakSet;function r_(t){return{enabled:(t&&typeof t=="object"&&!Array.isArray(t)?t:{}).enabled===!0}}function mE(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function t1(t=mE()){if(!t)return{...e1};try{return r_(JSON.parse(t.getItem(s_)||"null"))}catch{return{...e1}}}function w6(t,e=mE()){const n=r_(t);if(e)try{e.setItem(s_,JSON.stringify(n))}catch{}return n}function nl(){try{return typeof window<"u"?window:null}catch{return null}}function Ic(t=nl()){try{return!!(t&&t.speechSynthesis&&typeof t.speechSynthesis.speak=="function"&&typeof t.SpeechSynthesisUtterance=="function")}catch{return!1}}function gE(t=nl()){return!!(t&&(typeof t=="object"||typeof t=="function")&&i_.has(t))}function zg(t=nl()){t&&(typeof t=="object"||typeof t=="function")&&i_.delete(t)}function Ua(t){const e=String(t||"").trim().toLowerCase().split("-")[0];return _6[e]||""}function _h(t){return String(t||"").normalize("NFC").replace(/[\p{Cc}\p{Cf}]+/gu," ").replace(/\s+/g," ").trim()}function b6(t){const e=_h(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(y6).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 S6(t,e){const n=Ua(t&&t.lang);return n||Ua(b6(t&&t.body))||Ua(e)}function vE(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 _E(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 n1(t){return _h(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 x6(t,e=h6){const n=n1(t&&t.title),s=n1(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 k6(t){try{return!!(t&&t.visibilityState==="visible"&&typeof t.hasFocus=="function"&&t.hasFocus())}catch{return!1}}function yE(t=nl()){if(!Ic(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($g))}catch{}}function E6(t,e,n=nl(),s={}){var f;if(zg(n),!Ic(n))return Promise.resolve(!1);const i=_h(t);if(!i||(f=s.signal)!=null&&f.aborted)return Promise.resolve(!1);const a=Number.isFinite(s.timeoutMs)&&s.timeoutMs>0?s.timeoutMs:m6,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,k=null;const R=C=>{if(!v){if(v=!0,h&&k&&h.removeEventListener("abort",k),b!==null&&u(b),C!==!0)try{n.speechSynthesis.cancel()}catch{}else i_.add(n);g(C)}};k=()=>R("no-activation"),h&&h.addEventListener("abort",k,{once:!0});try{n.speechSynthesis.cancel();const C=new n.SpeechSynthesisUtterance(i);C.lang=Ua(e);const L=_E(vE(n),C.lang);L&&(C.voice=L),C.onstart=()=>{_=!0},C.onend=()=>R(_?!0:"no-activation"),C.onerror=()=>R("voice-error"),b=c(()=>R("timeout"),a),n.speechSynthesis.speak(C)}catch{R("no-activation")}})}function N6(t={}){const e=t.scope||nl(),n=t.document||e&&e.document,s=Number.isInteger(t.maxPending)&&t.maxPending>=0?t.maxPending:f6,i=Number.isFinite(t.watchdogMs)&&t.watchdogMs>0?t.watchdogMs:p6,a=Number.isFinite(t.dedupWindowMs)&&t.dedupWindowMs>0?t.dedupWindowMs:g6,c=Number.isInteger(t.maxDedup)&&t.maxDedup>0?t.maxDedup:v6,u=t.now||Date.now,h=t.setTimer||((Y,B)=>setTimeout(Y,B)),f=t.clearTimer||(Y=>clearTimeout(Y)),g=t.isPrimed||(()=>gE(e)),v=e&&e.speechSynthesis;let _=null,b=null,k=[],R=[],C=()=>{};const L=new Map,S=()=>{R=vE(e)};if(S(),v&&typeof v.addEventListener=="function")v.addEventListener("voiceschanged",S),C=()=>v.removeEventListener("voiceschanged",S);else if(v&&"onvoiceschanged"in v){const Y=v.onvoiceschanged,B=(...P)=>{S(),typeof Y=="function"&&Y.apply(v,P)};v.onvoiceschanged=B,C=()=>{v.onvoiceschanged===B&&(v.onvoiceschanged=Y)}}const T=Y=>{if(Y&&typeof Y.id=="string"&&Y.id)return`id:${Y.id}`;const B=Number(Y&&Y.ts),P=_h(Y&&Y.title);return Number.isFinite(B)&&P?`frame:${B}:${P}`:""},E=Y=>{if(!Y)return!0;const B=u();for(const[P,D]of L)B-D>=a&&L.delete(P);if(L.has(Y))return!1;for(L.set(Y,B);L.size>c;)L.delete(L.keys().next().value);return!0},H=()=>{b!==null&&f(b),b=null},F=()=>{H(),_&&(_.onend=null,_.onerror=null,_=null),yE(e)},X=Y=>{if(!Ic(e))return k=[],"unsupported";let B;try{B=new e.SpeechSynthesisUtterance(Y.text),B.lang=Ua(Y.lang);const D=_E(R,B.lang);D&&(B.voice=D)}catch{return k=[],"error"}_=B;const P=()=>{if(_!==B)return;H(),_=null,B.onend=null,B.onerror=null;const D=k.shift();D&&X(D)};B.onend=P,B.onerror=P;try{return b=h(()=>{if(_!==B)return;_=null,B.onend=null,B.onerror=null;try{e.speechSynthesis.cancel()}catch{}H();const D=k.shift();D&&X(D)},i),e.speechSynthesis.speak(B),"speaking"}catch{return P(),"error"}},V=(Y,B)=>{if(!Ic(e))return"unsupported";const P=x6(Y);if(!P)return"empty";if(!E(T(Y)))return"duplicate";if(!k6(n))return"inactive";if(!g())return"unprimed";const D={text:P,lang:B};return Y&&Y.urgency==="high"?(k=[],F(),X(D)):_?s===0?"dropped":(k.length>=s&&k.shift(),k.push(D),"queued"):X(D)},G=()=>{k=[],F()};return{enqueue:V,stop:G,dispose:()=>{G(),C(),C=()=>{}}}}function wE(){const[t,e]=w.useState(t1);w.useEffect(()=>{const s=i=>{if((i==null?void 0:i.type)==="storage"&&i.key!==s_&&i.key!==null)return;const a=(i==null?void 0:i.type)===ld?r_(i.detail):t1();e(a)};return window.addEventListener(ld,s),window.addEventListener("storage",s),()=>{window.removeEventListener(ld,s),window.removeEventListener("storage",s)}},[]);const n=w.useCallback(s=>{const i=w6({enabled:s===!0});return e(i),window.dispatchEvent(new CustomEvent(ld,{detail:i})),i.enabled},[]);return[t.enabled,n]}const o_="nc_storage_persist_v1",R6=1440*60*1e3;function Fg(t=globalThis.localStorage){return Ar(o_,{storage:t,fallback:()=>null,parse:e=>e&&typeof e=="object"&&!Array.isArray(e)?e:void 0})}async function L6({manager:t=(s=>(s=globalThis.navigator)==null?void 0:s.storage)(),ls:e=globalThis.localStorage,now:n=Date.now}={}){const i=Fg(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<R6)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)&&Gi({reason:"storage-persist",note:c.status}),_i(o_,c,{storage:e}),c}const A6=t=>{try{return new Date(t).toLocaleString()}catch{return String(t)}},om=t=>Array.isArray(t)?t.join(", "):"";function j6(){$n();const[t,e]=w.useState(()=>gg()),[n,s]=w.useState(()=>Fg()),[i,a]=w.useState(!1);w.useEffect(()=>{const f=()=>{e(gg()),s(Fg())};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=()=>{nP(),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":o_,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})," · ",A6(f.t),f.position?` · ${f.position}`:"",f.key?` · ${f.key}`:"",f.note?` · ${f.note}`:"",f.before?l.jsxs("div",{children:[p("prefs-before"),": ",om(f.before)]}):null,f.after?l.jsxs("div",{children:[p("prefs-after"),": ",om(f.after)]}):null,f.visible?l.jsxs("div",{children:[p("prefs-visible"),": ",om(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 a_="nc_device_id_v1",bE="nc_prefs_sync_v1",M6="nexuscrew-roster-preferences",l_=/^[a-f0-9]{32}$/,T6=192,P6=256,s1=128,SE="nexuscrew-preferences",$o=t=>t&&typeof t=="object"&&!Array.isArray(t),xd=(t,e)=>typeof t=="string"&&t.length>0&&t.length<=e&&!/[\u0000-\u001f\u007f]/.test(t),am=(t,e=P6)=>Array.isArray(t)&&t.length<=e&&t.every(n=>xd(n,T6));function sl(t){if(!$o(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(!am(t.pins))return null;e.pins=[...new Set(t.pins)]}if(t.nodeOrder!==void 0){if(!am(t.nodeOrder,128))return null;e.nodeOrder=[...new Set(t.nodeOrder)]}if(t.orders!==void 0){if(!$o(t.orders)||Object.keys(t.orders).length>s1)return null;for(const[n,s]of Object.entries(t.orders)){if(!xd(n,96)||!am(s))return null;e.orders[n]=[...new Set(s)]}}if(t.views!==void 0){if(!$o(t.views)||Object.keys(t.views).length>s1)return null;for(const[n,s]of Object.entries(t.views)){if(!xd(n,96)||!$o(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(!xd(s.filter,16))return null;i.filter=s.filter}e.views[n]=i}}return e}const Hg=t=>!t||!(t.pins||[]).length&&!(t.nodeOrder||[]).length&&!Object.keys(t.orders||{}).length&&!Object.keys(t.views||{}).length;function c_(t){const e={pins:eo(),orders:hc(t),views:bd(t),nodeOrder:Sg(t)};return sl(e)||{pins:[],orders:{},views:{},nodeOrder:[]}}const Ug=t=>Array.isArray(t)?`[${t.map(Ug).join(",")}]`:$o(t)?`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${Ug(t[e])}`).join(",")}}`:JSON.stringify(t),kd=t=>{const e=Ug(sl(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)},lm=["nc_pins",Yo,Vo,uh];function u_(t,{storage:e,note:n="restore"}={}){const s=sl(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 lm)try{a[u]=i.getItem(u)}catch{a[u]=null}const c={nc_pins:s.pins,[Yo]:s.orders,[Vo]:s.views,[uh]:s.nodeOrder};for(const u of lm){const h=_i(u,c[u],{storage:e});if(h){for(const f of lm)try{a[f]===null||a[f]===void 0?i.removeItem(f):i.setItem(f,a[f])}catch{}return Gi({reason:"prefs-restore-failed",key:u,note:String(h&&h.message||h).slice(0,120)}),h}}Gi({reason:"prefs-restore",note:n,after:s.pins});try{window.dispatchEvent(new Event(M6))}catch{}return null}const xE=t=>({status:"error",code:"storage-write-failed",note:String(t&&t.message||t).slice(0,120)}),d_=t=>{try{return t||globalThis.localStorage}catch{return null}},yh=t=>{var e;try{const n=(e=d_(t))==null?void 0:e.getItem(a_);return l_.test(n||"")?n:""}catch{return""}},kE=(t,e)=>{var n;try{(n=d_(e))==null||n.setItem(a_,t)}catch{}};function I6(t,e){l_.test(t||"")&&!yh(e)&&kE(t,e)}const D6=yh,O6=t=>Ar(bE,{storage:t,fallback:()=>null,parse:e=>$o(e)?e:void 0}),Ud=(t,e,n)=>_i(bE,{revision:t,hash:kd(e),at:Date.now()},{storage:n});function CE(t){return async(e,n,{headers:s={},body:i}={})=>Wn(n,t,{method:e,headers:{...i?{"content-type":"application/json"}:{},...s},body:i,timeoutMs:8e3})}async function i1(t,e){let n=yh(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,!l_.test(n||""))throw new Error("device non valido");kE(n,e)}return n}async function Wg(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 Ud(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:sl(c.current.data)||null,revision:c.current.revision,deviceId:e}}:{status:"error",code:c.code||`http-${a.status}`}}async function B6({request:t,token:e,storage:n}={}){var i;const s=t||CE(e);try{let a=await i1(s,n),c=await s("GET","/api/prefs",{headers:{"x-nc-device":a}});if(c.status===404){try{(i=d_(n))==null||i.removeItem(a_)}catch{}a=await i1(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=c_(n),f=sl(u.data);if(!f)return Hg(h)?{status:"synced",revision:u.revision}:Wg(s,a,h,u.revision,n);if(Hg(h)){const v=u_(f,{storage:n});return v?xE(v):(Ud(u.revision,f,n),{status:"restored",revision:u.revision})}if(kd(h)===kd(f))return Ud(u.revision,h,n),{status:"synced",revision:u.revision};const g=O6(n);return g&&g.revision===u.revision&&g.hash!==kd(h)?Wg(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 $6(t,e,{request:n,token:s,storage:i}={}){if(!e)return{status:"error",code:"no-conflict"};const a=n||CE(s);try{if(t==="server"){if(!e.server)return{status:"error",code:"no-server-copy"};const c=u_(e.server,{storage:i,note:"restore-from-server"});return c?xE(c):(Ud(e.revision,e.server,i),{status:"restored",revision:e.revision})}return await Wg(a,e.deviceId||yh(i),e.local,e.revision,i)}catch(c){return{status:"offline",note:String((c==null?void 0:c.message)||c).slice(0,120)}}}function z6(t){return JSON.stringify({kind:SE,version:1,exportedAt:new Date().toISOString(),data:c_(t)},null,2)}function F6(t,{storage:e}={}){let n;try{n=JSON.parse(t)}catch{return{ok:!1,reason:"not-json"}}if(!$o(n)||n.kind!==SE||n.version!==1)return{ok:!1,reason:"wrong-kind"};const s=sl(n.data);if(!s)return{ok:!1,reason:"bad-schema"};const i=u_(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 Wd={status:"idle"};let Er=Wd;const qg=new Set,qd=t=>{Er=t,qg.forEach(e=>e(t))};let Kg=null,Dc=0;const H6=t=>{const e=t||null;Kg!==e&&(Kg=e,Dc+=1,Er!==Wd&&qd(Wd))},EE=()=>{const[t,e]=w.useState(Er);return w.useEffect(()=>(qg.add(e),e(Er),()=>{qg.delete(e)}),[]),t};async function NE(t,e){var i;if(Er.status!=="conflict")return;const n=Dc;if(Kg!==(t||null)||((i=Er.conflict)==null?void 0:i.deviceId)!==D6()){qd(Wd);try{window.dispatchEvent(new Event("nexuscrew-roster-preferences"))}catch{}return}const s=await $6(e,Er.conflict,{token:t});n===Dc&&qd({...s,at:Date.now()})}const U6=1500,W6=3e3,r1="nexuscrew-roster-preferences";function q6(t){w.useEffect(()=>{if(H6(t),!t)return;let n=null,s=!0;const i=async()=>{if(!s||Er.status==="conflict")return;const u=Dc,h=await B6({token:t});s&&u===Dc&&qd({...h,at:Date.now()})},a=u=>{clearTimeout(n),n=setTimeout(i,u)},c=()=>{Er.status!=="conflict"&&a(W6)};return a(U6),window.addEventListener(r1,c),window.addEventListener("storage",c),()=>{s=!1,clearTimeout(n),window.removeEventListener(r1,c),window.removeEventListener("storage",c)}},[t]);const e=w.useCallback(n=>NE(t,n),[t]);return{state:EE(),resolve:e}}const K6=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 V6({token:t=""}){$n();const e=EE(),n=w.useRef(null),s=h=>NE(t,h),[i,a]=w.useState(null),c=()=>{try{const h=URL.createObjectURL(new Blob([z6()],{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 K6(f)}catch(_){a({ok:!1,text:String((_==null?void 0:_.message)||_)});return}if(!Hg(c_())&&!window.confirm(p("prefs-import-confirm")))return;const v=F6(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 Y6({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 G6({value:t}){const[e,n]=w.useState("");return w.useEffect(()=>{let s=!0;return JD.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 X6({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,k]=w.useState(null),[R,C]=w.useState({ssh:"",sshPort:"",name:""}),[L,S]=w.useState(""),[T,E]=w.useState(""),[H,F]=w.useState(!1),[X,V]=w.useState(null),G=Date.now(),ne=s&&s.deviceName||"",Y=(e||[]).filter(N=>N&&N.direction==="outbound"&&N.name&&N.ssh),B=Y.find(N=>N.name===L)||Y[0]||null,P=B?Ag(B.tunnel,G):null,D=B!=null&&B.shared?P!=null&&P.up?"share-local-active":"share-local-pending":P!=null&&P.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")}],$=X&&(e||[]).find(N=>`${N.kind||"direct"}:${N.nodeId||N.name}`===X)||null,A=async N=>{if(B){g(null),_(`${B.name}:share`);try{const U=await n5(t,B.name,N);await a(),U&&U.reversePoolPending===!0&&g(`${B.name}: ${p("share-reverse-pool-pending")}`)}catch(U){const I=U!=null&&U.data&&U.data.shared===!1?U.data:null;if(I)try{await a()}catch{}const W=U!=null&&U.data&&typeof U.data.hint=="string"?U.data.hint:"",se=(I==null?void 0:I.revoked)===!0&&(I==null?void 0:I.localReconcilePending)===!0?p("share-off-local-reconcile-pending"):(I==null?void 0:I.revoked)===!1&&(I==null?void 0:I.reconcilePending)===!0?p("share-off-hub-reconcile-pending"):"",me=U!=null&&U.data&&U.data.reversePoolPending===!0?p("share-reverse-pool-pending"):"",pe=U!=null&&U.data&&typeof U.data.code=="string"?U.data.code:"",Ie=U!=null&&U.data&&typeof U.data.detail=="string"?U.data.detail.trim():"",J=Ie&&Ie!==String(U.message||"")?Ie:"";g(`${B.name}: ${String(U.message||U)}${pe?` [${pe}]`:""}${J?` — ${J}`:""}${W?` — ${W}`:""}${se?` — ${se}`:""}${me?` — ${me}`:""}`)}_(null)}},j=async()=>{g(null);const N=uo(R.name||T||ne||"NexusCrew"),U=ZP({name:N,ssh:R.ssh,sshPort:R.sshPort});if(!U.ok){g(p(U.error));return}_("invite");try{k(await QN(t,{...T||ne?{label:T||ne}:{},name:N,ssh:U.value.ssh,...U.value.sshPort?{sshPort:U.value.sshPort}:{}}))}catch(I){g(String(I.message||I))}_(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 I=c3(U);if(!I)return null;const W=`${U.kind||"direct"}:${U.nodeId||U.name}`,se=I.routed?{up:I.reach.up,since:null}:Ag(U.tunnel,G);return l.jsxs("button",{type:"button",className:`nc-set-node nc-node-row${I.routed?" routed":""}`,"aria-label":`${I.title} — ${p("node-detail-open")}`,onClick:()=>V(W),children:[l.jsx("span",{className:`nc-dot ${I.reach.up?"on":""}`}),l.jsxs("span",{className:"nc-node-row-text",children:[l.jsx("b",{children:I.title}),l.jsxs("small",{children:[I.routed?I.routeLabel:`${I.subtitle} · ${p(I.exposure.shortKey)}`,!I.routed&&I.exposure.shortKey==="visibility-selected"?` (${I.exposure.count})`:""]})]}),l.jsxs("span",{className:`nc-set-tunnel${I.reach.up?" up":""}`,children:[p(I.reach.key),se.since?` · ${se.since}`:""]}),l.jsx("span",{className:"nc-node-row-more",children:l.jsx(Tt,{name:"chevronDown",size:14})})]},W)})]},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(", ")]}),$&&l.jsx(M3,{node:$,nodes:e||[],token:t,readonly:i,refresh:a,onClose:()=>V(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()&&!Ya(U.normalize("NFC"))){g(p("err-label"));return}_(`${N.instanceId}:alias`),g(null);try{U.trim()?await e5(t,N.instanceId,U):await Hw(t,N.instanceId),c()}catch(I){g(String(I.message||I))}_(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 Hw(t,N.instanceId),c()}catch(U){g(String(U.message||U))}_(null)},children:p("reset-alias")})]})]},N.instanceId))]}),B&&l.jsxs("div",{className:"nc-set-form nc-local-share",children:[l.jsx("div",{className:"nc-sheet-label",children:p("share-local-heading")}),Y.length>1&&l.jsxs("label",{className:"nc-field",children:[p("share-local-hub"),l.jsx("select",{value:B.name,disabled:i||!!v,onChange:N=>S(N.target.value),children:Y.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:B.shared===!0,disabled:i||!!v,onChange:N=>A(N.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("share-local-through").replace("{device}",ne||p("local")).replace("{hub}",B.label||B.name)}),l.jsx("small",{children:p(B.shared?"share-node-on-desc":"share-node-off-desc")})]})]}),l.jsx("div",{className:`nc-set-test${B.shared&&(P!=null&&P.up)?" ok":P!=null&&P.up?"":" ko"}`,children:p(D)}),!(P!=null&&P.up)&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:i||!!v,onClick:()=>A(B.shared===!0),children:p("share-local-reconnect")})]}),l.jsx(qC,{token:t,deviceDefault:ne,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:ne||p("invite-target-this")})]}),l.jsxs("label",{className:"nc-field",children:[p("invite-endpoint-label"),l.jsx("input",{placeholder:"user@host",value:R.ssh,disabled:i,onChange:N=>C({...R,ssh:N.target.value})}),l.jsx("small",{className:"nc-set-hint",children:p("invite-endpoint-needed")})]}),Y.length>0&&l.jsx("small",{className:"nc-set-hint nc-invite-hub-hint",children:p("invite-hub-only")}),H&&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:R.sshPort,disabled:i,onChange:N=>C({...R,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:ne||"NexusCrew",value:T,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:uo(T||ne||p("node-name-ph")),value:R.name,disabled:i,onChange:N=>C({...R,name:N.target.value?uo(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||!R.ssh.trim(),onClick:j,children:p("create-pairing-link")}),l.jsxs("button",{type:"button",className:"nc-btn ghost",disabled:!!v,onClick:()=>F(N=>!N),children:[H?"▾":"▸"," ",p("pair-advanced")]})]}),b&&l.jsxs(l.Fragment,{children:[l.jsx(G6,{value:b.pairingUrl}),l.jsx(Y6,{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 J6({token:t,readonly:e}){const[n,s]=w.useState("idle"),[i,a]=w.useState(()=>XC()),[c,u]=w.useState(!1),[h,f]=w.useState(null);w.useEffect(()=>{let _=!1;return JC().then(b=>{_||s(b)}),()=>{_=!0}},[]);const g=async()=>{f(null),u(!0);try{n==="subscribed"?(await VS(t),s("idle")):(await QC(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 _=x3({enabled:i.enabled!==!1});if(a(_),f(null),_.enabled===!1&&n==="subscribed"){u(!0);try{await VS(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 Q6(){const[t,e]=wE(),[n,s]=w.useState(""),[i,a]=w.useState(""),[c,u]=w.useState(!1),[h,f]=w.useState(gE),g=w.useRef(0),v=w.useRef(!1),_=w.useRef(null),b=Ic();w.useEffect(()=>()=>{var C;g.current+=1,v.current&&((C=_.current)==null||C.abort(),_.current=null,v.current=!1,zg())},[]);const k=async()=>{const C=g.current+=1,L=typeof AbortController=="function"?new AbortController:null;s(""),a(""),u(!0),f(!1),v.current=!0,_.current=L;const S=await E6(p("notification-speech-preview"),Nd(),void 0,L?{signal:L.signal}:{});return C!==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},R=C=>{var L;if(e(C),s(""),a(""),C)k();else{g.current+=1;const S=v.current;(L=_.current)==null||L.abort(),_.current=null,v.current=!1,u(!1),f(!1),zg(),S||yE()}};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:C=>R(C.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:()=>{k()},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 Z6({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),[k,R]=w.useState(null),[C,L]=w.useState(""),S=w.useCallback(async()=>{try{const[A,j]=await Promise.all([i5(t),l5(t)]);a(A),u(Array.isArray(j==null?void 0:j.groups)?j.groups:[]),L("")}catch(A){L(String(A.message||A))}},[t]);w.useEffect(()=>{S()},[S]);const T=async A=>{b(!0),R(null),L("");try{a(await r5(t,A))}catch(j){L(String(j.message||j))}b(!1)},E=async()=>{b(!0),R(null),L("");try{R({kind:"test",...await o5(t)})}catch(A){L(String(A.message||A))}b(!1)},H=async()=>{b(!0),R(null),L("");try{R({kind:"stop",...await a5(t)})}catch(A){L(String(A.message||A))}b(!1)},F=[],X=new Set,V=(A,j)=>{const N=typeof A=="string"?A.toLowerCase():"";!/^[a-f0-9]{32}$/.test(N)||X.has(N)||(X.add(N),F.push({id:N,label:j||N}))};V(s==null?void 0:s.nodeId,p("audio-group-local"));for(const A of n||[])V((A==null?void 0:A.nodeId)||(A==null?void 0:A.instanceId),(A==null?void 0:A.label)||(A==null?void 0:A.name)||(A==null?void 0:A.nodeId));for(const A of h.targets)V(A,`${A} (${p("audio-group-unavailable-target")})`);const G=(A=null)=>{L(""),A?(v(A.name),f({name:A.name,mode:A.mode,targets:[...A.targets||[]]})):(v(null),f({name:"",mode:"primary-failover",targets:[]}))},ne=(A,j)=>f(N=>({...N,targets:j?[...new Set([...N.targets,A])]:N.targets.filter(U=>U!==A)})),Y=async()=>{const A=h.name.trim().toLowerCase();if(!/^[a-z0-9][a-z0-9-]{0,31}$/.test(A)||h.targets.length<1){L(p("audio-group-invalid"));return}b(!0),L("");try{const j=await c5(t,A,{targets:h.targets,mode:h.mode}),N=j==null?void 0:j.group;if(!N||!N.name)throw new Error(p("audio-group-save-failed"));u(U=>[...U.filter(I=>I.name!==N.name),N].sort((I,W)=>I.name.localeCompare(W.name))),G(null)}catch(j){L(String(j.message||j))}b(!1)},B=async A=>{b(!0),L("");try{await u5(t,A),u(j=>j.filter(N=>N.name!==A)),g===A&&G(null)}catch(j){L(String(j.message||j))}b(!1)},P=(i==null?void 0:i.installed)===!0,D=(i==null?void 0:i.liveness)==="ready",M=(i==null?void 0:i.consent)===!0&&P&&D,$=k?k.kind==="stop"?p(k.stopped?"audio-stop-stopped":"audio-stop-idle"):k.status==="accepted"||k.status==="spoken"?p("audio-test-accepted"):k.status==="unknown"?p("audio-test-unknown"):`${p("audio-test-refused")}${k.reason?` (${k.reason})`:""}`:"";return l.jsxs("div",{className:"nc-set-tab nc-audio-settings",children:[l.jsxs("div",{className:"nc-set-info",children:[l.jsx("b",{children: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:A=>{T(A.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(P?"audio-installed-yes":"audio-installed-no"),l.jsx("br",{}),p("audio-liveness"),": ",p(D?"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")}),!P&&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:()=>{H()},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(A=>{var j;return l.jsxs("div",{className:"nc-set-row",children:[l.jsxs("span",{children:[l.jsx("b",{children:A.name})," ",l.jsxs("small",{children:["· ",A.mode==="fanout"?p("audio-group-fanout"):p("audio-group-primary")," · ",((j=A.targets)==null?void 0:j.length)||0]})]}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>G(A),children:p("audio-group-edit")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>{B(A.name)},children:p("audio-group-delete")})]},A.name)}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:e||_,onClick:()=>G(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:A=>f(j=>({...j,name:A.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:A=>f(j=>({...j,mode:A.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")}),F.length===0?l.jsx("small",{className:"nc-set-hint",children:p("audio-group-no-targets")}):F.map(A=>l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:h.targets.includes(A.id),disabled:e||_,onChange:j=>ne(A.id,j.target.checked)}),l.jsxs("span",{children:[A.label,l.jsx("small",{children:A.id})]})]},A.id)),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn primary",disabled:e||_,onClick:()=>{Y()},children:p("audio-group-save")}),g&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:_,onClick:()=>G(null),children:p("audio-group-cancel")})]})]})]}):l.jsx("div",{className:"nc-set-info",children:p("audio-loading")}),$&&l.jsx("div",{className:"nc-set-note",role:"status",children:$}),C&&l.jsx("div",{className:"nc-err",children:C})]})}function e4(){const[t,e]=zv(),[n,s]=w.useState(dE),[i,a]=w.useState(fE),[c,u]=w.useState(pE);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:SC.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:xC.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),hE(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),u6(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),d6(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(Sr),children:p("input-settings-reset")})})]})}function t4({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,k]=w.useState(!1),[R,C]=w.useState(!0),[L,S]=w.useState(900),[T,E]=w.useState("all"),[H,F]=w.useState(""),X=w.useRef(0),V=w.useRef(null),G=w.useCallback(async()=>{try{const M=await p5(t,c.route);if(h(M),_(""),!b){const $=await m5(t,{after:X.current,limit:200},c.route);Array.isArray($.records)&&$.records.length&&(X.current=$.cursor,g(A=>[...A,...$.records].slice(-500)))}}catch(M){_(M&&M.status===404?p("diagnostics-unsupported"):String(M.message||M))}},[t,c.key,b]);w.useEffect(()=>{X.current=0,g([]),h(null),_("")},[c.key]),w.useEffect(()=>{let M=null,$=!0;const A=()=>{!$||document.visibilityState==="hidden"||G()},j=()=>{M&&clearInterval(M),M=document.visibilityState==="hidden"?null:setInterval(A,2e3),document.visibilityState!=="hidden"&&A()};return document.addEventListener("visibilitychange",j),j(),()=>{$=!1,M&&clearInterval(M),document.removeEventListener("visibilitychange",j)}},[G]),w.useEffect(()=>{R&&V.current&&(V.current.scrollTop=V.current.scrollHeight)},[f,R]);const ne=f.filter(M=>(T==="all"||M.level===T)&&(!H||String(M.component||"").toLowerCase().includes(H.toLowerCase()))),Y=ne.map(M=>`${M.ts} ${M.level.toUpperCase()} ${M.component} ${M.code} ${M.message}${Object.keys(M.meta||{}).length?` ${JSON.stringify(M.meta)}`:""}`).join(`
|
|
168
|
+
`),B=async M=>{_("");try{const $=await M();h($),await G()}catch($){_(String($.message||$))}},P=async()=>{try{await navigator.clipboard.writeText(Y)}catch{_(p("copy-manual"))}},D=()=>{try{const M=new Blob([`${JSON.stringify(ne,null,2)}
|
|
169
|
+
`],{type:"application/json"}),$=URL.createObjectURL(M),A=document.createElement("a");A.href=$,A.download="nexuscrew-diagnostics.json",A.click(),URL.revokeObjectURL($)}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:L,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:()=>B(()=>Uw(t,!0,L,c.route)),children:p("enable")}),l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||(u==null?void 0:u.verbose)!==!0,onClick:()=>B(()=>Uw(t,!1,L,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:T,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:H,onChange:M=>F(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=>k(M.target.checked)})," ",p("diagnostics-pause")]}),l.jsxs("label",{className:"nc-check",children:[l.jsx("input",{type:"checkbox",checked:R,onChange:M=>C(M.target.checked)})," ",p("diagnostics-autoscroll")]})]}),l.jsx("pre",{ref:V,className:"nc-diag-log","aria-label":p("diagnostics-log"),children:Y||p("diagnostics-empty")}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:P,children:p("copy")}),l.jsx("button",{type:"button",className:"nc-btn ghost",onClick:D,children:p("diagnostics-export")}),l.jsx("button",{type:"button",className:"nc-btn danger",disabled:n,onClick:()=>{window.confirm(p("diagnostics-clear-confirm"))&&B(async()=>{const M=await g5(t,c.route);return X.current=0,g([]),M})},children:p("diagnostics-clear")})]}),v&&l.jsx("div",{className:"nc-err",children:v})]})}function n4(){typeof window<"u"&&window.location&&typeof window.location.reload=="function"&&window.location.reload()}function s4({token:t,settings:e,readonly:n,refresh:s,roster:i,section:a,setSection:c}){const[u,h]=w.useState(Ec),[f,g]=w.useState(null),[v,_]=w.useState(null),[b,k]=w.useState(!1),[R,C]=w.useState(!1),[L,S]=w.useState(null),[T,E]=w.useState(!1),[H,F]=w.useState(!1),[X,V]=w.useState(null);w.useEffect(()=>{S(e&&e.update||null),E(!!(e&&e.autoUpdate===!0)),F(!!(e&&e.alternateScreen))},[e]);const G=async()=>{g(null),_(null),C(!0);try{const N=await XN(t);_(N.note||"ok"),k(!1)}catch(N){g(String(N.message||N))}C(!1)},ne=async()=>{g(null),_(null),C(!0);try{const N=await d5(t);_(`${N.note||"ok"}${N.target?` (${N.target})`:""}`)}catch(N){g(String(N.message||N))}C(!1)},Y=async N=>{g(null),_(null),C(!0);try{await Ed(t,{autoUpdate:N}),E(N),s&&await s()}catch(U){g(String(U.message||U))}C(!1)},B=async N=>{g(null),_(null),C(!0);try{await Ed(t,{alternateScreen:N}),F(N),s&&await s()}catch(U){g(String(U.message||U))}C(!1)},P=w.useCallback(async()=>{if(t)try{V(await GN(t))}catch{V(null)}},[t]);w.useEffect(()=>{P()},[P]);const D=async N=>{g(null),_(null),C(!0);try{if(!N&&X&&X.running&&!window.confirm(p("ai-desktop-confirm-stop"))){C(!1);return}const U=await z1(t,N);U&&U.ok===!1&&g(U.error||"comando fallito"),await P(),s&&await s()}catch(U){g(String(U.message||U))}C(!1)},M=async()=>{g(null),_(null),C(!0);try{S(await h5(t))}catch(N){g(String(N.message||N))}C(!1)},$=async()=>{g(null),_(null),C(!0);try{const N=await f5(t);S(N),_(p("npm-update-restarting"))}catch(N){g(String(N.message||N))}C(!1)},A=()=>{window.confirm(p("composer-clear-confirm"))&&(g(null),AI()?(window.dispatchEvent(new Event(Tg)),_(p("composer-clear-done"))):g(p("composer-clear-failed")))},j=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===ho,onChange:N=>{const U=Sk(N.target.checked?ho:fo);h(U),n4()}}),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",{}),j&&j.installed?p("service-installed"):p("service-missing"),j&&j.installed?` · ${j.active?p("service-active"):p("service-inactive")}`:"",j?` · boot ${j.boot?"on":"off"}`:""]}),l.jsx("div",{className:"nc-set-row",children:l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||R,title:n?p("settings-readonly"):"",onClick:ne,children:p("service-regenerate")})}),l.jsx(J6,{token:t,readonly:n}),l.jsx(Q6,{})]}),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:T,disabled:n||R||L&&!L.supported,onChange:N=>Y(N.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("npm-auto-update")}),l.jsx("small",{children:p("npm-auto-update-help")})]})]}),L&&l.jsxs("div",{className:"nc-set-info",children:[p("npm-update-current")," v",L.current,L.latest?` · ${p("npm-update-latest")} v${L.latest}`:""," · ",p(L.supported?L.phase==="idle"&&L.checked!==!0?"npm-update-never":`npm-update-${L.phase}`:"unsupported")]}),l.jsxs("div",{className:"nc-set-row",children:[l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:n||R||!L||!L.supported,onClick:M,children:p("npm-update-check")}),L&&L.available&&l.jsx("button",{type:"button",className:"nc-btn primary",disabled:n||R||L.phase==="installing",onClick:$,children:p("npm-update-install")})]}),L&&L.lastError&&l.jsx("div",{className:"nc-err",children:L.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||R,checked:!!(X&&X.desired),onChange:N=>D(N.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("ai-desktop")}),l.jsx("small",{children:p("ai-desktop-help")})]})]}),X&&!X.desired&&X.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||R,title:n?p("settings-readonly"):"",onClick:()=>{g(null),_(null),k(!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:A,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:H,disabled:n||R,onChange:N=>B(N.target.checked)}),l.jsxs("span",{children:[l.jsx("b",{children:p("alternate-screen")}),l.jsx("small",{children:p("alternate-screen-help")})]})]})]}),l.jsx(V6,{token:t}),l.jsx(j6,{}),l.jsx(t4,{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:R,onClick:()=>k(!1),children:p("cancel")}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:R,onClick:G,children:p("confirm")})]})]}),v&&l.jsx("div",{className:"nc-set-note",children:v}),f&&l.jsx("div",{className:"nc-err",children:f})]})}function i4({token:t,onClose:e,initialTab:n="nodes",initialLocation:s="",startNewCell:i=!1}){$n();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),[k,R]=w.useState(null),[C,L]=w.useState([]),[S,T]=w.useState(null),[E,H]=w.useState([]),[F,X]=w.useState(!1),[V,G]=w.useState(null),[ne,Y]=w.useState(0),B=Nv(t,!0,ne),P=w.useCallback(()=>{const I=h.current;if(!I)return;const W=I.scrollWidth>I.clientWidth+1,se={start:W&&I.scrollLeft>1,end:W&&I.scrollLeft+I.clientWidth<I.scrollWidth-1};v(me=>me.start===se.start&&me.end===se.end?me:se)},[]);w.useEffect(()=>{const I=h.current;if(!I)return;const W=typeof ResizeObserver=="function"?new ResizeObserver(P):null;return W==null||W.observe(I),window.addEventListener("resize",P),P(),()=>{W==null||W.disconnect(),window.removeEventListener("resize",P)}},[P]),w.useEffect(()=>{var W,se;(se=(W=f.current)==null?void 0:W.scrollIntoView)==null||se.call(W,{behavior:"smooth",block:"nearest",inline:"nearest"});const I=window.requestAnimationFrame?window.requestAnimationFrame(P):setTimeout(P,0);return()=>{window.cancelAnimationFrame?window.cancelAnimationFrame(I):clearTimeout(I)}},[c,P]);const D=w.useRef(th()),M=w.useRef(null),$=w.useRef([]),A=w.useRef(new Map),j=w.useRef({token:null,instanceId:null}),N=w.useCallback((I,W)=>{if(!I.isCurrent(W))return;const se=$.current,me=[],pe=new Set;for(const Ie of A.current.values())for(const J of Ie){const te=Array.isArray(J.route)&&J.route.length?J.route.join("/"):"local",ge=`${J.ownerInstanceId}:${te}:${J.nodeId||J.name||J.label||""}`;pe.has(ge)||(pe.add(ge),me.push(J))}L([...se,...me])},[]),U=w.useCallback(async()=>{const I=D.current,W=I.begin();if(W===null)return;const se=new AbortController;M.current=se;const me={timeoutMs:L1,signal:se.signal};try{const pe=O1(t,me).then(te=>{I.isCurrent(W)&&(R(te),G(null))}).catch(te=>{I.isCurrent(W)&&G(String((te==null?void 0:te.message)||te))}),Ie=VN(t,me).then(te=>{if(!I.isCurrent(W))return;const ge=te.peers||[];$.current=ge,T(Number.isInteger(te.accessRevision)?te.accessRevision:null),N(I,W)}).catch(te=>{I.isCurrent(W)&&G(String((te==null?void 0:te.message)||te))}),J=(async()=>{const[te,ge]=await Promise.all([Bc(t,[],me).then(Q=>Q).catch(()=>null),$1(t,me).then(Q=>Q).catch(()=>null)]);if(!I.isCurrent(W))return;const Se=te&&typeof te.instanceId=="string"?te.instanceId:"";if(!Se)return;j.current.instanceId!==Se&&(A.current.clear(),j.current.instanceId=Se);const Be=[{instanceId:Se||null,route:[],label:null},...Dk(ge,Se)],Le=Q=>`${Q.instanceId}:${Q.route.join("/")}`;if(ge){const Q=new Set(Be.map(Le));for(const ve of A.current.keys())Q.has(ve)||A.current.delete(ve)}if(!ge)for(const[Q,ve]of A.current)ve.some(Z=>Z.route.length)&&A.current.set(Q,ve.map(Z=>({...Z,stale:!0,online:!1,canManage:!1,capabilities:[]})));const ze=new Map;H([]),N(I,W),await Promise.allSettled(Be.map(async Q=>{const ve=Le(Q);try{const Z=await B1(t,Q.route,{signal:se.signal});if(!I.isCurrent(W))return;const be=(Z.nodes||[]).map(K=>Ik(K,Q)).filter(Boolean);A.current.set(ve,be),ze.delete(ve)}catch(Z){if(!I.isCurrent(W))return;if((Z==null?void 0:Z.status)===403||(Z==null?void 0:Z.status)===404)A.current.delete(ve);else{const K=A.current.get(ve);K&&A.current.set(ve,K.map(fe=>({...fe,stale:!0,online:!1,canManage:!1,capabilities:[]})))}Q.route.length>0&&ze.set(ve,{instanceId:Q.instanceId,label:Q.label,route:Q.route,failure:/timeout/i.test(String((Z==null?void 0:Z.message)||Z))?"timeout":"unreachable"})}I.isCurrent(W)&&(H([...ze.values()]),N(I,W))}))})();await Promise.allSettled([pe,Ie,J])}finally{M.current===se&&(M.current=null),I.end(W)}},[t,N]);return w.useEffect(()=>{j.current.token!==t&&(j.current={token:t,instanceId:null},$.current=[],A.current.clear(),L([]),H([]),T(null)),U();const I=setInterval(U,5e3);return()=>{clearInterval(I),D.current.reset(),M.current&&M.current.abort()}},[U]),w.useEffect(()=>{let I=!1;return Wn("/api/config",t).then(W=>W.json()).then(W=>{I||X(!!W.readonlyDefault)}).catch(()=>{}),()=>{I=!0}},[t]),l.jsx("div",{className:"nc-set-overlay",onClick:e,children:l.jsxs("div",{className:"nc-set-panel",onClick:I=>I.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})})]}),F&&l.jsx("div",{className:"nc-set-readonly",children:p("settings-readonly")}),V&&l.jsx("div",{className:"nc-err",children:V}),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:P,children:["nodes","fleet","audio","input","system"].map(I=>l.jsx("button",{ref:c===I?f:null,type:"button",className:`nc-set-tabbtn${c===I?" on":""}`,onClick:()=>u(I),children:p(`tab-${I}`)},I))})}),l.jsxs("div",{className:"nc-set-body",children:[c==="nodes"&&l.jsx(X6,{token:t,nodes:C,roster:B,settings:k,readonly:F,vlUnavailable:E,accessRevision:S,refresh:U,refreshAliases:()=>Y(I=>I+1)}),c==="fleet"&&l.jsx(c6,{token:t,readonly:F,startNewCell:i,initialLocation:s,targets:B.map(I=>({route:I.route,label:I.label||I.name,status:I.status}))}),c==="audio"&&l.jsx(Z6,{token:t,readonly:F,nodes:C,settings:k}),c==="input"&&l.jsx(e4,{}),c==="system"&&l.jsx(s4,{token:t,settings:k,readonly:F,refresh:U,roster:B,section:_,setSection:b})]})]})})}function r4({token:t,initialPair:e,deviceDefault:n="",localNodeId:s="",localNameDefault:i="",deviceNameNeeded:a=!1,deviceNameSuggestion:c="",onPairDone:u,onDone:h}){$n();const[f,g]=w.useState(e?"pair":"welcome"),[v,_]=w.useState(!1),[b,k]=w.useState(null),[R,C]=w.useState(c||""),[L,S]=w.useState(null),T=async()=>{_(!0),k(null);try{const E={wizardDone:!0};a&&R.trim()&&(E.deviceName=R.trim()),await Ed(t,E),u&&u(),h()}catch(E){k(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:R,onChange:E=>C(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:T,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(qC,{token:t,initial:e||"",autoStart:!!e,deviceDefault:a&&R.trim()?R.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")}),L&&l.jsx(Gv,{line:L.line,note:L.note}),l.jsx("div",{className:"nc-sheet-actions",children:l.jsx("button",{className:"nc-btn primary",disabled:v,onClick:T,children:p("finish")})})]}),b&&l.jsx("div",{className:"nc-err",children:b})]})})}function o4({token:t,suggestion:e="",onSaved:n,onLater:s}){$n();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 Ed(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 a4=50;function l4(t){if(Number.isFinite(t))return t;const e=typeof t=="string"?Date.parse(t):NaN;return Number.isFinite(e)?e:0}function RE(t,e){return`${String(t)}|${String(e)}`}function o1(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:RE(e,t.eventId),ownerId:String(e),eventId:String(t.eventId),title:s,body:i,urgency:n.urgency==="high"?"high":"normal",ts:l4(t.emittedAt??(t.frame&&t.frame.ts)??t.ts),arrivalSeq:0}}function a1(t){return[...t].sort((e,n)=>n.ts-e.ts).slice(0,a4)}function l1(t,e,n,s=null){const i=new Set((e||[]).map(c=>c&&c.key)),a=new Map;for(const c of t||[])s&&s.owners.has(c.ownerId)&&!i.has(c.key)&&!s.arrivedAfter(c)||(!n||n.has(c.ownerId))&&a.set(c.key,c);for(const c of e||[])c&&a.set(c.key,c);return[...a.values()]}function c4(t,e,n,s){if(typeof EventSource>"u"||!t)return()=>{};const i=new EventSource(`/api/events?token=${encodeURIComponent(t)}`);return i.onopen=()=>{typeof n=="function"&&n()},i.onerror=()=>{typeof s=="function"&&s()},i.onmessage=a=>{try{const c=JSON.parse(a.data);c&&typeof c=="object"&&typeof c.type=="string"&&e(c)}catch{}},()=>{try{i.close()}catch{}}}const u4=6e3,d4=12e3,Zn=(t,e,n)=>`${e||""}:${n||t}`,h4=(t,e)=>{const n=t&&t[e];return n?n.stale===!0||n.error===!0?"degraded":"live":"missing"},LE=600*1e3,c1=30*1e3,f4=300*1e3,Vg=new Map,p4=900*1e3,$a=new Map;function cm(t){$a.set(t,Date.now()),$a.size>4096&&$a.delete($a.keys().next().value)}function um(t){const e=$a.get(t);return e===void 0?!1:Date.now()-e>p4?($a.delete(t),!1):!0}const m4={pending:"ask-dismiss-local-pending",blocked:"ask-dismiss-local-blocked"},g4=t=>m4[t]||t,Wo=t=>Object.hasOwn(t,"ownerAskTs")?t.ownerAskTs:t.ownerAskId||t.originNode?null:t.ts;function AE(t,e){Vg.set(t,e?{at:Date.now(),local:!0,ts:Wo(e),fingerprint:e.question===void 0?null:JSON.stringify([e.question,e.options||[],e.session])}:{at:Date.now()})}function jE(t){const e=Zn(t.id,t.ownerId,t.ownerAskId),n=Vg.get(e);if(n===void 0)return!1;if(n.local){const s=Wo(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>LE?(Vg.delete(e),!1):!0}function Cd(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||jE(s))continue;const i=Zn(s.id,s.ownerId,s.ownerAskId),a=n.get(i),c=Wo(s),u=a&&Wo(a);(!a||Number.isSafeInteger(c)&&c>0&&Number.isSafeInteger(u)&&u>0&&c>u)&&n.set(i,s)}return[...n.values()]}function v4(t,e){const n=Cd([],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))&&!jE(a)),...n]}function _4({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 y4({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,k]=w.useState(!1),[R,C]=w.useState(null),[L,S]=w.useState(!1),[T,E]=w.useState(c),[H,F]=w.useState(!1),[X,V]=w.useState(!1),G=w.useRef(null);w.useEffect(()=>{c&&E(c)},[c]);const ne=L||b||!!T||X||!!t.ownerId&&f==="loading",Y=!!t.ownerId&&!h,B=async M=>{const $=String(M||"").trim();if(!(!$||b||L||T||X)){C(null),k(!0);try{if(t.ownerId){const A=t.ownerAskId||t.id,j=await w5(e,{ownerId:t.ownerId,askId:A,text:$,requestId:G.current||(G.current=crypto.randomUUID())});if(j&&j.uncertain){const N=j.reason==="delivery-unknown-block"&&!j.originalRequestId;E(N?null:j.originalRequestId||j.requestId||G.current),V(N);return}if(!j||j.status!=="committed"){G.current=null,g(),C(p("ask-reconcile"));return}n(t.id,t.ownerId,t.ownerAskId)}else await _5(e,t.id,$),n(t.id)}catch(A){C(String(A.message||A)),t.ownerId&&!A.status?E(G.current):G.current=null,g()}finally{k(!1)}}},P=async()=>{if(!ne){C(null),S(!0);try{let M;if(Y){if(M=await C5(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 k5(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id}):await y5(e,t.id);AE(Zn(t.id,t.ownerId,t.ownerAskId),Y?t:null),s(t.id,t.ownerId,t.ownerAskId,M)}catch(M){C(String(M&&M.message||M)),g()}finally{S(!1)}}},D=p(T||X?"ask-uncertain":Y?"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:D,"aria-label":D,disabled:ne,onClick:P,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")}),(T||X)&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-err",children:p("ask-uncertain")}),X&&!T&&l.jsx("div",{className:"nc-err",children:p("ask-reconcile")}),T&&l.jsx("button",{type:"button",className:"nc-btn ghost",disabled:H,onClick:async()=>{F(!0);try{const M=await b5(e,{ownerId:t.ownerId,askId:t.ownerAskId||t.id,requestId:T});(M==null?void 0:M.state)==="committed"?n(t.id,t.ownerId,t.ownerAskId):(M==null?void 0:M.state)==="failed"&&(E(null),G.current=null,g())}catch(M){C(String(M.message||M)),g()}finally{F(!1)}},children:p("ask-verify")})]}),(!t.ownerId||i===!0)&&!T&&!X&&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||L,onClick:()=>B(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||L,onChange:M=>_(M.target.value)}),l.jsx("button",{type:"button",className:"nc-btn primary",disabled:b||L||!v.trim(),onClick:()=>B(v),children:p("send")})]})]}),R&&l.jsx("div",{className:"nc-err",children:R})]})}function w4({token:t}){const[e]=$n(),[n]=wE(),[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,k]=w.useState({}),R=w.useRef(new Map),C=w.useRef(0),[L,S]=w.useState(0),T=w.useRef(new Map),E=w.useRef(0),H=w.useRef(0),F=w.useRef(new Map),X=w.useRef(new Map),V=w.useRef(new Map),G=J=>(J||[]).filter(te=>{const ge=T.current.get(Zn(te.id,te.ownerId,te.ownerAskId));if(!ge)return!0;if(Date.now()-ge.at>LE)return T.current.delete(Zn(te.id,te.ownerId,te.ownerAskId)),!0;const Se=Wo(te);return Number.isSafeInteger(Se)&&Se>0&&Number.isSafeInteger(ge.ts)&&ge.ts>0?Se!==ge.ts:ge.fingerprint!==null&&ge.fingerprint!==void 0&&ge.fingerprint!==JSON.stringify([te.question,te.options||[],te.session])}),ne=w.useRef(a);ne.current=a;const Y=w.useCallback((J=!1)=>{if(!t)return;const te=new Set;for(const ge of ne.current){if(!ge.ownerId)continue;const Se=ge.ownerAskId||ge.id,Be=`${ge.ownerId}|${Se}`;te.add(Be);const Le=R.current.get(Be);if(Le&&(!J||Le.pending))continue;const ze=new AbortController,Q=C.current,ve={controller:ze,pending:!0};R.current.set(Be,ve),k(Z=>({...Z,[Be]:{canReply:!1,status:"loading"}})),S5(t,{ownerId:ge.ownerId,askId:Se},{signal:ze.signal}).then(Z=>{if(Q!==C.current||ze.signal.aborted||R.current.get(Be)!==ve)return;const be=Z&&Z.ownerId===ge.ownerId&&Z.askId===Se&&typeof Z.canReply=="boolean"&&(!Z.canReply||Z.status==="open");k(K=>({...K,[Be]:be?Z:{canReply:!1,status:"unreachable"}}))}).catch(()=>{Q===C.current&&!ze.signal.aborted&&R.current.get(Be)===ve&&k(Z=>({...Z,[Be]:{canReply:!1,status:"unreachable"}}))}).finally(()=>{ve.pending=!1})}for(const[ge,Se]of R.current)te.has(ge)||(Se.controller.abort(),R.current.delete(ge))},[t]);w.useEffect(()=>{C.current++;for(const J of R.current.values())J.controller.abort();return R.current.clear(),k({}),()=>{C.current++;for(const J of R.current.values())J.controller.abort();R.current.clear()}},[t]),w.useEffect(()=>{Y()},[a,Y]);const B=w.useRef(!1);w.useEffect(()=>{v&&(B.current&&Y(!0),B.current=!0)},[v,Y]);const P=w.useRef(0),D=w.useRef(null);D.current||(D.current=N6());const M=w.useRef({enabled:n,lang:e});M.current={enabled:n,lang:e};const $=w.useCallback(J=>{i(te=>te.filter(ge=>ge.key!==J))},[]),A=w.useCallback(J=>{if(J.askId&&J.ownerId){const Se=Number.isSafeInteger(J.ownerAskTs)&&J.ownerAskTs>0?J.ownerAskTs:J.ownerAskFingerprint;if(Se){const Be=JSON.stringify([J.ownerId,J.ownerAskId||J.askId,Se]),Le=Date.now();for(const[ze,Q]of V.current)Le-Q>1440*60*1e3&&V.current.delete(ze);if(V.current.has(Be))return;V.current.set(Be,Le),V.current.size>4096&&V.current.delete(V.current.keys().next().value)}}const te=`t${P.current+=1}`;i(Se=>[...Se.slice(-3),{...J,key:te}]),setTimeout(()=>$(te),J.urgency==="high"?d4:u4);const ge=M.current;if(ge.enabled)try{D.current.enqueue(J,S6(J,ge.lang))}catch{}},[$]);w.useEffect(()=>{n||D.current.stop()},[n]),w.useEffect(()=>{const J=()=>{(document.visibilityState!=="visible"||!document.hasFocus())&&D.current.stop()},te=()=>D.current.stop();return document.addEventListener("visibilitychange",J),window.addEventListener("blur",J),window.addEventListener($g,te),()=>{document.removeEventListener("visibilitychange",J),window.removeEventListener("blur",J),window.removeEventListener($g,te),typeof D.current.dispose=="function"?D.current.dispose():D.current.stop()}},[]);const j=J=>{if(J.ownerAskId||!J.ownerId)return J;const te=ne.current.filter(Se=>Se.ownerId===J.ownerId&&(Se.id===J.id||Se.ownerAskId===J.id)),ge=new Set(te.map(Se=>Se.ownerAskId||Se.id));return ge.size>1?null:{...J,ownerAskId:ge.size===1?[...ge][0]:J.id}},N=(J,te)=>{const ge=ne.current.find(Be=>Zn(Be.id,Be.ownerId,Be.ownerAskId)===J),Se=ge&&Wo(ge);return Number.isSafeInteger(te==null?void 0:te.ownerAskTs)&&te.ownerAskTs>0&&Number.isSafeInteger(Se)&&Se>0&&te.ownerAskTs!==Se},U=(J,te,ge,Se)=>{const Be=Zn(J,te,ge);(Se==null?void 0:Se.scope)==="local"&&["pending","blocked"].includes(Se.ownerSync)&&h(Se.ownerSync);const Le=ne.current.find(ve=>Zn(ve.id,ve.ownerId,ve.ownerAskId)===Be),ze=Le&&Wo(Le);if(N(Be,Se))return;const Q=Le||(Se==null?void 0:Se.askGeneration);T.current.set(Be,{at:Date.now(),ts:Le?ze:Se==null?void 0:Se.ownerAskTs,fingerprint:Q&&Q.question!==void 0?JSON.stringify([Q.question,Q.options||[],Q.session]):null}),F.current.delete(Be),T.current.size>4096&&T.current.delete(T.current.keys().next().value),c(ve=>ve.filter(Z=>Zn(Z.id,Z.ownerId,Z.ownerAskId)!==Be))},I=async J=>{h(null);try{const te=await N5(t,{ownerId:J.ownerId,eventId:J.eventId});if(!te||te.dismissed!==!0)throw new Error(p("remote-notices-dismiss-failed"));(te.ownerSync==="pending"||te.ownerSync==="blocked")&&h(te.ownerSync),cm(J.key),g(ge=>ge.filter(Se=>Se.key!==J.key))}catch{h("remote-notices-dismiss-failed")}},W=async()=>{const J=f,te=[...new Set(J.map(ge=>ge.ownerId))];if(te.length!==0){h(null);try{const ge=await R5(t,{owners:te}),Se=ge&&ge.results||{},Be=new Set;let Le=null;for(const ze of te){const Q=Se[ze];if(!Q||Q.failed){Le!=="blocked"&&(Le="failed");continue}Q.blocked?Le="blocked":Q.pending&&Le!=="blocked"&&Le!=="failed"&&(Le="pending"),Be.add(ze)}for(const ze of J)Be.has(ze.ownerId)&&cm(ze.key);g(ze=>ze.filter(Q=>!Be.has(Q.ownerId))),Le==="blocked"?h("blocked"):Le==="failed"?h("remote-notices-clear-failed"):Le==="pending"&&h("pending")}catch{h("remote-notices-clear-failed")}}};w.useEffect(()=>{if(!t)return;let J=!0,te=!1,ge=null,Se=c1;const Be=()=>{ge!==null&&clearTimeout(ge),ge=null},Le=()=>{!J||te||ge!==null||(ge=setTimeout(()=>{ge=null,!(!J||te)&&(S(Q=>Q+1),Se=Math.min(Se*2,f4),Le())},Se))},ze=c4(t,Q=>{if(J){if(Q.type==="feed-state-changed"){S(ve=>ve+1);return}if(Q.type==="notify"&&Q.ownerId&&Q.eventId){const ve=o1(Q,Q.ownerId);ve&&(ve.arrivalSeq=++H.current),ve&&!um(ve.key)&&g(Z=>a1(l1(Z,[ve],null)))}if(Q.type==="notify-dismissed"){const ve=String(Q.ownerId||""),Z=String(Q.eventId||"");if(ve&&Z){const be=RE(ve,Z);cm(be),g(K=>K.filter(fe=>fe.key!==be))}return}if(Q.type==="notify")A(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(Z=>Cd(Z,G([Q.ask])))}else if(Q.type==="ask-answered"&&Q.id){const ve=j(Q);ve&&U(ve.id,ve.ownerId,ve.ownerAskId,Q)}else if(Q.type==="ask-dismissed"&&(Q.id||Q.ownerAskId)){const ve=j(Q);if(!ve)return;const Z=Zn(ve.id,ve.ownerId,ve.ownerAskId);if(N(Z,Q))return;const be=Q.scope==="local"&&ne.current.find(K=>Zn(K.id,K.ownerId,K.ownerAskId)===Z);AE(Z,Q.scope==="local"?be||{...Q.askGeneration,ownerAskTs:Q.ownerAskTs}:null),U(ve.id,ve.ownerId,ve.ownerAskId,Q)}}},()=>{J&&(te=!0,Se=c1,Be(),Y(!0),S(Q=>Q+1))},()=>{J&&(te=!1,Le())});return Le(),()=>{J=!1,Be(),ze()}},[t,A,Y]),w.useEffect(()=>{let J=!0;const te=E.current;return t&&v5(t).then(ge=>{J&&c(Se=>Cd(v4(Se,G((ge.asks||[]).filter(Be=>!Be.ownerId||(X.current.get(Be.ownerId)||0)<=te))),G(Se.filter(Be=>(F.current.get(Zn(Be.id,Be.ownerId,Be.ownerAskId))||0)>te))))}).catch(()=>{}),()=>{J=!1}},[t,L]);const[se,me]=w.useState({});w.useEffect(()=>{if(!t)return;let J=!0;return x5(t).then(te=>{if(!J)return;const ge={};for(const Se of te&&te.attempts||[])Se&&Se.state==="uncertain"&&Se.ownerId&&Se.askId&&Se.requestId&&(ge[Se.ownerId+"|"+Se.askId]=Se.requestId);me(ge)}).catch(()=>{}),()=>{J=!1}},[t]);const[pe,Ie]=w.useState({});return w.useEffect(()=>{let J=!0;const te=E.current,ge=H.current;return E5(t).then(Se=>{if(!J)return;const Be={},Le=[],ze=new Map,Q=new Set;for(const Z of Se&&Se.views||[]){Be[Z.ownerId]={stale:Z.stale===!0,error:!!Z.lastError},Q.add(Z.ownerId);for(const be of Z.asks||[])be&&be.id&&Le.push({...be,ownerId:Z.ownerId,imported:!0});for(const be of Z.notifications||[]){const K=o1(be,Z.ownerId);K&&ze.set(K.key,K)}}Ie(Be);const ve=new Set((Se&&Se.views||[]).filter(Z=>{const be=typeof Z.cursor=="string"&&/^([1-9]\d*):(\d+)$/.exec(Z.cursor);return Z.stale===!1&&Number.isSafeInteger(Z.viewEpoch)&&Z.viewEpoch>0&&be&&Number(be[1])===Z.viewEpoch&&Number.isSafeInteger(Number(be[2]))&&!Z.lastError&&!Z.error&&Z.resyncRequired!==!0&&Array.isArray(Z.asks)&&Z.asks.length<=100}).map(Z=>Z.ownerId));for(const Z of ve)X.current.delete(Z),X.current.set(Z,++E.current),X.current.size>4096&&X.current.delete(X.current.keys().next().value);c(Z=>Cd(Z.filter(be=>!ve.has(be.ownerId)||(F.current.get(Zn(be.id,be.ownerId,be.ownerAskId))||0)>te),G(Le))),g(Z=>a1(l1(Z.filter(be=>!um(be.key)),[...ze.values()].filter(be=>!um(be.key)),Q,{owners:ve,arrivedAfter:be=>(be.arrivalSeq||0)>ge})))}).catch(()=>{}),()=>{J=!1}},[t,L]),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(g4(u))}),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(_4,{n:J,onClose:()=>$(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 te,ge,Se,Be,Le,ze;return l.jsx(y4,{ask:J,token:t,askReplyAccess:!J.ownerId||((te=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:te.canReply)===!0,canDismissLocal:((ge=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:ge.canDismissLocal)===!0,canDismissRemote:((Se=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:Se.canDismissRemote)===!0||((Be=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:Be.canDismissRemote)===void 0&&((Le=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:Le.canReply)===!0,capabilityStatus:((ze=b[J.ownerId+"|"+(J.ownerAskId||J.id)])==null?void 0:ze.status)||"loading",onRefused:()=>Y(!0),feedViewState:J.ownerId?h4(pe,J.ownerId):"live",initialUncertainRid:J.ownerId&&se[J.ownerId+"|"+(J.ownerAskId||J.id)]||null,onAnswered:U,onDismiss:U},Zn(J.id,J.ownerId,J.ownerAskId))}),f.length>0&&l.jsxs("div",{className:"nc-remote-notices",children:[l.jsxs("div",{className:"nc-remote-notices-head",children:[l.jsx("b",{children:p("remote-notices-title")}),l.jsx("button",{type:"button",className:"nc-remote-notices-clear",onClick:W,children:p("remote-notices-clear")})]}),f.map(J=>l.jsxs("div",{className:"nc-remote-notice"+(J.urgency==="high"?" nc-remote-notice-high":""),children:[l.jsxs("div",{className:"nc-remote-notice-head",children:[J.title?l.jsx("b",{children:J.title}):null,l.jsx("button",{type:"button",className:"nc-ntf-x",title:p("remote-notices-dismiss"),"aria-label":p("remote-notices-dismiss"),onClick:()=>I(J),children:l.jsx(Tt,{name:"x",size:14})})]}),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 ME="nc_fontsize",TE=9,PE=24;function Yg(t=globalThis.localStorage){const e=Number(t.getItem(ME));return e>=TE&&e<=PE?e:13}function IE(t,e=globalThis.localStorage){const n=Math.max(TE,Math.min(PE,t));return e.setItem(ME,String(n)),n}async function b4(t){const e=await Wn("/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 S4(t,e=[]){var u;const[n,s]=await Promise.allSettled([e.length?nv(t,e):b4(t),Ja(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 x4(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 k4(t,e,n,s=[]){if(t.type==="session"){const c=t.value||{};return{kind:"session",key:t.key,cellName:t.label,session:t.label,node:e.length?e.join("/"):"",nodeLabel:n,route:e,live:!0,selectable:!0,working:!1,degraded:!1,active:!0,activity:t.activity||0,telemetry:c.telemetry||null,preview:c.preview||"",panelUrl:""}}const i=t.value||{},a=s.find(c=>c&&c.name===i.tmuxSession)||{};return{kind:"cell",key:t.key,cellName:i.cell,session:i.tmuxSession||i.cell,node:e.length?e.join("/"):"",nodeLabel:n,route:e,live:t.live===!0,selectable:t.live===!0,working:t.working===!0,degraded:!!i.degraded,active:i.active===!0,activity:t.activity||0,telemetry:a.telemetry||i.telemetry||null,preview:a.preview||i.preview||"",panelUrl:i.panelUrl||""}}function C4({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:_}){const[b,k]=w.useState(dI),[R,C]=w.useState(!1),[L,S]=w.useState("");w.useEffect(()=>wc(t,[],O=>{let de=null;if(!O.sessionsError&&O.sessionsJson)try{const We=JSON.parse(O.sessionsJson);We&&!We.error&&Array.isArray(We.sessions)&&(de=We.sessions)}catch{}const we=ch({fs:O.fs,error:O.fleetError});k(We=>({...We,...de?{sessions:de}:{},...we.kind==="data"?{cells:we.cells,localFresh:!0}:{}}))}),[t]);const[T,E]=w.useState(null),H="stream",[F,X]=w.useState(Yg),V=O=>X(de=>IE(de+O)),[G,ne]=w.useState(null),[Y,B]=w.useState(!1),[P,D]=w.useState(""),M=w.useRef(null),$=w.useRef(null),{pins:A,orders:j,views:N,togglePin:U,removePin:I,pinError:W,canMoveRoster:se,moveRoster:me,stepRoster:pe}=Lv(),{groupsFor:Ie}=dh(),{groups:J,hasLoaded:te}=Hk(t),ge=te?J:b.nodeGroups||[],Se=w.useMemo(()=>Ie(ge||[]).filter(O=>Array.isArray(O.route)&&O.route.length&&O.kind!=="vl"),[Ie,ge]),Be=w.useMemo(()=>{const O=new Map,de=Array.isArray(b.sessions)?b.sessions:[],we=Array.isArray(b.cells)?b.cells:[],We=new Map(de.map(Pe=>[Pe.name,Pe])),ie=new Set(we.map(Pe=>Pe.tmuxSession).filter(Boolean));O.set("local",Pv(we,de.filter(Pe=>!ie.has(Pe.name)),We));for(const Pe of Se)O.set(Pe.route.join("/"),vc(Pe).rawItems);return O},[b,Se]),Le=w.useMemo(()=>{const O=We=>R?"all":vg(N,We).filter,de=Array.isArray(b.sessions)?b.sessions:[],we=[];for(const[We,ie]of Be){const Pe=Se.find(Mt=>Mt.route.join("/")===We),ft=Pe&&(Pe.label||Pe.name)||"",Pt=Pe?Pe.route:[],bt=Pe?Array.isArray(Pe.sessions)?Pe.sessions:[]:de,xt=lo(ie,A,O(We),Ti(j,We)),vt=R?xt:xt.filter(Mt=>{var Qt,Dt;return Mt.live===!0||Mt.type==="cell"&&((Qt=Mt.value)==null?void 0:Qt.degraded)===!0&&((Dt=Mt.value)==null?void 0:Dt.active)===!0});we.push(...vt.map(Mt=>k4(Mt,Pt,ft,bt)))}return we},[Be,Se,N,j,A,R,b.sessions]),ze=Le,Q=w.useMemo(()=>T?Le.find(O=>O.key===T&&O.selectable):null,[Le,T]);w.useEffect(()=>{T&&!Le.some(O=>O.key===T&&O.selectable)&&E(null)},[Le,T]);const ve=w.useMemo(()=>G?ze.find(O=>O.key===G.key):null,[ze,G]),Z=!!(G&&ve);w.useEffect(()=>{W&&W.message&&S(W.message)},[W]),w.useEffect(()=>{var we;const O=document.activeElement;(we=$.current)==null||we.focus();const de=We=>{We.key==="Escape"&&!Z&&s()};return document.addEventListener("keydown",de),()=>{var We;document.removeEventListener("keydown",de),(We=O==null?void 0:O.focus)==null||We.call(O)}},[s,Z]);const[be,K]=w.useState(""),fe={getLiveHost:O=>Qd(t,O),designateHostCell:(O,de,we)=>Zd(t,O,de,we),clearHostCell:(O,de)=>eh(t,O,de)},Re=O=>(u[Ns(O)]||{}).hostCell||null,Ee=async(O,de)=>{K(O.key);const we=await nh({action:de?"remove":"use",cellId:O.cellName,route:O.route||[],api:fe});K(""),S(p(we.messageKey).replace("{cell}",we.hostCell||O.cellName)),we.ok&&g&&g({route:O.route||[],hostCell:we.hostCell,revision:we.revision})},qe=O=>O.degraded?p("cell-degraded"):O.selectable?O.working?p("cell-working"):p("cell-idle"):p("cell-off"),Ze=async O=>{if(S(""),!O.selectable){S(p("cell-switcher-not-active"));return}if(O.kind==="session"){n({session:O.session,...O.node?{node:O.node}:{}}),s();return}D(O.key);try{const de=await S4(t,O.route),we=(de.cells||[]).find(We=>(We==null?void 0:We.cell)===O.cellName&&(We==null?void 0:We.tmuxSession)===O.session);if(de.fresh!==!0){n({session:O.session,...O.node?{node:O.node}:{},cellName:O.cellName}),s();return}if(!x4(we,de.sessions,de.fresh)){S(p("cell-switcher-not-active"));return}n({session:O.session,...O.node?{node:O.node}:{},cellName:O.cellName}),s()}catch{n({session:O.session,...O.node?{node:O.node}:{},cellName:O.cellName}),s()}finally{D("")}},at=O=>{if(!O.selectable){Ze(O);return}if(T===O.key){Ze(O);return}E(O.key)},Oe=w.useRef(null),_e=8,$e=O=>{const de=Oe.current;if(O.isPrimary===!1){de&&de.state==="open"&&(de.state="invalid");return}if(de&&de.state==="open"&&(de.id!==O.pointerId||de.row!==O.currentTarget)){de.state="invalid";return}Oe.current={id:O.pointerId,row:O.currentTarget,x:O.clientX,y:O.clientY,maxDelta:0,state:"open"}},nt=O=>{const de=Oe.current;!de||de.state!=="open"||de.id!==O.pointerId||(de.maxDelta=Math.max(de.maxDelta,Math.hypot(O.clientX-de.x,O.clientY-de.y)),de.maxDelta>_e&&(de.state="invalid"))},Fe=O=>{const de=Oe.current;!de||de.id!==O.pointerId||de.state!=="open"||(de.state=de.maxDelta<=_e?"tap":"invalid")},rt=O=>{const de=Oe.current;de&&de.id===O.pointerId&&(de.state="invalid")},re=O=>{const de=Oe.current;return Oe.current=null,O.detail===0?!0:!de||de.state==="invalid"||de.row!==O.currentTarget?!1:Math.hypot(O.clientX-de.x,O.clientY-de.y)<=_e},ce=O=>({onToggleLive:()=>Ee(O,Re(O.route||[])===O.cellName),onTogglePin:()=>Av({view:hh({item:{key:O.key,value:{cell:O.cellName}},pins:A,hostByRoute:u,route:O.route||[]}),itemKey:O.key,togglePin:U,removePin:I})});return l.jsxs("div",{className:"nc-cell-switcher-backdrop",onClick:s,children:[Q&&l.jsxs("div",{className:"nc-cell-switcher-anteprima","data-testid":"cell-switcher-anteprima",onClick:O=>O.stopPropagation(),children:[l.jsxs("div",{className:"nc-cell-switcher-anteprima-testa",children:[l.jsxs("b",{children:[p("cell-switcher-preview-word")," ",Q.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:()=>V(-1),title:p("zoom-out"),"aria-label":p("zoom-out"),children:"−"}),l.jsxs("span",{"data-testid":"cell-switcher-fontsize",children:[F," px"]}),l.jsx("button",{type:"button",onClick:()=>V(1),title:p("zoom-in"),"aria-label":p("zoom-in"),children:"+"})]})]}),l.jsx(Sv,{row:Q,token:t,source:H,chrome:!1,panelPort:Nc(Q.route||[],a,i),liveHost:Wa({liveHost:u[Ns(Q.route||[])],cells:b.cells||[]}),onLiveHostApplied:g,fontSize:F,readOnly:!0})]}),l.jsxs("aside",{ref:M,className:`nc-cell-switcher${Q?" with-anteprima":""}`,role:"dialog","aria-label":p("fleet-cells"),tabIndex:-1,onClick:O=>O.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:R?"":"on","aria-pressed":!R,onClick:()=>{S(""),C(!1)},children:p("cell-switcher-show-active")}),l.jsx("button",{type:"button",className:R?"on":"","aria-pressed":R,onClick:()=>{S(""),C(!0)},children:p("cell-switcher-show-all")})]}),l.jsx("button",{type:"button",className:`nc-cell-switcher-reorder${Y?" on":""}`,"aria-pressed":Y,title:p("reorder-help"),"aria-label":p("reorder"),onClick:()=>{S(""),B(O=>!O)},children:"↕"}),l.jsx("button",{ref:$,type:"button",className:"nc-cell-switcher-close","aria-label":p("cell-switcher-close"),title:p("cell-switcher-close"),onClick:s,children:"×"})]}),!Q&&l.jsx("div",{className:"nc-cell-switcher-hint",children:p("cell-switcher-tap-hint")}),l.jsxs("div",{className:"nc-cell-switcher-list",children:[(()=>{const O=Wa({liveHost:u[Ns([])],cells:b.cells||[]});if(!O||!O.cell)return null;const{modeKey:de}=U5(O);return l.jsx("div",{className:"nc-cell-switcher-live-strip","data-testid":"cell-switcher-live-strip",children:p("cell-switcher-live-strip").replace("{cell}",O.cell).replace("{mode}",p(de||"live-host-mode-unknown"))})})(),Le.length===0&&l.jsx("div",{className:"nc-empty",role:"status",children:p("cell-switcher-empty-active")}),Le.map((O,de)=>{const we=(e==null?void 0:e.session)===O.session&&((e==null?void 0:e.node)||"")===O.node,We=!!G&&G.key===O.key,ie=v!=null&&v===O.key,Pe=qe(O),ft=pg(p,O.activity),Pt=mg(p,O.telemetry),bt=[ft,Pt].filter(Boolean).join(" · "),xt=O.node||"local",vt=de>0?Le[de-1].node||"local":null,Mt=xt!==vt,Qt=Be.get(xt)||ze.filter(Dt=>(Dt.node||"local")===xt);return l.jsxs(w.Fragment,{children:[Mt&&l.jsx("div",{className:"nc-cell-switcher-position",children:p("cell-switcher-group").replace("{node}",O.nodeLabel||c||p("cell-switcher-group-local"))}),l.jsxs("div",{className:`nc-cell-switcher-row${we?" current":""}${T===O.key?" selected":""}${ie?" side":""}${O.selectable?"":" off"}`,"data-roster-key":O.key,"data-position":xt,children:[Y&&l.jsx(Vi,{position:xt,itemKey:O.key,label:O.cellName,canMove:se,onMove:(Dt,It)=>me(xt,Dt,It,Qt),onStep:Dt=>pe(xt,O.key,Dt,Qt)}),l.jsx("span",{className:"nc-cell-switcher-peek",children:l.jsx("span",{className:`nc-cell-switcher-dot${O.degraded?" warn":O.live?` on${O.working?" working":""}`:""}`})}),l.jsx("button",{type:"button",className:"nc-cell-switcher-row-select","aria-current":we?"true":void 0,"aria-disabled":!O.selectable,"data-selected":T===O.key?"true":void 0,disabled:P===O.key,onPointerDown:$e,onPointerMove:nt,onPointerUp:Fe,onPointerCancel:rt,onClick:Dt=>{re(Dt)&&at(O)},children:l.jsxs("span",{className:"nc-cell-switcher-copy",children:[l.jsxs("span",{className:"nc-cell-switcher-nameline",children:[l.jsx("b",{children:O.cellName}),we&&l.jsx("span",{className:"nc-cell-switcher-here",children:p("cell-switcher-here")}),T===O.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:Pe}),bt&&l.jsx("small",{className:"nc-cell-switcher-telemetry",children:bt})]})]})}),_&&l.jsx("button",{type:"button",className:`nc-cell-switcher-side${ie?" on":""}`,title:p(ie?"cell-switcher-side-remove":"cell-switcher-side-add"),"aria-label":p(ie?"cell-switcher-side-remove":"cell-switcher-side-add"),"aria-pressed":ie?"true":"false",disabled:we||!O.selectable,onClick:Dt=>{Dt.stopPropagation(),!we&&O.selectable&&_(O)},children:l.jsx(Tt,{name:"splitView",size:20})}),l.jsx("button",{type:"button",className:`nc-cell-switcher-menu${We?" on":""}`,title:`${p("cell-actions-open")}: ${O.cellName}`,"aria-label":`${p("cell-actions-open")}: ${O.cellName}`,"aria-haspopup":"menu","aria-expanded":We?"true":"false",onClick:Dt=>{Dt.stopPropagation(),ne({key:O.key})},children:"⋯"})]})]},O.key)})]}),L&&l.jsx("div",{className:"nc-cell-switcher-notice",role:"status",children:L}),Z&&(()=>{const O=ve,de=jv({...ro({item:{key:O.key,value:{cell:O.cellName}},cellName:O.cellName,route:O.route||[],pins:A,hostByRoute:u}),canBoot:!1,alive:O.selectable,handlers:ce(O)});return l.jsx(Mv,{cellName:O.cellName,items:de,busy:be===O.key,onClose:()=>ne(null)})})()]})]})}const E4=2e3;function N4(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 R4({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 YN(t,e,u.current,n);if(!f)return;c(!1);const R=(Array.isArray(b==null?void 0:b.events)?b.events:[]).filter(C=>Number.isSafeInteger(C==null?void 0:C.seq)&&C.seq>u.current);R.length&&(i(C=>C.concat(R).slice(-500)),u.current=R[R.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,E4);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:N4(f)},`${f.seq}-${f.kind}`))})]})}function u1({peer:t,token:e,onBack:n}){var s;return $n(),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(R4,{token:e,nodeId:t.nodeId,route:t.route||[]})})]}):null}const Kd="nc_dual_side";function Gg(t,e){return!t||!e?!1:t.session===e.session&&(t.node||"")===(e.node||"")}function L4(t,e,n){return!n||!n.session||t&&Gg(t,n)?e:e&&Gg(e,n)?null:{session:n.session,...n.node?{node:n.node}:{},...n.ownerId?{ownerId:n.ownerId}:{}}}function A4(){try{const t=JSON.parse(localStorage.getItem(Kd)||"null");return!t||!t.main||!t.side||!t.main.session||!t.side.session?null:t}catch{return null}}function j4(t,e){try{if(!t||!e||!t.session||!e.session){localStorage.removeItem(Kd);return}const n=s=>({session:s.session,...s.node?{node:s.node}:{}});localStorage.setItem(Kd,JSON.stringify({main:n(t),side:n(e)}))}catch{}}function d1(){try{localStorage.removeItem(Kd)}catch{}}const M4=.2;function cd(t){return Math.max(M4,t)}function T4(){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 P4({onSubmit:t,reason:e=""}){$n();const[n,s]=w.useState(""),[i,a]=w.useState(T4),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 dm=t=>gs(Mi(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 h1(t,e){return t.length?t:Array.isArray(e.floating)&&e.floating.length?[]:void 0}function I4(t,e,n,s,i){const a=c=>za(c&&c.floating,u=>Ha(u,s,i));return UP(a(t),a(e),n)}function f1(t,e,n,s,i,a){const c=v=>Ha(v,i,a),u=v=>za(v&&v.floating,c),{grid:h,floating:f}=$d(n),g=WP(s(h),I4(t,e,f,i,a),{grid:t?c(t.layout):co(),floating:u(t)},{grid:c(e.layout),floating:u(e)},{grid:h,floating:f});return Rg(g.grid,g.floating)}const hm=t=>Array.isArray(t)?t.join("/"):"",D4="nc-decks-cache-v1",DE=t=>`${D4}:${t}`;function O4(t){if(!t)return[];try{const e=localStorage.getItem(DE(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(DE(t),JSON.stringify(e))}catch{}}function $4(t){const e=new Set,n=[];for(const s of Array.isArray(t)?t:[])!s||!Ks.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 tc(t){return{instanceId:t.ownerId,route:t.ownerRoute||[],label:t.ownerLabel,status:t.available===!1?"offline":"up"}}function Mo(t,e,n,s=!1,i=!0){const a=e.instanceId;return{...t,id:Uo(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:Dg(t.layout,a,n)}}function z4(t,e,n,s,i=[],a=[]){const[c,u]=w.useState([]),[h,f]=w.useState(!1),[g,v]=w.useState("idle"),[_,b]=w.useState(""),[k,R]=w.useState(!1),[C,L]=w.useState(""),S=w.useRef([]),T=w.useRef([]),E=w.useRef([]),H=w.useRef(new Map),F=w.useRef(""),X=w.useRef(e),V=w.useRef(n),G=w.useRef(!1),ne=w.useRef(!0),Y=w.useRef(""),B=w.useMemo(()=>$4(i),[i]),P=B.map(Q=>`${Q.instanceId}:${hm(Q.route)}`).join("|"),D=B.map(Q=>`${Q.instanceId}:${Q.status??""}:${Q.checking?"checking":"settled"}`).join("|"),M=w.useRef(new Map(B.map(Q=>[Q.instanceId,Q.checking?"pending":Q.status])));T.current=B,E.current=a,V.current=n,X.current=e,S.current=c;const $=w.useCallback(Q=>Ha(Q.layout,F.current,T.current),[]),A=w.useCallback(()=>Jl(X.current,F.current),[]),j=w.useCallback(Q=>(Array.isArray(Q)?Q:[]).find(ve=>ve.id===A()),[A]),N=w.useCallback((Q,ve=!0,Z)=>{const be=Z===void 0?A():Jl(Z,F.current),K=Pp(Q,Zl(),E.current),fe=S.current.some(Ee=>Ee.id===be);S.current=K,u(K),B4(F.current,K.map(Ee=>{if(!Ee.refreshFailedAt)return Ee;const qe={...Ee};return delete qe.refreshFailedAt,qe}));const Re=K.find(Ee=>Ee.id===be);if(ve&&Re){ne.current=!0;const Ee=Rg($(Re),za(Re.floating,qe=>Ha(qe,F.current,T.current)));s(Ee),Re.local&&uD(Re.name,Mi(Ee))}else fe&&!Re&&(ne.current=!0,s(co()),b("deck non più condiviso dal nodo owner"));oD(K.filter(Ee=>Ee.local).map(Ee=>Ee.name))},[s,$]),U=w.useCallback(async Q=>{let ve=await Uu(t);const Z=ve.decks.find(be=>be.name==="main");if(ve.decks.length===1&&Z&&Z.revision===0&&dm(Z.layout)){const be=rD(),K=Mi(Og("main")||co());if(!dm(K)){const fe=Dg(K,Q,[]);ve.decks[0]=await Wu(t,"main",fe,0,[])}for(const fe of be.filter(Re=>Re!=="main"))try{let Re=await Ww(t,fe,[]);const Ee=Mi(Og(fe)||co());dm(Ee)||(Re=await Wu(t,fe,Dg(Ee,Q,[]),Re.revision,[]))}catch{}ve=await Uu(t)}return ve},[t]),I=w.useCallback((Q,ve)=>{const Z=new Map(ve.map(fe=>[fe.id,fe])),be=new Set,K=[];for(const fe of S.current){if(fe.local||fe.ownerId!==Q.instanceId){K.push(fe);continue}const Re=Z.get(fe.id);Re&&(K.push(Re),be.add(fe.id))}for(const fe of ve)be.has(fe.id)||K.push(fe);N(K,!1)},[N]),W=w.useCallback(async Q=>{try{const[ve,Z]=await Promise.all([Uu(t,Q.route),Fw(t,Q.route).catch(()=>({nodes:[]}))]);I(Q,ve.decks.map(be=>Mo(be,Q,Z.nodes,!1,!0)))}catch(ve){if(ve&&(ve.status===403||ve.status===404)){I(Q,[]);return}const Z=S.current.filter(be=>!be.local&&be.ownerId===Q.instanceId).map(be=>({...be,stale:!0,refreshFailedAt:Date.now(),ownerRoute:[...Q.route],ownerLabel:Q.label}));I(Q,Z)}},[t,I]),se=w.useCallback(async({migrate:Q=!1}={})=>{const ve=await Bc(t,[]),Z=Ks.test(String(ve.instanceId||""))?ve.instanceId:"";if(!Z)throw new Error("instanceId locale non disponibile");F.current=Z,L(Z);const[be,K]=await Promise.all([Q?U(Z):Uu(t),Fw(t,[]).catch(()=>({nodes:[]}))]),fe={instanceId:Z,route:[],label:"Local"},Re=be.decks.map(_e=>Mo(_e,fe,K.nodes,!0,!0)),Ee=new Map(T.current.map(_e=>[_e.instanceId,_e])),qe=S.current.length?S.current:O4(Z),Ze=H.current,at=Date.now(),Oe=qe.filter(_e=>!_e.local).flatMap(_e=>{const $e=Ee.get(_e.ownerId);if(!$e){const rt=Ze.get(_e.ownerId);return rt===void 0?(Ze.set(_e.ownerId,at),[{..._e,available:!1,stale:!0}]):at-rt>Ev?[]:[{..._e,available:!1,stale:!0}]}Ze.delete(_e.ownerId);const nt=$e.status==="up",Fe=$e.status==="pending"||$e.checking===!0;return[{..._e,available:Fe?_e.available:nt?_e.available!==!1:!1,stale:$e.stale===!0,ownerRoute:[...$e.route],ownerLabel:$e.label}]});return setTimeout(()=>{for(const _e of Ee.values())_e.status==="up"&&!_e.checking&&W(_e)},0),[...Re,...Oe]},[t,U,W,P]);w.useEffect(()=>{if(!t)return;let Q=!1;const ve=Y.current!==t;return Y.current=t,se({migrate:ve}).then(Z=>{if(Q)return;const be=j(S.current),K=j(Z),fe=K&&(!be||K.revision>be.revision||be.available!==K.available||hm(be.ownerRoute)!==hm(K.ownerRoute));N(Z,ve||!!fe&&!G.current),f(!0),K&&b("")}).catch(Z=>{Q||(f(!0),b(String(Z.message||Z)))}),()=>{Q=!0}},[N,se,P,t,j]),w.useEffect(()=>{if(!S.current.length)return;const Q=Pp(S.current,Zl(),a);(Q.length!==S.current.length||Q.some((Z,be)=>Z.id!==S.current[be].id))&&(S.current=Q,u(Q))},[a]),w.useEffect(()=>{const Q=M.current,ve=new Map;for(const Z of T.current){if(Z.checking||Z.status==="pending"){ve.set(Z.instanceId,Q.get(Z.instanceId)||"pending");continue}Z.status==="up"&&Q.get(Z.instanceId)!=="up"&&W(Z),ve.set(Z.instanceId,Z.status)}M.current=ve},[D,W]);const me=w.useCallback(async(Q,ve=!0)=>{if(!h||!G.current)return!0;const Z=Q===void 0?A():Jl(Q,F.current),be=S.current.find(K=>K.id===Z);if(!be)return b(`deck inesistente: ${Z}`),!1;if(be.available===!1)return b(`nodo owner offline: ${be.ownerLabel}`),!1;v("saving");try{const{grid:K,floating:fe}=$d(V.current),Re=Ql(Mi(K),be.ownerId,be.ownerTopology),Ee=za(fe,at=>Ql(at,be.ownerId,be.ownerTopology)),qe=await Wu(t,be.name,Re,be.revision,be.ownerRoute,h1(Ee,be)),Ze=Mo(qe,tc(be),be.ownerTopology,be.local,!0);return N(S.current.map(at=>at.id===Z?Ze:at),!1),G.current=!1,v("saved"),b(""),R(!1),setTimeout(()=>v("idle"),1500),!0}catch(K){if(ve&&K.status===409&&K.data&&K.data.current){const fe=S.current.find(Re=>Re.id===Z);if(fe){const Re=Mo(K.data.current,tc(fe),fe.ownerTopology,fe.local,!0),Ee=f1(fe,Re,V.current,qe=>qe,F.current,T.current);return qP(Ee,V.current)||(V.current=Ee,ne.current=!0,s(Ee)),N(S.current.map(qe=>qe.id===Z?Re:qe),!1),G.current=!0,me(Z,!1)}}return v("error"),b(String(K.message||K)),K.status===409&&R(!0),!1}},[h,t,N,s]),pe=w.useCallback(async()=>{try{const Q=await se();G.current=!1,R(!1),N(Q,!0),b("")}catch(Q){b(String(Q.message||Q))}},[se,N]);w.useEffect(()=>{if(!h)return;const Q=ne.current&&!G.current;if(ne.current=!1,Q)return;G.current=!0,v("saving");const ve=setTimeout(me,650);return()=>clearTimeout(ve)},[n,h,me]),w.useEffect(()=>{if(!h)return;const Q=()=>{if(!G.current)return;const ve=S.current.find(Re=>Re.id===A());if(!ve||ve.available===!1)return;const{grid:Z,floating:be}=$d(V.current),K=Ql(Mi(Z),ve.ownerId,ve.ownerTopology),fe=za(be,Re=>Ql(Re,ve.ownerId,ve.ownerTopology));L5(t,ve.name,K,ve.revision,ve.ownerRoute,h1(fe,ve))};return window.addEventListener("pagehide",Q),window.addEventListener("beforeunload",Q),()=>{window.removeEventListener("pagehide",Q),window.removeEventListener("beforeunload",Q)}},[h,t,A]),w.useEffect(()=>{if(!h)return;const Q=setInterval(async()=>{try{const ve=await se(),Z=j(S.current),be=j(ve),K=!!(be&&Z&&be.revision>Z.revision),fe=!!(be&&(!Z||K||Z.available!==be.available));if(K&&G.current&&be){const Re=f1(Z,be,V.current,Ee=>YP($(be),Ee),F.current,T.current);N(ve,!1),s(Re);return}N(ve,fe&&!G.current)}catch{}},5e3);return()=>clearInterval(Q)},[h,se,N,$,s]);const Ie=w.useCallback(Q=>{s(ve=>{const Z=Q(ve);return Z!==ve&&(ne.current=!0),Z})},[]),J=async(Q,ve=null)=>{const Z=ve===Yi?S.current.find(fe=>fe.local):ve?S.current.find(fe=>fe.ownerId===ve):null;if(!Z||Z.available===!1)throw new Error("nodo owner non disponibile");const be=await Ww(t,Q,Z.ownerRoute),K=Mo(be,tc(Z),Z.ownerTopology,Z.local,!0);return N([...S.current,K],!1),K},te=async(Q,ve)=>{const Z=S.current.find(Ee=>Ee.id===Q);if(!Z)throw new Error("deck inesistente");if(Jl(Q,F.current)===A()&&G.current&&!await me(Q))throw new Error(`salvataggio di "${Z.name}" fallito: rinomina annullata`);const be=S.current.find(Ee=>Ee.id===Q);if(!be)throw new Error("deck inesistente");const K=await A5(t,be.name,ve,be.revision,be.ownerRoute),fe=Mo(K,tc(be),be.ownerTopology,be.local,!0),Re=be.local?Yi:be.ownerId;return Tp(lD(Zl(),Re,Q,fe.id)),N(S.current.map(Ee=>Ee.id===Q?fe:Ee),!1),fe},ge=async Q=>{const ve=S.current.find(be=>be.id===Q);if(!ve)throw new Error("deck inesistente");Jl(Q,F.current)===A()&&(G.current=!1),await j5(t,ve.name,ve.revision,ve.ownerRoute);const Z=ve.local?Yi:ve.ownerId;Tp(cD(Zl(),Z,Q)),N(S.current.filter(be=>be.id!==Q),!1)},Se=(Q,ve)=>{const Z=S.current.find(qe=>qe.id===Q),be=S.current.find(qe=>qe.id===ve);if(!Z||!be)return!1;const K=Z.local?Yi:Z.ownerId,fe=be.local?Yi:be.ownerId;if(K!==fe)return!1;const Re=S.current.filter(qe=>(qe.local?Yi:qe.ownerId)===K).map(qe=>qe.id),Ee=Tp(aD(Zl(),K,Q,ve,Re));return N(Pp(S.current,Ee),!1),!0},Be=async(Q,ve)=>{const Z=S.current.find(qe=>qe.id===Q);if(!Z)throw new Error("deck inesistente");if(Z.available===!1)throw new Error(`nodo owner offline: ${Z.ownerLabel}`);const be=NC(ve,F.current,T.current);if(!be)throw new Error("riferimento sessione non valido");const K=$(Z),fe=Ql(nC(K,be),Z.ownerId,Z.ownerTopology),Re=await Wu(t,Z.name,fe,Z.revision,Z.ownerRoute),Ee=Mo(Re,tc(Z),Z.ownerTopology,Z.local,!0);return N(S.current.map(qe=>qe.id===Q?Ee:qe),!1),Ee},Le=w.useCallback(Q=>Rg($(Q),za(Q.floating,ve=>Ha(ve,F.current,T.current))),[$]);return{decks:c,records:c,localNodeId:C,ready:h,saveState:g,error:_,setError:b,conflict:k,reloadCurrent:pe,saveNow:me,select:async Q=>{if(G.current&&!await me(A()))throw new Error("salvataggio del deck corrente fallito: cambio annullato");const ve=S.current.find(Z=>Z.id===Q);if(!ve)throw new Error(`deck inesistente: ${Q}`);return G.current=!1,ne.current=!0,Le(ve)},add:J,rename:te,remove:ge,reorder:Se,addTileTo:Be,viewUpdate:Ie,vistaMaterializzata:Le,localMainId:Uo(null,"main"),parseDeckId:Kc}}const F4="/sw.js",Xg="nc-sw-update";let Oc=null,Vd=!1,Yd=null,OE=Object.freeze({needed:!1,kind:null,version:"",browserVersion:""}),BE=!1;function h_(){typeof window<"u"&&window.dispatchEvent(new Event(Xg))}function f_(){const t=Yd||(Vd?{kind:"reload",version:"",browserVersion:""}:null);OE=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 p1(){return OE}function H4(t){return typeof window>"u"?()=>{}:(window.addEventListener(Xg,t),()=>window.removeEventListener(Xg,t))}function p_(t){Vd!==t&&(Vd=t,f_(),h_())}const ud="nc-auto-reload",Gd="nc-reload";function m_(){try{return typeof location<"u"?location:null}catch{return null}}function $E(){try{return typeof history<"u"?history:null}catch{return null}}function U4(t){const e=t===void 0?m_():t;if(!e||typeof e.search!="string")return null;try{return new URLSearchParams(e.search).get(Gd)}catch{return null}}function W4(t,{location:e,history:n}={}){const s=e===void 0?m_():e,i=n===void 0?$E():n;if(!s||!i||typeof i.replaceState!="function")return!1;try{const a=new URLSearchParams(s.search||"");return a.set(Gd,t),i.replaceState(i.state??null,"",`${s.pathname||"/"}?${a.toString()}${s.hash||""}`),!0}catch{return!1}}function q4({location:t,history:e}={}){const n=t===void 0?m_():t,s=e===void 0?$E():e;if(!n||!s||typeof s.replaceState!="function")return!1;try{const i=new URLSearchParams(n.search||"");if(!i.has(Gd))return!1;i.delete(Gd);const a=i.toString();return s.replaceState(s.state??null,"",`${n.pathname||"/"}${a?`?${a}`:""}${n.hash||""}`),!0}catch{return!1}}const zE="nc-update-dismissed";function FE(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function K4(t,e,n){return[t,e,n].map(s=>s||"").join("|")}let Jg=null;function V4(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 Y4(t,e){if(!t)return!1;try{return t.getItem(zE)===e}catch{return!1}}function G4(t={}){const e=t.storage===void 0?FE():t.storage;if(Jg&&e)try{e.setItem(zE,Jg)}catch{}Vd=!1,Yd=null,f_(),h_()}function X4(t,e,n,s={}){const i=s.storage===void 0?FE():s.storage,a=n,c=K4(t,e,a);Jg=c;const u=V4(t,e,a);let h=Y4(i,c)?null:u;if(h&&h.kind==="stale"){const g=`${e}|${a}`,v=U4(s.location)===g;let _=!1;if(!v&&i&&i.getItem(ud)!==g){try{i.setItem(ud,g)}catch{}_=i.getItem(ud)===g}_&&(W4(g,{location:s.location,history:s.history}),(s.applyImpl||HE)(),h=null)}const f=JSON.stringify(h)===JSON.stringify(Yd);if(Yd=h,f_(),f||h_(),!u){try{i&&i.removeItem(ud)}catch{}q4({location:s.location,history:s.history})}}const J4=1200;async function m1(t){if(typeof fetch=="function")try{await Promise.race([fetch(t,{cache:"reload"}),new Promise(e=>setTimeout(e,J4))])}catch{}}async function HE(){try{Oc&&await Oc.update()}catch{}typeof location<"u"&&(await m1(location.pathname),await m1("/version.json"),location.reload())}function Q4(t){t.addEventListener("statechange",()=>{t.state==="installed"&&navigator.serviceWorker.controller&&p_(!0)})}function Z4(){typeof navigator>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{BE&&location.reload()}),navigator.serviceWorker.register(F4).then(t=>{Oc=t,t.waiting&&p_(!0),t.addEventListener("updatefound",()=>{const e=t.installing;e&&Q4(e)}),setInterval(()=>{t.update().catch(()=>{})},3600*1e3)}).catch(()=>{}))}function eO(){BE=!0,p_(!1);const t=Oc&&Oc.waiting;t?(t.postMessage({type:"SKIP_WAITING"}),setTimeout(()=>location.reload(),4e3)):location.reload()}function tO({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 UE="nc_side_w",g1="nc_side_min",nO=240,v1=new Set(["absent","present","active","unknown"]);function sO(){const t=Number(localStorage.getItem(UE));return t>=180&&t<=480?t:nO}function iO(){const t={token:"",pair:""};try{const{token:e,pair:n,device:s,nextUrl:i}=tO({hash:location.hash,origin:location.origin,pathname:location.pathname,search:location.search});if(e&&(t.token=e,R1(e,{remember:!0})),s&&I6(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=RN()),!t.pair){const e=sessionStorage.getItem("nc_pair");e&&(t.pair=e)}return t}function _1(t){try{return Mi(Og(t))}catch{return co()}}function y1(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 rO({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 oO(t,e){if(!t||!t.tmux)return"";const n=Tv(t,e||{});return n.stato==="lavora"?p("cell-working"):n.stato==="attesa"?p("cell-permission"):n.stato==="ferma"?p("cell-idle"):""}function w1({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;$n();const[k]=zv(),R=Ek(),[C,L]=w.useState(!1),[S,T]=w.useState(null),[E,H]=w.useState(()=>k.showComposer),[F,X]=w.useState(Yg),[V,G]=w.useState(()=>Ec()),ne=()=>{Sk(JM(Ec())),typeof window<"u"&&window.location.reload()},[Y,B]=w.useState(s||t),[P,D]=w.useState(""),[M,$]=w.useState(""),[A,j]=w.useState(""),[N,U]=w.useState(!1),[I,W]=w.useState(!1),se=!!v&&I,[me,pe]=w.useState(!1),[Ie,J]=w.useState({v:{main:1,side:1},h:{main:1,side:1}}),[te,ge]=w.useState(()=>window.matchMedia("(orientation: landscape)").matches);w.useEffect(()=>{const oe=window.matchMedia("(orientation: landscape)"),Me=Ke=>ge(Ke.matches);return oe.addEventListener("change",Me),()=>oe.removeEventListener("change",Me)},[]);const Se=te?Ie.h:Ie.v,Be=w.useRef(Se);Be.current=Se;const[Le,ze]=w.useState(null),[Q,ve]=w.useState(!0),Z=w.useRef(()=>{}),be=w.useRef(()=>!1),K=w.useRef(()=>{}),fe=w.useRef(!1),Re=w.useRef(!1),Ee=w.useRef(null),qe=w.useRef(null),[Ze,at]=w.useState(null),Oe=w.useCallback(oe=>at({source:"main",ev:oe}),[]),_e=w.useCallback(oe=>at({source:"side",ev:oe}),[]),$e=!!v&&(Ze==null?void 0:Ze.source)==="side",nt=oe=>{W(oe),bt((oe?fe:ft).current),Mt((oe?Re:xt).current)},Fe=v?`${v.node||""}:${v.session}`:"";w.useEffect(()=>{W(!1),pe(!1),J({v:{main:1,side:1},h:{main:1,side:1}}),ze(null),at(oe=>oe&&oe.source==="side"?null:oe)},[Fe]);const rt=w.useMemo(()=>{const oe=new Map;return Me=>{if(oe.has(Me))return oe.get(Me);let Ke=Me*.6;try{const mt=document.createElement("span");mt.style.cssText="position:absolute;visibility:hidden;white-space:pre;font-family:courier-new,courier,monospace;",mt.style.fontSize=`${Me}px`,mt.textContent="0".repeat(20),document.body.appendChild(mt);const q=mt.getBoundingClientRect().width;document.body.removeChild(mt),Number.isFinite(q)&&q>0&&(Ke=q/20)}catch{}return oe.set(Me,Ke),Ke}},[]),re=Math.max(.01,Se.main+Se.side),ce=((le=qe.current)==null?void 0:le.clientWidth)||window.innerWidth,O=Math.max(0,ce-12)*(Math.min(Se.main,Se.side)/re)-26,de=!!v&&te&&O/rt(Math.max(1,F))<40,we=oe=>X(Me=>IE(Me+oe));w.useEffect(()=>{f||X(Yg())},[f]);const We=w.useRef(()=>{}),ie=w.useRef(()=>!1),Pe=w.useRef(()=>{}),ft=w.useRef(!1),[Pt,bt]=w.useState(!1),xt=w.useRef(!1),[vt,Mt]=w.useState(!1),Qt=w.useRef(null),[Dt,It]=w.useState(!1),en=()=>{const oe=se?fe:ft;oe.current=!oe.current,bt(oe.current)},Kn=()=>{const oe=se?Re:xt;oe.current=!oe.current,Mt(oe.current)};w.useEffect(()=>{B(s||t),U(!1)},[s,t]);const rn=oe=>{const Me=!oe||oe.sessionsError?null:oe.sessionsJson;let Ke=null;Me&&Array.isArray(Me.sessions)&&(Ke=Me.sessions.find(Te=>Te.name===t));const mt=!oe||oe.fleetError?null:oe.fs;let q=null;mt&&mt.available&&Array.isArray(mt.cells)&&(q=mt.cells.find(Te=>Te.tmuxSession===t)),B(Mc({session:t,cell:q||(s?{cell:s}:null)})),$(typeof(q==null?void 0:q.panelUrl)=="string"?q.panelUrl.trim():""),j(typeof(q==null?void 0:q.cell)=="string"?q.cell:"");let ae="";q?ae=[`${q.engine}${q.key?`·${q.key}`:""}`,oO(q,Ke)].filter(Boolean).join(" · "):Ke&&(ae=Ke.attached?`attached · ${y1(Ke.activity)}`:Ke.activity?y1(Ke.activity):""),D(ae),ve(!!(Ke||q))},tn=w.useRef(rn);tn.current=rn,w.useEffect(()=>{const oe=e?e.split("/"):[],Me=Ke=>tn.current(Ke);return Me(sc(oe)),wc(i,oe,Me)},[e,i]),w.useEffect(()=>{tn.current(sc(e?e.split("/"):[]))},[t,s]);const nn=w.useRef(b);nn.current=b;const mn=oe=>{var Ge;if(!v)return;const Me=!oe||oe.sessionsError?null:oe.sessionsJson;let Ke=null,mt=!1;Me&&Array.isArray(Me.sessions)&&(mt=!0,Ke=Me.sessions.find(Ae=>Ae.name===v.session));const q=!oe||oe.fleetError?null:oe.fs;let ae=null,Te=!1;q&&q.available&&Array.isArray(q.cells)&&(Te=!0,ae=q.cells.find(Ae=>Ae.tmuxSession===v.session)),ze({title:Mc({session:v.session,cell:ae}),present:!!(Ke||ae)}),(mt||Te)&&!Ke&&!ae&&((Ge=nn.current)==null||Ge.call(nn))},Wt=w.useRef(mn);Wt.current=mn,w.useEffect(()=>{if(!v){ze(null);return}const oe=v.node?v.node.split("/"):[],Me=Ke=>Wt.current(Ke);return Me(sc(oe)),wc(i,oe,Me)},[v,v==null?void 0:v.node,i]),w.useEffect(()=>{v&&Wt.current(sc(v.node?v.node.split("/"):[]))},[v==null?void 0:v.session]);const Zt=se?"side":"main",yn=()=>at(oe=>oe&&oe.source===Zt?null:{source:Zt,ev:null}),[Vt,ln]=w.useState(dE),[Vs]=w.useState(fE),[vs]=w.useState(pE),qt=rO({showComposer:E,showFiles:(Ze==null?void 0:Ze.source)===Zt,showPanel:N,hasPanel:!!M,rendererKind:V,filesSetting:R?null:Vt,handlers:{onToggleComposer:()=>H(oe=>!oe),onToggleFiles:R?yn:()=>ln(oe=>(hE(!oe),!oe)),onTogglePanel:()=>U(oe=>!oe),onSwitchRenderer:ne}}),Ys=oe=>{oe.preventDefault();const Me=qe.current;if(!Me)return;const Ke=(Ct,_t)=>J(Qe=>({...Qe,[te?"h":"v"]:{main:Ct,side:_t}}));if(te){const Ct=oe.clientX,_t=Be.current,Qe=Me.clientWidth||1,Lt=me?-1:1,Tn=st=>{const Ht=_t.main+_t.side,ke=(st.clientX-Ct)/Qe*Ht*Lt,je=cd(_t.main+ke);Ke(je,cd(Ht-je))},Xe=()=>{window.removeEventListener("pointermove",Tn),window.removeEventListener("pointerup",Xe),window.removeEventListener("pointercancel",Xe),window.removeEventListener("blur",Xe)};window.addEventListener("pointermove",Tn),window.addEventListener("pointerup",Xe),window.addEventListener("pointercancel",Xe),window.addEventListener("blur",Xe);return}const mt=oe.clientY,q=Be.current,ae=Me.clientHeight||1,Te=me?-1:1,Ge=Ct=>{const _t=q.main+q.side,Qe=(Ct.clientY-mt)/ae*_t*Te,Lt=cd(q.main+Qe);Ke(Lt,cd(_t-Lt))},Ae=()=>{window.removeEventListener("pointermove",Ge),window.removeEventListener("pointerup",Ae),window.removeEventListener("pointercancel",Ae),window.removeEventListener("blur",Ae)};window.addEventListener("pointermove",Ge),window.addEventListener("pointerup",Ae),window.addEventListener("pointercancel",Ae),window.addEventListener("blur",Ae)},Vn=v&&l.jsxs("div",{className:`nc-dual-pane${se?"":" foco"}${de&&se?" nascosto":""}`,"data-testid":"pane-main",style:{flexGrow:Se.main,flexBasis:te?0:void 0},onPointerDown:()=>nt(!1),children:[l.jsxs("div",{className:"nc-dual-strip",children:[l.jsx("span",{className:`nc-dual-dot${Q?" on":""}`,"aria-hidden":"true"}),l.jsx("b",{children:Y}),!se&&l.jsx("span",{className:"nc-dual-matita","aria-hidden":"true",title:p("dual-focus"),children:"✎"}),de&&l.jsxs("button",{type:"button",className:"nc-dual-alt",title:p("dual-go-to").replace("{cell}",(Le==null?void 0:Le.title)||v.session),"aria-label":p("dual-go-to").replace("{cell}",(Le==null?void 0:Le.title)||v.session),onPointerDown:oe=>oe.stopPropagation(),onClick:oe=>{oe.stopPropagation(),nt(!se)},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${Le!=null&&Le.present?" on":""}`,"aria-hidden":"true"})]})]}),l.jsx("div",{className:"nc-dual-body",children:l.jsx(gc,{session:t,node:e,token:i,readonly:a,takeSize:!0,focused:!se,sendRef:We,composerRef:ie,actionRef:Pe,ctrlRef:ft,setCtrlArmed:bt,altRef:xt,setAltArmed:Mt,keyboardRef:Qt,onFiles:Oe,fontSize:F,selectionMode:Dt,onSelectionModeChange:It,keyboardGesture:k.terminalKeyboardGesture,onRendererChange:G})})]},"pane-main"),ls=v&&l.jsxs("div",{className:`nc-dual-pane${se?" foco":""}${de&&!se?" nascosto":""}`,"data-testid":"pane-side",style:{flexGrow:Se.side,flexBasis:te?0:void 0},onPointerDown:()=>nt(!0),children:[l.jsxs("div",{className:"nc-dual-strip",children:[l.jsx("span",{className:`nc-dual-dot${Le!=null&&Le.present?" on":""}`,"aria-hidden":"true"}),l.jsx("b",{children:Le?Le.title:v.session}),se&&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:oe=>oe.stopPropagation(),onClick:oe=>{oe.stopPropagation(),pe(Me=>!Me)},children:te?"⇆":"⇅"}),l.jsx("button",{type:"button",title:p("dual-close"),"aria-label":p("dual-close"),onPointerDown:oe=>oe.stopPropagation(),onClick:oe=>{oe.stopPropagation(),_==null||_()},children:"✕"})]}),de&&l.jsxs("button",{type:"button",className:"nc-dual-alt",title:p("dual-go-to").replace("{cell}",Y),"aria-label":p("dual-go-to").replace("{cell}",Y),onPointerDown:oe=>oe.stopPropagation(),onClick:oe=>{oe.stopPropagation(),nt(!se)},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${Q?" on":""}`,"aria-hidden":"true"})]})]}),l.jsx("div",{className:"nc-dual-body",children:l.jsx(gc,{session:v.session,node:v.node,token:i,readonly:a,takeSize:!1,focused:se,sendRef:Z,composerRef:be,actionRef:K,ctrlRef:fe,setCtrlArmed:bt,altRef:Re,setAltArmed:Mt,keyboardRef:Ee,onFiles:_e,fontSize:F,selectionMode:Dt,onSelectionModeChange:It,keyboardGesture:k.terminalKeyboardGesture})})]},"pane-side"),St=l.jsx("div",{className:"nc-dual-handle","data-testid":"dual-handle",role:"separator","aria-orientation":te?"vertical":"horizontal",onPointerDown:Ys},"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?`${Y} · ${e}`:Y,children:Y}),g&&g.cell&&g.cell===s?l.jsx("span",{className:`nc-live-host-dot ${ov(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,P&&l.jsx("small",{className:"nc-bar-sub",children:P})]}),l.jsxs("span",{className:"nc-bar-right",children:[l.jsx("button",{onClick:()=>we(-1),title:p("zoom-out"),"aria-label":p("zoom-out"),children:l.jsx(Tt,{name:"zoomOut",size:18})}),l.jsx("button",{onClick:()=>we(1),title:p("zoom-in"),"aria-label":p("zoom-in"),children:l.jsx(Tt,{name:"zoomIn",size:18})}),Vt&&l.jsx("button",{type:"button",onClick:yn,title:p("bar-menu-files"),"aria-label":p("bar-menu-files"),"aria-pressed":(Ze==null?void 0:Ze.source)===Zt?"true":"false",children:l.jsx(Tt,{name:"folder",size:18})}),Vs&&l.jsx("button",{type:"button",onClick:()=>H(oe=>!oe),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&&vs&&l.jsx("button",{type:"button",onClick:()=>U(oe=>!oe),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${C?" on":""}`,title:p("bar-menu-open"),"aria-label":p("bar-menu-open"),"aria-haspopup":"menu","aria-expanded":C?"true":"false",onClick:oe=>{C||T(oe.currentTarget.getBoundingClientRect()),L(Me=>!Me)},children:"⋯"})]})]}),l.jsxs("div",{className:"nc-termwrap",children:[v?l.jsx("div",{className:`nc-dual${te?" row":""}`,ref:qe,children:de?me?[ls,Vn]:[Vn,ls]:me?[ls,St,Vn]:[Vn,St,ls]}):l.jsx(gc,{session:t,node:e,token:i,readonly:a,takeSize:!0,sendRef:We,composerRef:ie,actionRef:Pe,ctrlRef:ft,setCtrlArmed:bt,altRef:xt,setAltArmed:Mt,keyboardRef:Qt,onFiles:Oe,fontSize:F,selectionMode:Dt,onSelectionModeChange:It,keyboardGesture:k.terminalKeyboardGesture,onRendererChange:G}),N&&M&&A&&l.jsx(bv,{cellId:A,panelUrl:M,route:e?e.split("/"):[],panelPort:c,token:i,title:Y})]}),l.jsx(yI,{onKeyboard:()=>H(oe=>!oe),onCellSwitcher:h,cellSwitcherOpen:f,send:oe=>(se?Z:We).current(oe),action:oe=>(se?K:Pe).current(oe),ctrlArmed:Pt,onCtrl:en,altArmed:vt,onAlt:Kn,onAltConsume:()=>{const oe=se?Re:xt;oe.current=!1,Mt(!1)},onKeyboardKeep:()=>{var oe,Me;return(Me=(oe=se?Ee:Qt).current)==null?void 0:Me.call(oe)},selectionMode:Dt,onSelectionMode:It,keepKeyboardClosed:k.keybarKeepsKeyboardClosed,showEnter:k.showKeybarEnter,keybarLayout:k.keybarLayout}),E&&l.jsx(wC,{submitText:oe=>(se?be:ie).current(oe),token:i,session:se?v.session:t,node:se?v.node:e,ownerId:se?v.ownerId:n,readonly:a,keepKeyboardClosedOnVoice:k.voiceKeepsKeyboardClosed}),Ze&&($e?l.jsx(Mg,{session:v.session,node:v.node,token:i,filesEvent:Ze.ev,onClose:()=>at(null)}):Ze.source==="main"?l.jsx(Mg,{session:t,node:e,token:i,filesEvent:Ze.ev,onClose:()=>at(null)}):null),C&&(R?l.jsx(Vk,{anchorRect:S,items:qt,onClose:()=>L(!1)}):l.jsx(Mv,{cellName:Y,items:qt,onClose:()=>L(!1)}))]})}function aO(){$n();const[t]=w.useState(iO),[e,n]=w.useState(t.token),[s,i]=w.useState(!1);q6(s?"":e);const a=w.useRef(t.token);a.current=e,w.useEffect(()=>{const ke=je=>{je&&je.detail&&je.detail.token===a.current&&i(!0)};return window.addEventListener(pm,ke),()=>window.removeEventListener(pm,ke)},[]);const c=w.useCallback((ke,je)=>{const Je=R1(ke,{remember:je});if(!Je.ok||je&&Je.where!=="local")try{window.dispatchEvent(new CustomEvent(mm))}catch{}i(!1),n(ke)},[]),[u,h]=w.useState(t.pair||""),f=w.useCallback(()=>{h("");try{sessionStorage.removeItem("nc_pair")}catch{}},[]),g=Ek(),[v]=w.useState(()=>iD(typeof location<"u"?location.pathname:"/")),[_,b]=w.useState(v.id),k=_===Uo(null,si),[R,C]=w.useState(null),L=ke=>{const je=Nr(ke);C(je?{...je,...typeof(ke==null?void 0:ke.cellName)=="string"&&ke.cellName?{cellName:ke.cellName}:{}}:null)},[S,T]=w.useState(null);w.useEffect(()=>{const ke=A4();T(ke&&R&&Gg(ke.main,R)?ke.side:null)},[R]);const E=ke=>{const je=R?{session:R.session,node:R.node}:null,Je=L4(je,S,ke);T(Je),Je?j4(je,Je):d1()},H=()=>{T(null),d1()},[F,X]=w.useState([]),[V,G]=w.useState(!0),[ne,Y]=w.useState(null),[B,P]=w.useState([]),[D,M]=w.useState([]),[$,A]=w.useState(!1),[j,N]=w.useState(null),[U,I]=w.useState(()=>v.ownerId?co():_1(v.name)),[W,se]=w.useState(null),[me,pe]=w.useState(null),Ie=ke=>pe(Nr(ke)),[J,te]=w.useState(null),ge=Nv(e,g),Se=w.useMemo(()=>(ge||[]).filter(ke=>ke.instanceId).map(ke=>({instanceId:ke.instanceId,route:ke.route,label:ke.label,status:ke.status,stale:ke.stale===!0,checking:ke.checking===!0})),[ge]),{order:Be}=dh(),Le=z4(e,_,U,I,Se,Be),{notice:ze,showActionNotice:Q}=dC(),ve=Le.decks;w.useEffect(()=>{const ke=new Map;for(const je of ge||[]){const Je=(je.route||[je.name]).join("/"),ct=new Set((je.sessions||[]).map(kt=>kt.name));for(const kt of je.cells||[])!kt.cell||!kt.tmuxSession||kt.cell===kt.tmuxSession||ct.has(kt.cell)||ke.set(`${Je}:${kt.cell}`,`${Je}:${kt.tmuxSession}`)}I(je=>OP(je,ke))},[ge]),w.useEffect(()=>{Le.localNodeId&&v.ownerId&&v.ownerId===Le.localNodeId&&I(ke=>ke.columns.some(je=>je.tiles.length)?ke:_1(v.name))},[Le.localNodeId]),w.useEffect(()=>{Le.localNodeId&&(ZI(Se),Le.viewUpdate(ke=>{const je=Ha(ke,Le.localNodeId,Se);return JSON.stringify(je)===JSON.stringify(ke)?ke:je}))},[Se,Le.localNodeId,Le.viewUpdate]);const[Z,be]=w.useState(null),[K,fe]=w.useState(null),Re=w.useRef(0),[Ee,qe]=w.useState(!1),[Ze,at]=w.useState(sO),[Oe,_e]=w.useState(!k),[$e,nt]=w.useState(()=>k?localStorage.getItem(g1)==="1":!0),[Fe,rt]=w.useState(!1),[re,ce]=w.useState("nodes"),[O,de]=w.useState(!1),[we,We]=w.useState(""),[ie,Pe]=w.useState(!1),ft=(ke="nodes",je=!1,Je="")=>{ce(ke),de(je),We(Je),rt(!0)},[Pt,bt]=w.useState(!1),[xt,vt]=w.useState(null),[Mt,Qt]=w.useState({deviceDefault:"",localNodeId:"",localNameDefault:"",deviceNameNeeded:!1,deviceNameSuggestion:""}),[Dt,It]=w.useState(""),[en,Kn]=w.useState(!1),[rn,tn]=w.useState(0),[nn,mn]=w.useState({});w.useEffect(()=>{try{localStorage.setItem(UE,String(Ze))}catch{}},[Ze]),w.useEffect(()=>{try{localStorage.setItem(g1,$e?"1":"")}catch{}},[$e]),w.useEffect(()=>{if(!e)return;let ke=!1;return Promise.all([O1(e),Wn("/api/config",e).then(je=>je.json())]).then(([je,Je])=>{if(!ke){if(Qt({deviceDefault:je.deviceName||"",localNodeId:je.nodeId||"",localNameDefault:je.localName||"",deviceNameNeeded:je.deviceNameNeeded===!0,deviceNameSuggestion:je.deviceNameSuggestion||""}),It(je.deviceName||""),Kn(!!Je.readonlyDefault),tT(Je.terminal),tn(Number.isInteger(Je.panelPort)?Je.panelPort:0),mn(Je.nodePanelPorts&&typeof Je.nodePanelPorts=="object"&&!Array.isArray(Je.nodePanelPorts)?Je.nodePanelPorts:{}),WT(Je.hostOnlyNodes),je.firstRun===!0&&!Je.readonlyDefault)bt(!0);else if(u)bt(!0);else if(je.deviceNameNeeded===!0&&!Je.readonlyDefault){let ct=!1;try{ct=sessionStorage.getItem("nc_device_ask_later")==="1"}catch{}ct||vt({suggestion:je.deviceNameSuggestion||""})}}}).catch(()=>{}),()=>{ke=!0}},[e,u]);const[Wt,Zt]=w.useState({}),yn=w.useCallback(({route:ke,hostCell:je,revision:Je})=>{const ct=Ns(ke);Zt(kt=>({...kt,[ct]:{hostCell:je||null,hostLease:null,hostRevision:Number.isInteger(Je)?Je:(kt[ct]||{}).hostRevision||0,threadStatus:"absent"}}))},[]),Vt=ke=>{const je=Ns(ke),Je=ke.length?((ge||[]).find(ct=>Ns(Array.isArray(ct.route)?ct.route:[])===je)||{}).cells||[]:B;return Wa({liveHost:Wt[je]||null,cells:Je,localNodeId:Le.localNodeId,ownerId:ke.length?je:Le.localNodeId})},ln=w.useRef(ge);w.useEffect(()=>{ln.current=ge},[ge]);const Vs=w.useRef(null);Vs.current||(Vs.current=th());const vs=3500;w.useEffect(()=>{let ke=!1;const je=async()=>{const ct=Vs.current,kt=ct.begin();if(kt!==null)try{const Gs=[[],...(ln.current||[]).filter(Jt=>Jt.kind!=="vl"&&Jt.status==="up").map(Jt=>Array.isArray(Jt.route)&&Jt.route.length?Jt.route:[Jt.name])],wi=await Promise.all(Gs.map(async Jt=>{const _s=Ns(Jt);try{const Ot=await Qd(e,Jt,{timeoutMs:vs});return[_s,{hostCell:Ot&&typeof Ot.hostCell=="string"?Ot.hostCell:null,hostLease:Ot&&Ot.host&&typeof Ot.host.lease=="string"?Ot.host.lease:null,hostRevision:Number.isInteger(Ot&&Ot.revision)?Ot.revision:0,threadStatus:Ot&&v1.has(Ot.threadStatus)?Ot.threadStatus:"unknown"}]}catch{return[_s,{error:!0}]}}));if(ke||!ct.isCurrent(kt))return;Zt(Jt=>{let _s=!1;const Ot={...Jt};for(const Os of wi){if(!Os)continue;const[po,sr]=Os;Ot[po]=sr.error?{...Jt[po]||{},threadStatus:"unknown"}:sr,_s=!0}return _s?Ot:Jt})}finally{ct.end(kt)}};je();const Je=setInterval(je,4e3);return()=>{ke=!0,clearInterval(Je),Vs.current.reset()}},[e]),w.useEffect(()=>{if(!g)return;const ke=je=>{if(!je)return;const Je=je.sessionsError?null:je.sessionsJson;Je&&!Je.error?(X(Je.sessions||[]),G(!0),Y(je.at)):G(!1);const ct=ch({fs:je.fs,error:je.fleetError});ct.kind==="data"?(Ka("local",ct.cells),P(ct.cells),M(ct.capabilities),A(!1),N(null)):ct.kind==="stale"?(P(kt=>kt.length?kt:Cv("local")),A(!0),N(null)):(P([]),Ka("local",[]),M([]),A(!1),N(ct.reason||""))};return ke(sc([])),wc(e,[],ke)},[g,e]);const qt=w.useCallback(async(ke,je=[])=>{const Je=Ns(je),ct=Wt[Je]&&Wt[Je].hostRevision||0;try{const kt=await Zd(e,ke,ct,je);return Zt(Gs=>({...Gs,[Je]:{hostCell:kt.hostCell||null,hostLease:kt.host&&typeof kt.host.lease=="string"?kt.host.lease:null,hostRevision:Number.isInteger(kt.revision)?kt.revision:ct,threadStatus:v1.has(kt.threadStatus)?kt.threadStatus:"unknown"}})),{ok:!0}}catch(kt){return{ok:!1,error:kt}}},[e,Wt]),Ys=w.useCallback(async(ke,je=[])=>{const Je=await qt(ke,je);return Je.ok||window.alert(p(_m(Je.error))),Je.ok},[qt]),Vn=w.useCallback(async(ke=[])=>{const je=Ns(ke),Je=Wt[je]&&Wt[je].hostRevision||0;try{const ct=await eh(e,Je,ke);return Zt(kt=>({...kt,[je]:{hostCell:ct.hostCell||null,hostLease:null,hostRevision:Number.isInteger(ct.revision)?ct.revision:Je,threadStatus:"unknown"}})),{ok:!0}}catch(ct){return{ok:!1,error:ct}}},[e,Wt]),ls=w.useCallback(async(ke=[])=>{const je=await Vn(ke);return je.ok||window.alert(p(_m(je.error))),je.ok},[Vn]);w.useEffect(()=>{let ke=!1;const je=()=>{Wn("/api/config",e).then(ct=>ct.json()).then(ct=>{ke||X4(ct.version,ct.uiVersion,"0.9.68")}).catch(()=>{})};je();const Je=setInterval(je,6e4);return()=>{ke=!0,clearInterval(Je)}},[e]);const St=new Set([...F.map(ke=>ke.name),...ge.flatMap(ke=>ke.sessions.map(je=>je.key))]),le=w.useMemo(()=>{const ke=new Map;for(const je of F)je&&typeof je.name=="string"&&Number.isFinite(je.created)&&ke.set(je.name,je.created);return ke},[F]),oe=gs(U),Me=ke=>I(je=>{const Je=NC(ke,Le.localNodeId,Se)||ke,ct=nC(je,Je);return ct===je&&gs(je).length>=9&&Le.setError(p("grid-full")),ct}),Ke=async(ke,je=[])=>{try{await ev(e,ke,je)}catch{return}const Je=je.length?`${je.join("/")}:${ke}`:ke;I(ct=>jc(ct,Je)),ic(je,e)},mt=async(ke,je,Je=[])=>{try{await D1(e,ke,je,Je)}catch{return}ic(Je,e)},q=async(ke,je,Je=[])=>{await T1(e,{cell:ke,enabled:!!je},Je),ic(Je,e)},ae=async ke=>{if(!Z)return;const{cell:je}=Z,Je=Array.isArray(Z.route)?Z.route:[];if(!await Dv({token:e,powerCell:Z,payload:ke,onNotice:Q})){const kt=ke.action==="up"?!!ke.boot:ke.boot?!1:!!Z.boot;fe({id:++Re.current,cell:je,route:Je,enabled:kt})}ic(Je,e)},Te=w.useCallback(ke=>{fe(je=>(je==null?void 0:je.id)===ke?null:je)},[]),Ge=async ke=>{if(!(!(ke!=null&&ke.direct)||Ee)){qe(!0);try{await sv(e,ke.name,ke.tunnelStatus==="up"?"down":"up")}finally{qe(!1)}}},Ae=async(ke,je)=>{const Je=String(je||"").trim();return!(ke!=null&&ke.direct)||!Ya(Je)?!1:(await F1(e,ke.name,Je),!0)},Ct=ke=>{const je=ve.find(Je=>Je.id===ke);if(!je)return!1;try{const Je=window.open(Mp(je,e),"_blank");return Je&&(Je.opener=null),!!Je}catch{return!1}},_t=async ke=>{if(!ke||ke===_)return;const je=await Le.select(ke),Je=Le.records.find(ct=>ct.id===ke);b(ke),I(je),se(null),pe(null);try{history.replaceState(null,"",Mp(Je||ke,null))}catch{}},Qe=async(ke,je)=>{const Je=await Le.add(ke,je);await _t(Je.id)},Lt=async(ke,je)=>{const Je=await Le.rename(ke,je);if(ke===_){b(Je.id),I(Le.vistaMaterializzata(Je)),se(null),pe(null);try{history.replaceState(null,"",Mp(Je,null))}catch{}}},Tn=async ke=>{await Le.remove(ke),ke===_&&await _t(Le.localMainId)},Xe=async(ke,je)=>{!je||je===_||(await Le.addTileTo(je,ke),I(Je=>jc(Je,ke)))};if(!e||s)return l.jsx(P4,{onSubmit:c,reason:s?"invalid":""});const st=l.jsxs(l.Fragment,{children:[Fe&&l.jsx(i4,{token:e,initialTab:re,initialLocation:we,startNewCell:O,onClose:()=>{rt(!1),de(!1),We("")}}),Pt&&l.jsx(r4,{token:e,initialPair:u,...Mt,onPairDone:f,onDone:()=>bt(!1)}),xt&&l.jsx(o4,{token:e,suggestion:xt.suggestion,onSaved:ke=>{It(ke),Qt(je=>({...je,deviceDefault:ke,deviceNameNeeded:!1})),vt(null)},onLater:()=>{try{sessionStorage.setItem("nc_device_ask_later","1")}catch{}vt(null)}}),l.jsx(w4,{token:e})]});if(!g)return J?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"nc-single-overlay",children:l.jsx(u1,{peer:J,token:e,onBack:()=>te(null)})}),st]}):R?l.jsxs(l.Fragment,{children:[l.jsx(w1,{session:R.session,node:R.node,ownerId:R.ownerId,cellName:R.cellName,token:e,readonly:en,liveHost:Vt(R.node?R.node.split("/"):[]),panelPort:Nc(R.node?R.node.split("/"):[],nn,rn),side:S,onSideClose:H,onSideGone:H,onBack:()=>C(null),onCellSwitcher:()=>Pe(!0),cellSwitcherOpen:ie}),ie&&l.jsx(C4,{token:e,current:R,localNodeLabel:Dt,panelPort:rn,nodePanelPorts:nn,hostByRoute:Wt,onDesignateCell:qt,onClearHostCell:Vn,onLiveHostApplied:yn,sideKey:S?Lc(S.node?S.node.split("/"):[],S.session):null,onToggleSide:E,onPick:ke=>{L(ke),Pe(!1)},onClose:()=>Pe(!1)}),st]}):l.jsxs(l.Fragment,{children:[l.jsx(fI,{onPick:L,token:e,onSettings:ft,onOpenVlSession:te,panelPort:rn,nodePanelPorts:nn,hostByRoute:Wt,onDesignateCell:Ys,onClearHostCell:ls}),st]});const Ht=k||!Oe;return l.jsxs("div",{className:"nc-workspace",children:[Ht&&l.jsx(BI,{sessions:F,cells:B,localVerified:V,activeSessions:oe,nodeGroups:ge,token:e,onPeekOpen:()=>Pe(!1),overlayOpen:ie,fleetCapabilities:D,fleetStale:$,fleetOff:j,bootSettlement:K,onBootSettlementApplied:Te,localNodeId:Le.localNodeId,hostByRoute:Wt,onDesignateCell:Ys,onClearHostCell:ls,onPick:Ie,onAddTile:Me,onPower:be,onBoot:q,onBootError:ke=>Le.setError(String((ke==null?void 0:ke.message)||ke)),onNodePower:Ge,onNodeRename:Ae,onKill:Ke,onVisibility:mt,onNew:()=>ft("fleet",!0),onSettings:ft,onOpenVlSession:te,width:Ze,collapsed:$e,onResize:at,onToggleCollapse:()=>nt(ke=>!ke)}),l.jsxs("div",{className:"nc-workspace-main",children:[l.jsx(ND,{decks:ve,currentDeck:_,onCreate:Qe,onRename:Lt,onDelete:Tn,onReorder:Le.reorder,onOpenWindow:Ct,onNavigate:_t,saveState:Le.saveState,error:Le.error,conflict:Le.conflict,onReloadDeck:Le.reloadCurrent,sidebarVisible:Ht,onToggleSidebar:k?null:()=>_e(ke=>!ke)}),ze&&l.jsx("div",{className:"nc-notice nc-deck-notice",role:"status",title:ze,children:ze}),l.jsx(QI,{layout:U,onLayoutChange:I,onResizeEnd:()=>{Le.saveNow()},token:e,readonly:en,sessionsAlive:St,localVerified:V,localIdentities:le,localVerifiedAt:ne,focusSession:W,onFocus:se,onOpenSingle:Ie,decks:ve,currentDeck:_,onSendToDeck:Xe,cells:B,nodeGroups:ge,panelPort:rn,nodePanelPorts:nn})]}),J&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(u1,{peer:J,token:e,onBack:()=>te(null)})}),me&&l.jsx("div",{className:"nc-single-overlay",children:l.jsx(w1,{session:me.session,node:me.node,ownerId:me.ownerId,cellName:Mc({session:me.session,node:me.node,ownerId:me.ownerId,cells:B,nodeGroups:ge}),token:e,readonly:en,liveHost:Vt(me.node?me.node.split("/"):[]),panelPort:Nc(me.node?me.node.split("/"):[],nn,rn),onBack:()=>pe(null)})}),Z&&l.jsx(Dd,{cell:Z,token:e,route:Array.isArray(Z.route)?Z.route:[],onConfirm:ae,onClose:()=>be(null)}),st]})}function lO(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 cO(){$n();const t=w.useSyncExternalStore(H4,p1,p1);return t.needed?l.jsxs("div",{className:"nc-update",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"nc-update-msg",children:lO(t)}),t.kind==="stale"&&l.jsx("button",{className:"nc-update-btn",onClick:HE,children:p("reload-no-cache")}),t.kind==="reload"&&l.jsx("button",{className:"nc-update-btn",onClick:eO,children:p("reload")}),l.jsx("button",{className:"nc-update-close",onClick:G4,"aria-label":p("update-dismiss"),title:p("update-dismiss"),children:"×"})]}):null}function uO(){$n();const[t,e]=w.useState(!1);return w.useEffect(()=>{const n=()=>e(!0);return window.addEventListener(mm,n),()=>window.removeEventListener(mm,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}Z4();L6();EN.createRoot(document.getElementById("root")).render(l.jsxs(yN.StrictMode,{children:[l.jsx(aO,{}),l.jsx(cO,{}),l.jsx(uO,{})]}));
|